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