예제 #1
0
 @Override
 protected RouteBuilder createRouteBuilder() throws Exception {
   builder.setDelay(0);
   builder.setPeriod(1000);
   builder.setEndpoint(resultEndpoint);
   return builder;
 }
예제 #2
0
 @Test
 public void testOnline() throws InterruptedException {
   // Wait for 5 seconds while Camel route is exercised
   resultEndpoint.whenAnyExchangeReceived(null);
   Thread.sleep(5000);
   // Ensure online symptoms are reported
   List<Exchange> exchanges = resultEndpoint.getExchanges();
   Assert.assertTrue(!exchanges.isEmpty());
   Assert.assertEquals(1, alerts);
   Assert.assertEquals(exchanges.size(), builder.getPingProcessor().getSucceeded());
   Assert.assertEquals(0, builder.getPingProcessor().getFailed());
   Assert.assertEquals(exchanges.size(), builder.getPingProcessor().getTotal());
 }
예제 #3
0
  @Test
  public void testOffline() throws InterruptedException {
    resultEndpoint.whenAnyExchangeReceived(
        new Processor() {
          @Override
          public void process(Exchange exchange) throws Exception {
            // Treat the endpoint as offline
            throw new Exception("OFFLINE");
          }
        });

    // Wait for 5 seconds while Camel route is exercised
    Thread.sleep(5000);
    // Ensure offline symptoms are reported
    final List<Exchange> exchanges = resultEndpoint.getExchanges();
    Assert.assertTrue(!exchanges.isEmpty());
    Assert.assertEquals(1, alerts);
    Assert.assertEquals(exchanges.size(), builder.getPingProcessor().getFailed());
    Assert.assertEquals(0, builder.getPingProcessor().getSucceeded());
    Assert.assertEquals(exchanges.size(), builder.getPingProcessor().getTotal());
  }
예제 #4
0
 @Before
 public void init() {
   // Reset values of interest prior to each test
   alerts = 0;
   builder.getPingProcessor().reset();
 }