[jboss-svn-commits] JBL Code SVN: r38204 - in labs/jbossesb/trunk/product: services/soap/src/main/java/org/jboss/soa/esb/actions/soap and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Sep 27 05:22:16 EDT 2012
Author: tadayosi
Date: 2012-09-27 05:22:15 -0400 (Thu, 27 Sep 2012)
New Revision: 38204
Added:
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SchemaDeployerUnitTest.java
labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-ext.wsdl
labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int-cxf.wsdl
labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int-https.wsdl
labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int-prefixed.wsdl
labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int.wsdl
Removed:
labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema.wsdl
Modified:
labs/jbossesb/trunk/product/contract-web/src/main/webapp/contract.jsp
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaDeployerImpl.java
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaLocationParser.java
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SchemaLocatorUnitTest.java
Log:
JBESB-3802
Port changes from the 4.11 CP branch back to trunk.
Modified: labs/jbossesb/trunk/product/contract-web/src/main/webapp/contract.jsp
===================================================================
--- labs/jbossesb/trunk/product/contract-web/src/main/webapp/contract.jsp 2012-09-27 03:32:21 UTC (rev 38203)
+++ labs/jbossesb/trunk/product/contract-web/src/main/webapp/contract.jsp 2012-09-27 09:22:15 UTC (rev 38204)
@@ -1,4 +1,5 @@
<%@page contentType="text/xml; charset=UTF-8"%>
+<%@page trimDirectiveWhitespaces="true" %>
<%@page import="java.net.URI"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java 2012-09-27 03:32:21 UTC (rev 38203)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java 2012-09-27 09:22:15 UTC (rev 38204)
@@ -59,11 +59,11 @@
private static Logger logger = Logger.getLogger(AbstractWsdlContractPublisher.class);
- public static final String CACHE_REMOTE_SCHEMAS = "cache-remote-schemas";
+ public static final String CACHE_SCHEMAS = "cache-schemas";
public static final String REWRITE_ENDPOINT_URL = "rewrite-endpoint-url";
private Properties actionProperties;
- private boolean cacheRemoteSchemas = false;
+ private boolean cacheSchemas = false;
private boolean rewriteEndpointUrl = true;
private Smooks transformer;
@@ -134,9 +134,9 @@
}
public ContractInfo getContractInfo(EPR epr, HttpServletRequest servletRequest) {
- final String cacheRemoteSchemasVal = actionProperties.getProperty(AbstractWsdlContractPublisher.CACHE_REMOTE_SCHEMAS);
- if (cacheRemoteSchemasVal != null) {
- cacheRemoteSchemas = !cacheRemoteSchemasVal.equals("false");
+ final String cacheSchemasVal = actionProperties.getProperty(AbstractWsdlContractPublisher.CACHE_SCHEMAS);
+ if (cacheSchemasVal != null) {
+ cacheSchemas = !cacheSchemasVal.equals("false");
}
String wsdlAddress = getWsdlAddress();
@@ -155,7 +155,7 @@
throw new Exception("null Contract data");
}
- if (cacheRemoteSchemas) {
+ if (cacheSchemas) {
SchemaDeployer sd = (SchemaDeployer) new SchemaDeployerImpl();
SchemaLocationParser slp = new SchemaLocationParser(sd);
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaDeployerImpl.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaDeployerImpl.java 2012-09-27 03:32:21 UTC (rev 38203)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaDeployerImpl.java 2012-09-27 09:22:15 UTC (rev 38204)
@@ -22,35 +22,29 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
-import java.io.InputStream;
import java.io.InputStreamReader;
-import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-import java.util.zip.ZipOutputStream;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import javax.management.JMException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
-import javax.management.MBeanServer;
import org.apache.log4j.Logger;
import org.jboss.mx.util.MBeanServerLocator;
public class SchemaDeployerImpl implements SchemaDeployer {
+ private static final String XSD_PATTERN = "\\w+[.]xsd";
private Logger logger = Logger.getLogger(SchemaDeployerImpl.class);
private Map<String,String> resources = new HashMap<String,String>();
- private final String ESB_WAR_FILES_DIR = "esbwarfiles";
private String esbContext;
+ private Pattern xsdPattern = Pattern.compile(XSD_PATTERN);
/* (non-Javadoc)
* @see org.jboss.soa.esb.actions.soap.SchemaDeployer#getResources()
@@ -94,7 +88,7 @@
* @return
* @throws IOException
*/
- public String getXSDFile(URL url, File tempFile) throws IOException {
+ protected String getXSDString(URL url, File tempFile) throws IOException {
BufferedReader bufferedIn = new BufferedReader(new InputStreamReader(url.openStream()));
BufferedWriter bufferedOut = new BufferedWriter(new FileWriter(tempFile));
@@ -110,30 +104,42 @@
return buffer.toString();
}
-
+
+ protected String extractXSDFile(URL url) {
+ // try external XSD first
+ Matcher pathMatcher = xsdPattern.matcher(url.getPath());
+ if (pathMatcher.find()) {
+ return pathMatcher.group();
+ }
+ // try internal XSD
+ Matcher queryMatcher = xsdPattern.matcher(url.getQuery());
+ if (queryMatcher.find()) {
+ return queryMatcher.group();
+ }
+ return null;
+ }
+
/* (non-Javadoc)
* @see org.jboss.soa.esb.actions.soap.SchemaDeployer#deploy(java.lang.String, java.lang.String)
*/
public String deploy(String location, String soapAddress) {
-// String tmpDir = getTempDirectory();
-// String warLocation = tmpDir + File.separator + ESB_WAR_FILES_DIR + File.separator + esbContext + ".war";
-
File tmpXSD = null;
URL xsdUrl = null;
- String xsdFile = new String();
- String xsdString = new String();
-
+ String xsdFile = null;
+ String xsdString = null;
+
try {
xsdUrl = new URL(location);
-
- if (xsdUrl.getFile().startsWith(File.separator)) {
- xsdFile = xsdUrl.getFile().substring(1);
+ xsdFile = extractXSDFile(xsdUrl);
+ if (xsdFile == null) {
+ throw new IllegalArgumentException("Could not find match for pattern: " + XSD_PATTERN +
+ ", in location: " + location);
}
tmpXSD = File.createTempFile(xsdFile, ".tmp");
- xsdString = getXSDFile(xsdUrl, tmpXSD);
- } catch (IOException ioe) {
- logger.error(ioe);
+ xsdString = getXSDString(xsdUrl, tmpXSD);
+ } catch (Exception ioe) {
+ logger.error("Failed to get an XSD file", ioe);
return location;
}
@@ -154,60 +160,4 @@
resources.put(xsdFile, xsdString);
return soapAddress + "?wsdl&resource=" + xsdFile;
}
-
- /*
- public void writeToJar() {
- File warFile = new File(warLocation);
-
- ZipInputStream in = null;
- ZipOutputStream out = null;
- FileInputStream fileIn = null;
- File tmpWarFile = null;
- try {
- tmpWarFile = File.createTempFile((esbContext + ".war"), ".tmp");
- out = new ZipOutputStream(new FileOutputStream(tmpWarFile));
- in = new ZipInputStream(new FileInputStream(warFile));
-
- fileIn = new FileInputStream(tmpXSD);
-
-
- ZipEntry entry = in.getNextEntry();
- byte[] buffer = new byte[1024];
- int length = 0;
-
- while (entry != null) {
- String entryName = entry.getName();
- if (entryName.equals(xsdFile)) {
- } else {
- out.putNextEntry(new ZipEntry(entryName));
- while ((length = in.read(buffer)) > 0) {
- out.write(buffer, 0, length);
- }
- }
- entry = in.getNextEntry();
- }
-
- out.putNextEntry(new ZipEntry(xsdFile));
-
- while ((length = fileIn.read(buffer)) > 0) {
- out.write(buffer, 0, length);
- }
- } catch (IOException ioe) {
- logger.error(ioe);
- return location;
- } finally {
- try {
- out.closeEntry();
-
- in.close();
- fileIn.close();
- out.close();
- } catch (IOException ioe) {
- logger.error(ioe);
- }
- }
- tmpWarFile.renameTo(new File(warLocation));
- tmpXSD.delete();
- }
- */
}
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaLocationParser.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaLocationParser.java 2012-09-27 03:32:21 UTC (rev 38203)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaLocationParser.java 2012-09-27 09:22:15 UTC (rev 38204)
@@ -38,7 +38,6 @@
import org.xml.sax.SAXException;
import java.io.ByteArrayInputStream;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
@@ -86,12 +85,12 @@
Document doc = dBuilder.parse(is);
doc.getDocumentElement().normalize();
-
- NodeList nList = doc.getElementsByTagName("service");
+
+ NodeList nList = doc.getDocumentElement().getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node nNode = nList.item(i);
- if (nNode.getNodeType() == Node.ELEMENT_NODE) {
+ if (nNode.getNodeType() == Node.ELEMENT_NODE && Constants.ELEM_SERVICE.equals(getLocalPart(nNode))) {
Element eElement = (Element) nNode;
getPort(eElement);
}
@@ -113,12 +112,12 @@
Document doc = dBuilder.parse(is);
doc.getDocumentElement().normalize();
-
- NodeList nList = doc.getElementsByTagName(Constants.ELEM_TYPES);
+
+ NodeList nList = doc.getDocumentElement().getChildNodes();
for (int i = 0; i < nList.getLength(); i++) {
Node nNode = nList.item(i);
- if (nNode.getNodeType() == Node.ELEMENT_NODE) {
+ if (nNode.getNodeType() == Node.ELEMENT_NODE && Constants.ELEM_TYPES.equals(getLocalPart(nNode))) {
Element eElement = (Element) nNode;
getSchema(eElement);
}
@@ -149,7 +148,6 @@
if(node instanceof Element) {
Element child = (Element) node;
- String lp = getLocalPart(node);
if (SCHEMA_ELEM.equals(getLocalPart(node))) {
getImport(child);
}
@@ -169,7 +167,6 @@
if(node instanceof Element) {
Element child = (Element) node;
- String lp = getLocalPart(node);
if (PORT_ELEM.equals(getLocalPart(node))) {
getSOAPAddress(child);
}
@@ -190,14 +187,14 @@
if(node instanceof Element){
Element child = (Element) node;
- String imp = getLocalPart(node);
if (IMPORT_ELEM.equals(getLocalPart(node))) {
-
+
if (child.hasAttribute(SCHEMA_LOCATION_ATTR)) {
- if ((child.getAttribute(SCHEMA_LOCATION_ATTR) != null)
- && (child.getAttribute(SCHEMA_LOCATION_ATTR).startsWith("http://"))) {
- String xsdLocation = deployXSD(child.getAttribute(SCHEMA_LOCATION_ATTR));
- child.setAttribute(SCHEMA_LOCATION_ATTR, xsdLocation);
+ String schemaLocation = child.getAttribute(SCHEMA_LOCATION_ATTR);
+ if (schemaLocation != null
+ && (schemaLocation.startsWith("http://") || schemaLocation.startsWith("https://"))) {
+ String rewrittenLocation = deployXSD(schemaLocation);
+ child.setAttribute(SCHEMA_LOCATION_ATTR, rewrittenLocation);
}
}
}
@@ -218,7 +215,6 @@
if(node instanceof Element){
Element child = (Element) node;
- String imp = getLocalPart(node);
if ("address".equals(getLocalPart(node))) {
if ( (child.hasAttribute(SOAP_ADDRESS_LOCATION)) && (child.getAttribute(SOAP_ADDRESS_LOCATION) != null)) {
@@ -249,7 +245,6 @@
QName q = QNameUtils.newQName(child);
return q.getLocalPart();
} catch (IllegalArgumentException iae){
- Element el = (Element) child;
String nodeName = child.getNodeName();
if (nodeName.contains(":")) {
return nodeName.substring(nodeName.indexOf(":") + 1);
Added: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SchemaDeployerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SchemaDeployerUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SchemaDeployerUnitTest.java 2012-09-27 09:22:15 UTC (rev 38204)
@@ -0,0 +1,86 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2008, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.soap;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+public class SchemaDeployerUnitTest extends TestCase {
+
+ private SchemaDeployer deployer;
+
+ @Override
+ protected void setUp() {
+ deployer = new SchemaDeployerImpl() {
+ // mock method to eschew actual network access
+ @Override
+ public String getXSDString(URL url, File tempFile) throws IOException {
+ return "!!! Dummy XSD data !!!";
+ }
+ };
+ }
+
+ @Override
+ protected void tearDown() {
+ deployer = null;
+ }
+
+ public void testDeploy_JBossWS_Native() {
+ String rewrittenLocation = deployer.deploy("http://127.0.0.1:8080/Quickstart_HelloWorldWS/HelloWorldWS?wsdl&resource=HelloWorldService.xsd",
+ "http://www.jboss.org/HelloWorld");
+
+ assertEquals("http://www.jboss.org/HelloWorld?wsdl&resource=HelloWorldService.xsd", rewrittenLocation);
+ Map<String, String> resources = deployer.getResources();
+ assertEquals(resources.size(), 1);
+ assertEquals("!!! Dummy XSD data !!!", resources.get("HelloWorldService.xsd"));
+ }
+
+ public void testDeploy_JBossWS_CXF() {
+ String rewrittenLocation = deployer.deploy("http://127.0.0.1:8080/Quickstart_HelloWorldWS/HelloWorldWS?xsd=HelloWorldService.xsd",
+ "http://www.jboss.org/HelloWorld");
+
+ assertEquals("http://www.jboss.org/HelloWorld?wsdl&resource=HelloWorldService.xsd", rewrittenLocation);
+ Map<String, String> resources = deployer.getResources();
+ assertEquals(resources.size(), 1);
+ assertEquals("!!! Dummy XSD data !!!", resources.get("HelloWorldService.xsd"));
+ }
+
+ public void testDeploy_DuplicateNames() {
+ String rewrittenLocation1 = deployer.deploy("http://127.0.0.1:8080/Quickstart_HelloWorldWS/HelloWorldWS?wsdl&resource=HelloWorldService.xsd",
+ "http://www.jboss.org/HelloWorld");
+ String rewrittenLocation2 = deployer.deploy("http://127.0.0.1:8080/Quickstart_HelloWorldWS/HelloWorldWS?wsdl&resource=HelloWorldService.xsd",
+ "http://www.jboss.org/HelloWorld");
+ String rewrittenLocation3 = deployer.deploy("http://127.0.0.1:8080/Quickstart_HelloWorldWS/HelloWorldWS?wsdl&resource=HelloWorldService.xsd",
+ "http://www.jboss.org/HelloWorld");
+
+ assertEquals("http://www.jboss.org/HelloWorld?wsdl&resource=HelloWorldService.xsd", rewrittenLocation1);
+ assertEquals("http://www.jboss.org/HelloWorld?wsdl&resource=1HelloWorldService.xsd", rewrittenLocation2);
+ assertEquals("http://www.jboss.org/HelloWorld?wsdl&resource=2HelloWorldService.xsd", rewrittenLocation3);
+ Map<String, String> resources = deployer.getResources();
+ assertEquals(resources.size(), 3);
+ assertEquals("!!! Dummy XSD data !!!", resources.get("HelloWorldService.xsd"));
+ assertEquals("!!! Dummy XSD data !!!", resources.get("1HelloWorldService.xsd"));
+ assertEquals("!!! Dummy XSD data !!!", resources.get("2HelloWorldService.xsd"));
+ }
+}
Property changes on: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SchemaDeployerUnitTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SchemaLocatorUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SchemaLocatorUnitTest.java 2012-09-27 03:32:21 UTC (rev 38203)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SchemaLocatorUnitTest.java 2012-09-27 09:22:15 UTC (rev 38204)
@@ -21,31 +21,139 @@
import java.io.BufferedReader;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
import java.util.Map;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.TransformerException;
-
import junit.framework.TestCase;
import org.jboss.soa.esb.actions.soap.SchemaDeployer;
import org.jboss.soa.esb.actions.soap.SchemaDeployerImpl;
import org.jboss.soa.esb.actions.soap.SchemaLocationParser;
-import org.xml.sax.SAXException;
+import org.jboss.soa.esb.util.XPathUtil;
public class SchemaLocatorUnitTest extends TestCase {
public SchemaLocatorUnitTest() {
}
- public void testSchemaLocation()
- throws ParserConfigurationException, SAXException, IOException, TransformerException {
+ public void testSchemaLocationExternal() throws Exception {
+ StringBuffer fileData = getFileData("/test-schema-ext.wsdl");
+
+ SchemaDeployer sd = (SchemaDeployer) new SchemaDeployerImpl();
+ SchemaLocationParser slp = new SchemaLocationParser(sd);
+
+ String data = slp.parse(fileData.toString());
+
+ assertEquals(slp.getSoapAddress(), "http://localhost:8080/jaxws-jbws2526");
+ assertEquals(
+ "http://localhost:8080/jaxws-jbws2526?wsdl&resource=jbws2526.xsd",
+ XPathUtil.getNodeFromXPathExpression(data, "/definitions/types/schema/import").getAttribute("schemaLocation"));
+
+ Map<String, String> resources = sd.getResources();
+ assertEquals(1, resources.size());
+
+ for (String key : resources.keySet()) {
+ assertEquals(key, "jbws2526.xsd");
+ }
+
+ }
+
+ public void testSchemaLocationInternal() throws Exception{
+ StringBuffer fileData = getFileData("/test-schema-int.wsdl");
+ SchemaDeployer sd = new SchemaDeployerImpl() {
+ // mock method to eschew actual network access
+ @Override
+ public String getXSDString(URL url, File tempFile) throws IOException {
+ return "!!! Dummy XSD data !!!";
+ }
+ };
+ SchemaLocationParser slp = new SchemaLocationParser(sd);
+ String data = slp.parse(fileData.toString());
+
+ assertEquals(slp.getSoapAddress(), "http://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS");
+ assertEquals(
+ "http://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS?wsdl&resource=HelloWorldService.xsd",
+ XPathUtil.getNodeFromXPathExpression(data, "/definitions/types/schema/import").getAttribute("schemaLocation"));
+
+ Map<String, String> resources = sd.getResources();
+ assertEquals(1, resources.size());
+ assertEquals("!!! Dummy XSD data !!!", resources.get("HelloWorldService.xsd"));
+ }
+
+ public void testSchemaLocationInternal_cxf() throws Exception {
+ StringBuffer fileData = getFileData("/test-schema-int-cxf.wsdl");
+ SchemaDeployer sd = new SchemaDeployerImpl() {
+ // mock method to eschew actual network access
+ @Override
+ public String getXSDString(URL url, File tempFile) throws IOException {
+ return "!!! Dummy XSD data !!!";
+ }
+ };
+ SchemaLocationParser slp = new SchemaLocationParser(sd);
+ String data = slp.parse(fileData.toString());
+
+ assertEquals(slp.getSoapAddress(), "http://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS");
+ assertEquals(
+ "http://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS?wsdl&resource=HelloWorldService.xsd",
+ XPathUtil.getNodeFromXPathExpression(data, "/definitions/types/schema/import").getAttribute("schemaLocation"));
+
+ Map<String, String> resources = sd.getResources();
+ assertEquals(1, resources.size());
+ assertEquals("!!! Dummy XSD data !!!", resources.get("HelloWorldService.xsd"));
+ }
+
+ public void testSchemaLocationInternal_wsdlPrefixed() throws Exception {
+ StringBuffer fileData = getFileData("/test-schema-int-prefixed.wsdl");
+ SchemaDeployer sd = new SchemaDeployerImpl() {
+ // mock method to eschew actual network access
+ @Override
+ public String getXSDString(URL url, File tempFile) throws IOException {
+ return "!!! Dummy XSD data !!!";
+ }
+ };
+ SchemaLocationParser slp = new SchemaLocationParser(sd);
+ String data = slp.parse(fileData.toString());
+
+ assertEquals(slp.getSoapAddress(), "http://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS");
+ assertEquals(
+ "http://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS?wsdl&resource=HelloWorldService.xsd",
+ XPathUtil.getNodeFromXPathExpression(data, "/definitions/types/schema/import").getAttribute("schemaLocation"));
+
+ Map<String, String> resources = sd.getResources();
+ assertEquals(1, resources.size());
+ assertEquals("!!! Dummy XSD data !!!", resources.get("HelloWorldService.xsd"));
+ }
+
+ public void testSchemaLocationInternal_https() throws Exception {
+ StringBuffer fileData = getFileData("/test-schema-int-https.wsdl");
+ SchemaDeployer sd = new SchemaDeployerImpl() {
+ // mock method to eschew actual network access
+ @Override
+ public String getXSDString(URL url, File tempFile) throws IOException {
+ return "!!! Dummy XSD data !!!";
+ }
+ };
+ SchemaLocationParser slp = new SchemaLocationParser(sd);
+ String data = slp.parse(fileData.toString());
+
+ assertEquals(slp.getSoapAddress(), "https://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS");
+ assertEquals(
+ "https://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS?wsdl&resource=HelloWorldService.xsd",
+ XPathUtil.getNodeFromXPathExpression(data, "/definitions/types/schema/import").getAttribute("schemaLocation"));
+
+ Map<String, String> resources = sd.getResources();
+ assertEquals(1, resources.size());
+ assertEquals("!!! Dummy XSD data !!!", resources.get("HelloWorldService.xsd"));
+ }
+
+ private StringBuffer getFileData(String filePath) throws FileNotFoundException,
+ IOException {
StringBuffer fileData = new StringBuffer(1000);
- URL testSchema = getClass().getResource("/test-schema.wsdl");
+ URL testSchema = getClass().getResource(filePath);
BufferedReader reader = new BufferedReader(new FileReader(testSchema.getPath()));
char[] buffer = new char[1024];
@@ -56,18 +164,7 @@
buffer = new char[1024];
}
reader.close();
-
- SchemaDeployer sd = (SchemaDeployer) new SchemaDeployerImpl();
- SchemaLocationParser slp = new SchemaLocationParser(sd);
-
- String data = slp.parse(fileData.toString());
-
- assertEquals(slp.getSoapAddress(), "http://localhost:8080/jaxws-jbws2526");
-
- Map<String, String> resources = sd.getResources();
- assertEquals(resources.size(), 1);
- for (String key : resources.keySet()) {
- assertEquals(key, "jbws2526.xsd");
- }
+ return fileData;
}
+
}
Added: labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-ext.wsdl
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-ext.wsdl (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-ext.wsdl 2012-09-27 09:22:15 UTC (rev 38204)
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions name="JBWS-2526"
+ targetNamespace="urn:JBWS-2526-Service"
+ xmlns:service="urn:JBWS-2526-Service"
+ xmlns:schema="urn:JBWS-2526-Schema"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+ xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+ xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <types>
+ <xs:schema>
+ <xs:import namespace="urn:JBWS-2526-Schema"
+ schemaLocation="http://www.rotowatch.com/jbws2526.xsd"/>
+ </xs:schema>
+ </types>
+
+ <message name="Request">
+ <part name="request" element="schema:Request"/>
+ </message>
+ <message name="Response">
+ <part name="response" element="schema:Response"/>
+ </message>
+
+ <portType name="Port">
+ <operation name="evaluate">
+ <input message="service:Request"/>
+ <output message="service:Response"/>
+ </operation>
+ </portType>
+
+ <binding name="Binding" type="service:Port">
+ <soap:binding style="document"
+ transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="evaluate">
+ <soap:operation/>
+ <input>
+ <soap:body use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ </operation>
+ </binding>
+
+ <service name="Service">
+ <port binding="service:Binding" name="Port">
+ <soap:address location="http://localhost:8080/jaxws-jbws2526"/>
+ </port>
+ </service>
+</definitions>
Property changes on: labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-ext.wsdl
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int-cxf.wsdl
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int-cxf.wsdl (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int-cxf.wsdl 2012-09-27 09:22:15 UTC (rev 38204)
@@ -0,0 +1,36 @@
+<definitions name='HelloWorldServiceService' targetNamespace='http://webservice_producer/helloworld' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://webservice_producer/helloworld' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <types>
+ <xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <xsd:import namespace='http://webservice_producer/helloworld' schemaLocation='http://127.0.0.1:8080/HelloWorld_WS/HelloWorldWS?xsd=HelloWorldService.xsd'/>
+ </xsd:schema>
+ </types>
+ <message name='HelloWorldWS_sayHelloResponse'>
+ <part element='tns:sayHelloResponse' name='sayHelloResponse'></part>
+ </message>
+ <message name='HelloWorldWS_sayHello'>
+ <part element='tns:sayHello' name='sayHello'></part>
+ </message>
+ <portType name='HelloWorldWS'>
+ <operation name='sayHello' parameterOrder='sayHello'>
+ <input message='tns:HelloWorldWS_sayHello'></input>
+ <output message='tns:HelloWorldWS_sayHelloResponse'></output>
+ </operation>
+ </portType>
+ <binding name='HelloWorldWSBinding' type='tns:HelloWorldWS'>
+ <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
+ <operation name='sayHello'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body use='literal'/>
+ </input>
+ <output>
+ <soap:body use='literal'/>
+ </output>
+ </operation>
+ </binding>
+ <service name='HelloWorldServiceService'>
+ <port binding='tns:HelloWorldWSBinding' name='HelloWorldWSPort'>
+ <soap:address location='http://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS'/>
+ </port>
+ </service>
+</definitions>
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int-cxf.wsdl
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int-https.wsdl
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int-https.wsdl (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int-https.wsdl 2012-09-27 09:22:15 UTC (rev 38204)
@@ -0,0 +1,36 @@
+<definitions name='HelloWorldServiceService' targetNamespace='http://webservice_producer/helloworld' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://webservice_producer/helloworld' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <types>
+ <xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <xsd:import namespace='http://webservice_producer/helloworld' schemaLocation='https://127.0.0.1:8080/HelloWorld_WS/HelloWorldWS?wsdl&resource=HelloWorldService.xsd'/>
+ </xsd:schema>
+ </types>
+ <message name='HelloWorldWS_sayHelloResponse'>
+ <part element='tns:sayHelloResponse' name='sayHelloResponse'></part>
+ </message>
+ <message name='HelloWorldWS_sayHello'>
+ <part element='tns:sayHello' name='sayHello'></part>
+ </message>
+ <portType name='HelloWorldWS'>
+ <operation name='sayHello' parameterOrder='sayHello'>
+ <input message='tns:HelloWorldWS_sayHello'></input>
+ <output message='tns:HelloWorldWS_sayHelloResponse'></output>
+ </operation>
+ </portType>
+ <binding name='HelloWorldWSBinding' type='tns:HelloWorldWS'>
+ <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
+ <operation name='sayHello'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body use='literal'/>
+ </input>
+ <output>
+ <soap:body use='literal'/>
+ </output>
+ </operation>
+ </binding>
+ <service name='HelloWorldServiceService'>
+ <port binding='tns:HelloWorldWSBinding' name='HelloWorldWSPort'>
+ <soap:address location='https://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS'/>
+ </port>
+ </service>
+</definitions>
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int-https.wsdl
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int-prefixed.wsdl
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int-prefixed.wsdl (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int-prefixed.wsdl 2012-09-27 09:22:15 UTC (rev 38204)
@@ -0,0 +1,36 @@
+<wsdl:definitions name='HelloWorldServiceService' targetNamespace='http://webservice_producer/helloworld' xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://webservice_producer/helloworld' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <wsdl:types>
+ <xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <xsd:import namespace='http://webservice_producer/helloworld' schemaLocation='http://127.0.0.1:8080/HelloWorld_WS/HelloWorldWS?wsdl&resource=HelloWorldService.xsd'/>
+ </xsd:schema>
+ </wsdl:types>
+ <wsdl:message name='HelloWorldWS_sayHelloResponse'>
+ <wsdl:part element='tns:sayHelloResponse' name='sayHelloResponse'></wsdl:part>
+ </wsdl:message>
+ <wsdl:message name='HelloWorldWS_sayHello'>
+ <wsdl:part element='tns:sayHello' name='sayHello'></wsdl:part>
+ </wsdl:message>
+ <wsdl:portType name='HelloWorldWS'>
+ <wsdl:operation name='sayHello' parameterOrder='sayHello'>
+ <wsdl:input message='tns:HelloWorldWS_sayHello'></wsdl:input>
+ <wsdl:output message='tns:HelloWorldWS_sayHelloResponse'></wsdl:output>
+ </wsdl:operation>
+ </wsdl:portType>
+ <wsdl:binding name='HelloWorldWSBinding' type='tns:HelloWorldWS'>
+ <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
+ <wsdl:operation name='sayHello'>
+ <soap:operation soapAction=''/>
+ <wsdl:input>
+ <soap:body use='literal'/>
+ </wsdl:input>
+ <wsdl:output>
+ <soap:body use='literal'/>
+ </wsdl:output>
+ </wsdl:operation>
+ </wsdl:binding>
+ <wsdl:service name='HelloWorldServiceService'>
+ <wsdl:port binding='tns:HelloWorldWSBinding' name='HelloWorldWSPort'>
+ <soap:address location='http://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS'/>
+ </wsdl:port>
+ </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int-prefixed.wsdl
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int.wsdl
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int.wsdl (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int.wsdl 2012-09-27 09:22:15 UTC (rev 38204)
@@ -0,0 +1,36 @@
+<definitions name='HelloWorldServiceService' targetNamespace='http://webservice_producer/helloworld' xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/' xmlns:tns='http://webservice_producer/helloworld' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <types>
+ <xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <xsd:import namespace='http://webservice_producer/helloworld' schemaLocation='http://127.0.0.1:8080/HelloWorld_WS/HelloWorldWS?wsdl&resource=HelloWorldService.xsd'/>
+ </xsd:schema>
+ </types>
+ <message name='HelloWorldWS_sayHelloResponse'>
+ <part element='tns:sayHelloResponse' name='sayHelloResponse'></part>
+ </message>
+ <message name='HelloWorldWS_sayHello'>
+ <part element='tns:sayHello' name='sayHello'></part>
+ </message>
+ <portType name='HelloWorldWS'>
+ <operation name='sayHello' parameterOrder='sayHello'>
+ <input message='tns:HelloWorldWS_sayHello'></input>
+ <output message='tns:HelloWorldWS_sayHelloResponse'></output>
+ </operation>
+ </portType>
+ <binding name='HelloWorldWSBinding' type='tns:HelloWorldWS'>
+ <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
+ <operation name='sayHello'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body use='literal'/>
+ </input>
+ <output>
+ <soap:body use='literal'/>
+ </output>
+ </operation>
+ </binding>
+ <service name='HelloWorldServiceService'>
+ <port binding='tns:HelloWorldWSBinding' name='HelloWorldWSPort'>
+ <soap:address location='http://127.0.0.1:8080/HelloWorld_ESB/http/HelloWorldWS'/>
+ </port>
+ </service>
+</definitions>
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema-int.wsdl
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted: labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema.wsdl
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema.wsdl 2012-09-27 03:32:21 UTC (rev 38203)
+++ labs/jbossesb/trunk/product/services/soap/src/test/resources/test-schema.wsdl 2012-09-27 09:22:15 UTC (rev 38204)
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<definitions name="JBWS-2526"
- targetNamespace="urn:JBWS-2526-Service"
- xmlns:service="urn:JBWS-2526-Service"
- xmlns:schema="urn:JBWS-2526-Schema"
- xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
- xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
- xmlns="http://schemas.xmlsoap.org/wsdl/">
- <types>
- <xs:schema>
- <xs:import namespace="urn:JBWS-2526-Schema"
- schemaLocation="http://www.rotowatch.com/jbws2526.xsd"/>
- </xs:schema>
- </types>
-
- <message name="Request">
- <part name="request" element="schema:Request"/>
- </message>
- <message name="Response">
- <part name="response" element="schema:Response"/>
- </message>
-
- <portType name="Port">
- <operation name="evaluate">
- <input message="service:Request"/>
- <output message="service:Response"/>
- </operation>
- </portType>
-
- <binding name="Binding" type="service:Port">
- <soap:binding style="document"
- transport="http://schemas.xmlsoap.org/soap/http"/>
- <operation name="evaluate">
- <soap:operation/>
- <input>
- <soap:body use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- </operation>
- </binding>
-
- <service name="Service">
- <port binding="service:Binding" name="Port">
- <soap:address location="http://localhost:8080/jaxws-jbws2526"/>
- </port>
- </service>
-</definitions>
More information about the jboss-svn-commits
mailing list