Search in sources :

Example 6 with PurchaseOrder

use of org.apache.camel.dataformat.jibx.model.PurchaseOrder in project camel by apache.

the class JibxDataFormatUnmarshallFail method testUnmarshallFail.

@Test(expected = CamelExecutionException.class)
public void testUnmarshallFail() throws InterruptedException, ParserConfigurationException, IOException, SAXException {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    String name = "foo";
    double price = 1;
    double amount = 2;
    String purchaseOrderXml = String.format("<order name='%s' price='%s' amount='%s' />", name, price + "", amount + "");
    template.sendBody("direct:start", purchaseOrderXml);
    assertMockEndpointsSatisfied();
    PurchaseOrder body = mock.getReceivedExchanges().get(0).getIn().getBody(PurchaseOrder.class);
    assertEquals(name, body.getName());
    assertEquals(price, body.getPrice(), 1);
    assertEquals(amount, body.getAmount(), 1);
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) PurchaseOrder(org.apache.camel.dataformat.jibx.model.PurchaseOrder) Test(org.junit.Test)

Example 7 with PurchaseOrder

use of org.apache.camel.dataformat.jibx.model.PurchaseOrder in project camel by apache.

the class JibxDataFormatUnmarshallWithBindingNameTest method testUnmarshallWithBindingName.

@Test
public void testUnmarshallWithBindingName() throws InterruptedException, ParserConfigurationException, IOException, SAXException {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    String name = "foo";
    double price = 1;
    double amount = 2;
    String purchaseOrderXml = String.format("<order name='%s' price='%s' amount='%s' />", name, price + "", amount + "");
    template.sendBody("direct:start", purchaseOrderXml);
    assertMockEndpointsSatisfied();
    PurchaseOrder body = mock.getReceivedExchanges().get(0).getIn().getBody(PurchaseOrder.class);
    assertEquals(name, body.getName());
    assertEquals(price, body.getPrice(), 1);
    assertEquals(amount, body.getAmount(), 1);
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) PurchaseOrder(org.apache.camel.dataformat.jibx.model.PurchaseOrder) Test(org.junit.Test)

Aggregations

MockEndpoint (org.apache.camel.component.mock.MockEndpoint)7 PurchaseOrder (org.apache.camel.dataformat.jibx.model.PurchaseOrder)7 Test (org.junit.Test)7 StringReader (java.io.StringReader)3 DocumentBuilder (javax.xml.parsers.DocumentBuilder)3 Element (org.w3c.dom.Element)3 InputSource (org.xml.sax.InputSource)3