Search in sources :

Example 21 with StringSource

use of org.springframework.xml.transform.StringSource in project spring-integration by spring-projects.

the class UnmarshallingTransformerTests method testMessageReturnValue.

@Test
public void testMessageReturnValue() {
    Unmarshaller unmarshaller = new TestUnmarshaller(true);
    UnmarshallingTransformer transformer = new UnmarshallingTransformer(unmarshaller);
    Object transformed = transformer.transformPayload(new StringSource("foo"));
    assertEquals(GenericMessage.class, transformed.getClass());
    assertEquals("message: foo", ((Message<?>) transformed).getPayload());
}
Also used : StringSource(org.springframework.xml.transform.StringSource) Unmarshaller(org.springframework.oxm.Unmarshaller) Test(org.junit.Test)

Example 22 with StringSource

use of org.springframework.xml.transform.StringSource in project citrus-samples by christophd.

the class FieldForceJmsConsumer method onMessage.

@Override
public void onMessage(Message message) {
    try {
        if (message instanceof TextMessage) {
            OrderNotification notification = (OrderNotification) unmarshaller.unmarshal(new StringSource(((TextMessage) message).getText()));
            fieldForceService.process(notification);
        }
    } catch (JMSException e) {
        throw new ServiceException("Failed to convert field force notification message", e);
    } catch (IOException e) {
        throw new ServiceException("Failed to read field force notification message", e);
    }
}
Also used : ServiceException(com.consol.citrus.samples.incident.exception.ServiceException) StringSource(org.springframework.xml.transform.StringSource) IOException(java.io.IOException) OrderNotification(org.citrusframework.schema.samples.fieldforceservice.v1.OrderNotification)

Aggregations

StringSource (org.springframework.xml.transform.StringSource)22 Test (org.junit.Test)15 Source (javax.xml.transform.Source)7 Transformer (javax.xml.transform.Transformer)5 DOMSource (javax.xml.transform.dom.DOMSource)4 GenericMessage (org.springframework.messaging.support.GenericMessage)4 StringResult (org.springframework.xml.transform.StringResult)4 BufferedReader (java.io.BufferedReader)3 IOException (java.io.IOException)3 MessageChannel (org.springframework.messaging.MessageChannel)3 PollableChannel (org.springframework.messaging.PollableChannel)3 Unmarshaller (org.springframework.oxm.Unmarshaller)3 StringWriter (java.io.StringWriter)2 StreamResult (javax.xml.transform.stream.StreamResult)2 XmlMappingException (org.springframework.oxm.XmlMappingException)2 WebServiceMessage (org.springframework.ws.WebServiceMessage)2 MessageContext (org.springframework.ws.context.MessageContext)2 Document (org.w3c.dom.Document)2 ServiceException (com.consol.citrus.samples.incident.exception.ServiceException)1 HashMap (java.util.HashMap)1