Java 类org.apache.camel.cdi.ContextName 实例源码

项目: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-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    文件:MultiContextEventEndpointTest.java   
@Test
@InSequence(2)
public void sendEventsToConsumers() throws InterruptedException {
    firstConsumeString.expectedMessageCount(1);
    firstConsumeString.expectedBodiesReceived("testFirst");

    secondConsumeString.expectedMessageCount(2);
    secondConsumeString.expectedBodiesReceived("testSecond1", "testSecond2");

    objectEvent.select(String.class, ContextName.Literal.of("first")).fire("testFirst");
    objectEvent.select(String.class, ContextName.Literal.of("second")).fire("testSecond1");
    objectEvent.select(String.class, ContextName.Literal.of("second")).fire("testSecond2");

    assertIsSatisfied(2L, TimeUnit.SECONDS, firstConsumeString, secondConsumeString);
}
项目: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    文件:MultiContextEventNotifierTest.java   
@Test
@InSequence(5)
public void stopCamelContexts(List<Class> defaultEvents,
                              @ContextName("first") List<Class> firstEvents,
                              @ContextName("second") List<Class> secondEvents,
                              @Named("anyContext") List<Class> anyEvents) throws Exception {
    defaultCamelContext.stop();
    firstCamelContext.stop();
    secondCamelContext.stop();

    assertThat("Events count fired for default context are incorrect", defaultEvents, hasSize(8));
    assertThat("Events count fired for first context are incorrect", firstEvents, hasSize(8));
    assertThat("Events count fired for second context are incorrect", secondEvents, hasSize(8));
    assertThat("Events count fired for any contexts are incorrect", anyEvents, hasSize(24));
}
项目:Camel    文件:RouteBuildersWithContextNamesTest.java   
@Test
public void sendMessageToSecondInbound(@Uri("direct:inbound") @ContextName("second")
                                       ProducerTemplate inbound,
                                       @Uri("mock:outbound") @ContextName("second")
                                       MockEndpoint outbound) throws InterruptedException {
    outbound.expectedMessageCount(1);
    outbound.expectedBodiesReceived("test");
    outbound.expectedHeaderReceived("context", "second");

    inbound.sendBody("test");

    assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
}
项目:camel-cdi    文件:MultiContextEventEndpointTest.java   
@Test
@InSequence(2)
public void sendEventsToConsumers() throws InterruptedException {
    firstConsumeString.expectedMessageCount(1);
    firstConsumeString.expectedBodiesReceived("testFirst");

    secondConsumeString.expectedMessageCount(2);
    secondConsumeString.expectedBodiesReceived("testSecond1", "testSecond2");

    objectEvent.select(String.class, ContextName.Literal.of("first")).fire("testFirst");
    objectEvent.select(String.class, ContextName.Literal.of("second")).fire("testSecond1");
    objectEvent.select(String.class, ContextName.Literal.of("second")).fire("testSecond2");

    assertIsSatisfied(2L, TimeUnit.SECONDS, firstConsumeString, secondConsumeString);
}
项目: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    文件:MultiContextEventNotifierTest.java   
@Test
@InSequence(5)
public void stopCamelContexts(@Named("defaultContext") List<Class> defaultEvents,
                              @ContextName("first") List<Class> firstEvents,
                              @ContextName("second") List<Class> secondEvents,
                              @Named("anyContext") List<Class> anyEvents) throws Exception {
    defaultCamelContext.stop();
    firstCamelContext.stop();
    secondCamelContext.stop();

    assertThat("Events count fired for default context are incorrect", defaultEvents, hasSize(8));
    assertThat("Events count fired for first context are incorrect", firstEvents, hasSize(8));
    assertThat("Events count fired for second context are incorrect", secondEvents, hasSize(8));
    assertThat("Events count fired for any contexts are incorrect", anyEvents, hasSize(24));
}
项目:camel-cdi    文件:RouteBuildersWithContextNamesTest.java   
@Test
public void sendMessageToFirstInbound(@Uri("direct:inbound") @ContextName("first")
                                      ProducerTemplate inbound,
                                      @Uri("mock:outbound") @ContextName("first")
                                      MockEndpoint outbound) throws InterruptedException {
    outbound.expectedMessageCount(1);
    outbound.expectedBodiesReceived("test");
    outbound.expectedHeaderReceived("context", "first");

    inbound.sendBody("test");

    assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
}
项目:camel-cdi    文件:RouteBuildersWithContextNamesTest.java   
@Test
public void sendMessageToSecondInbound(@Uri("direct:inbound") @ContextName("second")
                                       ProducerTemplate inbound,
                                       @Uri("mock:outbound") @ContextName("second")
                                       MockEndpoint outbound) throws InterruptedException {
    outbound.expectedMessageCount(1);
    outbound.expectedBodiesReceived("test");
    outbound.expectedHeaderReceived("context", "second");

    inbound.sendBody("test");

    assertIsSatisfied(2L, TimeUnit.SECONDS, outbound);
}
项目:Camel    文件:CamelCdiTest.java   
protected CamelContext assertCamelContext(String contextName) {
    CamelContext answer = camelContexts.select(ContextName.Literal.of(contextName)).get();
    assertTrue("CamelContext '" + contextName + "' is not started", answer.getStatus().isStarted());
    return answer;
}
项目:Camel    文件:MultiCamelContextProducerTest.java   
@Produces
@ApplicationScoped
@ContextName("second")
private static CamelContext secondContext() {
    return new DefaultCamelContext();
}
项目:Camel    文件:MultiContextEventEndpointTest.java   
@Test
@InSequence(1)
public void configureCamelContexts(@ContextName("second") CamelContext secondContext) throws Exception {
    secondContext.startAllRoutes();
}
项目:Camel    文件:MultiContextEventEndpointTest.java   
void collectFirstStringEvents(@Observes @ContextName("first") String event) {
    firstStringEvents.add(event);
}
项目:Camel    文件:MultiContextEventEndpointTest.java   
void collectSecondStringEvents(@Observes @ContextName("second") String event) {
    secondStringEvents.add(event);
}
项目:Camel    文件:RouteBuildersWithSameContextNameTest.java   
@Test
public void verifyCamelContext(@ContextName("first") CamelContext first) {
    assertThat("Context name is incorrect!", first.getName(), is(equalTo("first")));
    assertThat("Number of routes is incorrect!", first.getRoutes().size(), is(equalTo(3)));
    assertThat("Context status is incorrect!", first.getStatus(), is(equalTo(ServiceStatus.Started)));
}
项目: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 onFirstContextStartedEvent(@Observes @ContextName("first") CamelContextStartedEvent event, @ContextName("first") List<Class> events) {
    events.add(CamelContextStartedEvent.class);
}
项目:Camel    文件:MultiContextEventNotifierTest.java   
private void onFirstExchangeEvent(@Observes @ContextName("first") AbstractExchangeEvent event, @ContextName("first") List<Class> events) {
    events.add(event.getClass());
}
项目:Camel    文件:MultiContextEventNotifierTest.java   
private void onSecondContextStartingEvent(@Observes @ContextName("second") CamelContextStartingEvent event, @ContextName("second") List<Class> events) {
    events.add(CamelContextStartingEvent.class);
}
项目:Camel    文件:MultiContextEventNotifierTest.java   
private void onSecondContextStartedEvent(@Observes @ContextName("second") CamelContextStartedEvent event, @ContextName("second") List<Class> events) {
    events.add(CamelContextStartedEvent.class);
}
项目:Camel    文件:MultiContextEventNotifierTest.java   
private void onSecondExchangeEvent(@Observes @ContextName("second") AbstractExchangeEvent event, @ContextName("second") List<Class> events) {
    events.add(event.getClass());
}
项目:Camel    文件:RouteBuilderWithContextNameTest.java   
@Test
public void verifyNamedCamelContext(@ContextName("first") CamelContext first) {
    assertThat("Context name is incorrect!", first.getName(), is(equalTo("first")));
    assertThat("Number of routes is incorrect!", first.getRoutes().size(), is(equalTo(1)));
    assertThat("Context status is incorrect!", first.getStatus(), is(equalTo(ServiceStatus.Started)));
}
项目:Camel    文件:RouteBuildersWithContextNamesTest.java   
@Test
public void verifyFirstCamelContext(@ContextName("first") CamelContext first) {
    assertThat("Context name is incorrect!", first.getName(), is(equalTo("first")));
    assertThat("Number of routes is incorrect!", first.getRoutes().size(), is(equalTo(1)));
    assertThat("Context status is incorrect!", first.getStatus(), is(equalTo(ServiceStatus.Started)));
}
项目:Camel    文件:RouteBuildersWithContextNamesTest.java   
@Test
public void verifySecondCamelContext(@ContextName("second") CamelContext second) {
    assertThat("Context name is incorrect!", second.getName(), is(equalTo("second")));
    assertThat("Number of routes is incorrect!", second.getRoutes().size(), is(equalTo(1)));
    assertThat("Context status is incorrect!", second.getStatus(), is(equalTo(ServiceStatus.Started)));
}
项目:camel-cdi    文件:MultiCamelContextProducerTest.java   
@Produces
@ApplicationScoped
@ContextName("second")
private static CamelContext secondContext() {
    return new DefaultCamelContext();
}
项目:camel-cdi    文件:MultiContextEventEndpointTest.java   
@Test
@InSequence(1)
public void configureCamelContexts(@ContextName("second") CamelContext secondContext) throws Exception {
    secondContext.startAllRoutes();
}
项目:camel-cdi    文件:MultiContextEventEndpointTest.java   
void collectFirstStringEvents(@Observes @ContextName("first") String event) {
    firstStringEvents.add(event);
}
项目:camel-cdi    文件:MultiContextEventEndpointTest.java   
void collectSecondStringEvents(@Observes @ContextName("second") String event) {
    secondStringEvents.add(event);
}
项目:camel-cdi    文件:RouteBuildersWithSameContextNameTest.java   
@Test
public void verifyCamelContext(@ContextName("first") CamelContext first) {
    assertThat("Context name is incorrect!", first.getName(), is(equalTo("first")));
    assertThat("Number of routes is incorrect!", first.getRoutes().size(), is(equalTo(3)));
    assertThat("Context status is incorrect!", first.getStatus(), is(equalTo(ServiceStatus.Started)));
}
项目: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 onFirstContextStartedEvent(@Observes @ContextName("first") CamelContextStartedEvent event, @ContextName("first") List<Class> events) {
    events.add(CamelContextStartedEvent.class);
}
项目:camel-cdi    文件:MultiContextEventNotifierTest.java   
private void onFirstExchangeEvent(@Observes @ContextName("first") AbstractExchangeEvent event, @ContextName("first") List<Class> events) {
    events.add(event.getClass());
}
项目:camel-cdi    文件:MultiContextEventNotifierTest.java   
private void onSecondContextStartingEvent(@Observes @ContextName("second") CamelContextStartingEvent event, @ContextName("second") List<Class> events) {
    events.add(CamelContextStartingEvent.class);
}
项目:camel-cdi    文件:MultiContextEventNotifierTest.java   
private void onSecondContextStartedEvent(@Observes @ContextName("second") CamelContextStartedEvent event, @ContextName("second") List<Class> events) {
    events.add(CamelContextStartedEvent.class);
}
项目:camel-cdi    文件:MultiContextEventNotifierTest.java   
private void onSecondExchangeEvent(@Observes @ContextName("second") AbstractExchangeEvent event, @ContextName("second") List<Class> events) {
    events.add(event.getClass());
}
项目:camel-cdi    文件:RouteBuilderWithContextNameTest.java   
@Test
public void verifyNamedCamelContext(@ContextName("first") CamelContext first) {
    assertThat("Context name is incorrect!", first.getName(), is(equalTo("first")));
    assertThat("Number of routes is incorrect!", first.getRoutes().size(), is(equalTo(1)));
    assertThat("Context status is incorrect!", first.getStatus(), is(equalTo(ServiceStatus.Started)));
}