01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.axis2.jaxws.wsdl.schemareader;
20:
21: import java.io.File;
22: import java.net.MalformedURLException;
23: import java.net.URL;
24: import java.util.Set;
25:
26: import javax.wsdl.Definition;
27:
28: import org.apache.axis2.jaxws.util.WSDL4JWrapper;
29: import org.apache.axis2.jaxws.wsdl.impl.SchemaReaderImpl;
30: import org.apache.axis2.jaxws.TestLogger;
31:
32: import junit.framework.TestCase;
33:
34: public class SchemaReaderTests extends TestCase {
35: public void testSchemaReader() {
36: SchemaReaderImpl sri = new SchemaReaderImpl();
37:
38: String wsdlLocation = "/test-resources/wsdl/shapes.wsdl";
39: URL url = null;
40: try {
41: try {
42: String baseDir = new File(System.getProperty("basedir",
43: ".")).getCanonicalPath();
44: wsdlLocation = new File(baseDir + wsdlLocation)
45: .getAbsolutePath();
46: } catch (Exception e) {
47: e.printStackTrace();
48: fail();
49: }
50: File file = new File(wsdlLocation);
51: url = file.toURL();
52: } catch (MalformedURLException e) {
53: e.printStackTrace();
54: fail();
55: }
56: try {
57: WSDL4JWrapper w4j = new WSDL4JWrapper(url);
58: Definition wsdlDef = w4j.getDefinition();
59: assertNotNull(wsdlDef);
60: Set<String> pkg = sri.readPackagesFromSchema(wsdlDef);
61: TestLogger.logger.debug("Packages:");
62: for (String pkgName : pkg) {
63: TestLogger.logger.debug(pkgName);
64: }
65: } catch (Exception e) {
66: e.printStackTrace();
67: fail();
68: }
69: }
70:
71: }
|