use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class MllpTcpClientProducerTest method testMissingEndOfDataByte.
@Test
public void testMissingEndOfDataByte() throws Exception {
int sendMessageCount = 3;
acknowledged.expectedMessageCount(sendMessageCount - 1);
timeoutError.expectedMessageCount(1);
NotifyBuilder[] complete = new NotifyBuilder[sendMessageCount];
for (int i = 0; i < sendMessageCount; ++i) {
complete[i] = new NotifyBuilder(context).whenDone(i + 1).create();
}
mllpServer.setExcludeEndOfDataModulus(sendMessageCount);
for (int i = 0; i < sendMessageCount; ++i) {
source.sendBody(generateMessage(i + 1));
assertTrue("Messege " + i + " not completed", complete[i].matches(1, TimeUnit.SECONDS));
}
assertMockEndpointsSatisfied(15, TimeUnit.SECONDS);
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class MllpTcpClientProducerTest method testMissingEndOfBlockByte.
@Test
public void testMissingEndOfBlockByte() throws Exception {
int sendMessageCount = 3;
acknowledged.expectedMessageCount(sendMessageCount - 1);
timeoutError.expectedMessageCount(1);
NotifyBuilder[] complete = new NotifyBuilder[sendMessageCount];
for (int i = 0; i < sendMessageCount; ++i) {
complete[i] = new NotifyBuilder(context).whenDone(i + 1).create();
}
mllpServer.setExcludeEndOfBlockModulus(sendMessageCount);
for (int i = 0; i < sendMessageCount; ++i) {
source.sendBody(generateMessage(i + 1));
assertTrue("Messege " + i + " not completed", complete[i].matches(1, TimeUnit.SECONDS));
}
assertMockEndpointsSatisfied(15, TimeUnit.SECONDS);
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class MllpTcpServerConsumerTest method testOpenMllpEnvelopeWithReset.
@Test
public void testOpenMllpEnvelopeWithReset() throws Exception {
result.expectedMessageCount(4);
timeout.expectedMessageCount(1);
NotifyBuilder notify1 = new NotifyBuilder(context).whenDone(2).create();
NotifyBuilder notify2 = new NotifyBuilder(context).whenDone(5).create();
mllpClient.connect();
mllpClient.setSoTimeout(10000);
log.info("Sending TEST_MESSAGE_1");
String acknowledgement1 = mllpClient.sendMessageAndWaitForAcknowledgement(generateMessage(1));
log.info("Sending TEST_MESSAGE_2");
String acknowledgement2 = mllpClient.sendMessageAndWaitForAcknowledgement(generateMessage(2));
assertTrue("First two normal exchanges did not complete", notify1.matches(10, TimeUnit.SECONDS));
log.info("Sending TEST_MESSAGE_3");
mllpClient.setSendEndOfBlock(false);
mllpClient.setSendEndOfData(false);
// Acknowledgement won't come here
try {
mllpClient.sendMessageAndWaitForAcknowledgement(generateMessage(3));
} catch (MllpJUnitResourceException resourceEx) {
log.info("Expected exception reading response");
}
mllpClient.disconnect();
Thread.sleep(1000);
mllpClient.connect();
log.info("Sending TEST_MESSAGE_4");
mllpClient.setSendEndOfBlock(true);
mllpClient.setSendEndOfData(true);
String acknowledgement4 = mllpClient.sendMessageAndWaitForAcknowledgement(generateMessage(4));
log.info("Sending TEST_MESSAGE_5");
String acknowledgement5 = mllpClient.sendMessageAndWaitForAcknowledgement(generateMessage(5));
assertTrue("Remaining exchanges did not complete", notify2.matches(10, TimeUnit.SECONDS));
assertMockEndpointsSatisfied(10, TimeUnit.SECONDS);
assertTrue("Should be acknowledgment for message 1", acknowledgement1.contains("MSA|AA|00001"));
assertTrue("Should be acknowledgment for message 2", acknowledgement2.contains("MSA|AA|00002"));
// assertTrue("Should be acknowledgment for message 3", acknowledgement3.contains("MSA|AA|00003"));
assertTrue("Should be acknowledgment for message 4", acknowledgement4.contains("MSA|AA|00004"));
assertTrue("Should be acknowledgment for message 5", acknowledgement5.contains("MSA|AA|00005"));
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class MllpTcpServerConsumerMessageValidationTest method testMessageReadTimeout.
@Test
public void testMessageReadTimeout() throws Exception {
result.expectedMessageCount(0);
result.setAssertPeriod(1000);
timeout.expectedMessageCount(1);
invalid.expectedMessageCount(0);
NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
mllpClient.setSendEndOfBlock(false);
mllpClient.setSendEndOfData(false);
mllpClient.sendFramedData(generateMessage());
assertTrue("One exchange should have completed", notify.matches(15, TimeUnit.SECONDS));
assertMockEndpointsSatisfied();
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class MllpTcpServerConsumerMessageValidationTest method testOpenMllpEnvelopeWithReset.
@Test
public void testOpenMllpEnvelopeWithReset() throws Exception {
result.expectedMessageCount(4);
result.setAssertPeriod(1000);
timeout.expectedMessageCount(1);
invalid.expectedMessageCount(0);
NotifyBuilder notify1 = new NotifyBuilder(context).whenDone(2).create();
NotifyBuilder notify2 = new NotifyBuilder(context).whenDone(5).create();
mllpClient.connect();
mllpClient.setSoTimeout(10000);
log.info("Sending TEST_MESSAGE_1");
String acknowledgement1 = mllpClient.sendMessageAndWaitForAcknowledgement(generateMessage(1));
log.info("Sending TEST_MESSAGE_2");
String acknowledgement2 = mllpClient.sendMessageAndWaitForAcknowledgement(generateMessage(2));
assertTrue("First two normal exchanges did not complete", notify1.matches(10, TimeUnit.SECONDS));
log.info("Sending TEST_MESSAGE_3");
mllpClient.setSendEndOfBlock(false);
mllpClient.setSendEndOfData(false);
// Acknowledgement won't come here
try {
mllpClient.sendMessageAndWaitForAcknowledgement(generateMessage(3));
} catch (MllpJUnitResourceException resourceEx) {
log.info("Expected exception reading response");
}
mllpClient.disconnect();
Thread.sleep(1000);
mllpClient.connect();
log.info("Sending TEST_MESSAGE_4");
mllpClient.setSendEndOfBlock(true);
mllpClient.setSendEndOfData(true);
String acknowledgement4 = mllpClient.sendMessageAndWaitForAcknowledgement(generateMessage(4));
log.info("Sending TEST_MESSAGE_5");
String acknowledgement5 = mllpClient.sendMessageAndWaitForAcknowledgement(generateMessage(5));
assertTrue("Remaining exchanges did not complete", notify2.matches(10, TimeUnit.SECONDS));
assertMockEndpointsSatisfied(10, TimeUnit.SECONDS);
assertTrue("Should be acknowledgment for message 1", acknowledgement1.contains("MSA|AA|00001"));
assertTrue("Should be acknowledgment for message 2", acknowledgement2.contains("MSA|AA|00002"));
// assertTrue("Should be acknowledgment for message 3", acknowledgement3.contains("MSA|AA|00003"));
assertTrue("Should be acknowledgment for message 4", acknowledgement4.contains("MSA|AA|00004"));
assertTrue("Should be acknowledgment for message 5", acknowledgement5.contains("MSA|AA|00005"));
}
Aggregations