1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package tests.w3c;
17
18 import junit.framework.Test;
19 import junit.framework.TestSuite;
20
21 import java.io.File;
22 import java.util.ArrayList;
23 import java.util.List;
24 import java.util.ListIterator;
25
26
27
28
29
30
31
32
33
34
35
36 public class TestW3CSchemaBucket extends TestSuite {
37
38 private static List allTestSetFiles;
39
40
41 private static String testSetsLocation = "./target/xmlschema2002-01-16";
42
43 public TestW3CSchemaBucket(String name) {
44 super(name);
45 }
46
47 public static void main(String[] args) {
48 try {
49 junit.textui.TestRunner.run(TestW3CSchemaBucket.suite());
50 } catch (Exception e) {
51 e.printStackTrace();
52 }
53 }
54
55
56 public static Test suite() throws Exception {
57 testSetsLocation = System.getProperty("W3CTestLocation", testSetsLocation);
58 TestSuite suite = new TestSuite("Test for tests");
59 allTestSetFiles = getTestSetFiles(testSetsLocation);
60 ListIterator li = allTestSetFiles.listIterator();
61 while (li.hasNext()) {
62 Object o = li.next();
63 File testSet = null;
64 if (o instanceof File) {
65 testSet = (File) o;
66 }
67 suite.addTest(TestW3CSchemaTestSet.suite(testSet));
68 }
69 return suite;
70 }
71
72 private static List getTestSetFiles(String testSetsLocation) throws Exception {
73 File dir = new File(testSetsLocation);
74 if (!dir.isDirectory()) {
75 throw new Exception ("testSet files location must be a directory");
76 }
77 ArrayList testSetFiles = new ArrayList();
78 File[] files = dir.listFiles();
79 for (int i = 0; i < files.length; i++) {
80 if (files[i].getAbsolutePath().endsWith("testSet")) {
81 testSetFiles.add(files[i]);
82 }
83 }
84 return testSetFiles;
85 }
86 }