use of org.apache.camel.dataformat.jibx.model.PurchaseOrder in project camel by apache.
the class JibxDataFormatMarshallTest method testMarshall.
@Test
public void testMarshall() throws InterruptedException, ParserConfigurationException, IOException, SAXException {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
PurchaseOrder purchaseOrder = new PurchaseOrder();
String name = "foo";
purchaseOrder.setName(name);
double price = 49;
purchaseOrder.setPrice(price);
double amount = 3;
purchaseOrder.setAmount(amount);
template.sendBody("direct:start", purchaseOrder);
assertMockEndpointsSatisfied();
String body = mock.getReceivedExchanges().get(0).getIn().getBody(String.class);
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Element root = builder.parse(new InputSource(new StringReader(body))).getDocumentElement();
assertEquals(name, root.getAttribute("name"));
assertEquals(price + "", root.getAttribute("price"));
assertEquals(amount + "", root.getAttribute("amount"));
}
use of org.apache.camel.dataformat.jibx.model.PurchaseOrder in project camel by apache.
the class JibxDataFormatMarshallWithBindingNameTest method testMarshall.
@Test
public void testMarshall() throws InterruptedException, ParserConfigurationException, IOException, SAXException {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
PurchaseOrder purchaseOrder = new PurchaseOrder();
String name = "foo";
purchaseOrder.setName(name);
double price = 49;
purchaseOrder.setPrice(price);
double amount = 3;
purchaseOrder.setAmount(amount);
template.sendBody("direct:start", purchaseOrder);
assertMockEndpointsSatisfied();
String body = mock.getReceivedExchanges().get(0).getIn().getBody(String.class);
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Element root = builder.parse(new InputSource(new StringReader(body))).getDocumentElement();
assertEquals(name, root.getAttribute("name"));
assertEquals(price + "", root.getAttribute("price"));
assertEquals(amount + "", root.getAttribute("amount"));
}
use of org.apache.camel.dataformat.jibx.model.PurchaseOrder in project camel by apache.
the class JibxDataFormatSpringDslTest method testMarshall.
@Test
public void testMarshall() throws InterruptedException, ParserConfigurationException, IOException, SAXException {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
PurchaseOrder purchaseOrder = new PurchaseOrder();
String name = "foo";
purchaseOrder.setName(name);
double price = 49;
purchaseOrder.setPrice(price);
double amount = 3;
purchaseOrder.setAmount(amount);
template.sendBody("direct:marshall", purchaseOrder);
assertMockEndpointsSatisfied();
String body = mock.getReceivedExchanges().get(0).getIn().getBody(String.class);
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Element root = builder.parse(new InputSource(new StringReader(body))).getDocumentElement();
assertEquals(name, root.getAttribute("name"));
assertEquals(price + "", root.getAttribute("price"));
assertEquals(amount + "", root.getAttribute("amount"));
}
use of org.apache.camel.dataformat.jibx.model.PurchaseOrder in project camel by apache.
the class JibxDataFormatUnmarshallTest method testUnmarshall.
@Test
public void testUnmarshall() 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);
}
use of org.apache.camel.dataformat.jibx.model.PurchaseOrder in project camel by apache.
the class JibxDataFormatSpringDslTest method testUnmarshall.
@Test
public void testUnmarshall() 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:unmarshall", 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);
}
Aggregations