01: package test.ant;
02:
03: import static org.testng.AssertJUnit.assertEquals;
04:
05: import java.io.File;
06:
07: import org.testng.TestNGCommandLineArgs;
08: import org.testng.annotations.Test;
09:
10: /**
11: * Tests some of the functionality in {@link TestNGCommandLineArgs}.
12: *
13: * @author jkuhnert
14: */
15: public class TestCommandLineArgs {
16:
17: @Test
18: public void testUnixPathResolution() {
19: String path = "/wee/wom/flibble.txt";
20:
21: String[] segments = path.split("[/\\\\]", -1);
22:
23: assertEquals(4, segments.length);
24: assertEquals("wee", segments[1]);
25: }
26:
27: @Test
28: public void testDOSPathResolution() {
29: String path = "c:\\\\com\\pants\\wibble.txt";
30:
31: String[] segments = path.split("[/\\\\]", -1);
32:
33: assertEquals(5, segments.length);
34: assertEquals("com", segments[2]); // because c: is actually \\ which will be split twice
35: }
36:
37: @Test
38: public void testPathResolution() {
39: File file = new File("build.xml");
40:
41: assert file.exists();
42:
43: String path = file.getAbsolutePath();
44:
45: assert path.split("[/\\\\]", -1).length > 1;
46: }
47: }
|