use of org.apache.camel.Exchange in project camel by apache.
the class Mina2FiltersTest method testFilter.
private void testFilter(final String uri) throws Exception {
context.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
from(uri).to("mock:result");
}
});
MockEndpoint mock = this.getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");
Endpoint endpoint = context.getEndpoint(uri);
Exchange exchange = endpoint.createExchange();
Producer producer = endpoint.createProducer();
producer.start();
// set input and execute it
exchange.getIn().setBody("Hello World");
producer.process(exchange);
assertMockEndpointsSatisfied();
assertEquals("The filter should have been called twice (producer and consumer)", 2, TestFilter.called);
producer.stop();
}
use of org.apache.camel.Exchange in project camel by apache.
the class Mina2ConverterTest method testToStringTwoTimes.
public void testToStringTwoTimes() throws UnsupportedEncodingException {
String in = "Hello World 你好";
IoBuffer bb = IoBuffer.wrap(in.getBytes("UTF-8"));
Exchange exchange = new DefaultExchange(new DefaultCamelContext());
exchange.setProperty(Exchange.CHARSET_NAME, "UTF-8");
String out = Mina2Converter.toString(bb, exchange);
assertEquals("Hello World 你好", out);
// should NOT be possible to convert to string without affecting the ByteBuffer
out = Mina2Converter.toString(bb, exchange);
assertEquals("", out);
}
use of org.apache.camel.Exchange in project camel by apache.
the class MllpEndpoint method createExchange.
@Override
public Exchange createExchange(ExchangePattern exchangePattern) {
Exchange mllpExchange = super.createExchange(exchangePattern);
setExchangeProperties(mllpExchange);
return mllpExchange;
}
use of org.apache.camel.Exchange in project camel by apache.
the class MllpEndpoint method createExchange.
@Override
public Exchange createExchange(Exchange exchange) {
Exchange mllpExchange = super.createExchange(exchange);
setExchangeProperties(mllpExchange);
return mllpExchange;
}
use of org.apache.camel.Exchange in project camel by apache.
the class MllpTcpServerConsumerAcknowledgementTest method testAcknowledgementDeliveryFailure.
@Test
public void testAcknowledgementDeliveryFailure() throws Exception {
final String testMessage = "MSH|^~\\&|APP_A|FAC_A|^org^sys||||ADT^A04^ADT_A04|||2.6" + '\r' + "PID|1||1100832^^^^PI||TEST^FIG||98765432|U||R|435 MAIN STREET^^LONGMONT^CO^80503||123-456-7890|||S" + '\r' + '\r' + '\n';
final String expectedAcknowledgement = "MSH|^~\\&|^org^sys||APP_A|FAC_A|||ACK^A04^ADT_A04|||2.6" + '\r' + "MSA|AA|" + '\r' + '\r' + '\n';
result.expectedBodiesReceived(testMessage);
result.expectedHeaderReceived(MLLP_SENDING_APPLICATION, "APP_A");
result.expectedHeaderReceived(MLLP_SENDING_FACILITY, "FAC_A");
result.expectedHeaderReceived(MLLP_RECEIVING_APPLICATION, "^org^sys");
result.expectedHeaderReceived(MLLP_EVENT_TYPE, "ADT");
result.expectedHeaderReceived(MLLP_TRIGGER_EVENT, "A04");
result.expectedHeaderReceived(MLLP_VERSION_ID, "2.6");
complete.expectedMessageCount(0);
failure.expectedBodiesReceived(testMessage);
failure.expectedHeaderReceived(MLLP_SENDING_APPLICATION, "APP_A");
failure.expectedHeaderReceived(MLLP_SENDING_FACILITY, "FAC_A");
failure.expectedHeaderReceived(MLLP_RECEIVING_APPLICATION, "^org^sys");
failure.expectedHeaderReceived(MLLP_EVENT_TYPE, "ADT");
failure.expectedHeaderReceived(MLLP_TRIGGER_EVENT, "A04");
failure.expectedHeaderReceived(MLLP_VERSION_ID, "2.6");
failure.expectedHeaderReceived(MllpConstants.MLLP_ACKNOWLEDGEMENT_TYPE, "AA");
failure.expectedHeaderReceived(MLLP_ACKNOWLEDGEMENT, expectedAcknowledgement);
boolean disconnectAfterSend = true;
mllpClient.setDisconnectMethod(MllpClientResource.DisconnectMethod.RESET);
mllpClient.connect();
mllpClient.sendFramedData(testMessage, disconnectAfterSend);
assertMockEndpointsSatisfied(10, TimeUnit.SECONDS);
Exchange failureExchange = failure.getExchanges().get(0);
Object failureException = failureExchange.getProperty(MLLP_ACKNOWLEDGEMENT_EXCEPTION);
assertNotNull("OnFailureOnly exchange should have a " + MLLP_ACKNOWLEDGEMENT_EXCEPTION + " property", failureException);
assertIsInstanceOf(Exception.class, failureException);
}
Aggregations