Search in sources :

Example 16 with NotifyBuilder

use of org.apache.camel.builder.NotifyBuilder in project camel by apache.

the class JmsHttpPostIssueTest method testJmsInOnlyHttpPostIssue.

@Test
public void testJmsInOnlyHttpPostIssue() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenCompleted(1).from("jms*").create();
    template.sendBody("jms:queue:in", "Hello World");
    assertTrue("Should complete the JMS route", notify.matchesMockWaitTime());
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder) Test(org.junit.Test)

Example 17 with NotifyBuilder

use of org.apache.camel.builder.NotifyBuilder in project camel by apache.

the class SpringTarFileDataFormatTest method testTarToFileWithoutFileName.

@Test
public void testTarToFileWithoutFileName() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
    String[] files = TEST_DIR.list();
    assertTrue(files == null || files.length == 0);
    MockEndpoint mock = getMockEndpoint("mock:intercepted");
    mock.expectedMessageCount(1);
    template.sendBody("direct:tarToFile", TEXT);
    assertMockEndpointsSatisfied();
    // use builder to ensure the exchange is fully done before we check for file exists
    assertTrue(notify.matches(5, TimeUnit.SECONDS));
    Exchange exchange = mock.getReceivedExchanges().get(0);
    File file = new File(TEST_DIR, exchange.getIn().getMessageId() + ".tar");
    assertTrue(file.exists());
    assertArrayEquals(getTaredText(exchange.getIn().getMessageId()), getBytes(file));
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder) Exchange(org.apache.camel.Exchange) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) File(java.io.File) Test(org.junit.Test)

Example 18 with NotifyBuilder

use of org.apache.camel.builder.NotifyBuilder in project camel by apache.

the class SpringTarFileDataFormatTest method testTarToFileWithFileName.

@Test
public void testTarToFileWithFileName() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
    MockEndpoint mock = getMockEndpoint("mock:tarToFile");
    mock.expectedMessageCount(1);
    File file = new File(TEST_DIR, "poem.txt.tar");
    assertFalse(file.exists());
    template.sendBodyAndHeader("direct:tarToFile", TEXT, FILE_NAME, "poem.txt");
    // just make sure the file is created
    mock.assertIsSatisfied();
    // use builder to ensure the exchange is fully done before we check for file exists
    assertTrue(notify.matches(5, TimeUnit.SECONDS));
    assertTrue(file.exists());
    assertArrayEquals(getTaredText("poem.txt"), getBytes(file));
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) File(java.io.File) Test(org.junit.Test)

Example 19 with NotifyBuilder

use of org.apache.camel.builder.NotifyBuilder in project camel by apache.

the class TarFileDataFormatTest method testTarToFileWithFileName.

@Test
public void testTarToFileWithFileName() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
    MockEndpoint mock = getMockEndpoint("mock:tarToFile");
    mock.expectedMessageCount(1);
    File file = new File(TEST_DIR, "poem.txt.tar");
    assertFalse(file.exists());
    template.sendBodyAndHeader("direct:tarToFile", TEXT, FILE_NAME, "poem.txt");
    // just make sure the file is created
    mock.assertIsSatisfied();
    // use builder to ensure the exchange is fully done before we check for file exists
    assertTrue(notify.matches(5, TimeUnit.SECONDS));
    assertTrue(file.exists());
    assertTrue(ObjectHelper.equalByteArray(getTaredText("poem.txt"), getBytes(file)));
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) File(java.io.File) Test(org.junit.Test)

Example 20 with NotifyBuilder

use of org.apache.camel.builder.NotifyBuilder in project camel by apache.

the class TarFileDataFormatTest method testTarToFileWithoutFileName.

@Test
public void testTarToFileWithoutFileName() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
    String[] files = TEST_DIR.list();
    assertTrue(files == null || files.length == 0);
    MockEndpoint mock = getMockEndpoint("mock:intercepted");
    mock.expectedMessageCount(1);
    template.sendBody("direct:tarToFile", TEXT);
    assertMockEndpointsSatisfied();
    // use builder to ensure the exchange is fully done before we check for file exists
    assertTrue(notify.matches(5, TimeUnit.SECONDS));
    Exchange exchange = mock.getReceivedExchanges().get(0);
    File file = new File(TEST_DIR, exchange.getIn().getMessageId() + ".tar");
    assertTrue(file.exists());
    assertTrue(ObjectHelper.equalByteArray(getTaredText(exchange.getIn().getMessageId()), getBytes(file)));
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder) Exchange(org.apache.camel.Exchange) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) File(java.io.File) 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