Search in sources :

Example 26 with StringSource

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

the class WebServiceClientIntegrationTests method mockServerCall2.

@Test
void mockServerCall2() {
    this.server.expect(payload(new StringSource("<request/>"))).andRespond(withError("Invalid Request"));
    assertThatExceptionOfType(WebServiceTransportException.class).isThrownBy(this.client::test).withMessageContaining("Invalid Request");
}
Also used : StringSource(org.springframework.xml.transform.StringSource) Test(org.junit.jupiter.api.Test)

Example 27 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)27 Test (org.junit.Test)15 Source (javax.xml.transform.Source)7 Transformer (javax.xml.transform.Transformer)5 Test (org.junit.jupiter.api.Test)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