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