1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.support.wsdl;
14
15 import com.eviware.soapui.impl.support.definition.export.WsdlDefinitionExporter;
16 import com.eviware.soapui.impl.wsdl.WsdlInterface;
17 import com.eviware.soapui.impl.wsdl.WsdlProject;
18 import com.eviware.soapui.settings.WsdlSettings;
19 import com.eviware.soapui.support.TestCaseWithJetty;
20 import org.apache.xmlbeans.XmlException;
21
22 import java.io.File;
23 import java.io.IOException;
24
25 public class WsdlDefinitionExporterTestCase extends TestCaseWithJetty
26 {
27 public void testSaveDefinition() throws Exception
28 {
29 testLoader("http://localhost:8082/test1/TestService.wsdl");
30 testLoader("http://localhost:8082/test2/TestService.wsdl");
31 testLoader("http://localhost:8082/test3/TestService.wsdl");
32 testLoader("http://localhost:8082/test4/TestService.wsdl");
33 testLoader("http://localhost:8082/test5/TestService.wsdl");
34 testLoader("http://localhost:8082/test6/TestService.wsdl");
35 testLoader("http://localhost:8082/test7/TestService.wsdl");
36 testLoader("http://localhost:8082/test8/TestService.wsdl");
37 testLoader("http://localhost:8082/testonewayop/TestService.wsdl");
38 }
39
40 private void testLoader(String wsdlUrl) throws XmlException, IOException, Exception
41 {
42 WsdlProject project = new WsdlProject();
43 project.getSettings().setBoolean( WsdlSettings.CACHE_WSDLS, true );
44 WsdlInterface wsdlInterface = WsdlImporter.importWsdl( project, wsdlUrl )[0];
45
46 assertTrue( wsdlInterface.isCached() );
47
48 WsdlDefinitionExporter exporter = new WsdlDefinitionExporter( wsdlInterface );
49
50 String root = exporter.export( "test" + File.separatorChar + "output" );
51
52 WsdlProject project2 = new WsdlProject();
53 WsdlInterface wsdl2 = WsdlImporter.importWsdl( project2, new File( root ).toURI().toURL().toString() )[0];
54
55 assertEquals( wsdlInterface.getBindingName(), wsdl2.getBindingName() );
56 assertEquals( wsdlInterface.getOperationCount(), wsdl2.getOperationCount() );
57 assertEquals( wsdlInterface.getWsdlContext().getInterfaceDefinition().getDefinedNamespaces(), wsdl2.getWsdlContext().getInterfaceDefinition().getDefinedNamespaces() );
58 }
59 }