Author: bimargulies
Date: Wed Oct 31 07:54:45 2007
New Revision: 590691
URL: http://svn.apache.org/viewvc?rev=590691&view=rev
Log:
Add a test case to explore the handling of form= attributes in schema by jaxb.
Added:
incubator/cxf/trunk/rt/databinding/jaxb/src/test/resources/wsdl/jaxb/form_test.xsd
Modified:
incubator/cxf/trunk/rt/databinding/jaxb/pom.xml
incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java
Modified: incubator/cxf/trunk/rt/databinding/jaxb/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/pom.xml?rev=590691&r1=590690&r2=590691&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/jaxb/pom.xml (original)
+++ incubator/cxf/trunk/rt/databinding/jaxb/pom.xml Wed Oct 31 07:54:45 2007
@@ -69,6 +69,9 @@
<xsdOption>
<xsd>${basedir}/src/test/resources/wsdl/jaxb/misc_test.xsd</xsd>
</xsdOption>
+ <xsdOption>
+
<xsd>${basedir}/src/test/resources/wsdl/jaxb/form_test.xsd</xsd>
+ </xsdOption>
</xsdOptions>
</configuration>
<goals>
Modified:
incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java?rev=590691&r1=590690&r2=590691&view=diff
==============================================================================
---
incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java
(original)
+++
incubator/cxf/trunk/rt/databinding/jaxb/src/test/java/org/apache/cxf/jaxb/JAXBEncoderDecoderTest.java
Wed Oct 31 07:54:45 2007
@@ -22,6 +22,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
+import java.io.StringWriter;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
@@ -46,6 +47,7 @@
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.jaxb_form.ObjectWithQualifiedElement;
import org.apache.cxf.jaxb_misc.Base64WithDefaultValueType;
import org.apache.cxf.jaxb_misc.ObjectFactory;
import org.apache.cxf.service.model.MessagePartInfo;
@@ -87,7 +89,8 @@
context = JAXBContext.newInstance(new Class[] {
GreetMe.class,
GreetMeResponse.class,
- StringStruct.class
+ StringStruct.class,
+ ObjectWithQualifiedElement.class
});
Method method = TestUtil.getMethod(Greeter.class, "greetMe");
wrapperAnnotation = method.getAnnotation(RequestWrapper.class);
@@ -151,6 +154,31 @@
} catch (Fault ex) {
//expected - not a valid object
}
+ }
+
+ @Test
+ public void testMarshallWithFormQualifiedElement() throws Exception {
+ ObjectWithQualifiedElement testObject = new
ObjectWithQualifiedElement();
+ testObject.setString1("twine");
+ testObject.setString2("cord");
+
+ QName elName = new QName(wrapperAnnotation.targetNamespace(),
+ wrapperAnnotation.localName());
+ MessagePartInfo part = new MessagePartInfo(elName, null);
+ part.setElement(true);
+ part.setElementQName(elName);
+
+ StringWriter stringWriter = new StringWriter();
+ XMLOutputFactory opFactory = XMLOutputFactory.newInstance();
+ opFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES,
Boolean.TRUE);
+ XMLEventWriter writer = opFactory.createXMLEventWriter(stringWriter);
+ JAXBEncoderDecoder.marshall(context, null, testObject, part, writer);
+ writer.flush();
+ writer.close();
+ String xmlResult = stringWriter.toString();
+ // the following is a bit of a crock, but, to tell the truth, this
test case most exists
+ // so that it could be examined inside the debugger to see how JAXB
works.
+ assertTrue(xmlResult.contains("ns3:string2"));
}
@Test
Added:
incubator/cxf/trunk/rt/databinding/jaxb/src/test/resources/wsdl/jaxb/form_test.xsd
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/test/resources/wsdl/jaxb/form_test.xsd?rev=590691&view=auto
==============================================================================
---
incubator/cxf/trunk/rt/databinding/jaxb/src/test/resources/wsdl/jaxb/form_test.xsd
(added)
+++
incubator/cxf/trunk/rt/databinding/jaxb/src/test/resources/wsdl/jaxb/form_test.xsd
Wed Oct 31 07:54:45 2007
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://cxf.apache.org/jaxb_form"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://cxf.apache.org/jaxb_form"
+ elementFormDefault='unqualified' >
+ <xs:element name="ObjectWithQualifiedElementElement" >
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="string1" type="xs:string" />
+ <xs:element name="string2" type="xs:string" form='qualified' />
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+</schema>
\ No newline at end of file