[jboss-svn-commits] JBL Code SVN: r31558 - labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-pipeline/drools-camel/src/test/java/org/drools/camel/component.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Feb 10 16:04:53 EST 2010


Author: baunax
Date: 2010-02-10 16:04:53 -0500 (Wed, 10 Feb 2010)
New Revision: 31558

Modified:
   labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-pipeline/drools-camel/src/test/java/org/drools/camel/component/CamelEndpointWithJaxWrapperCollectionTest.java
Log:
jaxb round-tripping 

Modified: labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-pipeline/drools-camel/src/test/java/org/drools/camel/component/CamelEndpointWithJaxWrapperCollectionTest.java
===================================================================
--- labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-pipeline/drools-camel/src/test/java/org/drools/camel/component/CamelEndpointWithJaxWrapperCollectionTest.java	2010-02-10 20:50:43 UTC (rev 31557)
+++ labs/jbossrules/branches/camel_jaxb_marshaller2-lucaz/drools-pipeline/drools-camel/src/test/java/org/drools/camel/component/CamelEndpointWithJaxWrapperCollectionTest.java	2010-02-10 21:04:53 UTC (rev 31558)
@@ -1,6 +1,8 @@
 package org.drools.camel.component;
 
+import java.io.ByteArrayInputStream;
 import java.io.IOException;
+import java.io.StringReader;
 import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -11,10 +13,10 @@
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
 import javax.xml.bind.annotation.XmlElements;
 import javax.xml.bind.annotation.XmlRootElement;
 
@@ -62,23 +64,28 @@
 		
 		Marshaller marshaller = jaxbContext.createMarshaller();
 		marshaller.setProperty("jaxb.formatted.output", true);
-		StringWriter setGlobalXML = new StringWriter();
-		marshaller.marshal(cmd, setGlobalXML);
+		StringWriter xml = new StringWriter();
+		marshaller.marshal(cmd, xml);
 
-		System.out.println(setGlobalXML.toString());
+		System.out.println(xml.toString());
 		
-		String outXml = (String) template.requestBodyAndHeader("direct:test-with-session", setGlobalXML.toString(), "jaxb-context", jaxbContext);
+		byte[] response = (byte[]) template.requestBodyAndHeader("direct:test-with-session", xml.toString(), "jaxb-context", jaxbContext);
+		assertNotNull(response);
+		System.out.println("response:\n" + new String(response));
+		ExecutionResults res = (ExecutionResults) unmarshaller.unmarshal(new ByteArrayInputStream(response));
+		WrappedList resp = (WrappedList) res.getValue("list");
+		assertNotNull(resp);
+		
+		assertEquals(resp.size(), 2);
+		assertEquals("baunax", resp.get(0).getName());
+		assertEquals("Hadrian", resp.get(1).getName());
 
-		System.out.println(outXml);
-
-		assertNotNull(outXml);
-
 	}
 	
 	@XmlRootElement(name="list")
 	@XmlAccessorType(XmlAccessType.FIELD)
 	public static class WrappedList {
-		@XmlElementWrapper(name="bar")
+//		@XmlElementWrapper(name="list")
         @XmlElements({@XmlElement(name="org.drools.pipeline.camel.Person", type=Person.class)})
 		private List<Person> people = new ArrayList<Person>();
 
@@ -251,7 +258,7 @@
         process1 += "      <import name=\"org.drools.model.Person\" />\n";
         process1 += "    </imports>\n";
         process1 += "    <globals>\n";
-        process1 += "      <global identifier=\"list\" type=\"java.util.List\" />\n";
+        process1 += "      <global identifier=\"list\" type=\"org.drools.camel.component.CamelEndpointWithJaxWrapperCollectionTest.WrappedList\" />\n";
         process1 += "    </globals>\n";
         process1 += "    <variables>\n";
         process1 += "      <variable name=\"person\" >\n";



More information about the jboss-svn-commits mailing list