1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.support;
14
15 import java.io.File;
16 import java.util.Map;
17
18 import javax.xml.namespace.QName;
19
20 import org.apache.xmlbeans.SchemaTypeLoader;
21 import org.apache.xmlbeans.XmlObject;
22
23 import com.eviware.soapui.impl.wsdl.support.soap.SoapVersion;
24 import com.eviware.soapui.impl.wsdl.support.wsdl.UrlWsdlLoader;
25 import com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils;
26 import com.eviware.soapui.support.TestCaseWithJetty;
27
28 public class SchemaUtilsTestCase extends TestCaseWithJetty
29 {
30 public void testFileImport() throws Exception
31 {
32 File file = new File( "src//test-resources//test1//TestService.wsdl" );
33 validate( file.toURL().toString(), 3 );
34 }
35
36 public void testHttpImport() throws Exception
37 {
38 validate("http://localhost:8082/test1/TestService.wsdl", 3);
39 validate( new File( "src//test-resources//test1//TestService.wsdl" ).toURL().toString(), 3);
40 }
41
42 public void testHttpImport2() throws Exception
43 {
44 validate("http://localhost:8082/test2/TestService.wsdl", 3);
45 validate( new File( "src//test-resources//test2//TestService.wsdl" ).toURL().toString(), 3);
46 }
47
48 public void testHttpImport3() throws Exception
49 {
50 validate("http://localhost:8082/test3/TestService.wsdl", 3);
51 validate( new File( "src//test-resources//test3//TestService.wsdl" ).toURL().toString(), 3);
52 }
53
54 public void testHttpImport4() throws Exception
55 {
56 validate("http://localhost:8082/test4/TestService.wsdl", 3);
57 validate( new File( "src//test-resources//test4//TestService.wsdl" ).toURL().toString(), 3);
58 }
59
60 public void testHttpImport5() throws Exception
61 {
62 validate("http://localhost:8082/test5/TestService.wsdl", 4);
63 validate( new File( "src//test-resources//test5//TestService.wsdl" ).toURL().toString(), 4);
64 }
65
66 public void testHttpImport6() throws Exception
67 {
68 SchemaTypeLoader schemaTypes = validate("http://localhost:8082/test6/TestService.wsdl", 4);
69 assertNotNull( schemaTypes.findType( new QName( "http://schemas.eviware.com/TestService/v2/", "TestType")));
70
71 schemaTypes = validate( new File( "src//test-resources//test6//TestService.wsdl" ).toURL().toString(), 4);
72 assertNotNull( schemaTypes.findType( new QName( "http://schemas.eviware.com/TestService/v2/", "TestType")));
73 }
74
75 public void testHttpImport7() throws Exception
76 {
77 SchemaTypeLoader schemaTypes = validate("http://localhost:8082/test7/TestService.wsdl", 4);
78 assertNotNull( schemaTypes.findType( new QName( "http://schemas.eviware.com/TestService/v2/", "TestType")));
79
80 schemaTypes = validate( new File( "src//test-resources//test7//TestService.wsdl" ).toURL().toString(), 4);
81 assertNotNull( schemaTypes.findType( new QName( "http://schemas.eviware.com/TestService/v2/", "TestType")));
82 }
83
84 public void testHttpImport8() throws Exception
85 {
86 SchemaTypeLoader schemaTypes = validate("http://localhost:8082/test8/TestService.wsdl", 4);
87 assertNotNull( schemaTypes.findType( new QName( "http://schemas.eviware.com/TestService/v2/", "TestType")));
88
89 schemaTypes = validate( new File( "src//test-resources//test8//TestService.wsdl" ).toURL().toString(), 4);
90 assertNotNull( schemaTypes.findType( new QName( "http://schemas.eviware.com/TestService/v2/", "TestType")));
91 }
92
93 private SchemaTypeLoader validate( String url, int cnt ) throws Exception
94 {
95 SchemaTypeLoader schemaTypes = SchemaUtils.loadSchemaTypes( url, SoapVersion.Soap11, new UrlWsdlLoader( url ) );
96 Map<String, XmlObject> definitionUrls = SchemaUtils.getDefinitionParts( new UrlWsdlLoader( url ) );
97
98 assertNotNull( schemaTypes );
99 assertNotNull( definitionUrls );
100 assertEquals( cnt, definitionUrls.size() );
101
102 assertNotNull( schemaTypes.findType( new QName( "http://schemas.eviware.com/TestService/v1/", "PageReference")));
103
104 return schemaTypes;
105 }
106
107 }