Java Code Examples for org.apache.camel.component.mock.MockEndpoint#expectedMinimumMessageCount()
The following examples show how to use
org.apache.camel.component.mock.MockEndpoint#expectedMinimumMessageCount() .
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: DigitalOceanIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("unchecked") public void testGetTags() 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(); List<Tag> tags = producer.requestBody("direct:getTags", null, List.class); Assert.assertEquals("tag1", tags.get(0).getName()); mockResult.assertIsSatisfied(); } finally { camelctx.close(); } }
Example 2
Source File: CaffeineLoadCacheIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Test public void testCacheClear() throws Exception { camelctx.addRoutes(createRouteBuilder()); camelctx.start(); try { MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class); mock.expectedMinimumMessageCount(1); mock.expectedBodiesReceived((Object)null); mock.expectedHeaderReceived(CaffeineConstants.ACTION_HAS_RESULT, false); mock.expectedHeaderReceived(CaffeineConstants.ACTION_SUCCEEDED, true); camelctx.createFluentProducerTemplate().to("direct://start") .withHeader(CaffeineConstants.ACTION, CaffeineConstants.ACTION_CLEANUP) .send(); mock.assertIsSatisfied(); } finally { camelctx.close(); } }
Example 3
Source File: DigitalOceanIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("unchecked") public void getRegions() 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(); List<Region> regions = producer.requestBody("direct:getRegions", null, List.class); Assert.assertNotEquals(1, regions.size()); mockResult.assertIsSatisfied(); } finally { camelctx.close(); } }
Example 4
Source File: PubNubIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Test public void testPubNubSubscriber() throws Exception { CamelContext camelctx = new DefaultCamelContext(new JndiBeanRepository()); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("pubnub:subscriberChannel?pubnub=#pubnub").id("subscriber").autoStartup(false) .to("mock:resultB"); } }); MockEndpoint mockEndpoint = camelctx.getEndpoint("mock:resultB", MockEndpoint.class); mockEndpoint.expectedHeaderReceived(CHANNEL, "subscriberChannel"); mockEndpoint.expectedMinimumMessageCount(1); camelctx.start(); try { camelctx.getRouteController().startRoute("subscriber"); mockEndpoint.assertIsSatisfied(3000); } finally { camelctx.close(); } }
Example 5
Source File: WordpressIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Test public void testUserListRequest() throws Exception { CamelContext camelctx = new DefaultCamelContext(); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { configureComponent(getContext()); from("wordpress:user?criteria.perPage=10&criteria.orderBy=name&criteria.roles=admin,editor") .to("mock:resultList"); } }); camelctx.start(); try { MockEndpoint mock = camelctx.getEndpoint("mock:resultList", MockEndpoint.class); mock.expectedMinimumMessageCount(1); mock.allMessages().body().isInstanceOf(User.class); mock.assertIsSatisfied(); } finally { camelctx.close(); } }
Example 6
Source File: WordpressIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Test public void testPostSingleRequest() throws Exception { CamelContext camelctx = new DefaultCamelContext(); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { configureComponent(getContext()); from("wordpress:post?id=114913").to("mock:resultSingle"); } }); camelctx.start(); try { MockEndpoint mock = camelctx.getEndpoint("mock:resultSingle", MockEndpoint.class); mock.expectedMinimumMessageCount(1); mock.allMessages().body().isInstanceOf(Post.class); mock.assertIsSatisfied(); } finally { camelctx.close(); } }
Example 7
Source File: DigitalOceanIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Test public void testCreateTag() 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(); Tag tag = producer.requestBody("direct:createTag", null, Tag.class); Assert.assertEquals("tag1", tag.getName()); mockResult.assertIsSatisfied(); } finally { camelctx.close(); } }
Example 8
Source File: DigitalOceanIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("unchecked") public void getImages() 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(); List<Image> images = producer.requestBody("direct:getImages", null, List.class); mockResult.assertIsSatisfied(); Assert.assertNotEquals(1, images.size()); } finally { camelctx.close(); } }
Example 9
Source File: KarafIT.java From fcrepo-camel-toolbox with Apache License 2.0 | 6 votes |
@Test public void testService() throws Exception { final String baseUrl = "http://localhost:" + System.getProperty("fcrepo.port") + "/fcrepo/rest"; final CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.name=FcrepoService)", 10000); assertNotNull(ctx); final MockEndpoint resultEndpoint = (MockEndpoint) ctx.getEndpoint("mock:result"); final String url1 = post(baseUrl).replace(baseUrl, ""); final String url2 = post(baseUrl).replace(baseUrl, ""); final ProducerTemplate template = ctx.createProducerTemplate(); final Map<String, Object> headers = new HashMap<>(); headers.put(FCREPO_BASE_URL, baseUrl); headers.put(FCREPO_IDENTIFIER, url1); template.sendBodyAndHeaders(ctx.getEndpoint("direct:start"), null, headers); template.sendBodyAndHeader(ctx.getEndpoint("direct:start"), null, FCREPO_URI, baseUrl + url2); resultEndpoint.expectedMinimumMessageCount(2); assertIsSatisfied(resultEndpoint); }
Example 10
Source File: MyComponentTest.java From camelinaction with Apache License 2.0 | 5 votes |
@Test public void testTimerInvokesBeanMethod() throws Exception { MockEndpoint mock = getMockEndpoint("mock:result"); mock.expectedMinimumMessageCount(1); assertMockEndpointsSatisfied(); }
Example 11
Source File: CaffeineLoadCacheIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void testCacheInvalidateAll() throws Exception { final Map<Integer, Integer> map = new HashMap<>(); map.put(1, 1); map.put(2, 2); map.put(3, 3); final Set<Integer> keys = map.keySet().stream().limit(2).collect(Collectors.toSet()); cache.putAll(map); camelctx.addRoutes(createRouteBuilder()); camelctx.start(); try { MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class); mock.expectedMinimumMessageCount(1); mock.expectedHeaderReceived(CaffeineConstants.ACTION_HAS_RESULT, false); mock.expectedHeaderReceived(CaffeineConstants.ACTION_SUCCEEDED, true); camelctx.createFluentProducerTemplate().to("direct://start") .withHeader(CaffeineConstants.ACTION, CaffeineConstants.ACTION_INVALIDATE_ALL) .withHeader(CaffeineConstants.KEYS, keys) .send(); mock.assertIsSatisfied(); final Map<Integer, Integer> elements = cache.getAllPresent(keys); keys.forEach(k -> { Assert.assertFalse(elements.containsKey(k)); }); } finally { camelctx.close(); } }
Example 12
Source File: SplunkIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void testSalesforceQuery() throws Exception { String SPLUNK_USERNAME = System.getenv("SPLUNK_USERNAME"); String SPLUNK_PASSWORD = System.getenv("SPLUNK_PASSWORD"); Assume.assumeNotNull("[#1673] Enable Splunk testing in Jenkins", SPLUNK_USERNAME, SPLUNK_PASSWORD); SplunkEvent splunkEvent = new SplunkEvent(); splunkEvent.addPair("key1", "value1"); splunkEvent.addPair("key2", "value2"); splunkEvent.addPair("key3", "value1"); CamelContext camelctx = new DefaultCamelContext(); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:submit") .to("splunk://submit?username=" + SPLUNK_USERNAME + "&password=" + SPLUNK_PASSWORD + "&sourceType=testSource&source=test") .to("mock:result"); } }); MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class); mock.expectedMinimumMessageCount(1); camelctx.start(); try { ProducerTemplate producer = camelctx.createProducerTemplate(); producer.sendBody("direct:submit", splunkEvent); mock.assertIsSatisfied(); } finally { camelctx.close(); } }
Example 13
Source File: CaffeineLoadCacheIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void testCacheInvalidate() throws Exception { final Integer key = 1; final Integer val = 1; cache.put(key, val); camelctx.addRoutes(createRouteBuilder()); camelctx.start(); try { MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class); mock.expectedMinimumMessageCount(1); mock.expectedHeaderReceived(CaffeineConstants.ACTION_HAS_RESULT, false); mock.expectedHeaderReceived(CaffeineConstants.ACTION_SUCCEEDED, true); camelctx.createFluentProducerTemplate().to("direct://start") .withHeader(CaffeineConstants.ACTION, CaffeineConstants.ACTION_INVALIDATE) .withHeader(CaffeineConstants.KEY, key) .send(); mock.assertIsSatisfied(); Assert.assertFalse(cache.getIfPresent(key) != null); } finally { camelctx.close(); } }
Example 14
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 15
Source File: CaffeineCacheIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void testCacheInvalidate() throws Exception { final String key = generateRandomString(); final String val = generateRandomString(); cache.put(key, val); camelctx.addRoutes(createRouteBuilder()); camelctx.start(); try { MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class); mock.expectedMinimumMessageCount(1); mock.expectedHeaderReceived(CaffeineConstants.ACTION_HAS_RESULT, false); mock.expectedHeaderReceived(CaffeineConstants.ACTION_SUCCEEDED, true); camelctx.createFluentProducerTemplate().to("direct://start") .withHeader(CaffeineConstants.ACTION, CaffeineConstants.ACTION_INVALIDATE) .withHeader(CaffeineConstants.KEY, key) .send(); mock.assertIsSatisfied(); Assert.assertFalse(cache.getIfPresent(key) != null); } finally { camelctx.close(); } }
Example 16
Source File: FlipRoutePolicyJavaDSLTest.java From camelinaction with Apache License 2.0 | 5 votes |
@Test public void testFlipRoutePolicyTest() throws Exception { MockEndpoint foo = getMockEndpoint("mock:foo"); foo.expectedMinimumMessageCount(5); MockEndpoint bar = getMockEndpoint("mock:bar"); bar.expectedMinimumMessageCount(5); assertMockEndpointsSatisfied(); }
Example 17
Source File: ZookeeperMasterIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void testEndpoint() throws Exception { CamelContext camelctx = contextRegistry.getCamelContext("master-quartz2"); Assert.assertEquals(ServiceStatus.Started, camelctx.getStatus()); MockEndpoint mockResult = camelctx.getEndpoint("mock:results", MockEndpoint.class); mockResult.expectedMinimumMessageCount(2); MockEndpoint.assertIsSatisfied(10, TimeUnit.SECONDS, mockResult); }
Example 18
Source File: CaffeineCacheIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void testCacheInvalidateAll() throws Exception { final Map<String, String> map = generateRandomMapOfString(3); final Set<String> keys = map.keySet().stream().limit(2).collect(Collectors.toSet()); cache.putAll(map); camelctx.addRoutes(createRouteBuilder()); camelctx.start(); try { MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class); mock.expectedMinimumMessageCount(1); mock.expectedHeaderReceived(CaffeineConstants.ACTION_HAS_RESULT, false); mock.expectedHeaderReceived(CaffeineConstants.ACTION_SUCCEEDED, true); camelctx.createFluentProducerTemplate().to("direct://start") .withHeader(CaffeineConstants.ACTION, CaffeineConstants.ACTION_INVALIDATE_ALL) .withHeader(CaffeineConstants.KEYS, keys) .send(); mock.assertIsSatisfied(); final Map<Object, Object> elements = cache.getAllPresent(keys); keys.forEach(k -> { Assert.assertFalse(elements.containsKey(k)); }); } finally { camelctx.close(); } }
Example 19
Source File: CaffeineLoadCacheIntegrationTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void testCachePut() throws Exception { final Integer key = 1; final Integer val = 3; camelctx.addRoutes(createRouteBuilder()); camelctx.start(); try { MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class); mock.expectedMinimumMessageCount(1); mock.expectedBodiesReceived(val); mock.expectedHeaderReceived(CaffeineConstants.ACTION_HAS_RESULT, false); mock.expectedHeaderReceived(CaffeineConstants.ACTION_SUCCEEDED, true); camelctx.createFluentProducerTemplate().to("direct://start") .withHeader(CaffeineConstants.ACTION, CaffeineConstants.ACTION_PUT) .withHeader(CaffeineConstants.KEY, key) .withBody(val) .send(); Assert.assertTrue(cache.getIfPresent(key) != null); Assert.assertEquals(val, cache.getIfPresent(key)); } finally { camelctx.close(); } }
Example 20
Source File: SWFIntegrationTest.java From wildfly-camel with Apache License 2.0 | 4 votes |
@Test public void deciderAndWorker() throws Exception { AmazonSimpleWorkflowClient swfClient = provider.getClient(); Assume.assumeNotNull("AWS client not null", swfClient); WildFlyCamelContext camelctx = new WildFlyCamelContext(); camelctx.getNamingContext().bind("swfClient", swfClient); camelctx.addRoutes(new RouteBuilder() { public void configure() { String options = "amazonSWClient=#swfClient&domainName=" + SWFUtils.DOMAIN + "&activityList=swf-alist&workflowList=swf-wlist&version=1.0"; from("aws-swf://activity?" + options + "&eventName=processActivities") .log("FOUND ACTIVITY TASK ${body}") .setBody(constant("1")) .to("mock:worker"); from("aws-swf://workflow?" + options + "&eventName=processWorkflows") .log("FOUND WORKFLOW TASK ${body}").filter(header(SWFConstants.ACTION).isEqualTo(SWFConstants.EXECUTE_ACTION)) .to("aws-swf://activity?" + options + "&eventName=processActivities") .setBody(constant("Message two")) .to("aws-swf://activity?" + options + "&eventName=processActivities") .log("SENT ACTIVITY TASK ${body}") .to("mock:decider"); from("direct:start") .to("aws-swf://workflow?" + options + "&eventName=processWorkflows") .log("SENT WORKFLOW TASK ${body}") .to("mock:starter"); } }); MockEndpoint decider = camelctx.getEndpoint("mock:decider", MockEndpoint.class); MockEndpoint worker = camelctx.getEndpoint("mock:worker", MockEndpoint.class); MockEndpoint starter = camelctx.getEndpoint("mock:starter", MockEndpoint.class); camelctx.start(); try { ProducerTemplate producer = camelctx.createProducerTemplate(); producer.sendBody("direct:start", "Hello world!"); starter.expectedMessageCount(1); decider.expectedMinimumMessageCount(1); worker.expectedMessageCount(2); String workflowId = starter.getReceivedExchanges().get(0).getIn().getHeader(SWFConstants.WORKFLOW_ID, String.class); Assert.assertNotNull(SWFConstants.WORKFLOW_ID + " not null", workflowId); SWFUtils.terminateWorkflowExecution(swfClient, workflowId); } finally { camelctx.close(); } }