KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > nbbuild > ShorterPathsTest


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.nbbuild;
21
22 import java.io.BufferedReader JavaDoc;
23 import java.io.File JavaDoc;
24 import java.io.FileInputStream JavaDoc;
25 import java.io.FileOutputStream JavaDoc;
26 import java.io.FileReader JavaDoc;
27 import java.io.PrintStream JavaDoc;
28 import java.util.Properties JavaDoc;
29 import junit.framework.*;
30 import org.netbeans.junit.*;
31
32 /**
33  *
34  * @author pzajac
35  */

36 public class ShorterPathsTest extends NbTestCase {
37     
38     public ShorterPathsTest(java.lang.String JavaDoc testName) {
39         super(testName);
40     }
41     
42     public static void main(java.lang.String JavaDoc[] args) {
43         junit.textui.TestRunner.run(suite());
44     }
45     public void testShorterPaths () throws Exception JavaDoc {
46       // create test
47
File JavaDoc wd = getWorkDir();
48       File JavaDoc modules = new File JavaDoc(wd,"modules");
49       modules.mkdirs();
50       File JavaDoc module = new File JavaDoc(modules,"module.jar");
51       module.createNewFile();
52       File JavaDoc extlib = new File JavaDoc(wd,"extlib.jar");
53       File JavaDoc extraLibsDir = new File JavaDoc (wd,"extralibs");
54       File JavaDoc testProperties = new File JavaDoc (wd,"outtest.properties");
55       extraLibsDir.mkdirs();
56       
57       PrintStream JavaDoc ps = new PrintStream JavaDoc(extlib);
58       ps.println("content");
59       ps.close();
60       
61       
62       PublicPackagesInProjectizedXMLTest.execute ("ShorterPathsTest.xml", new String JavaDoc[] {"-verbose",
63                                                                                         "-Dtest.ext.lib=" + extlib.getPath(),
64                                                                                         "-Dtest.modules.dir=" + modules.getPath(),
65                                                                                         "-Dextra.test.libs.dir=" + extraLibsDir.getPath(),
66                                                                                         "-Dtest.properties=" + testProperties.getPath(),
67                                                                                         "all"});
68       File JavaDoc extralibCopy = new File JavaDoc(extraLibsDir,"extlib.jar");
69       
70       assertTrue("No extra library has been copied",extralibCopy.exists());
71       BufferedReader JavaDoc reader = new BufferedReader JavaDoc(new FileReader JavaDoc(extralibCopy));
72       assertEquals("Different content in copy of extra library:","content",reader.readLine());
73
74       Properties JavaDoc props = new Properties JavaDoc();
75       FileInputStream JavaDoc propsIs = new FileInputStream JavaDoc(testProperties);
76       props.load(propsIs);
77       propsIs.close();
78       assertEquals("extra.test.libs.dir","${extra.test.libs}/extlib.jar",props.getProperty("extra.test.libs.dir"));
79       assertEquals("test.unit.run.cp","${nb.root.test.dir}/module.jar",props.getProperty("test.unit.run.cp"));
80       assertEquals("test-unit-sys-prop.prop1","value1",props.getProperty("test-unit-sys-prop.prop1"));
81       assertEquals("test-unit-sys-prop.prop2","${nb.root.test.dir}/module.jar",props.getProperty("test-unit-sys-prop.prop2"));
82       assertNull(props.getProperty("test-unit-sys-prop.xtest.data"));
83       assertEquals("props.size()",4,props.size());
84       
85       
86       // test dist
87
}
88     public static Test suite() {
89         TestSuite suite = new NbTestSuite(ShorterPathsTest.class);
90         return suite;
91     }
92     
93     // Add test methods here, they have to start with 'test' name.
94
// for example:
95
// public void testHello() {}
96

97     
98     
99     
100 }
101
Popular Tags