1 package org.apache.maven.abbot;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 import junit.extensions.abbot.ScriptFixture;
21 import junit.framework.Test;
22 import junit.framework.TestCase;
23
24 /**
25 * Unit tests for {@link AbbotTestAll}.
26 */
27 public class AbbotTestAllTest extends TestCase
28 {
29 public void testGetScriptFileNamesNoPropertyDefined()
30 {
31 assertNull("The maven.abbot.src.files property must not be set for "
32 + "this test", System.getProperty("maven.abbot.src.files"));
33 String[] result = AbbotTestAll.getScriptFileNames();
34 assertNull(result);
35 }
36
37 public void testGetScriptFileNamesEmptyFileList()
38 {
39 System.setProperty("maven.abbot.src.files", "");
40 String[] result = AbbotTestAll.getScriptFileNames();
41 assertNull(result);
42 }
43
44 public void testGetScriptFileNamesSingleFile()
45 {
46 System.setProperty("maven.abbot.src.files", "c:/some/file");
47 String[] result = AbbotTestAll.getScriptFileNames();
48 assertEquals(1, result.length);
49 assertEquals("c:/some/file", result[0]);
50 }
51
52 public void testGetScriptFileNamesTwoFiles()
53 {
54 System.setProperty("maven.abbot.src.files",
55 "c:/some/file,c:/other/file");
56 String[] result = AbbotTestAll.getScriptFileNames();
57 assertEquals(2, result.length);
58 assertEquals("c:/some/file", result[0]);
59 assertEquals("c:/other/file", result[1]);
60 }
61
62 /**
63 * Verify we can construct a valid
64 * {@link junit.extensions.abbot.ScriptTestSuite} object when
65 * executing a single script.
66 */
67 public void testConstructionOfScriptTestSuiteWithUniqueScript()
68 {
69 System.setProperty("maven.abbot.src.files", "c:/some/file.xml");
70
71 Test suite = AbbotTestAll.suite();
72
73 assertNotNull(suite);
74 assertEquals(AbbotTestAll.MavenScriptTestSuite.class.getName(),
75 suite.getClass().getName());
76
77 AbbotTestAll.MavenScriptTestSuite mavenSuite =
78 (AbbotTestAll.MavenScriptTestSuite) suite;
79 assertEquals(1, mavenSuite.testCount());
80
81 Test test = (Test) mavenSuite.tests().nextElement();
82 assertEquals(ScriptFixture.class.getName(), test.getClass().getName());
83 }
84
85 }