當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。