Search in sources :

Example 56 with NotifyBuilder

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

the class MarkerFileExclusiveReadLockStrategyUnlockTest method testUnlocking.

public void testUnlocking() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
    writeFiles();
    boolean done = notify.matches(5, TimeUnit.SECONDS);
    assertTrue("Route should be done processing 1 exchanges", done);
    assertFileNotExists("target/marker-unlock/input-a/file1.dat.camelLock");
    assertFileNotExists("target/marker-unlock/input-b/file2.dat.camelLock");
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder)

Example 57 with NotifyBuilder

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

the class SedaUnitOfWorkTest method testSedaUOWWithException.

public void testSedaUOWWithException() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(2).create();
    template.sendBodyAndHeader("direct:start", "Hello World", "kaboom", "yes");
    notify.matchesMockWaitTime();
    assertEquals("onFailureA", sync);
    assertEquals("onFailureA", lastOne);
    assertEquals("Should have propagated the header inside the Synchronization.onFailure() callback", "yes", kaboom);
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder)

Example 58 with NotifyBuilder

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

the class SedaUnitOfWorkTest method testSedaUOW.

public void testSedaUOW() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(2).create();
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    template.sendBodyAndHeader("direct:start", "Hello World", "foo", "bar");
    assertMockEndpointsSatisfied();
    notify.matchesMockWaitTime();
    assertEquals("onCompleteA", sync);
    assertEquals("onCompleteA", lastOne);
    assertEquals("Should have propagated the header inside the Synchronization.onComplete() callback", "bar", foo);
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Example 59 with NotifyBuilder

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

the class ZipDataFormatFileUnmarshalDeleteTest method testZipFileUnmarshalDelete.

public void testZipFileUnmarshalDelete() throws Exception {
    // there are 2 exchanges
    NotifyBuilder event = event().whenDone(2).create();
    getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
    template.sendBodyAndHeader("file:target/zip", "Hello World", Exchange.FILE_NAME, "hello.txt");
    assertMockEndpointsSatisfied();
    event.matchesMockWaitTime();
    File in = new File("target/zip/hello.txt");
    assertFalse("Should have been deleted " + in, in.exists());
    File out = new File("target/zip/out/hello.txt.zip");
    assertFalse("Should have been deleted " + out, out.exists());
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder) File(java.io.File)

Example 60 with NotifyBuilder

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

the class GzipDataFormatFileUnmarshalDeleteTest method testGzipFileUnmarshalDelete.

public void testGzipFileUnmarshalDelete() throws Exception {
    NotifyBuilder notify = new NotifyBuilder(context).whenDone(2).create();
    getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
    template.sendBodyAndHeader("file:target/gzip", "Hello World", Exchange.FILE_NAME, "hello.txt");
    assertMockEndpointsSatisfied();
    notify.matchesMockWaitTime();
    File in = new File("target/gzip/hello.txt");
    assertFalse("Should have been deleted " + in, in.exists());
    File out = new File("target/gzip/out/hello.txt.gz");
    assertFalse("Should have been deleted " + out, out.exists());
}
Also used : NotifyBuilder(org.apache.camel.builder.NotifyBuilder) File(java.io.File)

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