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