Java Code Examples for org.apache.camel.component.mock.MockEndpoint#reset()
The following examples show how to use
org.apache.camel.component.mock.MockEndpoint#reset() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CDIIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Test public void checkContextsHaveCorrectEndpointsAndRoutes() throws Exception { CamelContext contextD = assertSingleCamelContext(); assertHasEndpoints(contextD, "seda://D.a", "mock://D.b"); MockEndpoint mockEndpointD = routesD.b; mockEndpointD.expectedBodiesReceived(Constants.EXPECTED_BODIES_D); routesD.sendMessages(); mockEndpointD.assertIsSatisfied(); MockEndpoint mockDb = CamelContextHelper.getMandatoryEndpoint(contextD, "mock://D.b", MockEndpoint.class); mockDb.reset(); mockDb.expectedBodiesReceived(Constants.EXPECTED_BODIES_D_A); for (Object body : Constants.EXPECTED_BODIES_D_A) { producerD.sendBody("seda:D.a", body); } mockDb.assertIsSatisfied(); }
Example 2
Source File: CdiCustomNonDefaultNamedContextTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void setUp() throws Exception { super.setUp(); camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start").to("flowable:camelProcess"); from("flowable:camelProcess:serviceTask1").setBody().exchangeProperty("var1").to("mock:service1").setProperty("var2").constant("var2").setBody() .exchangeProperties(); from("flowable:camelProcess:serviceTask2?copyVariablesToBodyAsMap=true").to("mock:service2"); from("direct:receive").to("flowable:camelProcess:receive"); } }); service1 = (MockEndpoint) camelContext.getEndpoint("mock:service1"); service1.reset(); service2 = (MockEndpoint) camelContext.getEndpoint("mock:service2"); service2.reset(); }
Example 3
Source File: CdiCustomContextTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void setUp() throws Exception { super.setUp(); camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start").to("flowable:camelProcess"); from("flowable:camelProcess:serviceTask1").setBody().exchangeProperty("var1").to("mock:service1").setProperty("var2").constant("var2").setBody() .exchangeProperties(); from("flowable:camelProcess:serviceTask2?copyVariablesToBodyAsMap=true").to("mock:service2"); from("direct:receive").to("flowable:camelProcess:receive"); } }); service1 = (MockEndpoint) camelContext.getEndpoint("mock:service1"); service1.reset(); service2 = (MockEndpoint) camelContext.getEndpoint("mock:service2"); service2.reset(); }
Example 4
Source File: SimpleSpringProcessTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void setUp() throws Exception { camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:startWithInitiatorHeader").setHeader("CamelProcessInitiatorHeader", constant("kermit")).to( "activiti:InitiatorCamelCallProcess?processInitiatorHeaderName=CamelProcessInitiatorHeader"); from("direct:start").to("activiti:camelProcess"); from("direct:receive").to("activiti:camelProcess:receive"); from("activiti:camelProcess:serviceTask2?copyVariablesToBodyAsMap=true").to("mock:service2"); from("activiti:camelProcess:serviceTask1").setBody().simple("property[var1]").to("mock:service1").setProperty("var2").constant("var2").setBody().mvel("properties"); } }); service1 = (MockEndpoint) camelContext.getEndpoint("mock:service1"); service1.reset(); service2 = (MockEndpoint) camelContext.getEndpoint("mock:service2"); service2.reset(); }
Example 5
Source File: SimpleSpringProcessTest.java From flowable-engine with Apache License 2.0 | 6 votes |
public void setUp() throws Exception { camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:startWithInitiatorHeader").setHeader("CamelProcessInitiatorHeader", constant("kermit")).to( "flowable:InitiatorCamelCallProcess?processInitiatorHeaderName=CamelProcessInitiatorHeader"); from("direct:start").to("flowable:camelProcess"); from("direct:receive").to("flowable:camelProcess:receive"); from("flowable:camelProcess:serviceTask2?copyVariablesToBodyAsMap=true").to("mock:service2"); from("flowable:camelProcess:serviceTask1").setBody().simple("property[var1]").to("mock:service1").setProperty("var2").constant("var2").setBody().mvel("properties"); } }); service1 = (MockEndpoint) camelContext.getEndpoint("mock:service1"); service1.reset(); service2 = (MockEndpoint) camelContext.getEndpoint("mock:service2"); service2.reset(); }
Example 6
Source File: CdiSimpleProcessTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void setUp() throws Exception { super.setUp(); service1 = (MockEndpoint) camelContext.getEndpoint("mock:service1"); service1.reset(); service2 = (MockEndpoint) camelContext.getEndpoint("mock:service2"); service2.reset(); camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start").to("flowable:camelProcess"); from("flowable:camelProcess:serviceTask1").setBody().exchangeProperty("var1").to("mock:service1").setProperty("var2").constant("var2").setBody().exchangeProperties(); from("direct:receive").to("flowable:camelProcess:receive"); from("flowable:camelProcess:serviceTask2?copyVariablesToBodyAsMap=true").to("mock:service2"); } }); }
Example 7
Source File: CustomContextTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void setUp() throws Exception { camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start").to("activiti:camelProcess"); from("activiti:camelProcess:serviceTask1").setBody().property("var1").to("mock:service1").setProperty("var2").constant("var2").setBody().properties(); from("activiti:camelProcess:serviceTask2?copyVariablesToBodyAsMap=true").to("mock:service2"); from("direct:receive").to("activiti:camelProcess:receive"); } }); service1 = (MockEndpoint) camelContext.getEndpoint("mock:service1"); service1.reset(); service2 = (MockEndpoint) camelContext.getEndpoint("mock:service2"); service2.reset(); }
Example 8
Source File: SimpleSpringProcessTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void setUp() throws Exception { camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:startWithInitiatorHeader").setHeader("CamelProcessInitiatorHeader", constant("kermit")).to( "activiti:InitiatorCamelCallProcess?processInitiatorHeaderName=CamelProcessInitiatorHeader"); from("direct:start").to("activiti:camelProcess"); from("direct:receive").to("activiti:camelProcess:receive"); from("activiti:camelProcess:serviceTask2?copyVariablesToBodyAsMap=true").to("mock:service2"); from("activiti:camelProcess:serviceTask1").setBody().simple("property[var1]").to("mock:service1").setProperty("var2").constant("var2").setBody().mvel("properties"); } }); service1 = (MockEndpoint) camelContext.getEndpoint("mock:service1"); service1.reset(); service2 = (MockEndpoint) camelContext.getEndpoint("mock:service2"); service2.reset(); }
Example 9
Source File: CustomContextTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@BeforeEach public void setUp() throws Exception { camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start").to("flowable:camelProcess"); from("flowable:camelProcess:serviceTask1").setBody().exchangeProperty("var1").to("mock:service1").setProperty("var2").constant("var2").setBody().exchangeProperties(); from("flowable:camelProcess:serviceTask2?copyVariablesToBodyAsMap=true").to("mock:service2"); from("direct:receive").to("flowable:camelProcess:receive"); } }); service1 = (MockEndpoint) camelContext.getEndpoint("mock:service1"); service1.reset(); service2 = (MockEndpoint) camelContext.getEndpoint("mock:service2"); service2.reset(); }
Example 10
Source File: SimpleProcessTest.java From flowable-engine with Apache License 2.0 | 6 votes |
@BeforeEach public void setUp() throws Exception { service1 = (MockEndpoint) camelContext.getEndpoint("mock:service1"); service1.reset(); service2 = (MockEndpoint) camelContext.getEndpoint("mock:service2"); service2.reset(); camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start").to("flowable:camelProcess"); from("flowable:camelProcess:serviceTask1").setBody().exchangeProperty("var1").to("mock:service1").setProperty("var2").constant("var2").setBody().exchangeProperties(); from("direct:receive").to("flowable:camelProcess:receive"); from("flowable:camelProcess:serviceTask2?copyVariablesToBodyAsMap=true").to("mock:service2"); } }); }
Example 11
Source File: DigitalOceanIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void testCreateDroplet() throws Exception { CamelContext camelctx = createCamelContext(oauthToken); camelctx.addRoutes(createRouteBuilder()); camelctx.start(); try { MockEndpoint mockResult = camelctx.getEndpoint("mock:result", MockEndpoint.class); mockResult.expectedMinimumMessageCount(1); ProducerTemplate producer = camelctx.createProducerTemplate(); Droplet droplet = producer.requestBody("direct:createDroplet", null, Droplet.class); mockResult.assertIsSatisfied(); Assert.assertNotNull(droplet.getId()); Assert.assertEquals(droplet.getRegion().getSlug(), "fra1"); Assert.assertEquals(2, droplet.getTags().size()); mockResult.reset(); mockResult.expectedMinimumMessageCount(1); Droplet resDroplet = producer.requestBodyAndHeader("direct:getDroplet", null, DigitalOceanHeaders.ID, droplet.getId(), Droplet.class); mockResult.assertIsSatisfied(); Assert.assertEquals(droplet.getId(), resDroplet.getId()); Delete delres = producer.requestBodyAndHeader("direct:deleteDroplet", null, DigitalOceanHeaders.ID, droplet.getId(), Delete.class); Assert.assertTrue("Droplet deleted", delres.getIsRequestSuccess()); } finally { camelctx.close(); } }
Example 12
Source File: CamelVariableBodyMapTest.java From flowable-engine with Apache License 2.0 | 5 votes |
public void setUp() throws Exception { camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("flowable:HelloCamel:serviceTask1").log(LoggingLevel.INFO, "Received message on service task").to("mock:serviceBehavior"); } }); service1 = (MockEndpoint) camelContext.getEndpoint("mock:serviceBehavior"); service1.reset(); }
Example 13
Source File: CdiCamelVariableBodyTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void setUp() throws Exception { super.setUp(); camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("flowable:HelloCamel:serviceTask1").log(LoggingLevel.INFO, "Received message on service task").to("mock:serviceBehavior"); } }); service1 = (MockEndpoint) camelContext.getEndpoint("mock:serviceBehavior"); service1.reset(); }
Example 14
Source File: CamelVariableBodyTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@BeforeEach public void setUp() throws Exception { camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("flowable:HelloCamel:serviceTask1").log(LoggingLevel.INFO, "Received message on service task").to("mock:serviceBehavior"); } }); service1 = (MockEndpoint) camelContext.getEndpoint("mock:serviceBehavior"); service1.reset(); }
Example 15
Source File: CamelVariableBodyMapTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void setUp() throws Exception { camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("activiti:HelloCamel:serviceTask1").log(LoggingLevel.INFO, "Received message on service task").to("mock:serviceBehavior"); } }); service1 = (MockEndpoint) camelContext.getEndpoint("mock:serviceBehavior"); service1.reset(); }
Example 16
Source File: QuartzPersistentStoreTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void restartRouteTest() throws Exception { CamelContext camelctx = contextRegistry.getCamelContext("quartz-context"); Assert.assertNotNull(camelctx); MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:result", MockEndpoint.class); mockEndpoint.expectedMinimumMessageCount(2); mockEndpoint.assertIsSatisfied(); // restart route camelctx.getRouteController().stopRoute("myRoute"); mockEndpoint.reset(); mockEndpoint.expectedMessageCount(0); // wait a bit Thread.sleep(2000); mockEndpoint.assertIsSatisfied(); // start route, and we got messages again mockEndpoint.reset(); mockEndpoint.expectedMinimumMessageCount(2); camelctx.getRouteController().startRoute("myRoute"); mockEndpoint.assertIsSatisfied(); }
Example 17
Source File: KarafIT.java From fcrepo-camel-toolbox with Apache License 2.0 | 5 votes |
@Test public void testQueuingService() throws Exception { final String webPort = System.getProperty("fcrepo.port"); final String baseUrl = "http://localhost:" + webPort + "/fcrepo/rest"; final CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.name=FcrepoQueuingService)", 10000); assertNotNull(ctx); final MockEndpoint resultEndpoint = (MockEndpoint) ctx.getEndpoint("mock:result"); resultEndpoint.reset(); final String url1 = post(baseUrl); final String url2 = post(baseUrl); final List<String> expected = new ArrayList<>(); expected.add(baseUrl); expected.add(baseUrl); expected.add(url1); expected.add(url2); expected.add(url1 + "/fcr:versions"); expected.add(url2 + "/fcr:versions"); resultEndpoint.expectedHeaderValuesReceivedInAnyOrder(FCREPO_URI, expected); resultEndpoint.await(500, TimeUnit.MILLISECONDS); assertIsSatisfied(resultEndpoint); }
Example 18
Source File: QuteSetTemplateViaHeaderTest.java From camel-quarkus with Apache License 2.0 | 4 votes |
@Test public void testLetter() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); mock.message(0).body(String.class).contains("Thanks for the order of Camel in Action"); template.send("direct:a", createLetter("org/apache/camel/component/qute/letter.txt")); mock.assertIsSatisfied(); mock.reset(); mock.expectedMessageCount(1); mock.message(0).body(String.class).contains("Regards Apache Camel Riders Bookstore"); template.send("direct:a", createLetter("org/apache/camel/component/qute/letter2.txt")); mock.assertIsSatisfied(); }
Example 19
Source File: ShiroIntegrationTest.java From wildfly-camel with Apache License 2.0 | 4 votes |
@Test public void testShiroAuthentication() throws Exception { ShiroSecurityPolicy securityPolicy = new ShiroSecurityPolicy("classpath:securityconfig.ini", passPhrase); ShiroSecurityToken goodToken = new ShiroSecurityToken("ringo", "starr"); MySecurityTokenInjector goodInjector = new MySecurityTokenInjector(goodToken, passPhrase); ShiroSecurityToken badToken = new ShiroSecurityToken("ringo", "stirr"); MySecurityTokenInjector badInjector = new MySecurityTokenInjector(badToken, passPhrase); CamelContext camelctx = new DefaultCamelContext(); camelctx.addRoutes(new RouteBuilder() { @Override @SuppressWarnings("unchecked") public void configure() throws Exception { onException(IncorrectCredentialsException.class, AuthenticationException.class). to("mock:authenticationException"); from("direct:secureEndpoint"). policy(securityPolicy). to("log:incoming payload"). to("mock:success"); } }); MockEndpoint successEndpoint = camelctx.getEndpoint("mock:success", MockEndpoint.class); MockEndpoint failureEndpoint = camelctx.getEndpoint("mock:authenticationException", MockEndpoint.class); camelctx.start(); try { ProducerTemplate template = camelctx.createProducerTemplate(); successEndpoint.expectedMessageCount(1); failureEndpoint.expectedMessageCount(0); template.send("direct:secureEndpoint", goodInjector); successEndpoint.assertIsSatisfied(); failureEndpoint.assertIsSatisfied(); successEndpoint.reset(); failureEndpoint.reset(); successEndpoint.expectedMessageCount(0); failureEndpoint.expectedMessageCount(1); template.send("direct:secureEndpoint", badInjector); successEndpoint.assertIsSatisfied(); failureEndpoint.assertIsSatisfied(); } finally { camelctx.close(); } }
Example 20
Source File: QuteDynamicTemplateTest.java From camel-quarkus with Apache License 2.0 | 4 votes |
@Test public void testLetter() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMessageCount(1); mock.message(0).body(String.class).contains("Thanks for the order of Camel in Action"); template.send("direct:a", createLetter()); mock.assertIsSatisfied(); mock.reset(); mock.expectedMessageCount(1); mock.message(0).body(String.class).contains("Regards Apache Camel Riders Bookstore"); template.send("direct:a", createLetter()); mock.assertIsSatisfied(); }