当前位置: 首页>>代码示例>>Java>>正文


Java ServiceStatus类代码示例

本文整理汇总了Java中org.apache.camel.ServiceStatus的典型用法代码示例。如果您正苦于以下问题:Java ServiceStatus类的具体用法?Java ServiceStatus怎么用?Java ServiceStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ServiceStatus类属于org.apache.camel包,在下文中一共展示了ServiceStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testErrorOkError

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
public void testErrorOkError() throws Exception {
    getMockEndpoint("mock:error").expectedBodiesReceived("Kaboom");
    getMockEndpoint("mock:start").expectedBodiesReceived("Kaboom", "World", "Kaboom");
    getMockEndpoint("mock:result").expectedBodiesReceived("Bye World");
    getMockEndpoint("mock:exception").expectedBodiesReceived("Kaboom", "Kaboom");

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

    // give time for route to stop
    Thread.sleep(1000);
    assertEquals(ServiceStatus.Stopped, context.getRouteStatus("errorRoute"));

    template.sendBody("direct:start", "Kaboom");

    assertMockEndpointsSatisfied();

    // should be 1 on the seda queue
    SedaEndpoint seda = getMandatoryEndpoint("seda:error", SedaEndpoint.class);
    SedaEndpoint seda2 = getMandatoryEndpoint("seda:error2", SedaEndpoint.class);
    int size = seda.getQueue().size();
    int size2 = seda2.getQueue().size();
    assertTrue("There should be 1 exchange on the seda or seda2 queue", size == 1 || size2 == 1);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:ContextScopedOnExceptionLoadBalancerStopRouteTest.java

示例2: testUnregisterComponent

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
public void testUnregisterComponent() throws Exception {
    // JMX tests dont work well on AIX CI servers (hangs them)
    if (isPlatform("aix")) {
        return;
    }

    MBeanServer mbeanServer = getMBeanServer();

    Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=components,*"), null);
    assertEquals(2, set.size());

    ObjectName on = set.iterator().next();
    assertTrue("Should be registered", mbeanServer.isRegistered(on));

    String state = (String) mbeanServer.getAttribute(on, "State");
    assertEquals(ServiceStatus.Started.name(), state);

    String id = (String) mbeanServer.getAttribute(on, "CamelId");
    assertEquals("camel-1", id);

    context.stop();

    assertFalse("Should no longer be registered", mbeanServer.isRegistered(on));
    set = mbeanServer.queryNames(new ObjectName("*:type=components,*"), null);
    assertEquals("Should no longer be registered", 0, set.size());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:ManagedUnregisterComponentTest.java

示例3: testCustomName

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
public void testCustomName() throws Exception {
    // JMX tests dont work well on AIX CI servers (hangs them)
    if (isPlatform("aix")) {
        return;
    }

    MBeanServer mbeanServer = getMBeanServer();

    Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=components,*"), null);
    assertEquals(3, set.size());

    ObjectName on = set.iterator().next();
    assertTrue("Should be registered", mbeanServer.isRegistered(on));

    String state = (String) mbeanServer.getAttribute(on, "State");
    assertEquals(ServiceStatus.Started.name(), state);

    String id = (String) mbeanServer.getAttribute(on, "CamelId");
    assertEquals("camel-1", id);

    context.stop();

    assertFalse("Should no longer be registered", mbeanServer.isRegistered(on));
    set = mbeanServer.queryNames(new ObjectName("*:type=components,*"), null);
    assertEquals("Should no longer be registered", 0, set.size());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:ManagedCustomComponentNameTest.java

示例4: testScheduledStopRoutePolicy

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
@Test
public void testScheduledStopRoutePolicy() throws Exception {
    context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
    context.addRoutes(new RouteBuilder() {
        public void configure() {
            CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
            policy.setRouteStopTime("*/3 * * * * ?");
            policy.setRouteStopGracePeriod(0);
            policy.setTimeUnit(TimeUnit.MILLISECONDS);
            
            from("direct:start")
                .routeId("test")
                .routePolicy(policy)
                .to("mock:unreachable");
        }
    });
    context.start();
    
    Thread.sleep(5000);
    assertTrue(context.getRouteStatus("test") == ServiceStatus.Stopped);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:CronScheduledRoutePolicyTest.java

示例5: testMultiplePoliciesOnRoute

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
@Test
public void testMultiplePoliciesOnRoute() throws Exception {
    MockEndpoint success = context.getEndpoint("mock:success", MockEndpoint.class);        
    success.expectedMinimumMessageCount(size - 10);
    
    context.getComponent("quartz2", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz2/myquartz.properties");
    context.addRoutes(new RouteBuilder() {
        public void configure() {   
            from(url)
                .routeId("test")
                .routePolicyRef("startPolicy, throttlePolicy")
                .to("log:foo?groupSize=10")
                .to("mock:success");
        }
    });
    context.start();

    assertTrue(context.getRouteStatus("test") == ServiceStatus.Started);
    for (int i = 0; i < size; i++) {
        template.sendBody(url, "Message " + i);
        Thread.sleep(3);
    }

    context.getComponent("quartz2", QuartzComponent.class).stop();
    success.assertIsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:MultiplePoliciesOnRouteTest.java

示例6: testPositive

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
@Test
@Override
public void testPositive() throws Exception {
    
    assertEquals(ServiceStatus.Started, camelContext.getStatus());
    assertEquals(ServiceStatus.Started, camelContext2.getStatus());
    
    mockA.expectedBodiesReceived("David");
    mockB.expectedBodiesReceived("Hello David");
    mockC.expectedBodiesReceived("David");
    mock.expectedBodiesReceived("Hello David");
    
    start.sendBody("David");
    start2.sendBody("David");
    
    MockEndpoint.assertIsSatisfied(camelContext);
    MockEndpoint.assertIsSatisfied(camelContext2);
    assertTrue("Original endpoint should be invoked", ((SedaEndpoint) original.getDelegate()).getExchanges().size() == 1);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:20,代码来源:CamelSpringRunnerMockEndpointsTest.java

示例7: testPositive

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
@Test
@Override
public void testPositive() throws Exception {
    assertEquals(ServiceStatus.Started, camelContext.getStatus());
    assertEquals(ServiceStatus.Started, camelContext2.getStatus());
    
    mockA.expectedBodiesReceived("David");
    mockB.expectedBodiesReceived("Hello David");
    mockC.expectedMessageCount(0);
    mockMockC.expectedBodiesReceived("Hello David");
    
    start.sendBody("David");
    start2.sendBody("David");
    
    MockEndpoint.assertIsSatisfied(camelContext);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:AbstractCamelTestNGSpringContextTestsMockEndpointsAndSkipTest.java

示例8: testPositive

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
@Test
@Override
public void testPositive() throws Exception {
    
    assertEquals(ServiceStatus.Started, camelContext.getStatus());
    assertEquals(ServiceStatus.Started, camelContext2.getStatus());
    
    mockA.expectedBodiesReceived("David");
    mockB.expectedBodiesReceived("Hello David");
    mockC.expectedBodiesReceived("Hello David");
    mockMockC.expectedBodiesReceived("Hello David");
    
    start.sendBody("David");
    start2.sendBody("David");
    
    MockEndpoint.assertIsSatisfied(camelContext);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:AbstractCamelTestNGSpringContextTestsMockEndpointsTest.java

示例9: testMultiplePoliciesOnRoute

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
@Test
public void testMultiplePoliciesOnRoute() throws Exception {
    MockEndpoint success = context.getEndpoint("mock:success", MockEndpoint.class);        
    success.expectedMinimumMessageCount(size - 10);
    
    context.getComponent("quartz", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz/myquartz.properties");
    context.addRoutes(new RouteBuilder() {
        public void configure() {   
            from(url)
                .routeId("test")
                .routePolicyRef("startPolicy, throttlePolicy")
                .to("log:foo?groupSize=10")
                .to("mock:success");
        }
    });
    context.start();

    assertTrue(context.getRouteStatus("test") == ServiceStatus.Started);
    for (int i = 0; i < size; i++) {
        template.sendBody(url, "Message " + i);
        Thread.sleep(3);
    }

    context.getComponent("quartz", QuartzComponent.class).stop();
    success.assertIsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:MultiplePoliciesOnRouteTest.java

示例10: testPositive

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
@Test
@Override
public void testPositive() throws Exception {
    assertEquals(ServiceStatus.Started, camelContext.getStatus());
    assertEquals(ServiceStatus.Started, camelContext2.getStatus());

    mockA.expectedBodiesReceived("David");
    mockB.expectedBodiesReceived("Hello David");
    mock.expectedBodiesReceived("Hello David");

    start.sendBody("David");
    start2.sendBody("David");

    MockEndpoint.assertIsSatisfied(camelContext);
    MockEndpoint.assertIsSatisfied(camelContext2);
    assertTrue("Original endpoint was invoked", ((SedaEndpoint) original.getDelegate()).getExchanges().isEmpty());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:CamelSpringRunnerMockEndpointsAndSkipTest.java

示例11: testScheduledStopRoutePolicy

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
@Test
public void testScheduledStopRoutePolicy() throws Exception {
    context.getComponent("quartz", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz/myquartz.properties");
    context.addRoutes(new RouteBuilder() {
        public void configure() {
            CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
            policy.setRouteStopTime("*/3 * * * * ?");
            policy.setRouteStopGracePeriod(0);
            policy.setTimeUnit(TimeUnit.MILLISECONDS);
            
            from("direct:start")
                .routeId("test")
                .routePolicy(policy)
                .to("mock:unreachable");
        }
    });
    context.start();
    
    Thread.sleep(5000);
    assertTrue(context.getRouteStatus("test") == ServiceStatus.Stopped);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:CronScheduledRoutePolicyTest.java

示例12: testScheduledStopRoutePolicyWithExtraPolicy

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
@Test
public void testScheduledStopRoutePolicyWithExtraPolicy() throws Exception {
    final MyRoutePolicy myPolicy = new MyRoutePolicy();

    context.getComponent("quartz", QuartzComponent.class).setPropertiesFile("org/apache/camel/routepolicy/quartz/myquartz.properties");
    context.addRoutes(new RouteBuilder() {
        public void configure() {
            CronScheduledRoutePolicy policy = new CronScheduledRoutePolicy();
            policy.setRouteStopTime("*/3 * * * * ?");
            policy.setRouteStopGracePeriod(0);
            policy.setTimeUnit(TimeUnit.MILLISECONDS);

            from("direct:start")
                .routeId("test")
                .routePolicy(policy, myPolicy)
                .to("mock:unreachable");
        }
    });
    context.start();
    
    Thread.sleep(5000);

    assertTrue(context.getRouteStatus("test") == ServiceStatus.Stopped);
    assertTrue("Should have called onStart", myPolicy.isStart());
    assertTrue("Should have called onStop", myPolicy.isStop());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:CronScheduledRoutePolicyTest.java

示例13: testSimpleTransform

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
@Test
public void testSimpleTransform() throws Exception {

    CamelContextRegistry contextRegistry = ServiceLocator.getRequiredService(CamelContextRegistry.class);
    CamelContext camelctx = contextRegistry.getCamelContext("camel-1");
    Assert.assertEquals(CamelContextRegistry.class.getClassLoader(), camelctx.getApplicationContextClassLoader());
    Assert.assertEquals(ServiceStatus.Started, camelctx.getStatus());

    ProducerTemplate producer = camelctx.createProducerTemplate();
    String result = producer.requestBody("direct:start", "Kermit", String.class);
    Assert.assertEquals("Hello Kermit", result);
}
 
开发者ID:wildfly-swarm-archive,项目名称:wildfly-swarm-camel,代码行数:13,代码来源:SystemContextTransformTest.java

示例14: testContextStarted

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
@Before
public void testContextStarted() throws Exception {
    
    assertEquals(ServiceStatus.Stopped, camelContext.getStatus());
    assertEquals(ServiceStatus.Stopped, camelContext2.getStatus());
    camelContext.start();
    camelContext2.start();

    // just sleep a little to simulate testing take a bit time
    Thread.sleep(1000);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:CamelSpringRunnerUseAdviceWithTest.java

示例15: testStopCommand

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
@Test (description = "Test result of stop command")
public void testStopCommand() throws Exception{
    String method = ConfigurationManager.HTTP_GET;
    String uri = "/mock/cmd";
    Exchange exchange = this.generateExchange(method, uri);
    LOGGER.info("About to stop, current current context: {} -> started: {}", super.getProducerTemplate().getCamelContext().getName(), getMain().isStarted());
    super.getProducerTemplate().send("direct:main", exchange);
    Thread.sleep(1000L);
    LOGGER.info("Exchange send, current context: {} -> started: {}", super.getProducerTemplate().getCamelContext().getName(), exchange.getContext().getStatus());
    Assert.assertEquals(exchange.getContext().getStatus(), ServiceStatus.Stopped);
}
 
开发者ID:Technolords,项目名称:microservice-mock,代码行数:12,代码来源:StopCommandTest.java


注:本文中的org.apache.camel.ServiceStatus类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。