Java 类org.apache.camel.management.event.CamelContextStartingEvent 实例源码

项目:Camel    文件:AdviceTest.java   
void advice(@Observes CamelContextStartingEvent event,
            @Uri("mock:messages") MockEndpoint messages,
            ModelCamelContext context) throws Exception {
    messages.expectedMessageCount(2);
    messages.expectedBodiesReceived("Hello", "Bye");

    verifier.messages = messages;

    context.getRouteDefinition("route")
        .adviceWith(context, new AdviceWithRouteBuilder() {
            @Override
            public void configure() {
                weaveAddLast().to("mock:messages");
            }
        });
}
项目:Camel    文件:EventNotifierEventsTest.java   
public void testSuspendResume() throws Exception {
    assertEquals(6, events.size());
    assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(1));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(2));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(3));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(4));
    assertIsInstanceOf(CamelContextStartedEvent.class, events.get(5));

    context.suspend();

    assertEquals(8, events.size());
    assertIsInstanceOf(CamelContextSuspendingEvent.class, events.get(6));
    // notice direct component is not suspended (as they are internal)
    assertIsInstanceOf(CamelContextSuspendedEvent.class, events.get(7));

    context.resume();

    assertEquals(10, events.size());
    assertIsInstanceOf(CamelContextResumingEvent.class, events.get(8));
    assertIsInstanceOf(CamelContextResumedEvent.class, events.get(9));
}
项目:Camel    文件:EventNotifierServiceStoppingFailedEventTest.java   
public void testStopWithFailure() throws Exception {
    stopOrder = "";

    context.stop();

    assertEquals("CBA", stopOrder);

    assertEquals(5, events.size());

    assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
    assertIsInstanceOf(CamelContextStartedEvent.class, events.get(1));
    assertIsInstanceOf(CamelContextStoppingEvent.class, events.get(2));
    ServiceStopFailureEvent event = assertIsInstanceOf(ServiceStopFailureEvent.class, events.get(3));
    assertIsInstanceOf(CamelContextStoppedEvent.class, events.get(4));

    assertEquals("Fail B", event.getCause().getMessage());
    assertEquals("Failure to stop service: B due to Fail B", event.toString());
}
项目:Camel    文件:MultiContextEventNotifierTest.java   
@Test
@InSequence(2)
public void sendMessageToDefaultCamelContextInbound(List<Class> events) throws InterruptedException {
    defaultOutbound.expectedMessageCount(1);
    defaultOutbound.expectedBodiesReceived("test-default");
    defaultOutbound.message(0).exchange().matches(fromCamelContext("camel-cdi"));

    defaultInbound.sendBody("test-default");

    assertIsSatisfied(2L, TimeUnit.SECONDS, defaultOutbound);

    assertThat("Events fired are incorrect", events,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeCreatedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeSentEvent.class,
            ExchangeCompletedEvent.class,
            ExchangeSentEvent.class));
}
项目:Camel    文件:MultiContextEventNotifierTest.java   
@Test
@InSequence(3)
public void sendMessageToFirstCamelContextInbound(@ContextName("first") List<Class> events) throws InterruptedException {
    firstOutbound.expectedMessageCount(1);
    firstOutbound.expectedBodiesReceived("test-first");
    firstOutbound.expectedHeaderReceived("context", "first");
    firstOutbound.message(0).exchange().matches(fromCamelContext("first"));

    firstInbound.sendBody("test-first");

    assertIsSatisfied(2L, TimeUnit.SECONDS, firstOutbound);

    assertThat("Events fired are incorrect", events,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeCreatedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeSentEvent.class,
            ExchangeCompletedEvent.class,
            ExchangeSentEvent.class));
}
项目:Camel    文件:MultiContextEventNotifierTest.java   
@Test
@InSequence(4)
public void sendMessageToSecondCamelContextInbound(@ContextName("second") List<Class> events) throws InterruptedException {
    secondOutbound.expectedMessageCount(1);
    secondOutbound.expectedBodiesReceived("test-second");
    secondOutbound.expectedHeaderReceived("context", "second");
    secondOutbound.message(0).exchange().matches(fromCamelContext("second"));

    secondInbound.sendBody("test-second");

    assertIsSatisfied(2L, TimeUnit.SECONDS, secondOutbound);

    assertThat("Events fired are incorrect", events,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeCreatedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeSentEvent.class,
            ExchangeCompletedEvent.class,
            ExchangeSentEvent.class));
}
项目:Camel    文件:CamelEventNotifierTest.java   
@Test
@InSequence(2)
public void sendMessageToInbound(List<Class> events) throws InterruptedException {
    outbound.expectedMessageCount(1);
    outbound.expectedBodiesReceived("test");

    inbound.sendBody("test");

    assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);

    assertThat("Events fired are incorrect!", events,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeCreatedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeSentEvent.class,
            ExchangeCompletedEvent.class,
            ExchangeSentEvent.class));
}
项目:Camel    文件:CamelEventNotifierTest.java   
@Test
@InSequence(3)
public void stopCamelContext(CamelContext context, List<Class> events) throws Exception {
    context.stop();

    assertThat("Events fired are incorrect!", events,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeCreatedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeSentEvent.class,
            ExchangeCompletedEvent.class,
            ExchangeSentEvent.class,
            CamelContextStoppingEvent.class,
            CamelContextStoppedEvent.class));
}
项目:camel-cdi    文件:MultiContextEventNotifierTest.java   
@Test
@InSequence(2)
public void sendMessageToDefaultCamelContextInbound(@Named("defaultContext") List<Class> events) throws InterruptedException {
    defaultOutbound.expectedMessageCount(1);
    defaultOutbound.expectedBodiesReceived("test-default");
    defaultOutbound.message(0).exchange().matches(fromCamelContext("camel-cdi"));

    defaultInbound.sendBody("test-default");

    assertIsSatisfied(2L, TimeUnit.SECONDS, defaultOutbound);

    assertThat("Events fired are incorrect", events,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeCreatedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeSentEvent.class,
            ExchangeCompletedEvent.class,
            ExchangeSentEvent.class));
}
项目:camel-cdi    文件:MultiContextEventNotifierTest.java   
@Test
@InSequence(3)
public void sendMessageToFirstCamelContextInbound(@ContextName("first") List<Class> events) throws InterruptedException {
    firstOutbound.expectedMessageCount(1);
    firstOutbound.expectedBodiesReceived("test-first");
    firstOutbound.expectedHeaderReceived("context", "first");
    firstOutbound.message(0).exchange().matches(fromCamelContext("first"));

    firstInbound.sendBody("test-first");

    assertIsSatisfied(2L, TimeUnit.SECONDS, firstOutbound);

    assertThat("Events fired are incorrect", events,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeCreatedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeSentEvent.class,
            ExchangeCompletedEvent.class,
            ExchangeSentEvent.class));
}
项目:camel-cdi    文件:MultiContextEventNotifierTest.java   
@Test
@InSequence(4)
public void sendMessageToSecondCamelContextInbound(@ContextName("second") List<Class> events) throws InterruptedException {
    secondOutbound.expectedMessageCount(1);
    secondOutbound.expectedBodiesReceived("test-second");
    secondOutbound.expectedHeaderReceived("context", "second");
    secondOutbound.message(0).exchange().matches(fromCamelContext("second"));

    secondInbound.sendBody("test-second");

    assertIsSatisfied(2L, TimeUnit.SECONDS, secondOutbound);

    assertThat("Events fired are incorrect", events,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeCreatedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeSentEvent.class,
            ExchangeCompletedEvent.class,
            ExchangeSentEvent.class));
}
项目:camel-cdi    文件:CamelEventNotifierTest.java   
@Test
@InSequence(2)
public void sendMessageToInbound(List<Class> events) throws InterruptedException {
    outbound.expectedMessageCount(1);
    outbound.expectedBodiesReceived("test");

    inbound.sendBody("test");

    assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);

    assertThat("Events fired are incorrect!", events,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeCreatedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeSentEvent.class,
            ExchangeCompletedEvent.class,
            ExchangeSentEvent.class));
}
项目:camel-cdi    文件:CamelEventNotifierTest.java   
@Test
@InSequence(3)
public void stopCamelContext(CamelContext context, List<Class> events) throws Exception {
    context.stop();

    assertThat("Events fired are incorrect!", events,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeCreatedEvent.class,
            ExchangeSendingEvent.class,
            ExchangeSentEvent.class,
            ExchangeCompletedEvent.class,
            ExchangeSentEvent.class,
            CamelContextStoppingEvent.class,
            CamelContextStoppedEvent.class));
}
项目:Camel    文件:CdiPropertiesTest.java   
static void advice(@Observes CamelContextStartingEvent event,
                   ModelCamelContext context) throws Exception {
    // Add a mock endpoint to the end of the route
    context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() {
            weaveAddLast().to("mock:outbound");
        }
    });
}
项目:Camel    文件:CdiXmlTest.java   
void pipeMatrixStream(@Observes CamelContextStartingEvent event,
                      ModelCamelContext context) throws Exception {
    context.getRouteDefinition("matrix")
        .adviceWith(context, new AdviceWithRouteBuilder() {
            @Override
            public void configure() {
                weaveAddLast().to("mock:matrix");
            }
        });
}
项目:Camel    文件:ClientApplication.java   
public void setupCamel(@Observes CamelContextStartingEvent event) {
    // create zipkin
    ZipkinTracer zipkin = new ZipkinTracer();
    zipkin.setHostName("192.168.99.100");
    zipkin.setPort(9410);
    zipkin.addClientServiceMapping("http://localhost:9090/service1", "service1");
    // capture 100% of all the events
    zipkin.setRate(1.0f);
    // include message bodies in the traces (not recommended for production)
    zipkin.setIncludeMessageBodyStreams(true);

    // register zipkin to CamelContext
    zipkin.init(event.getContext());
}
项目:Camel    文件:EventNotifierEventsTest.java   
public void testExchangeDone() throws Exception {
    getMockEndpoint("mock:result").expectedMessageCount(1);

    template.sendBody("direct:start", "Hello World");

    assertMockEndpointsSatisfied();

    assertEquals(14, events.size());
    assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(1));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(2));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(3));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(4));
    assertIsInstanceOf(CamelContextStartedEvent.class, events.get(5));
    assertIsInstanceOf(ExchangeCreatedEvent.class, events.get(7));
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(9));
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(11));
    assertIsInstanceOf(ExchangeCompletedEvent.class, events.get(12));

    // this is the sent using the produce template to start the test
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(13));

    context.stop();

    assertEquals(20, events.size());
    assertIsInstanceOf(CamelContextStoppingEvent.class, events.get(14));
    assertIsInstanceOf(RouteStoppedEvent.class, events.get(15));
    assertIsInstanceOf(RouteRemovedEvent.class, events.get(16));
    assertIsInstanceOf(RouteStoppedEvent.class, events.get(17));
    assertIsInstanceOf(RouteRemovedEvent.class, events.get(18));
    assertIsInstanceOf(CamelContextStoppedEvent.class, events.get(19));
}
项目:Camel    文件:EventNotifierEventsTest.java   
public void testExchangeFailed() throws Exception {
    try {
        template.sendBody("direct:fail", "Hello World");
        fail("Should have thrown an exception");
    } catch (Exception e) {
        // expected
        assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
    }

    assertEquals(10, events.size());
    assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(1));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(2));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(3));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(4));
    assertIsInstanceOf(CamelContextStartedEvent.class, events.get(5));
    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(6));
    assertIsInstanceOf(ExchangeCreatedEvent.class, events.get(7));
    assertIsInstanceOf(ExchangeFailedEvent.class, events.get(8));
    // this is the sent using the produce template to start the test
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(9));

    context.stop();

    assertEquals(16, events.size());
    assertIsInstanceOf(CamelContextStoppingEvent.class, events.get(10));
    assertIsInstanceOf(RouteStoppedEvent.class, events.get(11));
    assertIsInstanceOf(RouteRemovedEvent.class, events.get(12));
    assertIsInstanceOf(RouteStoppedEvent.class, events.get(13));
    assertIsInstanceOf(RouteRemovedEvent.class, events.get(14));
    assertIsInstanceOf(CamelContextStoppedEvent.class, events.get(15));
}
项目:Camel    文件:MultipleEventNotifierEventsTest.java   
public void testExchangeFailed() throws Exception {
    try {
        template.sendBody("direct:fail", "Hello World");
        fail("Should have thrown an exception");
    } catch (Exception e) {
        // expected
        assertIsInstanceOf(IllegalArgumentException.class, e.getCause());
    }

    assertEquals(10, events.size());
    assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(1));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(2));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(3));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(4));
    assertIsInstanceOf(CamelContextStartedEvent.class, events.get(5));
    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(6));
    assertIsInstanceOf(ExchangeCreatedEvent.class, events.get(7));
    assertIsInstanceOf(ExchangeFailedEvent.class, events.get(8));
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(9));

    assertEquals(4, events2.size());

    context.stop();
    assertIsInstanceOf(ExchangeSendingEvent.class, events2.get(0));
    assertIsInstanceOf(ExchangeCreatedEvent.class, events2.get(1));
    assertIsInstanceOf(ExchangeFailedEvent.class, events2.get(2));
    assertIsInstanceOf(ExchangeSentEvent.class, events2.get(3));

    assertEquals(16, events.size());
    assertIsInstanceOf(CamelContextStoppingEvent.class, events.get(10));
    assertIsInstanceOf(RouteStoppedEvent.class, events.get(11));
    assertIsInstanceOf(RouteRemovedEvent.class, events.get(12));
    assertIsInstanceOf(RouteStoppedEvent.class, events.get(13));
    assertIsInstanceOf(RouteRemovedEvent.class, events.get(14));
    assertIsInstanceOf(CamelContextStoppedEvent.class, events.get(15));

    assertEquals(4, events2.size());
}
项目:Camel    文件:MultiContextEventNotifierTest.java   
@Test
@InSequence(1)
public void configureCamelContexts(List<Class> defaultEvents,
                                   @ContextName("first") List<Class> firstEvents,
                                   @ContextName("second") List<Class> secondEvents,
                                   @Named("anyContext") List<Class> anyEvents) throws Exception {
    secondCamelContext.addRoutes(new RouteBuilder() {
        @Override
        public void configure() {
            from("direct:inbound").setHeader("context").constant("second").to("mock:outbound");
        }
    });

    secondCamelContext.startAllRoutes();

    assertThat("Events fired for any contexts are incorrect", anyEvents,
        everyItem(
            isOneOf(
                CamelContextStartingEvent.class,
                CamelContextStartedEvent.class)));
    assertThat("Events fired for default context are incorrect", defaultEvents,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class));
    assertThat("Events fired for first context are incorrect", firstEvents,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class));
    assertThat("Events fired for second context are incorrect", secondEvents,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class));
}
项目:Camel    文件:CamelEventNotifierTest.java   
@Test
@InSequence(1)
public void startedCamelContext(List<Class> events) {
    assertThat("Events fired are incorrect!", events,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class));
}
项目:camel-cdi    文件:MultiContextEventNotifierTest.java   
@Test
@InSequence(1)
public void configureCamelContexts(@Named("defaultContext") List<Class> defaultEvents,
                                   @ContextName("first") List<Class> firstEvents,
                                   @ContextName("second") List<Class> secondEvents,
                                   @Named("anyContext") List<Class> anyEvents) throws Exception {
    secondCamelContext.addRoutes(new RouteBuilder() {
        @Override
        public void configure() {
            from("direct:inbound").setHeader("context").constant("second").to("mock:outbound");
        }
    });

    secondCamelContext.startAllRoutes();

    assertThat("Events fired for any contexts are incorrect", anyEvents,
        everyItem(
            is(oneOf(
                CamelContextStartingEvent.class,
                CamelContextStartedEvent.class))));
    assertThat("Events fired for default context are incorrect", defaultEvents,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class));
    assertThat("Events fired for first context are incorrect", firstEvents,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class));
    assertThat("Events fired for second context are incorrect", secondEvents,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class));
}
项目:camel-cdi    文件:CamelEventNotifierTest.java   
@Test
@InSequence(1)
public void startedCamelContext(List<Class> events) throws Exception {
    assertThat("Events fired are incorrect!", events,
        contains(
            CamelContextStartingEvent.class,
            CamelContextStartedEvent.class));
}
项目:camel-cdi    文件:PropertiesSampleTest.java   
static void advice(@Observes CamelContextStartingEvent event,
                   ModelCamelContext context) throws Exception {
    // Add a mock endpoint to the end of the route
    context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() {
            weaveAddLast().to("mock:outbound");
        }
    });
}
项目:camel-cdi    文件:XmlSampleTest.java   
void pipeMatrixStream(@Observes CamelContextStartingEvent event,
                      ModelCamelContext context) throws Exception {
    context.getRouteDefinition("matrix")
        .adviceWith(context, new AdviceWithRouteBuilder() {
            @Override
            public void configure() {
                weaveAddLast().to("mock:matrix");
            }
        });
}
项目:Camel    文件:EventNotifierFailureHandledEventsTest.java   
public void testExchangeDeadLetterChannel() throws Exception {
    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            errorHandler(deadLetterChannel("mock:dead"));

            from("direct:start").throwException(new IllegalArgumentException("Damn"));
        }
    });
    context.start();

    getMockEndpoint("mock:dead").expectedMessageCount(1);
    template.sendBody("direct:start", "Hello World");
    assertMockEndpointsSatisfied();

    assertEquals(12, events.size());
    assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(1));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(2));
    assertIsInstanceOf(CamelContextStartedEvent.class, events.get(3));
    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(4));
    assertIsInstanceOf(ExchangeCreatedEvent.class, events.get(5));

    ExchangeFailureHandlingEvent e0 = assertIsInstanceOf(ExchangeFailureHandlingEvent.class, events.get(6));
    assertEquals("should be DLC", true, e0.isDeadLetterChannel());
    assertEquals("mock://dead", e0.getDeadLetterUri());

    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(7));
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(8));

    ExchangeFailureHandledEvent e = assertIsInstanceOf(ExchangeFailureHandledEvent.class, events.get(9));
    assertEquals("should be DLC", true, e.isDeadLetterChannel());
    assertTrue("should be marked as failure handled", e.isHandled());
    assertFalse("should not be continued", e.isContinued());
    SendProcessor send = assertIsInstanceOf(SendProcessor.class, e.getFailureHandler());
    assertEquals("mock://dead", send.getDestination().getEndpointUri());
    assertEquals("mock://dead", e.getDeadLetterUri());

    // dead letter channel will mark the exchange as completed
    assertIsInstanceOf(ExchangeCompletedEvent.class, events.get(10));
    // and the last event should be the direct:start
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(11));
    ExchangeSentEvent sent = (ExchangeSentEvent) events.get(11);
    assertEquals("direct://start", sent.getEndpoint().getEndpointUri());
}
项目:Camel    文件:EventNotifierFailureHandledEventsTest.java   
public void testExchangeOnException() throws Exception {
    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            onException(IllegalArgumentException.class).handled(true).to("mock:dead");

            from("direct:start").throwException(new IllegalArgumentException("Damn"));
        }
    });
    context.start();

    getMockEndpoint("mock:dead").expectedMessageCount(1);
    template.sendBody("direct:start", "Hello World");
    assertMockEndpointsSatisfied();

    assertEquals(12, events.size());
    assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(1));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(2));
    assertIsInstanceOf(CamelContextStartedEvent.class, events.get(3));
    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(4));
    assertIsInstanceOf(ExchangeCreatedEvent.class, events.get(5));

    ExchangeFailureHandlingEvent e0 = assertIsInstanceOf(ExchangeFailureHandlingEvent.class, events.get(6));
    assertEquals("should NOT be DLC", false, e0.isDeadLetterChannel());

    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(7));
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(8));

    ExchangeFailureHandledEvent e = assertIsInstanceOf(ExchangeFailureHandledEvent.class, events.get(9));
    assertEquals("should NOT be DLC", false, e.isDeadLetterChannel());
    assertTrue("should be marked as failure handled", e.isHandled());
    assertFalse("should not be continued", e.isContinued());

    // onException will handle the exception
    assertIsInstanceOf(ExchangeCompletedEvent.class, events.get(10));
    // and the last event should be the direct:start
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(11));
    ExchangeSentEvent sent = (ExchangeSentEvent) events.get(11);
    assertEquals("direct://start", sent.getEndpoint().getEndpointUri());
}
项目:Camel    文件:EventNotifierFailureHandledEventsTest.java   
public void testExchangeDoTryDoCatch() throws Exception {
    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:start")
                .doTry()
                    .throwException(new IllegalArgumentException("Damn"))
                .doCatch(IllegalArgumentException.class)
                    .to("mock:dead")
                .end();
        }
    });
    context.start();

    getMockEndpoint("mock:dead").expectedMessageCount(1);
    template.sendBody("direct:start", "Hello World");
    assertMockEndpointsSatisfied();

    assertEquals(12, events.size());
    assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(1));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(2));
    assertIsInstanceOf(CamelContextStartedEvent.class, events.get(3));
    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(4));
    assertIsInstanceOf(ExchangeCreatedEvent.class, events.get(5));

    ExchangeFailureHandlingEvent e0 = assertIsInstanceOf(ExchangeFailureHandlingEvent.class, events.get(6));
    assertEquals("should NOT be DLC", false, e0.isDeadLetterChannel());

    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(7));
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(8));

    ExchangeFailureHandledEvent e = assertIsInstanceOf(ExchangeFailureHandledEvent.class, events.get(9));
    assertEquals("should NOT be DLC", false, e.isDeadLetterChannel());
    assertFalse("should not be marked as failure handled as it was continued instead", e.isHandled());
    assertTrue("should be continued", e.isContinued());

    // onException will handle the exception
    assertIsInstanceOf(ExchangeCompletedEvent.class, events.get(10));
    // and the last event should be the direct:start
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(11));
    ExchangeSentEvent sent = (ExchangeSentEvent) events.get(11);
    assertEquals("direct://start", sent.getEndpoint().getEndpointUri());
}
项目:Camel    文件:MultipleEventNotifierEventsTest.java   
public void testExchangeDone() throws Exception {
    getMockEndpoint("mock:result").expectedMessageCount(1);

    template.sendBody("direct:start", "Hello World");

    assertMockEndpointsSatisfied();

    assertEquals(14, events.size());
    assertIsInstanceOf(CamelContextStartingEvent.class, events.get(0));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(1));
    assertIsInstanceOf(RouteAddedEvent.class, events.get(2));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(3));
    assertIsInstanceOf(RouteStartedEvent.class, events.get(4));
    assertIsInstanceOf(CamelContextStartedEvent.class, events.get(5));
    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(6));
    assertIsInstanceOf(ExchangeCreatedEvent.class, events.get(7));
    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(8));
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(9));
    assertIsInstanceOf(ExchangeSendingEvent.class, events.get(10));
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(11));
    assertIsInstanceOf(ExchangeCompletedEvent.class, events.get(12));
    assertIsInstanceOf(ExchangeSentEvent.class, events.get(13));

    assertEquals(8, events2.size());
    assertIsInstanceOf(ExchangeSendingEvent.class, events2.get(0));
    assertIsInstanceOf(ExchangeCreatedEvent.class, events2.get(1));
    assertIsInstanceOf(ExchangeSendingEvent.class, events2.get(2));
    assertIsInstanceOf(ExchangeSentEvent.class, events2.get(3));
    assertIsInstanceOf(ExchangeSendingEvent.class, events2.get(4));
    assertIsInstanceOf(ExchangeSentEvent.class, events2.get(5));
    assertIsInstanceOf(ExchangeCompletedEvent.class, events2.get(6));
    assertIsInstanceOf(ExchangeSentEvent.class, events2.get(7));

    context.stop();

    assertEquals(20, events.size());
    assertIsInstanceOf(CamelContextStoppingEvent.class, events.get(14));
    assertIsInstanceOf(RouteStoppedEvent.class, events.get(15));
    assertIsInstanceOf(RouteRemovedEvent.class, events.get(16));
    assertIsInstanceOf(RouteStoppedEvent.class, events.get(17));
    assertIsInstanceOf(RouteRemovedEvent.class, events.get(18));
    assertIsInstanceOf(CamelContextStoppedEvent.class, events.get(19));

    assertEquals(8, events2.size());
}
项目:Camel    文件:MultiContextEventNotifierTest.java   
private void onAnyContextStartingEvent(@Observes CamelContextStartingEvent event, @Named("anyContext") List<Class> events) {
    events.add(CamelContextStartingEvent.class);
}
项目:Camel    文件:MultiContextEventNotifierTest.java   
private void onDefaultContextStartingEvent(@Observes @Default CamelContextStartingEvent event, List<Class> events) {
    events.add(CamelContextStartingEvent.class);
}
项目:Camel    文件:MultiContextEventNotifierTest.java   
private void onFirstContextStartingEvent(@Observes @ContextName("first") CamelContextStartingEvent event, @ContextName("first") List<Class> events) {
    events.add(CamelContextStartingEvent.class);
}
项目:Camel    文件:MultiContextEventNotifierTest.java   
private void onSecondContextStartingEvent(@Observes @ContextName("second") CamelContextStartingEvent event, @ContextName("second") List<Class> events) {
    events.add(CamelContextStartingEvent.class);
}
项目:Camel    文件:CamelEventNotifierTest.java   
private void onCamelContextStartingEvent(@Observes CamelContextStartingEvent event, List<Class> events) {
    events.add(CamelContextStartingEvent.class);
}
项目:camel-cdi    文件:MultiContextEventNotifierTest.java   
private void onAnyContextStartingEvent(@Observes CamelContextStartingEvent event, @Named("anyContext") List<Class> events) {
    events.add(CamelContextStartingEvent.class);
}
项目:camel-cdi    文件:MultiContextEventNotifierTest.java   
private void onDefaultContextStartingEvent(@Observes @Default CamelContextStartingEvent event, @Named("defaultContext") List<Class> events) {
    events.add(CamelContextStartingEvent.class);
}
项目:camel-cdi    文件:MultiContextEventNotifierTest.java   
private void onFirstContextStartingEvent(@Observes @ContextName("first") CamelContextStartingEvent event, @ContextName("first") List<Class> events) {
    events.add(CamelContextStartingEvent.class);
}
项目:camel-cdi    文件:MultiContextEventNotifierTest.java   
private void onSecondContextStartingEvent(@Observes @ContextName("second") CamelContextStartingEvent event, @ContextName("second") List<Class> events) {
    events.add(CamelContextStartingEvent.class);
}
项目:camel-cdi    文件:CamelEventNotifierTest.java   
private void onCamelContextStartingEvent(@Observes CamelContextStartingEvent event, List<Class> events) {
    events.add(CamelContextStartingEvent.class);
}