KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > wsdl > extra > ExtraClassesTestCase


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 JavaDoc;
20 import java.io.IOException JavaDoc;
21 import java.util.HashSet JavaDoc;
22 import java.util.Set JavaDoc;
23 import java.util.Vector JavaDoc;
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 JavaDoc name) {
33         super(name);
34     }
35
36     /**
37      * List of files which should be generated.
38      */

39     protected Set JavaDoc shouldExist() {
40         HashSet JavaDoc set = new HashSet JavaDoc();
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 JavaDoc mayExist() {
55         HashSet JavaDoc set = new HashSet JavaDoc();
56         return set;
57     }
58
59     /**
60      * The directory containing the files that should exist.
61      */

62     protected String JavaDoc 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 JavaDoc {
69         String JavaDoc rootDir = rootDir();
70         Set JavaDoc shouldExist = shouldExist();
71         Set JavaDoc mayExist = mayExist();
72
73         // open up the output directory and check what files exist.
74
File JavaDoc outputDir = new File JavaDoc(rootDir);
75         
76         String JavaDoc[] files = outputDir.list();
77
78         Vector JavaDoc shouldNotExist = new Vector JavaDoc();
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
101
Popular Tags