• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ServiceStatus类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testMonitorMBeanAttribute

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
@Test
public void testMonitorMBeanAttribute() throws Exception {
    Context context = new InitialContext();
    CamelContextRegistry contextRegistry = (CamelContextRegistry) context.lookup("java:jboss/camel/CamelContextRegistry");

    CamelContext sysctx = contextRegistry.getCamelContext("camel-1");
    Assert.assertEquals(ServiceStatus.Started, sysctx.getStatus());
    final String routeName = sysctx.getRoutes().get(0).getId();

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("jmx:platform?format=raw&objectDomain=org.apache.camel&key.context=camel-1&key.type=routes&key.name=\"" + routeName + "\"" +
                    "&monitorType=counter&observedAttribute=ExchangesTotal&granularityPeriod=500").
                    to("direct:end");
        }
    });

    camelctx.start();
    try {
        ConsumerTemplate consumer = camelctx.createConsumerTemplate();
        MonitorNotification notifcation = consumer.receiveBody("direct:end", MonitorNotification.class);
        Assert.assertEquals("ExchangesTotal", notifcation.getObservedAttribute());
    } finally {
        camelctx.stop();
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:29,代码来源:JMXIntegrationTest.java


示例17: startTest

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
public void startTest() throws Exception {
    CamelContext context = startRouteWithPolicy("startPolicy");
    
    MockEndpoint mock = context.getEndpoint("mock:success", MockEndpoint.class);
    mock.expectedMinimumMessageCount(1);
    
    context.stopRoute("testRoute", 1000, TimeUnit.MILLISECONDS);
    
    Thread.sleep(4000);
    assertTrue(context.getRouteStatus("testRoute") == ServiceStatus.Started);
    context.createProducerTemplate().sendBody("direct:start", "Ready or not, Here, I come");

    context.stop();
    mock.assertIsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:SpringScheduledRoutePolicyTest.java


示例18: testSimpleTransform

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

    CamelContextRegistry contextRegistry = ServiceLocator.getRequiredService(CamelContextRegistry.class);
    CamelContext camelctx = contextRegistry.getCamelContext("myname");
    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,项目名称:wildfly-swarm,代码行数:12,代码来源:SystemContextTransformTest.java


示例19: getEndpointState

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
private static String getEndpointState(Endpoint endpoint) {
    // must use String type to be sure remote JMX can read the attribute without requiring Camel classes.
    if (endpoint instanceof StatefulService) {
        ServiceStatus status = ((StatefulService) endpoint).getStatus();
        return status.name();
    }

    // assume started if not a ServiceSupport instance
    return ServiceStatus.Started.name();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:AbstractLocalCamelController.java


示例20: getRouteState

import org.apache.camel.ServiceStatus; //导入依赖的package包/类
private static String getRouteState(Route route) {
    // must use String type to be sure remote JMX can read the attribute without requiring Camel classes.

    ServiceStatus status = route.getRouteContext().getCamelContext().getRouteStatus(route.getId());
    if (status != null) {
        return status.name();
    }

    // assume started if not a ServiceSupport instance
    return ServiceStatus.Started.name();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:AbstractLocalCamelController.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ExecutionBundle类代码示例发布时间:2022-05-22
下一篇:
Java StripesFilter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap