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:
20: package org.apache.axis2.jaxws.description;
21:
22: import javax.wsdl.Definition;
23: import javax.wsdl.factory.WSDLFactory;
24: import javax.wsdl.xml.WSDLReader;
25: import java.net.URL;
26:
27: /**
28: *
29: */
30: public class DescriptionTestUtils {
31:
32: /*
33: * ========================================================================
34: * Test utility methods
35: * ========================================================================
36: */
37:
38: static public URL getWSDLURL() {
39: return getWSDLURL("WSDLTests.wsdl");
40:
41: }
42:
43: static public URL getWSDLURL(String wsdlFileName) {
44: URL wsdlURL = null;
45: // Get the URL to the WSDL file. Note that 'basedir' is setup by Maven
46: String basedir = System.getProperty("basedir", ".");
47: String urlString = "file://localhost/" + basedir
48: + "/test-resources/wsdl/" + wsdlFileName;
49: try {
50: wsdlURL = new URL(urlString);
51: } catch (Exception e) {
52: System.out.println("Caught exception creating WSDL URL :"
53: + urlString + "; exception: " + e.toString());
54: }
55: return wsdlURL;
56: }
57:
58: static Definition createWSDLDefinition(URL wsdlURL) {
59: Definition wsdlDefinition = null;
60: try {
61: WSDLFactory factory = WSDLFactory.newInstance();
62: WSDLReader reader = factory.newWSDLReader();
63: wsdlDefinition = reader.readWSDL(wsdlURL.toString());
64: } catch (Exception e) {
65: System.out
66: .println("*** ERROR ***: Caught exception trying to create WSDL Definition: "
67: + e);
68: e.printStackTrace();
69: }
70:
71: return wsdlDefinition;
72: }
73: }
|