cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r606836 - in /incubator/cxf/trunk: parent/ rt/databinding/aegis/ rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/ rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ rt/databinding/aegis/src/test/java/or...
Date Wed, 26 Dec 2007 04:11:57 GMT
Author: bimargulies
Date: Tue Dec 25 20:11:51 2007
New Revision: 606836

URL: http://svn.apache.org/viewvc?rev=606836&view=rev
Log:
Fix CXF-1333, Aegis services that accept arrays of JDOMElements.

Added:
    incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/
    incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/
    incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/
    incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/
    incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/
    incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/
    incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayJDOM.xml
  (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayW3C.xml
  (with props)
Modified:
    incubator/cxf/trunk/parent/pom.xml
    incubator/cxf/trunk/rt/databinding/aegis/pom.xml
    incubator/cxf/trunk/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementReader.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/ArrayService.java
    incubator/cxf/trunk/rt/javascript/pom.xml
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AegisService.java
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AegisServiceImpl.java
    incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AegisTests.js

Modified: incubator/cxf/trunk/parent/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/parent/pom.xml?rev=606836&r1=606835&r2=606836&view=diff
==============================================================================
--- incubator/cxf/trunk/parent/pom.xml (original)
+++ incubator/cxf/trunk/parent/pom.xml Tue Dec 25 20:11:51 2007
@@ -57,6 +57,7 @@
         <activemq.version>4.1.1</activemq.version>
         <geronimo.version>1.1</geronimo.version>
         <rhino.version>1.6R7</rhino.version>
+        <jdom.version>1.0</jdom.version>
         <xmlbeans.version>2.2.0</xmlbeans.version>
 
         <spring.validation.mode>VALIDATION_AUTO</spring.validation.mode>

Modified: incubator/cxf/trunk/rt/databinding/aegis/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/pom.xml?rev=606836&r1=606835&r2=606836&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/pom.xml (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/pom.xml Tue Dec 25 20:11:51 2007
@@ -81,7 +81,7 @@
         <dependency>
             <groupId>jdom</groupId>
             <artifactId>jdom</artifactId>
-            <version>1.0</version>
+            <version>${jdom.version}</version>
         </dependency>
         <dependency>
             <groupId>net.java.dev.stax-utils</groupId>
@@ -154,4 +154,4 @@
             </plugin>
         </plugins>
     </build>
-</project>
\ No newline at end of file
+</project>

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java?rev=606836&r1=606835&r2=606836&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java
Tue Dec 25 20:11:51 2007
@@ -82,6 +82,7 @@
  *          2006) $
  * @author Tatu Saloranta
  * @author Bradley S. Huffman
+ * @author Benson I. Margulies, mods for CXF to allow reading a portion of a stream.
  */
 public class StaxBuilder {
 
@@ -126,6 +127,9 @@
     private XMLInputFactory xifactory;
 
     private Map additionalNamespaces;
+    // This is set to 'true' when we are reading the middle of a stream,
+    // and need to stop at the end of the element we start.
+    private boolean isReadingMidStream;
 
     /**
      * Default constructor.
@@ -173,9 +177,9 @@
     public JDOMFactory getFactory() {
         return factory;
     }
-
     /**
      * This will build a JDOM tree given a StAX stream reader.
+     * This API explicitly supports building mid-stream.
      * 
      * @param r Stream reader from which input is read.
      * @return <code>Document</code> - JDOM document object.
@@ -183,10 +187,24 @@
      *             indicate a parsing or I/O problem)
      */
     public Document build(XMLStreamReader r) throws XMLStreamException {
+        isReadingMidStream = true;
+        return buildInternal(r);
+    }
+
+    public Document build(InputStream is) throws XMLStreamException {
+        isReadingMidStream = false;
+        return buildInternal(xifactory.createXMLStreamReader(is));
+    }
+
+    public Document build(Reader reader) throws XMLStreamException {
+        isReadingMidStream = false;
+        return buildInternal(xifactory.createXMLStreamReader(reader));
+    }
+    
+    private Document buildInternal(XMLStreamReader r) throws XMLStreamException {
         /*
          * Should we do sanity checking to see that r is positioned at
-         * beginning? Not doing so will allow creating documents from sub-trees,
-         * though?
+         * beginning in the non-mid-stream case? 
          */
         JDOMFactory f = factory;
         if (f == null) {
@@ -197,14 +215,6 @@
         return doc;
     }
 
-    public Document build(InputStream is) throws XMLStreamException {
-        return build(xifactory.createXMLStreamReader(is));
-    }
-
-    public Document build(Reader reader) throws XMLStreamException {
-        return build(xifactory.createXMLStreamReader(reader));
-    }
-
     /**
      * This takes a <code>XMLStreamReader</code> and builds up a JDOM tree.
      * Recursion has been eliminated by using local stack of open elements; this
@@ -271,6 +281,8 @@
                     current = current.getParentElement();
                 }
                 noadd = true;
+                if(isReadingMidStream && current == null) 
+                    return;
                 break;
 
             case XMLStreamConstants.ENTITY_DECLARATION:

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementReader.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementReader.java?rev=606836&r1=606835&r2=606836&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementReader.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementReader.java
Tue Dec 25 20:11:51 2007
@@ -104,7 +104,7 @@
 
     private void extractXsiType() {
         /*
-         * We're making a conscious choice here -- garbage in == garbate out.
+         * We're making a conscious choice here -- garbage in == garbage out.
          */
         String xsiTypeQname = root.getAttributeValue(SOAPConstants.XSI_NS, "type");
         if (xsiTypeQname != null) {

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java?rev=606836&r1=606835&r2=606836&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java
Tue Dec 25 20:11:51 2007
@@ -33,11 +33,15 @@
  * @since Feb 21, 2004
  */
 public class WrappedTest extends AbstractAegisTest {
+    
+    private ArrayService arrayService;
+    
     @Before 
     public void setUp() throws Exception {
         super.setUp();
+        arrayService = new ArrayService();
         createService(BeanService.class, null, "BeanService", null);
-        createService(ArrayService.class, "Array", new QName("urn:Array", "Array"));
+        createService(ArrayService.class, arrayService, "Array", new QName("urn:Array", "Array"));
     }
 
     @Test
@@ -91,6 +95,41 @@
                         + "/xsd:complexType[@name=\"SimpleBean\"]/xsd:sequence/xsd:element"
                         + "[@type=\"xsd:string\"]",
                     doc);
+    }
+    
+    @Test 
+    public void testSubmitJDOMArray() throws Exception {
+        
+        org.jdom.xpath.XPath jxpathWalrus = 
+            org.jdom.xpath.XPath.newInstance("/a:anyType/iam:walrus");
+        jxpathWalrus.addNamespace("a", "urn:Array");
+        jxpathWalrus.addNamespace("iam", "uri:iam");
+        jxpathWalrus.addNamespace("linux", "uri:linux");
+        jxpathWalrus.addNamespace("planets", "uri:planets");
+
+        invoke("Array", "/org/apache/cxf/aegis/integration/anyTypeArrayJDOM.xml");
+        assertEquals("before items", arrayService.getBeforeValue());
+        assertEquals(3, arrayService.getJdomArray().length);
+        org.jdom.Element e = (org.jdom.Element)
+            jxpathWalrus.selectSingleNode(arrayService.getJdomArray()[0]);
+        assertNotNull(e);
+        assertEquals("tusks", e.getText());
+        assertEquals("after items", arrayService.getAfterValue());
+    }
+    
+    @Test 
+    public void testSubmitW3CArray() throws Exception {
+        addNamespace("a", "urn:Array");
+        addNamespace("iam", "uri:iam");
+        addNamespace("linux", "uri:linux");
+        addNamespace("planets", "uri:planets");
+
+        invoke("Array", "/org/apache/cxf/aegis/integration/anyTypeArrayW3C.xml");
+        assertEquals("before items", arrayService.getBeforeValue());
+        assertEquals(3, arrayService.getW3cArray().length);
+        org.w3c.dom.Document e = arrayService.getW3cArray()[0];
+        assertValid("/a:anyType/iam:walrus", e);
+        assertEquals("after items", arrayService.getAfterValue());
     }
 
     // public void testGetArray()

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/ArrayService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/ArrayService.java?rev=606836&r1=606835&r2=606836&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/ArrayService.java
(original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/ArrayService.java
Tue Dec 25 20:11:51 2007
@@ -24,6 +24,12 @@
  * @author <a href="mailto:dan@envoisolutions.com">Dan Diephouse</a>
  */
 public class ArrayService {
+    
+    private org.jdom.Element[] jdomArray;
+    private org.w3c.dom.Document[] w3cArray;
+    private String beforeValue;
+    private String afterValue;
+    
     public SimpleBean[] getBeanArray() {
         SimpleBean bean = new SimpleBean();
         bean.setBleh("bleh");
@@ -31,6 +37,13 @@
 
         return new SimpleBean[] {bean};
     }
+    
+    public void resetValues() {
+        beforeValue = null;
+        afterValue = null;
+        jdomArray = null;
+        w3cArray = null;
+    }
 
     public String[] getStringArray() {
         return new String[] {"bleh", "bleh"};
@@ -42,5 +55,33 @@
 
     public boolean submitBeanArray(SimpleBean[] array) {
         return true;
+    }
+    
+    public void submitJDOMArray(String before, org.jdom.Element[] anything, String after)
{
+        beforeValue = before;
+        jdomArray = anything;
+        afterValue = after;
+    }
+
+    public void submitW3CArray(String before, org.w3c.dom.Document[] anything, String after)
{
+        beforeValue = before;
+        w3cArray = anything;
+        afterValue = after;
+    }
+
+    public org.jdom.Element[] getJdomArray() {
+        return jdomArray;
+    }
+
+    public org.w3c.dom.Document[] getW3cArray() {
+        return w3cArray;
+    }
+
+    public String getBeforeValue() {
+        return beforeValue;
+    }
+
+    public String getAfterValue() {
+        return afterValue;
     }
 }

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayJDOM.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayJDOM.xml?rev=606836&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayJDOM.xml
(added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayJDOM.xml
Tue Dec 25 20:11:51 2007
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" 
+                   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <soap-env:Body xmlns:jns0='urn:Array' >
+  <jns0:submitJDOMArray>
+   <jns0:before>before items</jns0:before>
+   <jns0:anything>
+       <jns0:anyType><walrus xmlns='uri:iam'>tusks</walrus></jns0:anyType>
+       <jns0:anyType><penguin xmlns='uri:linux'>emperor</penguin></jns0:anyType>
+       <jns0:anyType><moon xmlns='uri:planets'>blue</moon></jns0:anyType>
+    </jns0:anything>
+    <jns0:after>after items</jns0:after>
+    </jns0:submitJDOMArray>
+  </soap-env:Body>
+</soap-env:Envelope>

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayJDOM.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayJDOM.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayJDOM.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayW3C.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayW3C.xml?rev=606836&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayW3C.xml
(added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayW3C.xml
Tue Dec 25 20:11:51 2007
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" 
+                   xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+ <soap-env:Body xmlns:jns0='urn:Array' >
+  <jns0:submitW3CArray>
+   <jns0:before>before items</jns0:before>
+   <jns0:anything>
+       <jns0:anyType><walrus xmlns='uri:iam'>tusks</walrus></jns0:anyType>
+       <jns0:anyType><penguin xmlns='uri:linux'>emperor</penguin></jns0:anyType>
+       <jns0:anyType><moon xmlns='uri:planets'>blue</moon></jns0:anyType>
+    </jns0:anything>
+    <jns0:after>after items</jns0:after>
+    </jns0:submitW3CArray>
+  </soap-env:Body>
+</soap-env:Envelope>

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayW3C.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayW3C.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayW3C.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: incubator/cxf/trunk/rt/javascript/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/pom.xml?rev=606836&r1=606835&r2=606836&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/pom.xml (original)
+++ incubator/cxf/trunk/rt/javascript/pom.xml Tue Dec 25 20:11:51 2007
@@ -89,7 +89,7 @@
         <dependency>
             <groupId>jdom</groupId>
             <artifactId>jdom</artifactId>
-            <version>1.0</version>
+            <version>${jdom.version}</version>
         </dependency>
         <dependency>
             <groupId>net.java.dev.stax-utils</groupId>

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AegisService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AegisService.java?rev=606836&r1=606835&r2=606836&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AegisService.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AegisService.java
Tue Dec 25 20:11:51 2007
@@ -23,5 +23,6 @@
 
 public interface AegisService {
     void acceptAny(String before, Collection<org.jdom.Element> anything);
+    void acceptStrings(Collection<String> someStrings);
 }
 

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AegisServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AegisServiceImpl.java?rev=606836&r1=606835&r2=606836&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AegisServiceImpl.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AegisServiceImpl.java
Tue Dec 25 20:11:51 2007
@@ -27,6 +27,7 @@
 public class AegisServiceImpl implements AegisService {
     private String acceptedString;
     private Collection<org.jdom.Element> acceptedCollection;
+    private Collection<String> acceptedStrings;
     
     public void reset() {
         acceptedString = null;
@@ -51,5 +52,15 @@
      */
     public String getAcceptedString() {
         return acceptedString;
+    }
+
+    public void acceptStrings(Collection<String> someStrings) {
+        acceptedStrings = someStrings;
+    }
+
+    /** * @return Returns the acceptedStrings.
+     */
+    public Collection<String> getAcceptedStrings() {
+        return acceptedStrings;
     }
 }

Modified: incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AegisTests.js
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AegisTests.js?rev=606836&r1=606835&r2=606836&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AegisTests.js
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AegisTests.js
Tue Dec 25 20:11:51 2007
@@ -50,6 +50,8 @@
 	service.url = url;
 	
 	var arrayItem = new fortest_javascript_cxf_apache_org__ArrayOfAnyType();
-	arrayItem.setAnyType(["<walrus xmlns='uri:iam'>tusks</walrus>", "<penguin
xmlns='uri:linux'>emperor</penguin>"]); 
+	arrayItem.setAnyType(["<walrus xmlns='uri:iam'>tusks</walrus>",
+	                      "<penguin xmlns='uri:linux'>emperor</penguin>",
+	                      "<moon xmlns='uri:planets'>blue</moon>"]); 
 	service.acceptAny(success, error, "before items", arrayItem);
 }



Mime
View raw message