[jboss-svn-commits] JBL Code SVN: r18824 - in labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src: test/java/org/jboss/soa/esb/services/soapui and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Mar 11 09:39:24 EDT 2008


Author: tfennelly
Date: 2008-03-11 09:39:23 -0400 (Tue, 11 Mar 2008)
New Revision: 18824

Added:
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/OrderProcessingSchema_JBESB-1329.xsd
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/OrderProcessing_JBESB-1329.wsdl
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/expected_01_JBESB-1329.xml
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/expected_02_JBESB-1329.xml
Modified:
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java
   labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java
Log:
http://jira.jboss.com/jira/browse/JBESB-1329

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java	2008-03-11 12:28:50 UTC (rev 18823)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/main/java/org/jboss/soa/esb/services/soapui/SoapUIClientService.java	2008-03-11 13:39:23 UTC (rev 18824)
@@ -64,6 +64,7 @@
     private DocumentBuilderFactory docBuilderFactory ;
     private Map<String, Smooks> smooksCache;
     private ESBProperties properties;
+    private static final String CLONED_POSTFIX = " - cloned";
 
     /**
      * Public default constructor.
@@ -211,7 +212,17 @@
 
                 collectionSize = calculateCollectionSize(ognl, params);
 
-                if(collectionSize < 1) {
+                if(collectionSize == -1) {
+                    // It's a collection, but has no entries that match the OGNL expression for this element...
+                    if(clonePoint == element) {
+                        // If the clonePoint is the element itself, we remove it... we're done with it...
+                        clonePoint.getParentNode().removeChild(clonePoint);
+                    } else {
+                        // If the clonePoint is not the element itself (it's a child element), leave it
+                        // and check it again when we get to it...
+                        resetClonePoint(clonePoint);
+                    }
+                } else if(collectionSize == 0) {
                     // It's a collection, but has no entries, remove it...
                     clonePoint.getParentNode().removeChild(clonePoint);
                 } else if(collectionSize == 1) {
@@ -273,6 +284,7 @@
             return maxIndex + 1;
         }
 
+        // It's a collection, but nothing in this message for it collection...
         return -1;
     }
 
@@ -282,7 +294,7 @@
         // Is it this element...
         comment = getCommentBefore(element);
         if(comment != null && comment.getTextContent().endsWith(SOAPUI_CLONE_COMMENT)) {
-            comment.setTextContent(comment.getTextContent() + " - cloned");
+            comment.setTextContent(comment.getTextContent() + CLONED_POSTFIX);
             return element;
         }
 
@@ -291,7 +303,7 @@
         if(firstChildElement != null) {
             comment = getCommentBefore(firstChildElement);
             if(comment != null && comment.getTextContent().endsWith(SOAPUI_CLONE_COMMENT)) {
-                comment.setTextContent(comment.getTextContent() + " - cloned");
+                comment.setTextContent(comment.getTextContent() + CLONED_POSTFIX);
                 return firstChildElement;
             }
         }
@@ -299,6 +311,21 @@
         return null;
     }
 
+    private void resetClonePoint(Element clonePoint) {
+        Comment comment = getCommentBefore(clonePoint);
+
+        if(comment == null) {
+            throw new IllegalStateException("Call to reset a 'clonePoint' that doesn't have a comment before it.");
+        }
+
+        String commentText = comment.getTextContent();
+        if(!commentText.endsWith(CLONED_POSTFIX)) {
+            throw new IllegalStateException("Call to reset a 'clonePoint' that doesn't have a proper clone comment before it.");
+        }
+
+        comment.setTextContent(commentText.substring(0, commentText.length() - CLONED_POSTFIX.length()));
+    }
+
     private Comment getCommentBefore(Element element) {
         Node sibling = element.getPreviousSibling();
 

Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java	2008-03-11 12:28:50 UTC (rev 18823)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/SoapUIClientServiceMBeanUnitTest.java	2008-03-11 13:39:23 UTC (rev 18824)
@@ -151,6 +151,45 @@
         assertTrue("Generated SOAP message not as expected. See orderprocessing/expected_01.xml.  Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("orderprocessing/expected_01.xml"), new ByteArrayInputStream(message.getBytes())));
     }
 
+    public void test_has_collections_02_JBESB_1329() throws IOException, SAXException, ConfigurationException {
+        File wsdlFile = new File(WSDL_LOCATAION + "/orderprocessing/OrderProcessing_JBESB-1329.wsdl");
+        SoapUIClientService mbean = new SoapUIClientService();
+        Map params = new HashMap();
+        ArrayList<LineItem> lineItems = new ArrayList<LineItem>();
+
+        properties.setProperty(HttpClientFactory.TARGET_HOST_URL, wsdlFile.toURI().toString());
+
+        Order order = new Order();
+        ProcessOrderRequest request = new ProcessOrderRequest(order);
+        order.setId(123L);
+        order.setShipTo("Skeagh Bridge");
+        order.setLineItems(lineItems);
+
+        LineItem lineItem;
+
+        lineItem = new LineItem();
+        lineItems.add(lineItem);
+        lineItem.setId(456L);
+        lineItem.setName("item1");
+        lineItem.setPrice(10.99f);
+
+        lineItem = new LineItem();
+        lineItems.add(lineItem);
+        lineItem.setId(890L);
+        lineItem.setName("item2");
+        lineItem.setPrice(12.11f);
+
+        lineItem = new LineItem();
+        lineItems.add(lineItem);
+        lineItem.setId(321L);
+        lineItem.setName("item3");
+        lineItem.setPrice(76.34f);
+
+        params.put("processOrder", request);
+        String message = mbean.buildRequest(wsdlFile.toURI().toString(), "processOrder", params, properties, null, null);
+        assertTrue("Generated SOAP message not as expected. See orderprocessing/expected_01_JBESB-1329.xml.  Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("orderprocessing/expected_01_JBESB-1329.xml"), new ByteArrayInputStream(message.getBytes())));
+    }
+
     public void test_has_collections_03() throws IOException, SAXException, ConfigurationException {
         File wsdlFile = new File(WSDL_LOCATAION + "/orderprocessing/OrderProcessing.wsdl");
         SoapUIClientService mbean = new SoapUIClientService();
@@ -172,6 +211,27 @@
         assertTrue("Generated SOAP message not as expected. See orderprocessing/expected_02.xml.  Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("orderprocessing/expected_02.xml"), new ByteArrayInputStream(message.getBytes())));
     }
 
+    public void test_has_collections_03_JBESB_1329() throws IOException, SAXException, ConfigurationException {
+        File wsdlFile = new File(WSDL_LOCATAION + "/orderprocessing/OrderProcessing_JBESB-1329.wsdl");
+        SoapUIClientService mbean = new SoapUIClientService();
+        Map params = new HashMap();
+        ArrayList<LineItem> lineItems = new ArrayList<LineItem>();
+
+        properties.setProperty(HttpClientFactory.TARGET_HOST_URL, wsdlFile.toURI().toString());
+
+        Order order = new Order();
+        ProcessOrderRequest request = new ProcessOrderRequest(order);
+        order.setId(123L);
+        order.setShipTo("Skeagh Bridge");
+        order.setLineItems(lineItems);
+
+        // No line Items....
+
+        params.put("processOrder", request);
+        String message = mbean.buildRequest(wsdlFile.toURI().toString(), "processOrder", params, properties, null, null);
+        assertTrue("Generated SOAP message not as expected. See orderprocessing/expected_02_JBESB-1329.xml.  Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("orderprocessing/expected_02_JBESB-1329.xml"), new ByteArrayInputStream(message.getBytes())));
+    }
+
     public void test_has_collections_04() throws IOException, SAXException, ConfigurationException {
         File wsdlFile = new File(WSDL_LOCATAION + "/orderprocessing/OrderProcessing.wsdl");
         SoapUIClientService mbean = new SoapUIClientService();
@@ -196,6 +256,30 @@
         assertTrue("Generated SOAP message not as expected. See orderprocessing/expected_01.xml.  Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("orderprocessing/expected_01.xml"), new ByteArrayInputStream(message.getBytes())));
     }
 
+    public void test_has_collections_04_JBESB_1329() throws IOException, SAXException, ConfigurationException {
+        File wsdlFile = new File(WSDL_LOCATAION + "/orderprocessing/OrderProcessing_JBESB-1329.wsdl");
+        SoapUIClientService mbean = new SoapUIClientService();
+        Map params = new HashMap();
+
+        properties.setProperty(HttpClientFactory.TARGET_HOST_URL, wsdlFile.toURI().toString());
+
+        params.put("processOrder.order.id", 123L);
+        params.put("processOrder.order.shipTo", "Skeagh Bridge");
+
+        params.put("processOrder.order.lineItems[0].id", 456L);
+        params.put("processOrder.order.lineItems[0].name", "item1");
+        params.put("processOrder.order.lineItems[0].price", 10.99f);
+        params.put("processOrder.order.lineItems[1].id", 890L);
+        params.put("processOrder.order.lineItems[1].name", "item2");
+        params.put("processOrder.order.lineItems[1].price", 12.11f);
+        params.put("processOrder.order.lineItems[2].id", 321L);
+        params.put("processOrder.order.lineItems[2].name", "item3");
+        params.put("processOrder.order.lineItems[2].price", 76.34f);
+
+        String message = mbean.buildRequest(wsdlFile.toURI().toString(), "processOrder", params, properties, null, null);
+        assertTrue("Generated SOAP message not as expected. See orderprocessing/expected_01_JBESB-1329.xml.  Generated message: \n" + message, compareCharStreams(getClass().getResourceAsStream("orderprocessing/expected_01_JBESB-1329.xml"), new ByteArrayInputStream(message.getBytes())));
+    }
+
     public void test_has_collections_05() throws IOException, SAXException, ConfigurationException {
         File wsdlFile = new File(WSDL_LOCATAION + "/orderprocessing/OrderProcessing.wsdl");
         SoapUIClientService mbean = new SoapUIClientService();

Copied: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/OrderProcessingSchema_JBESB-1329.xsd (from rev 18800, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/OrderProcessingSchema.xsd)
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/OrderProcessingSchema_JBESB-1329.xsd	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/OrderProcessingSchema_JBESB-1329.xsd	2008-03-11 13:39:23 UTC (rev 18824)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<xs:schema version="1.0" targetNamespace="http://endpoint/" xmlns:tns="http://endpoint/"
+           xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+    <xs:element name="processOrder" type="tns:processOrder"/>
+
+    <xs:element name="processOrderResponse" type="tns:processOrderResponse"/>
+
+    <xs:complexType name="processOrder">
+        <xs:sequence>
+            <xs:element name="order" type="tns:order" minOccurs="0"/>
+        </xs:sequence>
+
+    </xs:complexType>
+
+    <xs:complexType name="order">
+        <xs:sequence>
+            <xs:element name="lineItems" type="tns:lineItem" nillable="true" maxOccurs="unbounded" minOccurs="0"/>
+            <xs:element name="id" type="xs:long" minOccurs="0"/>
+            <xs:element name="shipTo" type="xs:string" minOccurs="0"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="lineItem">
+        <xs:sequence>
+            <xs:element name="id" type="xs:long" minOccurs="0"/>
+            <xs:element name="name" type="xs:string" minOccurs="0"/>
+            <xs:element name="price" type="xs:float" minOccurs="0"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="processOrderResponse">
+
+        <xs:sequence>
+            <xs:element name="return" type="tns:orderStatus" minOccurs="0"/>
+        </xs:sequence>
+    </xs:complexType>
+
+    <xs:complexType name="orderStatus">
+        <xs:sequence>
+            <xs:element name="comment" type="xs:string" minOccurs="0"/>
+            <xs:element name="id" type="xs:long" minOccurs="0"/>
+
+            <xs:element name="returnCode" type="xs:int"/>
+        </xs:sequence>
+    </xs:complexType>
+</xs:schema>
\ No newline at end of file

Copied: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/OrderProcessing_JBESB-1329.wsdl (from rev 18800, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/OrderProcessing.wsdl)
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/OrderProcessing_JBESB-1329.wsdl	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/OrderProcessing_JBESB-1329.wsdl	2008-03-11 13:39:23 UTC (rev 18824)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://endpoint/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://endpoint/" name="OrderProcessingService">
+  <types>
+    <xsd:schema>
+      <xsd:import namespace="http://endpoint/" schemaLocation="OrderProcessingSchema_JBESB-1329.xsd" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"/>
+    </xsd:schema>
+  </types>
+  <message name="processOrder">
+    <part name="parameters" element="tns:processOrder"/>
+  </message>
+
+  <message name="processOrderResponse">
+    <part name="parameters" element="tns:processOrderResponse"/>
+  </message>
+  <portType name="OrderProcessing">
+    <operation name="processOrder">
+      <input message="tns:processOrder"/>
+      <output message="tns:processOrderResponse"/>
+    </operation>
+  </portType>
+
+  <binding name="OrderProcessingPortBinding" type="tns:OrderProcessing">
+    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+    <operation name="processOrder">
+      <soap:operation soapAction=""/>
+      <input>
+        <soap:body use="literal"/>
+      </input>
+      <output>
+        <soap:body use="literal"/>
+
+      </output>
+    </operation>
+  </binding>
+  <service name="OrderProcessingService">
+    <port name="OrderProcessingPort" binding="tns:OrderProcessingPortBinding">
+      <soap:address location="http://tfennelly:8080/order-processing/OrderProcessingService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"/>
+    </port>
+  </service>
+</definitions>
\ No newline at end of file

Copied: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/expected_01_JBESB-1329.xml (from rev 18800, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/expected_01.xml)
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/expected_01_JBESB-1329.xml	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/expected_01_JBESB-1329.xml	2008-03-11 13:39:23 UTC (rev 18824)
@@ -0,0 +1,37 @@
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:end="http://endpoint/">
+   <soapenv:Header/>
+   <soapenv:Body>
+      <end:processOrder>
+         <!--Optional:-->
+         <order>
+            <!--Zero or more repetitions: - cloned-->
+            <lineItems>
+               <!--Optional:-->
+               <id>456</id>
+               <!--Optional:-->
+               <name>item1</name>
+               <!--Optional:-->
+               <price>10.99</price>
+            </lineItems>
+            <!--Optional:-->
+            <lineItems>
+               <!--Optional:-->
+               <id>890</id>
+               <!--Optional:-->
+               <name>item2</name>
+               <!--Optional:-->
+               <price>12.11</price>
+            </lineItems><lineItems>
+               <!--Optional:-->
+               <id>321</id>
+               <!--Optional:-->
+               <name>item3</name>
+               <!--Optional:-->
+               <price>76.34</price>
+            </lineItems><id>123</id>
+            <!--Optional:-->
+            <shipTo>Skeagh Bridge</shipTo>
+         </order>
+      </end:processOrder>
+   </soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file

Copied: labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/expected_02_JBESB-1329.xml (from rev 18800, labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/expected_02.xml)
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/expected_02_JBESB-1329.xml	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_CP/product/services/soapui-client/src/test/java/org/jboss/soa/esb/services/soapui/orderprocessing/expected_02_JBESB-1329.xml	2008-03-11 13:39:23 UTC (rev 18824)
@@ -0,0 +1,16 @@
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:end="http://endpoint/">
+   <soapenv:Header/>
+   <soapenv:Body>
+      <end:processOrder>
+         <!--Optional:-->
+         <order>
+            <!--Zero or more repetitions: - cloned-->
+
+            <!--Optional:-->
+            <id>123</id>
+            <!--Optional:-->
+            <shipTo>Skeagh Bridge</shipTo>
+         </order>
+      </end:processOrder>
+   </soapenv:Body>
+</soapenv:Envelope>
\ No newline at end of file




More information about the jboss-svn-commits mailing list