Author: bimargulies
Date: Mon Dec 31 18:44:12 2007
New Revision: 607793
URL: http://svn.apache.org/viewvc?rev=607793&view=rev
Log:
Begin to actually turn on the standalone Aegis binding. Here it is reading
a string. Well, one has to start someplace.
Added:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/StandaloneReadTest.java
(with props)
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/stringElement.xml
(with props)
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/TestUtilities.java
incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisXMLStreamDataReader.java
incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java
incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayJDOM.xml
incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayW3C.xml
Modified:
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/TestUtilities.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/TestUtilities.java?rev=607793&r1=607792&r2=607793&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/TestUtilities.java
(original)
+++
incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/test/TestUtilities.java
Mon Dec 31 18:44:12 2007
@@ -35,6 +35,9 @@
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLWriter;
import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
@@ -66,11 +69,10 @@
private static final Charset UTF8 = Charset.forName("utf-8");
private static String preKeepAlive;
-
private static String basedirPath;
protected Bus bus;
protected Class<?> classpathAnchor;
-
+ private XMLInputFactory xmlInputFactory;
/**
* Namespaces for the XPath expressions.
@@ -87,6 +89,7 @@
*/
public TestUtilities(Class<?> classpathReference) {
classpathAnchor = classpathReference;
+ xmlInputFactory = XMLInputFactory.newInstance();
}
public static void setKeepAliveSystemProperty(boolean setAlive) {
@@ -248,6 +251,10 @@
public Reader getResourceAsReader(String resource) {
return new InputStreamReader(getResourceAsStream(resource), UTF8);
+ }
+
+ public XMLStreamReader getResourceAsXMLStreamReader(String resource)
throws XMLStreamException {
+ return
xmlInputFactory.createXMLStreamReader(getResourceAsStream(resource));
}
public File getTestFile(String relativePath) {
Modified:
incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisXMLStreamDataReader.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisXMLStreamDataReader.java?rev=607793&r1=607792&r2=607793&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisXMLStreamDataReader.java
(original)
+++
incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisXMLStreamDataReader.java
Mon Dec 31 18:44:12 2007
@@ -71,7 +71,7 @@
return null;
}
- Type type = TypeUtil.getReadType(reader, aegisContext, desiredType);
+ Type type = TypeUtil.getReadTypeStandalone(reader, aegisContext,
desiredType);
if (type == null) {
throw new DatabindingException(new Message("NO_MAPPING", LOG));
Modified:
incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java?rev=607793&r1=607792&r2=607793&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java
(original)
+++
incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeUtil.java
Mon Dec 31 18:44:12 2007
@@ -86,6 +86,50 @@
}
}
+ /**
+ * getReadType cannot just look up the xsi:type in the mapping. This
function must be
+ * called instead at the root where there is no initial mapping to start
from, as from
+ * a part or an element of some containing item.
+ * @param xsr
+ * @param context
+ * @return
+ */
+ public static Type getReadTypeStandalone(XMLStreamReader xsr, AegisContext
context, Type baseType) {
+
+ if (baseType != null) {
+ return getReadType(xsr, context, baseType);
+ }
+
+ if (!context.isReadXsiTypes()) {
+ LOG.warn("xsi:type reading disabled, and no type available for "
+ + xsr.getName());
+ return null;
+ }
+
+ String typeNameString = xsr.getAttributeValue(SOAPConstants.XSI_NS,
"type");
+ if (typeNameString != null) {
+ QName schemaTypeName =
NamespaceHelper.createQName(xsr.getNamespaceContext(),
+ typeNameString);
+ TypeMapping tm;
+ tm = context.getTypeMapping();
+ Type type = tm.getType(schemaTypeName);
+
+ if (type == null) {
+ type = context.getOverrideType(schemaTypeName);
+ }
+
+ if (type != null) {
+ return type;
+ }
+
+ LOG.warn("xsi:type=\"" + schemaTypeName
+ + "\" was specified, but no corresponding Type was
registered; no default.");
+ return null;
+ }
+ LOG.warn("xsi:type was not specified for top-level element " +
xsr.getName());
+ return null;
+ }
+
public static Type getWriteType(AegisContext globalContext, Object value,
Type type) {
if (value != null && type != null && type.getTypeClass() !=
value.getClass()) {
Type overrideType =
globalContext.getOverrideType(value.getClass());
Added:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/StandaloneReadTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/StandaloneReadTest.java?rev=607793&view=auto
==============================================================================
---
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/StandaloneReadTest.java
(added)
+++
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/StandaloneReadTest.java
Mon Dec 31 18:44:12 2007
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.aegis.standalone;
+
+import javax.xml.stream.XMLStreamReader;
+
+import org.apache.cxf.aegis.AegisContext;
+import org.apache.cxf.aegis.AegisXMLStreamDataReader;
+import org.apache.cxf.test.TestUtilities;
+import org.junit.Before;
+import org.junit.Test;
+import static org.junit.Assert.assertTrue;
+
+/**
+ *
+ */
+public class StandaloneReadTest {
+ private AegisContext context;
+ private TestUtilities testUtilities;
+
+ @Before
+ public void before() {
+ testUtilities = new TestUtilities(getClass());
+ context = new AegisContext();
+ context.initialize();
+ }
+
+ @Test
+ public void testBasicTypeRead() throws Exception {
+ XMLStreamReader streamReader =
testUtilities.getResourceAsXMLStreamReader("stringElement.xml");
+ AegisXMLStreamDataReader reader =
+ context.createReader(AegisXMLStreamDataReader.class,
XMLStreamReader.class);
+ Object something = reader.read(streamReader);
+ assertTrue("ball-of-yarn".equals(something));
+ }
+}
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/StandaloneReadTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/StandaloneReadTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/stringElement.xml
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/stringElement.xml?rev=607793&view=auto
==============================================================================
---
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/stringElement.xml
(added)
+++
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/stringElement.xml
Mon Dec 31 18:44:12 2007
@@ -0,0 +1,23 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+ Licensed to the v Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<cat-toy xmlns='urn:meow'
+ xmlns:xsd='http://www.w3.org/2001/XMLSchema'
+ xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+ xsi:type='xsd:string'>ball-of-yarn</cat-toy>
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/stringElement.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/stringElement.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/standalone/stringElement.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified:
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=607793&r1=607792&r2=607793&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayJDOM.xml
(original)
+++
incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayJDOM.xml
Mon Dec 31 18:44:12 2007
@@ -1,4 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the v Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
<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' >
Modified:
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=607793&r1=607792&r2=607793&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayW3C.xml
(original)
+++
incubator/cxf/trunk/rt/databinding/aegis/src/test/resources/org/apache/cxf/aegis/integration/anyTypeArrayW3C.xml
Mon Dec 31 18:44:12 2007
@@ -1,4 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the v Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
<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' >