001: /*
002: * soapUI, copyright (C) 2004-2007 eviware.com
003: *
004: * soapUI is free software; you can redistribute it and/or modify it under the
005: * terms of version 2.1 of the GNU Lesser General Public License as published by
006: * the Free Software Foundation.
007: *
008: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
009: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
010: * See the GNU Lesser General Public License for more details at gnu.org.
011: */
012:
013: package com.eviware.soapui.impl.wsdl.support;
014:
015: import java.io.File;
016: import java.util.Map;
017:
018: import javax.xml.namespace.QName;
019:
020: import org.apache.xmlbeans.SchemaTypeLoader;
021: import org.apache.xmlbeans.XmlObject;
022:
023: import com.eviware.soapui.impl.wsdl.support.soap.SoapVersion;
024: import com.eviware.soapui.impl.wsdl.support.wsdl.UrlWsdlLoader;
025: import com.eviware.soapui.impl.wsdl.support.xsd.SchemaUtils;
026: import com.eviware.soapui.support.TestCaseWithJetty;
027:
028: public class SchemaUtilsTestCase extends TestCaseWithJetty {
029: public void testFileImport() throws Exception {
030: File file = new File(
031: "src\\test-resources\\test1\\TestService.wsdl");
032: validate(file.toURL().toString(), 3);
033: }
034:
035: public void testHttpImport() throws Exception {
036: validate("http://localhost:8082/test1/TestService.wsdl", 3);
037: validate(new File(
038: "src\\test-resources\\test1\\TestService.wsdl").toURL()
039: .toString(), 3);
040: }
041:
042: public void testHttpImport2() throws Exception {
043: validate("http://localhost:8082/test2/TestService.wsdl", 3);
044: validate(new File(
045: "src\\test-resources\\test2\\TestService.wsdl").toURL()
046: .toString(), 3);
047: }
048:
049: public void testHttpImport3() throws Exception {
050: validate("http://localhost:8082/test3/TestService.wsdl", 3);
051: validate(new File(
052: "src\\test-resources\\test3\\TestService.wsdl").toURL()
053: .toString(), 3);
054: }
055:
056: public void testHttpImport4() throws Exception {
057: validate("http://localhost:8082/test4/TestService.wsdl", 3);
058: validate(new File(
059: "src\\test-resources\\test4\\TestService.wsdl").toURL()
060: .toString(), 3);
061: }
062:
063: public void testHttpImport5() throws Exception {
064: validate("http://localhost:8082/test5/TestService.wsdl", 4);
065: validate(new File(
066: "src\\test-resources\\test5\\TestService.wsdl").toURL()
067: .toString(), 4);
068: }
069:
070: public void testHttpImport6() throws Exception {
071: SchemaTypeLoader schemaTypes = validate(
072: "http://localhost:8082/test6/TestService.wsdl", 4);
073: assertNotNull(schemaTypes.findType(new QName(
074: "http://schemas.eviware.com/TestService/v2/",
075: "TestType")));
076:
077: schemaTypes = validate(new File(
078: "src\\test-resources\\test6\\TestService.wsdl").toURL()
079: .toString(), 4);
080: assertNotNull(schemaTypes.findType(new QName(
081: "http://schemas.eviware.com/TestService/v2/",
082: "TestType")));
083: }
084:
085: public void testHttpImport7() throws Exception {
086: SchemaTypeLoader schemaTypes = validate(
087: "http://localhost:8082/test7/TestService.wsdl", 4);
088: assertNotNull(schemaTypes.findType(new QName(
089: "http://schemas.eviware.com/TestService/v2/",
090: "TestType")));
091:
092: schemaTypes = validate(new File(
093: "src\\test-resources\\test7\\TestService.wsdl").toURL()
094: .toString(), 4);
095: assertNotNull(schemaTypes.findType(new QName(
096: "http://schemas.eviware.com/TestService/v2/",
097: "TestType")));
098: }
099:
100: public void testHttpImport8() throws Exception {
101: SchemaTypeLoader schemaTypes = validate(
102: "http://localhost:8082/test8/TestService.wsdl", 4);
103: assertNotNull(schemaTypes.findType(new QName(
104: "http://schemas.eviware.com/TestService/v2/",
105: "TestType")));
106:
107: schemaTypes = validate(new File(
108: "src\\test-resources\\test8\\TestService.wsdl").toURL()
109: .toString(), 4);
110: assertNotNull(schemaTypes.findType(new QName(
111: "http://schemas.eviware.com/TestService/v2/",
112: "TestType")));
113: }
114:
115: private SchemaTypeLoader validate(String url, int cnt)
116: throws Exception {
117: SchemaTypeLoader schemaTypes = SchemaUtils.loadSchemaTypes(url,
118: SoapVersion.Soap11, new UrlWsdlLoader(url));
119: Map<String, XmlObject> definitionUrls = SchemaUtils
120: .getDefinitionParts(new UrlWsdlLoader(url));
121:
122: assertNotNull(schemaTypes);
123: assertNotNull(definitionUrls);
124: assertEquals(cnt, definitionUrls.size());
125:
126: assertNotNull(schemaTypes.findType(new QName(
127: "http://schemas.eviware.com/TestService/v1/",
128: "PageReference")));
129:
130: return schemaTypes;
131: }
132:
133: }
|