Debian Codegraph @

test/wsdl/extra/ExtraClassesTestCase.java

raw
1 /*
2 * Copyright 2001-2004 The Apache Software Foundation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package test.wsdl.extra;
18
19 import java.io.File;
20 import java.io.IOException;
21 import java.util.HashSet;
22 import java.util.Set;
23 import java.util.Vector;
24
25 /**
26 * This tests the file generation of only the items that are referenced in WSDL
27 * This should extend FileGenTestCase, but we have a dependancy problem as
28 * "extra" comes before "filegen". Oh well.
29 *
30 */
31 public class ExtraClassesTestCase extends junit.framework.TestCase {
32 public ExtraClassesTestCase(String name) {
33 super(name);
34 }
35
36 /**
37 * List of files which should be generated.
38 */
39 protected Set shouldExist() {
40 HashSet set = new HashSet();
41 set.add("Extra.java"); // this is the important one
42 set.add("MyService.java");
43 set.add("MyServiceService.java");
44 set.add("MyServiceServiceLocator.java");
45 set.add("MyServiceSoapBindingStub.java");
46 set.add("MyService.wsdl");
47 set.add("ExtraClassesTestCase.java");
48 return set;
49 } // shouldExist
50
51 /**
52 * List of files which may or may not be generated.
53 */
54 protected Set mayExist() {
55 HashSet set = new HashSet();
56 return set;
57 }
58
59 /**
60 * The directory containing the files that should exist.
61 */
62 protected String rootDir() {
63 return "build" + File.separator + "work" + File.separator +
64 "test" + File.separator + "wsdl" + File.separator +
65 "extra";
66 } // rootDir
67
68 public void testFileGen() throws IOException {
69 String rootDir = rootDir();
70 Set shouldExist = shouldExist();
71 Set mayExist = mayExist();
72
73 // open up the output directory and check what files exist.
74 File outputDir = new File(rootDir);
75
76 String[] files = outputDir.list();
77
78 Vector shouldNotExist = new Vector();
79
80 for (int i = 0; i < files.length; ++i) {
81 if (shouldExist.contains(files[i])) {
82 shouldExist.remove(files[i]);
83 }
84 else if (mayExist.contains(files[i])) {
85 mayExist.remove(files[i]);
86 }
87 else {
88 shouldNotExist.add(files[i]);
89 }
90 }
91
92 if (shouldExist.size() > 0) {
93 fail("The following files should exist but do not: " + shouldExist);
94 }
95
96 if (shouldNotExist.size() > 0) {
97 fail("The following files should NOT exist, but do: " + shouldNotExist);
98 }
99 }
100 } // class AllOptionTestCase