KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > apisupport > project > queries > AntArtifactProviderImplTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.apisupport.project.queries;
21
22 import java.net.URI JavaDoc;
23 import java.util.Arrays JavaDoc;
24 import java.util.Collections JavaDoc;
25 import java.util.Properties JavaDoc;
26 import org.netbeans.api.java.project.JavaProjectConstants;
27 import org.netbeans.api.project.ProjectManager;
28 import org.netbeans.api.project.ant.AntArtifact;
29 import org.netbeans.api.project.ant.AntArtifactQuery;
30 import org.netbeans.modules.apisupport.project.NbModuleProject;
31 import org.netbeans.modules.apisupport.project.TestBase;
32 import org.openide.filesystems.FileObject;
33
34 /**
35  * Test AntArtifactProviderImpl.
36  * @author Jaroslav Tulach, Jesse Glick
37  */

38 public class AntArtifactProviderImplTest extends TestBase {
39     
40     public AntArtifactProviderImplTest(String JavaDoc name) {
41         super(name);
42     }
43     
44     private NbModuleProject javaProjectProject;
45     private NbModuleProject loadersProject;
46     
47     protected void setUp() throws Exception JavaDoc {
48         super.setUp();
49         FileObject dir = nbCVSRoot().getFileObject("java/project");
50         assertNotNull("have java/project checked out", dir);
51         javaProjectProject = (NbModuleProject) ProjectManager.getDefault().findProject(dir);
52         dir = nbCVSRoot().getFileObject("openide/loaders");
53         assertNotNull("have openide/loaders checked out", dir);
54         loadersProject = (NbModuleProject) ProjectManager.getDefault().findProject(dir);
55     }
56     
57     public void testJARFileIsProduced() throws Exception JavaDoc {
58         AntArtifact[] arts = AntArtifactQuery.findArtifactsByType(loadersProject, JavaProjectConstants.ARTIFACT_TYPE_JAR);
59         assertEquals("one artifact produced", 1, arts.length);
60         assertEquals("correct project", loadersProject, arts[0].getProject());
61         assertEquals("correct type", JavaProjectConstants.ARTIFACT_TYPE_JAR, arts[0].getType());
62         assertEquals("correct ID", "module", arts[0].getID());
63         assertEquals("correct location",
64             Collections.singletonList(URI.create("../../nbbuild/netbeans/" + TestBase.CLUSTER_PLATFORM + "/modules/org-openide-loaders.jar")),
65             Arrays.asList(arts[0].getArtifactLocations()));
66         assertEquals("correct script", nbCVSRoot().getFileObject("openide/loaders/build.xml"), arts[0].getScriptFile());
67         assertEquals("correct build target", "netbeans", arts[0].getTargetName());
68         assertEquals("correct clean target", "clean", arts[0].getCleanTargetName());
69         assertEquals("no properties", new Properties JavaDoc(), arts[0].getProperties());
70         arts = AntArtifactQuery.findArtifactsByType(javaProjectProject, JavaProjectConstants.ARTIFACT_TYPE_JAR);
71         assertEquals("one artifact produced", 1, arts.length);
72         assertEquals("correct location",
73             Collections.singletonList(URI.create("../../nbbuild/netbeans/" + TestBase.CLUSTER_IDE + "/modules/org-netbeans-modules-java-project.jar")),
74             Arrays.asList(arts[0].getArtifactLocations()));
75     }
76     
77 }
78
Popular Tags