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.wsdl;
20:
21: import junit.framework.TestCase;
22: import org.apache.axis2.AxisFault;
23: import org.apache.axis2.context.ConfigurationContext;
24: import org.apache.axis2.context.ConfigurationContextFactory;
25: import org.apache.axis2.description.AxisService;
26: import org.apache.axis2.description.WSDL11ToAxisServiceBuilder;
27: import org.apache.axis2.engine.ListenerManager;
28:
29: import java.io.File;
30: import java.io.FileInputStream;
31: import java.io.FileOutputStream;
32: import java.io.OutputStream;
33:
34: public class WSDLServiceBuilderTest extends TestCase {
35:
36: private ConfigurationContext configContext;
37: ListenerManager lm;
38:
39: protected void setUp() throws Exception {
40: configContext = ConfigurationContextFactory
41: .createConfigurationContextFromFileSystem(null, null);
42: lm = new ListenerManager();
43: lm.init(configContext);
44: lm.start();
45: }
46:
47: protected void tearDown() throws AxisFault {
48: configContext.terminate();
49: }
50:
51: public void testWSDLClient() throws Exception {
52: File testResourceFile = new File("target/test-classes");
53: File outLocation = new File("target/test-resources");
54: outLocation.mkdirs();
55: if (testResourceFile.exists()) {
56: File files[] = testResourceFile.listFiles();
57: for (int i = 0; i < files.length; i++) {
58: File file1 = files[i];
59: if (file1.isFile() && file1.getName().endsWith(".wsdl")) {
60: if (file1.getName().equals("ping-modified.wsdl")
61: || file1.getName().equals(
62: "ping-unbound.wsdl")
63: || file1.getName().equals("wsat.wsdl")
64: || file1.getName()
65: .equals("no-service.wsdl")) {
66: continue;
67: }
68: try {
69: WSDL11ToAxisServiceBuilder builder = new WSDL11ToAxisServiceBuilder(
70: new FileInputStream(file1), null, null);
71: AxisService service = builder.populateService();
72: System.out.println("Testinf file: "
73: + file1.getName());
74: configContext.getAxisConfiguration()
75: .addService(service);
76: OutputStream out = new FileOutputStream(
77: new File(outLocation, file1.getName()));
78: service.printWSDL(out,
79: "http://google.com/axis2/services");
80: out.flush();
81: out.close();
82: configContext.getAxisConfiguration()
83: .removeService(service.getName());
84: } catch (Exception e) {
85: System.out.println("Error in WSDL : "
86: + file1.getName());
87: throw e;
88: }
89:
90: }
91: }
92: }
93: }
94: }
|