use of org.apache.camel.foo.bar.PersonType in project camel by apache.
the class DataFormatTest method testMarshalPrettyPrint.
@Test
public void testMarshalPrettyPrint() throws Exception {
PersonType person = new PersonType();
person.setFirstName("Willem");
person.setLastName("Jiang");
resultEndpoint.expectedMessageCount(1);
template.sendBody("direct:prettyPrint", person);
resultEndpoint.assertIsSatisfied();
Exchange exchange = resultEndpoint.getExchanges().get(0);
String result = exchange.getIn().getBody(String.class);
assertNotNull("The result should not be null", result);
int indexPerson = result.indexOf("<Person>");
int indexFirstName = result.indexOf("<firstName>");
assertTrue("we should find the <Person>", indexPerson > 0);
assertTrue("we should find the <firstName>", indexFirstName > 0);
assertTrue("There should some sapce between <Person> and <firstName>", indexFirstName - indexPerson > 8);
}
use of org.apache.camel.foo.bar.PersonType in project camel by apache.
the class CamelJaxbTest method testUnmarshalBadCharsWithFiltering.
@Test
public void testUnmarshalBadCharsWithFiltering() throws Exception {
String xml = "<Person><firstName>FOO</firstName><lastName>BAR</lastName></Person>";
PersonType expected = new PersonType();
expected.setFirstName("FOO");
expected.setLastName("BAR ");
MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
resultEndpoint.expectedBodiesReceived(expected);
template.sendBody("direct:unmarshalFilteringEnabled", xml);
resultEndpoint.assertIsSatisfied();
}
use of org.apache.camel.foo.bar.PersonType in project camel by apache.
the class CamelJaxbTest method testMarshalBadCharsWithFiltering.
@Test
public void testMarshalBadCharsWithFiltering() throws Exception {
PersonType person = new PersonType();
person.setFirstName("foo");
person.setLastName("bar");
MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
resultEndpoint.expectedMessageCount(1);
template.sendBody("direct:marshalFilteringEnabled", person);
resultEndpoint.assertIsSatisfied();
String body = resultEndpoint.getReceivedExchanges().get(0).getIn().getBody(String.class);
assertFalse("Non-xml character wasn't replaced", body.contains(""));
}
use of org.apache.camel.foo.bar.PersonType in project camel by apache.
the class CamelJaxbTest method testCustomXmlStreamWriter.
@Test
public void testCustomXmlStreamWriter() throws InterruptedException {
PersonType person = new PersonType();
person.setFirstName("foo");
person.setLastName("bar");
MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
resultEndpoint.expectedMessageCount(1);
template.sendBody("direct:marshalCustomWriter", person);
resultEndpoint.assertIsSatisfied();
String body = resultEndpoint.getReceivedExchanges().get(0).getIn().getBody(String.class);
assertTrue("Body did not get processed correctly by custom filter", body.contains("-Foo"));
}
use of org.apache.camel.foo.bar.PersonType in project camel by apache.
the class CamelJaxbTest method testFilterNonXmlChars.
@Test
public void testFilterNonXmlChars() throws Exception {
String xmlUTF = "<Person><firstName>FOO</firstName><lastName>BAR € </lastName></Person>";
String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + xmlUTF;
PersonType expected = new PersonType();
expected.setFirstName("FOO");
expected.setLastName("BAR € ");
MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result", MockEndpoint.class);
resultEndpoint.expectedBodiesReceived(expected);
template.sendBody("direct:unmarshalFilteringEnabled", xml);
resultEndpoint.assertIsSatisfied();
}
Aggregations