diff --git a/org.springframework.integration.xml/.classpath b/org.springframework.integration.xml/.classpath index 085fd00cc7..e86b9f4839 100644 --- a/org.springframework.integration.xml/.classpath +++ b/org.springframework.integration.xml/.classpath @@ -14,5 +14,6 @@ + diff --git a/org.springframework.integration.xml/ivy.xml b/org.springframework.integration.xml/ivy.xml index 1c0b1419f8..2f85d9bb18 100644 --- a/org.springframework.integration.xml/ivy.xml +++ b/org.springframework.integration.xml/ivy.xml @@ -26,6 +26,11 @@ + + + + + diff --git a/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/XmlMarshallingTransformerParserTests-context.xml b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/XmlMarshallingTransformerParserTests-context.xml index b415169098..8d2725d605 100644 --- a/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/XmlMarshallingTransformerParserTests-context.xml +++ b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/config/XmlMarshallingTransformerParserTests-context.xml @@ -48,7 +48,8 @@ input-channel="marshallingTransformerWithResultTransformer" output-channel="output" marshaller="marshaller" - result-transformer="resultTransformer" /> + result-transformer="resultTransformer"> + diff --git a/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/transformer/jaxbmarshaling/JaxbAnnotatedPerson.java b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/transformer/jaxbmarshaling/JaxbAnnotatedPerson.java new file mode 100644 index 0000000000..4e4e128264 --- /dev/null +++ b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/transformer/jaxbmarshaling/JaxbAnnotatedPerson.java @@ -0,0 +1,39 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * Licensed 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.springframework.integration.xml.transformer.jaxbmarshaling; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; + +@XmlType @XmlRootElement(name="person") +public class JaxbAnnotatedPerson { + + @XmlElement(name="firstname") + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + + private String firstName; + + + +} diff --git a/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/transformer/jaxbmarshaling/JaxbMarshallingIntegrationTests-context.xml b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/transformer/jaxbmarshaling/JaxbMarshallingIntegrationTests-context.xml new file mode 100644 index 0000000000..1bb02536eb --- /dev/null +++ b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/transformer/jaxbmarshaling/JaxbMarshallingIntegrationTests-context.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.springframework.integration.xml.transformer.jaxbmarshaling.JaxbAnnotatedPerson + + + + + + + + \ No newline at end of file diff --git a/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/transformer/jaxbmarshaling/JaxbMarshallingIntegrationTests.java b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/transformer/jaxbmarshaling/JaxbMarshallingIntegrationTests.java new file mode 100644 index 0000000000..6f5b7b1c34 --- /dev/null +++ b/org.springframework.integration.xml/src/test/java/org/springframework/integration/xml/transformer/jaxbmarshaling/JaxbMarshallingIntegrationTests.java @@ -0,0 +1,80 @@ +/* + * Copyright 2002-2007 the original author or authors. + * + * Licensed 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.springframework.integration.xml.transformer.jaxbmarshaling; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.dom.DOMResult; + +import org.junit.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.integration.channel.PollableChannel; +import org.springframework.integration.core.MessageChannel; +import org.springframework.integration.message.GenericMessage; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; +import org.springframework.xml.transform.StringSource; +import org.w3c.dom.Document; + +@ContextConfiguration +public class JaxbMarshallingIntegrationTests extends AbstractJUnit4SpringContextTests { + + + @Autowired @Qualifier("marshallIn") + MessageChannel marshallIn; + + @Autowired @Qualifier("marshallOut") + PollableChannel marshalledOut; + + @Autowired @Qualifier("unmarshallIn") + MessageChannel unmarshallIn; + + @Autowired @Qualifier("unmarshallOut") + PollableChannel unmarshallOut; + + + @Test + public void testMarshalling() throws Exception{ + JaxbAnnotatedPerson person = new JaxbAnnotatedPerson(); + person.setFirstName("john"); + marshallIn.send(new GenericMessage(person)); + GenericMessage res = (GenericMessage) marshalledOut.receive(2000); + assertNotNull("No response recevied" ,res); + assertTrue("payload was not a DOMResult" , res.getPayload() instanceof DOMResult); + Document doc = (Document)((DOMResult)res.getPayload()).getNode(); + assertEquals("Wrong name for root element ", "person",doc.getDocumentElement().getLocalName()); + } + + + @Test + public void testUnmarshalling() throws Exception{ + StringSource source = new StringSource("bob"); + unmarshallIn.send(new GenericMessage(source)); + GenericMessage res = (GenericMessage) unmarshallOut.receive(2000); + assertNotNull("No response", res); + assertTrue("Not a Person ", res.getPayload() instanceof JaxbAnnotatedPerson); + JaxbAnnotatedPerson person = (JaxbAnnotatedPerson)res.getPayload(); + assertEquals("Worng firstname", "bob", person.getFirstName()); + + } + + +}