Search in sources :

Example 6 with NotifyBuilder

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);
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 7 with NotifyBuilder

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);
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 8 with NotifyBuilder

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"));
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder) MllpJUnitResourceException(org.apache.camel.test.junit.rule.mllp.MllpJUnitResourceException) Test(org.junit.Test)

Example 9 with NotifyBuilder

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();
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder) Test(org.junit.Test)

Example 10 with NotifyBuilder

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"));
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder) MllpJUnitResourceException(org.apache.camel.test.junit.rule.mllp.MllpJUnitResourceException) Test(org.junit.Test)

Aggregations

NotifyBuilder (org.apache.camel.builder.NotifyBuilder)109 Test (org.junit.Test)72 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)30 File (java.io.File)24 Exchange (org.apache.camel.Exchange)10 RouteBuilder (org.apache.camel.builder.RouteBuilder)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 HashSet (java.util.HashSet)4 MBeanServer (javax.management.MBeanServer)4 ObjectName (javax.management.ObjectName)4 Processor (org.apache.camel.Processor)4 StopWatch (org.apache.camel.util.StopWatch)4 ConnectException (java.net.ConnectException)3 ExecutorService (java.util.concurrent.ExecutorService)3 Ignore (org.junit.Ignore)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Future (java.util.concurrent.Future)2 ZipFile (java.util.zip.ZipFile)2