1 19 20 package org.netbeans.nbbuild; 21 22 import java.io.BufferedReader ; 23 import java.io.File ; 24 import java.io.FileInputStream ; 25 import java.io.FileOutputStream ; 26 import java.io.FileReader ; 27 import java.io.PrintStream ; 28 import java.util.Properties ; 29 import junit.framework.*; 30 import org.netbeans.junit.*; 31 32 36 public class ShorterPathsTest extends NbTestCase { 37 38 public ShorterPathsTest(java.lang.String testName) { 39 super(testName); 40 } 41 42 public static void main(java.lang.String [] args) { 43 junit.textui.TestRunner.run(suite()); 44 } 45 public void testShorterPaths () throws Exception { 46 File wd = getWorkDir(); 48 File modules = new File (wd,"modules"); 49 modules.mkdirs(); 50 File module = new File (modules,"module.jar"); 51 module.createNewFile(); 52 File extlib = new File (wd,"extlib.jar"); 53 File extraLibsDir = new File (wd,"extralibs"); 54 File testProperties = new File (wd,"outtest.properties"); 55 extraLibsDir.mkdirs(); 56 57 PrintStream ps = new PrintStream (extlib); 58 ps.println("content"); 59 ps.close(); 60 61 62 PublicPackagesInProjectizedXMLTest.execute ("ShorterPathsTest.xml", new String [] {"-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 extralibCopy = new File (extraLibsDir,"extlib.jar"); 69 70 assertTrue("No extra library has been copied",extralibCopy.exists()); 71 BufferedReader reader = new BufferedReader (new FileReader (extralibCopy)); 72 assertEquals("Different content in copy of extra library:","content",reader.readLine()); 73 74 Properties props = new Properties (); 75 FileInputStream propsIs = new FileInputStream (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 } 88 public static Test suite() { 89 TestSuite suite = new NbTestSuite(ShorterPathsTest.class); 90 return suite; 91 } 92 93 97 98 99 100 } 101 | Popular Tags |