本文整理汇总了Java中org.apache.camel.component.mock.MockEndpoint.expectedPropertyReceived方法的典型用法代码示例。如果您正苦于以下问题:Java MockEndpoint.expectedPropertyReceived方法的具体用法?Java MockEndpoint.expectedPropertyReceived怎么用?Java MockEndpoint.expectedPropertyReceived使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.component.mock.MockEndpoint
的用法示例。
在下文中一共展示了MockEndpoint.expectedPropertyReceived方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRecipientExchangeProperty
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
public void testRecipientExchangeProperty() throws Exception {
getMockEndpoint("mock:a").expectedPropertyReceived(Exchange.RECIPIENT_LIST_ENDPOINT, "direct://a");
getMockEndpoint("mock:a").expectedPropertyReceived(Exchange.TO_ENDPOINT, "mock://a");
getMockEndpoint("mock:b").expectedPropertyReceived(Exchange.RECIPIENT_LIST_ENDPOINT, "direct://b");
getMockEndpoint("mock:b").expectedPropertyReceived(Exchange.TO_ENDPOINT, "mock://b");
getMockEndpoint("mock:c").expectedPropertyReceived(Exchange.RECIPIENT_LIST_ENDPOINT, "direct://c");
getMockEndpoint("mock:c").expectedPropertyReceived(Exchange.TO_ENDPOINT, "mock://c");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello c");
// would be the last one
mock.expectedPropertyReceived(Exchange.RECIPIENT_LIST_ENDPOINT, "direct://c");
String out = template.requestBodyAndHeader("direct:start", "Hello World", "slip", "direct:a,direct:b,direct:c", String.class);
assertEquals("Hello c", out);
assertMockEndpointsSatisfied();
assertEquals(3, strategy.getUris().size());
assertEquals("direct://a", strategy.getUris().get(0));
assertEquals("direct://b", strategy.getUris().get(1));
assertEquals("direct://c", strategy.getUris().get(2));
}
示例2: testSearch
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testSearch() throws Exception {
MockEndpoint searchMock = getMockEndpoint("mock:search-result");
searchMock.expectedMessageCount(3);
searchMock.expectedPropertyReceived(Exchange.BATCH_SIZE, 3);
JobCollection jobCollection = mock(JobCollection.class);
Job jobMock = mock(Job.class);
when(service.getJobs()).thenReturn(jobCollection);
when(jobCollection.create(anyString(), any(JobArgs.class))).thenReturn(jobMock);
when(jobMock.isDone()).thenReturn(Boolean.TRUE);
InputStream stream = ConsumerTest.class.getResourceAsStream("/resultsreader_test_data.json");
when(jobMock.getResults(any(JobResultsArgs.class))).thenReturn(stream);
assertMockEndpointsSatisfied();
SplunkEvent recieved = searchMock.getReceivedExchanges().get(0).getIn().getBody(SplunkEvent.class);
assertNotNull(recieved);
Map<String, String> data = recieved.getEventData();
assertEquals("indexertpool", data.get("name"));
assertEquals(true, searchMock.getReceivedExchanges().get(2).getProperty(Exchange.BATCH_COMPLETE, Boolean.class));
stream.close();
}
示例3: testConsumeBatchDelete
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testConsumeBatchDelete() throws Exception {
for (int counter = 0; counter <= 5; counter++) {
Message message = new Message();
message.setBody("{\"body\": \"Message " + counter + "\"}");
message.setId("" + counter);
((MockQueue)endpoint.getClient().queue("testqueue")).add(message);
}
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(5);
assertMockEndpointsSatisfied();
mock.message(0).exchangeProperty(Exchange.BATCH_INDEX).isEqualTo(0);
mock.message(1).exchangeProperty(Exchange.BATCH_INDEX).isEqualTo(1);
mock.message(2).exchangeProperty(Exchange.BATCH_INDEX).isEqualTo(2);
mock.message(3).exchangeProperty(Exchange.BATCH_INDEX).isEqualTo(3);
mock.message(4).exchangeProperty(Exchange.BATCH_INDEX).isEqualTo(4);
mock.message(0).exchangeProperty(Exchange.BATCH_COMPLETE).isEqualTo(false);
mock.message(1).exchangeProperty(Exchange.BATCH_COMPLETE).isEqualTo(false);
mock.message(2).exchangeProperty(Exchange.BATCH_COMPLETE).isEqualTo(false);
mock.message(3).exchangeProperty(Exchange.BATCH_COMPLETE).isEqualTo(false);
mock.message(3).exchangeProperty(Exchange.BATCH_COMPLETE).isEqualTo(false);
mock.message(4).exchangeProperty(Exchange.BATCH_COMPLETE).isEqualTo(true);
mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 5);
}
示例4: testBindySeparatorsAround
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
@Ignore("This issue will be revisit when we have chance to rewrite bindy parser")
public void testBindySeparatorsAround() throws Exception {
CamelContext ctx = new DefaultCamelContext();
ctx.addRoutes(createRoute()); // new ReconciliationRoute()
ctx.start();
// TODO The separator in the beginning of the quoted field is still not handled.
// We may need to convert the separators in the quote into some kind of safe code
String addressLine1 = ",8506 SIX FORKS ROAD,";
MockEndpoint mock = ctx.getEndpoint("mock:result", MockEndpoint.class);
mock.expectedPropertyReceived("addressLine1", addressLine1);
String csvLine = "\"PROBLEM SOLVER\",\"" + addressLine1
+ "\",\"SUITE 104\",\"RALEIGH\",\"NC\",\"27615\",\"US\"";
ProducerTemplate template = ctx.createProducerTemplate();
template.sendBody("direct:fromCsv", csvLine.trim());
mock.assertIsSatisfied();
}
示例5: testMaxMessagesPerPoll
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testMaxMessagesPerPoll() throws Exception {
// start route
context.startRoute("foo");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("AAA", "BBB");
mock.setResultWaitTime(4000);
mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 2);
assertMockEndpointsSatisfied();
mock.reset();
mock.expectedBodiesReceived("CCC");
mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 1);
assertMockEndpointsSatisfied();
}
示例6: testMaxMessagesPerPoll
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testMaxMessagesPerPoll() throws Exception {
// start route
context.startRoute("foo");
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Bye World", "Godday World");
mock.setResultWaitTime(4000);
mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 2);
assertMockEndpointsSatisfied();
mock.reset();
mock.expectedBodiesReceived("Hello World");
mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 1);
assertMockEndpointsSatisfied();
}
示例7: testBindy
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testBindy() throws Exception {
CamelContext ctx = new DefaultCamelContext();
ctx.addRoutes(createRoute()); // new ReconciliationRoute()
ctx.start();
String addressLine1 = "8506 SIX FORKS ROAD,";
MockEndpoint mock = ctx.getEndpoint("mock:result", MockEndpoint.class);
mock.expectedPropertyReceived("addressLine1", addressLine1);
String csvLine = "\"PROBLEM SOLVER\",\"" + addressLine1
+ "\",\"SUITE 104\",\"RALEIGH\",\"NC\",\"27615\",\"US\"";
ProducerTemplate template = ctx.createProducerTemplate();
template.sendBody("direct:fromCsv", csvLine.trim());
mock.assertIsSatisfied();
// The algorithm of BindyCvsDataFormat.unquoteTokens(..) does not handle
// separator at end of a field
// addressLine1 results in the next field being appended -> '8506 SIX
// FORKS ROAD,,SUITE 104'
}
示例8: testBindyMoreSeparators
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testBindyMoreSeparators() throws Exception {
CamelContext ctx = new DefaultCamelContext();
ctx.addRoutes(createRoute());
ctx.start();
String addressLine1 = "8506 SIX FORKS ROAD, , ,,, ,";
MockEndpoint mock = ctx.getEndpoint("mock:result", MockEndpoint.class);
mock.expectedPropertyReceived("addressLine1", addressLine1);
String csvLine = "\"PROBLEM SOLVER\",\"" + addressLine1
+ "\",\"SUITE 104\",\"RALEIGH\",\"NC\",\"27615\",\"US\"";
ProducerTemplate template = ctx.createProducerTemplate();
template.sendBody("direct:fromCsv", csvLine.trim());
mock.assertIsSatisfied();
}
示例9: testOk
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
public void testOk() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("World");
mock.expectedPropertyReceived(Exchange.EVALUATE_EXPRESSION_RESULT, "Hello World");
template.sendBody("direct:start", "World");
assertMockEndpointsSatisfied();
}
示例10: testAggregateConcurrency
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
public void testAggregateConcurrency() throws Exception {
int total = 0;
ExecutorService service = Executors.newFixedThreadPool(20);
List<Callable<Object>> tasks = new ArrayList<Callable<Object>>();
for (int i = 0; i < size; i++) {
final int count = i;
total += i;
tasks.add(new Callable<Object>() {
public Object call() throws Exception {
template.sendBodyAndHeader(uri, "Hello World", "index", count);
return null;
}
});
}
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.expectedBodiesReceived(total);
mock.expectedHeaderReceived("total", total);
mock.expectedPropertyReceived(Exchange.AGGREGATED_SIZE, size);
// submit all tasks
service.invokeAll(tasks);
assertMockEndpointsSatisfied();
assertEquals(100, COUNTER.get());
// Need to shutdown the threadpool
service.shutdownNow();
}
示例11: testAggregateProcessorCompletionPredicate
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
public void testAggregateProcessorCompletionPredicate() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("A+B+END");
mock.expectedPropertyReceived(Exchange.AGGREGATED_COMPLETED_BY, "predicate");
Processor done = new SendProcessor(context.getEndpoint("mock:result"));
Expression corr = header("id");
AggregationStrategy as = new BodyInAggregatingStrategy();
Predicate complete = body().contains("END");
AggregateProcessor ap = new AggregateProcessor(context, done, corr, as, executorService, true);
ap.setCompletionPredicate(complete);
ap.setEagerCheckCompletion(false);
ap.start();
Exchange e1 = new DefaultExchange(context);
e1.getIn().setBody("A");
e1.getIn().setHeader("id", 123);
Exchange e2 = new DefaultExchange(context);
e2.getIn().setBody("B");
e2.getIn().setHeader("id", 123);
Exchange e3 = new DefaultExchange(context);
e3.getIn().setBody("END");
e3.getIn().setHeader("id", 123);
Exchange e4 = new DefaultExchange(context);
e4.getIn().setBody("D");
e4.getIn().setHeader("id", 123);
ap.process(e1);
ap.process(e2);
ap.process(e3);
ap.process(e4);
assertMockEndpointsSatisfied();
ap.stop();
}
示例12: testAggregateProcessorCompletionPredicateEager
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
public void testAggregateProcessorCompletionPredicateEager() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("A+B+END");
mock.expectedPropertyReceived(Exchange.AGGREGATED_COMPLETED_BY, "predicate");
Processor done = new SendProcessor(context.getEndpoint("mock:result"));
Expression corr = header("id");
AggregationStrategy as = new BodyInAggregatingStrategy();
Predicate complete = body().isEqualTo("END");
AggregateProcessor ap = new AggregateProcessor(context, done, corr, as, executorService, true);
ap.setCompletionPredicate(complete);
ap.setEagerCheckCompletion(true);
ap.start();
Exchange e1 = new DefaultExchange(context);
e1.getIn().setBody("A");
e1.getIn().setHeader("id", 123);
Exchange e2 = new DefaultExchange(context);
e2.getIn().setBody("B");
e2.getIn().setHeader("id", 123);
Exchange e3 = new DefaultExchange(context);
e3.getIn().setBody("END");
e3.getIn().setHeader("id", 123);
Exchange e4 = new DefaultExchange(context);
e4.getIn().setBody("D");
e4.getIn().setHeader("id", 123);
ap.process(e1);
ap.process(e2);
ap.process(e3);
ap.process(e4);
assertMockEndpointsSatisfied();
ap.stop();
}
示例13: doTestAggregateProcessorCompletionAggregatedSize
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
private void doTestAggregateProcessorCompletionAggregatedSize(boolean eager) throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("A+B+C");
mock.expectedPropertyReceived(Exchange.AGGREGATED_COMPLETED_BY, "size");
Processor done = new SendProcessor(context.getEndpoint("mock:result"));
Expression corr = header("id");
AggregationStrategy as = new BodyInAggregatingStrategy();
AggregateProcessor ap = new AggregateProcessor(context, done, corr, as, executorService, true);
ap.setCompletionSize(3);
ap.setEagerCheckCompletion(eager);
ap.start();
Exchange e1 = new DefaultExchange(context);
e1.getIn().setBody("A");
e1.getIn().setHeader("id", 123);
Exchange e2 = new DefaultExchange(context);
e2.getIn().setBody("B");
e2.getIn().setHeader("id", 123);
Exchange e3 = new DefaultExchange(context);
e3.getIn().setBody("C");
e3.getIn().setHeader("id", 123);
Exchange e4 = new DefaultExchange(context);
e4.getIn().setBody("D");
e4.getIn().setHeader("id", 123);
ap.process(e1);
ap.process(e2);
ap.process(e3);
ap.process(e4);
assertMockEndpointsSatisfied();
ap.stop();
}
示例14: testBatchConsumer
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testBatchConsumer() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
mock.message(0).property(Exchange.BATCH_INDEX).isEqualTo(0);
mock.message(0).property(Exchange.BATCH_COMPLETE).isEqualTo(false);
mock.message(1).property(Exchange.BATCH_INDEX).isEqualTo(1);
mock.message(1).property(Exchange.BATCH_COMPLETE).isEqualTo(true);
mock.expectedPropertyReceived(Exchange.BATCH_SIZE, 2);
assertMockEndpointsSatisfied();
}
示例15: testAggregateProcessorTimeoutRestart
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
public void testAggregateProcessorTimeoutRestart() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("A+B");
mock.expectedPropertyReceived(Exchange.AGGREGATED_COMPLETED_BY, "timeout");
Processor done = new SendProcessor(context.getEndpoint("mock:result"));
Expression corr = header("id");
AggregationStrategy as = new BodyInAggregatingStrategy();
AggregateProcessor ap = new AggregateProcessor(context, done, corr, as, executorService, true);
// start with a high timeout so no completes before we stop
ap.setCompletionTimeout(2000);
ap.start();
Exchange e1 = new DefaultExchange(context);
e1.getIn().setBody("A");
e1.getIn().setHeader("id", 123);
Exchange e2 = new DefaultExchange(context);
e2.getIn().setBody("B");
e2.getIn().setHeader("id", 123);
ap.process(e1);
ap.process(e2);
// shutdown before the 2 sec timeout occurs
// however we use stop instead of shutdown as shutdown will clear the in memory aggregation repository,
ap.stop();
// should be no completed
assertEquals(0, mock.getReceivedCounter());
// start aggregator again
ap.start();
// the aggregator should restore the timeout condition and trigger timeout
assertMockEndpointsSatisfied();
assertEquals(1, mock.getReceivedCounter());
ap.shutdown();
}