You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2008/01/02 23:27:47 UTC
svn commit: r608264 - in /incubator/cxf/branches/2.0.x-fixes: ./ 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/aegi...
Author: dkulp
Date: Wed Jan 2 14:27:46 2008
New Revision: 608264
URL: http://svn.apache.org/viewvc?rev=608264&view=rev
Log:
Merged revisions 606836 via svnmerge from
https://svn.apache.org/repos/asf/incubator/cxf/trunk
........
r606836 | bimargulies | 2007-12-25 23:11:51 -0500 (Tue, 25 Dec 2007) | 2 lines
Fix CXF-1333, Aegis services that accept arrays of JDOMElements.
........
Added:
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/resources/
- copied from r606836, incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/resources/org/
- copied from r606836, incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/resources/org/apache/
- copied from r606836, incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/resources/org/apache/cxf/
- copied from r606836, incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/
- copied from r606836, incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/
- copied from r606836, incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayJDOM.xml
- copied unchanged from r606836, incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayJDOM.xml
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayW3C.xml
- copied unchanged from r606836, incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayW3C.xml
Modified:
incubator/cxf/branches/2.0.x-fixes/ (props changed)
incubator/cxf/branches/2.0.x-fixes/parent/pom.xml
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/pom.xml
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementReader.java
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java
incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/ArrayService.java
Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: incubator/cxf/branches/2.0.x-fixes/parent/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/parent/pom.xml?rev=608264&r1=608263&r2=608264&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/parent/pom.xml (original)
+++ incubator/cxf/branches/2.0.x-fixes/parent/pom.xml Wed Jan 2 14:27:46 2008
@@ -57,6 +57,7 @@
<activemq.version>4.1.1</activemq.version>
<geronimo.version>1.1</geronimo.version>
<rhino.version>1.6R5</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/branches/2.0.x-fixes/rt/databinding/aegis/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/pom.xml?rev=608264&r1=608263&r2=608264&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/pom.xml (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/pom.xml Wed Jan 2 14:27:46 2008
@@ -75,7 +75,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>
@@ -142,4 +142,4 @@
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
Modified: incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java?rev=608264&r1=608263&r2=608264&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/generated/org/apache/cxf/aegis/util/jdom/StaxBuilder.java Wed Jan 2 14:27:46 2008
@@ -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/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementReader.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementReader.java?rev=608264&r1=608263&r2=608264&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementReader.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementReader.java Wed Jan 2 14:27:46 2008
@@ -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(XmlConstants.XSI_NS, "type");
if (xsiTypeQname != null) {
Modified: incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java?rev=608264&r1=608263&r2=608264&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java Wed Jan 2 14:27:46 2008
@@ -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/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/ArrayService.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/ArrayService.java?rev=608264&r1=608263&r2=608264&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/ArrayService.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/ArrayService.java Wed Jan 2 14:27:46 2008
@@ -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;
}
}