[jboss-svn-commits] JBL Code SVN: r38171 - in labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src: test/java/org/jboss/soa/esb/actions/soap and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Sep 7 11:05:00 EDT 2012


Author: tcunning
Date: 2012-09-07 11:05:00 -0400 (Fri, 07 Sep 2012)
New Revision: 38171

Added:
   labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-ext.wsdl
   labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int.wsdl
Removed:
   labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema.wsdl
Modified:
   labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java
   labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaDeployerImpl.java
   labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaLocationParser.java
   labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SchemaLocatorUnitTest.java
Log:
JBESB-3802
Committing changes submitted by Jason Shepherd to the rewrite schemas patch.   The way in which
we parse out xsd names is changed slightly, a test is added, and the restriction that we only
deal with remote schemas is removed.    Due to that restriction being removed, the property
to set has changed from "cache-remote-schemas" to "cache-schemas".


Modified: labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java	2012-09-06 01:47:37 UTC (rev 38170)
+++ labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java	2012-09-07 15:05:00 UTC (rev 38171)
@@ -59,7 +59,7 @@
    
     private static Logger logger = Logger.getLogger(AbstractWsdlContractPublisher.class);
 
-    public static final String CACHE_REMOTE_SCHEMAS = "cache-remote-schemas";
+    public static final String CACHE_REMOTE_SCHEMAS = "cache-schemas";
     public static final String REWRITE_ENDPOINT_URL = "rewrite-endpoint-url";
 
     private Properties actionProperties;

Modified: labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaDeployerImpl.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaDeployerImpl.java	2012-09-06 01:47:37 UTC (rev 38170)
+++ labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaDeployerImpl.java	2012-09-07 15:05:00 UTC (rev 38171)
@@ -30,9 +30,13 @@
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 import java.util.zip.ZipOutputStream;
@@ -46,6 +50,7 @@
 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>();
 	
@@ -125,14 +130,20 @@
 		
 		try {
 			xsdUrl = new URL(location);
-	
-			if (xsdUrl.getFile().startsWith(File.separator)) {
-				xsdFile = xsdUrl.getFile().substring(1);
+			URI xsdUri = new URI(location);
+			Pattern p = Pattern.compile(XSD_PATTERN);
+			Matcher m = p.matcher(location);
+			
+			if(m.find()){
+				xsdFile = m.group();
+			} else {
+				throw new IllegalStateException("Could not find match for pattern: "+ XSD_PATTERN + 
+						", in location: " + location);
 			}
 			
 			tmpXSD = File.createTempFile(xsdFile, ".tmp");
 			xsdString = getXSDFile(xsdUrl, tmpXSD);
-		} catch (IOException ioe) {
+		} catch (Exception ioe) {
 			logger.error(ioe);
 			return location;
 		}

Modified: labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaLocationParser.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaLocationParser.java	2012-09-06 01:47:37 UTC (rev 38170)
+++ labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SchemaLocationParser.java	2012-09-07 15:05:00 UTC (rev 38171)
@@ -42,6 +42,8 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringWriter;
+import java.net.URI;
+import java.net.URISyntaxException;
 
 public class SchemaLocationParser {
 
@@ -194,9 +196,9 @@
 				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));
+						String schemaLocation = child.getAttribute(SCHEMA_LOCATION_ATTR);
+						if ((schemaLocation != null)) {
+							String xsdLocation = deployXSD(schemaLocation);
 							child.setAttribute(SCHEMA_LOCATION_ATTR, xsdLocation);
 						}
 					}
@@ -204,7 +206,6 @@
 			}
 		}		
 	}
-
 	/**
 	 * Get the SOAP Adddress.
 	 * @param element

Modified: labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SchemaLocatorUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SchemaLocatorUnitTest.java	2012-09-06 01:47:37 UTC (rev 38170)
+++ labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SchemaLocatorUnitTest.java	2012-09-07 15:05:00 UTC (rev 38171)
@@ -21,6 +21,7 @@
 
 import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
 import java.net.URL;
@@ -41,11 +42,47 @@
 		
 	}
 	
-	public void testSchemaLocation() 
+	public void testSchemaLocationExternal() 
 		throws ParserConfigurationException, SAXException, IOException, TransformerException {
     	
+		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");
+    	
+    	Map<String, String> resources = sd.getResources();
+    	assertEquals(resources.size(), 1);
+    	
+		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();
+		SchemaLocationParser slp = new SchemaLocationParser(sd);
+		String data = slp.parse(fileData.toString());
+		
+		assertEquals(slp.getSoapAddress(), "http://127.0.0.1:8080/Quickstart_HelloWorldWS/HelloWorldWS");
+		
+		Map<String, String> resources = sd.getResources();
+		assertEquals(resources.size(), 0);
+		
+		for (String key : resources.keySet()) {
+			assertEquals(key, "jbws2526.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 +93,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/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-ext.wsdl
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-ext.wsdl	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-ext.wsdl	2012-09-07 15:05:00 UTC (rev 38171)
@@ -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>

Added: labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int.wsdl
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int.wsdl	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema-int.wsdl	2012-09-07 15:05:00 UTC (rev 38171)
@@ -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/Quickstart_HelloWorldWS/HelloWorldWS?wsdl&amp;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/Quickstart_HelloWorldWS/HelloWorldWS'/>
+  </port>
+ </service>
+</definitions>
\ No newline at end of file

Deleted: labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema.wsdl
===================================================================
--- labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema.wsdl	2012-09-06 01:47:37 UTC (rev 38170)
+++ labs/jbossesb/branches/JBESB_4_11_CP/product/services/soap/src/test/resources/test-schema.wsdl	2012-09-07 15:05:00 UTC (rev 38171)
@@ -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