use of bind.feature.generichierarchy.case1.model.Message in project camel by apache.
the class HL7DataFormatTest method testUnmarshalWithExplicitUTF16Charset.
@Test
public void testUnmarshalWithExplicitUTF16Charset() throws Exception {
String charset = "UTF-16";
MockEndpoint mock = getMockEndpoint("mock:unmarshal");
mock.expectedMessageCount(1);
mock.message(0).body().isInstanceOf(Message.class);
mock.expectedHeaderReceived(HL7Constants.HL7_CHARSET, HL7Charset.getHL7Charset(charset).getHL7CharsetName());
mock.expectedHeaderReceived(Exchange.CHARSET_NAME, charset);
// Message with explicit encoding in MSH-18
byte[] body = createHL7WithCharsetAsString(HL7Charset.UTF_16).getBytes(Charset.forName(charset));
template.sendBodyAndHeader("direct:unmarshal", new ByteArrayInputStream(body), Exchange.CHARSET_NAME, charset);
assertMockEndpointsSatisfied();
Message msg = mock.getExchanges().get(0).getIn().getBody(Message.class);
assertEquals("2.4", msg.getVersion());
QRD qrd = (QRD) msg.get("QRD");
assertEquals("0101701234", qrd.getWhoSubjectFilter(0).getIDNumber().getValue());
}
use of bind.feature.generichierarchy.case1.model.Message in project camel by apache.
the class HL7DataFormatTest method testMarshal.
@Test
public void testMarshal() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:marshal");
mock.expectedMessageCount(1);
mock.message(0).body().isInstanceOf(byte[].class);
mock.message(0).body(String.class).contains("MSA|AA|123");
mock.message(0).body(String.class).contains("QRD|20080805120000");
Message message = createHL7AsMessage();
template.sendBody("direct:marshal", message);
assertMockEndpointsSatisfied();
}
use of bind.feature.generichierarchy.case1.model.Message in project camel by apache.
the class MessageValidatorTest method testDefaultHapiContext.
@Test
public void testDefaultHapiContext() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:test4");
mock.expectedMessageCount(1);
Message msg = createADT01Message();
template.sendBody("direct:test4", msg);
assertMockEndpointsSatisfied();
}
use of bind.feature.generichierarchy.case1.model.Message in project camel by apache.
the class MessageValidatorTest method testCustomHapiContext.
@Test(expected = CamelExecutionException.class)
public void testCustomHapiContext() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:test5");
mock.expectedMessageCount(0);
Message msg = createADT01Message();
template.sendBody("direct:test5", msg);
assertMockEndpointsSatisfied();
}
use of bind.feature.generichierarchy.case1.model.Message in project camel by apache.
the class MessageValidatorTest method testDynamicCustomHapiContext.
@Test(expected = CamelExecutionException.class)
public void testDynamicCustomHapiContext() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:test6");
mock.expectedMessageCount(0);
Message msg = createADT01Message();
msg.setParser(customContext.getPipeParser());
template.sendBody("direct:test6", msg);
assertMockEndpointsSatisfied();
}
Aggregations