本文整理汇总了Java中org.apache.camel.management.event.CamelContextStartedEvent类的典型用法代码示例。如果您正苦于以下问题:Java CamelContextStartedEvent类的具体用法?Java CamelContextStartedEvent怎么用?Java CamelContextStartedEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CamelContextStartedEvent类属于org.apache.camel.management.event包,在下文中一共展示了CamelContextStartedEvent类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testSuspendResume
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
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));
}
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:EventNotifierEventsTest.java
示例2: testStopWithFailure
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
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());
}
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:EventNotifierServiceStoppingFailedEventTest.java
示例3: sendMessageToDefaultCamelContextInbound
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
@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));
}
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:MultiContextEventNotifierTest.java
示例4: sendMessageToFirstCamelContextInbound
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
@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));
}
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:MultiContextEventNotifierTest.java
示例5: sendMessageToSecondCamelContextInbound
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
@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));
}
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:MultiContextEventNotifierTest.java
示例6: sendMessageToInbound
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
@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));
}
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:CamelEventNotifierTest.java
示例7: stopCamelContext
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
@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));
}
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:CamelEventNotifierTest.java
示例8: testEventBridge
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
@Test
public void testEventBridge() throws Exception {
EventManager eventManager = new EventManager();
CountingObserver observer = new CountingObserver();
eventManager.addObserver(observer, CamelContextStartedEvent.class);
eventManager.addObserver(observer, CamelContextStoppedEvent.class);
CamelEventBridge eventBridge = new CamelEventBridge(eventManager);
DefaultCamelContext context = new DefaultCamelContext();
context.getManagementStrategy().addEventNotifier(eventBridge);
assertTrue(observer.counter == 0);
context.start();
assertTrue(observer.counter == 1);
context.stop();
assertTrue(observer.counter == 2);
}
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:18,代码来源:CamelEventBridgeTest.java
示例9: notify
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
/**
* Remove all converters to {@link StAXSource}.
*
* @param event event about finished start of {@link CamelContext}
* @throws Exception all errors
*/
@Override
public void notify(final EventObject event) throws Exception {
if (event instanceof CamelContextStartedEvent) {
CamelContext camelContext = ((CamelContextStartedEvent) event).getContext();
if (camelContext.getTypeConverterRegistry().removeTypeConverter(StAXSource.class, byte[].class)) {
Log.debug("Remove converter from '{}' to '{}'.", byte[].class.getSimpleName(),
StAXSource.class.getSimpleName());
}
if (camelContext.getTypeConverterRegistry().removeTypeConverter(StAXSource.class, File.class)) {
Log.debug("Remove converter from '{}' to '{}'.", File.class.getSimpleName(),
StAXSource.class.getSimpleName());
}
if (camelContext.getTypeConverterRegistry().removeTypeConverter(StAXSource.class, InputStream.class)) {
Log.debug("Remove converter from '{}' to '{}'.", InputStream.class.getSimpleName(),
StAXSource.class.getSimpleName());
}
if (camelContext.getTypeConverterRegistry().removeTypeConverter(StAXSource.class, String.class)) {
Log.debug("Remove converter from '{}' to '{}'.", String.class.getSimpleName(),
StAXSource.class.getSimpleName());
}
}
}
开发者ID:integram,项目名称:cleverbus,代码行数:30,代码来源:RemoveStAXConverters.java
示例10: sendMessageToDefaultCamelContextInbound
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
@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));
}
开发者ID:astefanutti,项目名称:camel-cdi,代码行数:23,代码来源:MultiContextEventNotifierTest.java
示例11: hello
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
void hello(@Observes CamelContextStartedEvent event,
// Configuration properties can be injected with @ConfigProperty
@ConfigProperty(name = "message") String message,
// Property placeholders in @Uri qualifier are also resolved
@Uri("{{destination}}") ProducerTemplate producer) {
producer.sendBody(message);
}
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:Application.java
示例12: testExchangeDone
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
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));
}
开发者ID:HydAu,项目名称:Camel,代码行数:33,代码来源:EventNotifierEventsTest.java
示例13: testExchangeFailed
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
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));
}
开发者ID:HydAu,项目名称:Camel,代码行数:33,代码来源:EventNotifierEventsTest.java
示例14: testExchangeFailed
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
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());
}
开发者ID:HydAu,项目名称:Camel,代码行数:40,代码来源:MultipleEventNotifierEventsTest.java
示例15: camelStartedEvent
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
@Test
public void camelStartedEvent(@Uri("mock:started") MockEndpoint started) {
assertThat("Event fired is incorrect!", started.getExchanges(),
contains(
hasProperty("in",
hasProperty("body", instanceOf(CamelContextStartedEvent.class)))));
}
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:CamelEventEndpointTest.java
示例16: configureCamelContexts
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
@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));
}
开发者ID:HydAu,项目名称:Camel,代码行数:34,代码来源:MultiContextEventNotifierTest.java
示例17: startedCamelContext
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
@Test
@InSequence(1)
public void startedCamelContext(List<Class> events) {
assertThat("Events fired are incorrect!", events,
contains(
CamelContextStartingEvent.class,
CamelContextStartedEvent.class));
}
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:CamelEventNotifierTest.java
示例18: notify
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
@Override
public void notify(EventObject event) throws Exception {
// Note: there is also a CamelContextStartingEvent which is send first
// and then Camel is starting. And when all that is done this event
// (CamelContextStartedEvent) is send
if (event instanceof CamelContextStartedEvent) {
log.info("Sending a message on startup...");
template.sendBody("file:target/startandstop/start.txt", "Starting");
} else if (event instanceof CamelContextStoppingEvent) {
// Note: there is also a CamelContextStoppedEvent which is send
// afterwards, when Camel has been fully stopped.
log.info("Sending a message on stopping...");
template.sendBody("file:target/startandstop/stop.txt", "Stopping");
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:StartAndStopEventNotifier.java
示例19: configureCamelContexts
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
@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));
}
开发者ID:astefanutti,项目名称:camel-cdi,代码行数:34,代码来源:MultiContextEventNotifierTest.java
示例20: startedCamelContext
import org.apache.camel.management.event.CamelContextStartedEvent; //导入依赖的package包/类
@Test
@InSequence(1)
public void startedCamelContext(List<Class> events) throws Exception {
assertThat("Events fired are incorrect!", events,
contains(
CamelContextStartingEvent.class,
CamelContextStartedEvent.class));
}
开发者ID:astefanutti,项目名称:camel-cdi,代码行数:9,代码来源:CamelEventNotifierTest.java
注:本文中的org.apache.camel.management.event.CamelContextStartedEvent类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论