1 19 20 package org.netbeans.modules.ant.freeform; 21 22 import java.io.File ; 23 import java.util.Arrays ; 24 import java.util.Collections ; 25 import org.openide.filesystems.FileObject; 26 import org.openide.filesystems.FileUtil; 27 28 32 public class UtilTest extends TestBase { 33 34 public UtilTest(String name) { 35 super(name); 36 } 37 38 private FileObject test1Xml; 39 private FileObject test2Xml; 40 private FileObject test3Xml; 41 private FileObject test5Xml; 42 43 protected void setUp() throws Exception { 44 super.setUp(); 45 test1Xml = FileUtil.toFileObject(new File (datadir, "test1.xml")); 46 assertNotNull("have test1.xml", test1Xml); 47 test2Xml = FileUtil.toFileObject(new File (datadir, "test2.xml")); 48 assertNotNull("have test2.xml", test2Xml); 49 test3Xml = FileUtil.toFileObject(new File (datadir, "test3.xml")); 50 assertNotNull("have test3.xml", test3Xml); 51 test5Xml = FileUtil.toFileObject(new File (datadir, "test5.xml")); 52 assertNotNull("have test5.xml", test5Xml); 53 } 54 55 public void testGetAntScriptName() throws Exception { 56 assertEquals("correct name for test1.xml", "test1", Util.getAntScriptName(test1Xml)); 57 assertEquals("no name for test2.xml", null, Util.getAntScriptName(test2Xml)); 58 assertEquals("correct name for test3.xml", "test3", Util.getAntScriptName(test3Xml)); 59 assertEquals("no name for test5.xml", null, Util.getAntScriptName(test5Xml)); 60 } 61 62 public void testGetAntScriptTargetNames() throws Exception { 63 assertEquals("correct targets for test1.xml", 64 Arrays.asList(new String [] {"another", "main", "other"}), 65 Util.getAntScriptTargetNames(test1Xml)); 66 assertEquals("correct targets for test2.xml", 67 Collections.singletonList("sometarget"), 68 Util.getAntScriptTargetNames(test2Xml)); 69 assertEquals("correct targets for test3.xml", 70 Arrays.asList(new String [] {"imported1", "imported2", "main"}), 71 Util.getAntScriptTargetNames(test3Xml)); 72 assertEquals("no targets for test5.xml", null, Util.getAntScriptTargetNames(test5Xml)); 73 } 74 75 } 76 | Popular Tags |