@Test public void testBadLogin() throws Exception { getMockEndpoint("mock:result").expectedMessageCount(0); assertTrue(latch.await(5, TimeUnit.SECONDS)); assertMockEndpointsSatisfied(); // consumer should be stopped Thread.sleep(1000); Consumer consumer = context.getRoute("foo").getConsumer(); assertTrue("Consumer should be stopped", ((ServiceSupport)consumer).isStopped()); }
/** * This method is invoked when a Quartz job is fired. * * @param jobExecutionContext the Quartz Job context */ public void onJobExecute(final JobExecutionContext jobExecutionContext) throws JobExecutionException { boolean run = true; LoadBalancer balancer = getLoadBalancer(); if (balancer instanceof ServiceSupport) { run = ((ServiceSupport) balancer).isRunAllowed(); } if (!run) { // quartz scheduler could potential trigger during a route has been shutdown LOG.warn("Cannot execute Quartz Job with context: " + jobExecutionContext + " because processor is not started: " + balancer); return; } LOG.debug("Firing Quartz Job with context: {}", jobExecutionContext); Exchange exchange = createExchange(jobExecutionContext); try { balancer.process(exchange); if (exchange.getException() != null) { // propagate the exception back to Quartz throw new JobExecutionException(exchange.getException()); } } catch (Exception e) { // log the error LOG.error(CamelExchangeException.createExceptionMessage("Error processing exchange", exchange, e)); // and rethrow to let quartz handle it if (e instanceof JobExecutionException) { throw (JobExecutionException) e; } throw new JobExecutionException(e); } }
public void testEndpointRegistryStopRouteEndpoints() throws Exception { Endpoint seda = context.hasEndpoint("seda://foo"); assertNotNull(seda); Endpoint log = context.hasEndpoint("log://bar"); assertNotNull(log); assertTrue("Should be started", ((ServiceSupport) seda).isStarted()); assertTrue("Should be started", ((ServiceSupport) log).isStarted()); assertTrue(context.hasEndpoint("seda:foo") != null); assertTrue(context.hasEndpoint("seda:bar") != null); assertTrue(context.hasEndpoint("log://foo") != null); assertTrue(context.hasEndpoint("log://bar") != null); assertTrue(context.hasEndpoint("mock://result") != null); assertTrue(context.hasEndpoint("seda://stop") != null); assertTrue(context.hasEndpoint("mock://stop") != null); // stop and remove bar route context.stopRoute("bar"); context.removeRoute("bar"); assertTrue(context.hasEndpoint("seda://foo") != null); assertTrue(context.hasEndpoint("log://foo") != null); assertFalse(context.hasEndpoint("seda://bar") != null); assertFalse(context.hasEndpoint("log://bar") != null); assertTrue(context.hasEndpoint("mock://result") != null); assertTrue(context.hasEndpoint("seda://stop") != null); assertTrue(context.hasEndpoint("mock://stop") != null); assertTrue("Should be started", ((ServiceSupport) seda).isStarted()); assertTrue("Should be stopped", ((ServiceSupport) log).isStopped()); // stop and remove baz route context.stopRoute("baz"); context.removeRoute("baz"); assertTrue(context.hasEndpoint("seda://foo") != null); assertTrue(context.hasEndpoint("log://foo") != null); assertFalse(context.hasEndpoint("seda://bar") != null); assertFalse(context.hasEndpoint("log://bar") != null); assertTrue(context.hasEndpoint("mock://result") != null); assertFalse(context.hasEndpoint("seda://stop") != null); assertFalse(context.hasEndpoint("mock://stop") != null); // stop and remove foo route context.stopRoute("foo"); context.removeRoute("foo"); assertFalse(context.hasEndpoint("seda://foo") != null); assertFalse(context.hasEndpoint("log://foo") != null); assertFalse(context.hasEndpoint("seda://bar") != null); assertFalse(context.hasEndpoint("log://bar") != null); assertFalse(context.hasEndpoint("mock://result") != null); assertFalse(context.hasEndpoint("seda://stop") != null); assertFalse(context.hasEndpoint("mock://stop") != null); assertFalse("Should not be started", ((ServiceSupport) seda).isStarted()); assertFalse("Should not be started", ((ServiceSupport) log).isStarted()); }
public void testEndpointRegistryStopRouteEndpointsContextStop() throws Exception { Endpoint seda = context.hasEndpoint("seda://foo"); assertNotNull(seda); Endpoint log = context.hasEndpoint("log://bar"); assertNotNull(log); assertTrue("Should be started", ((ServiceSupport) seda).isStarted()); assertTrue("Should be started", ((ServiceSupport) log).isStarted()); assertTrue(context.hasEndpoint("seda://foo") != null); assertTrue(context.hasEndpoint("log://foo") != null); assertTrue(context.hasEndpoint("seda://bar") != null); assertTrue(context.hasEndpoint("log://bar") != null); assertTrue(context.hasEndpoint("mock://result") != null); assertTrue(context.hasEndpoint("seda://stop") != null); assertTrue(context.hasEndpoint("mock://stop") != null); // stop and remove bar route context.stopRoute("bar"); context.removeRoute("bar"); assertTrue("Should be started", ((ServiceSupport) seda).isStarted()); assertTrue("Should be stopped", ((ServiceSupport) log).isStopped()); assertTrue(context.hasEndpoint("seda:foo") != null); assertTrue(context.hasEndpoint("log://foo") != null); assertFalse(context.hasEndpoint("seda://bar") != null); assertFalse(context.hasEndpoint("log://bar") != null); assertTrue(context.hasEndpoint("mock://result") != null); assertTrue(context.hasEndpoint("seda://stop") != null); assertTrue(context.hasEndpoint("mock://stop") != null); // stop and remove baz route context.stopRoute("baz"); context.removeRoute("baz"); assertTrue(context.hasEndpoint("seda://foo") != null); assertTrue(context.hasEndpoint("log://foo") != null); assertFalse(context.hasEndpoint("seda://bar") != null); assertFalse(context.hasEndpoint("log://bar") != null); assertTrue(context.hasEndpoint("mock://result") != null); assertFalse(context.hasEndpoint("seda://stop") != null); assertFalse(context.hasEndpoint("mock://stop") != null); // stop camel which should stop the endpoint context.stop(); assertFalse("Should not be started", ((ServiceSupport) seda).isStarted()); assertFalse("Should not be started", ((ServiceSupport) log).isStarted()); }