本文整理匯總了Java中org.apache.camel.component.mock.MockEndpoint.expectsNoDuplicates方法的典型用法代碼示例。如果您正苦於以下問題:Java MockEndpoint.expectsNoDuplicates方法的具體用法?Java MockEndpoint.expectsNoDuplicates怎麽用?Java MockEndpoint.expectsNoDuplicates使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.camel.component.mock.MockEndpoint
的用法示例。
在下文中一共展示了MockEndpoint.expectsNoDuplicates方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testConcurrencyParallelMulticast
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testConcurrencyParallelMulticast() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(20);
// this time we cannot expect in order but there should be no duplicates
mock.expectsNoDuplicates(header("id"));
ExecutorService executor = Executors.newFixedThreadPool(10);
for (int i = 0; i < 20; i++) {
final int index = i;
executor.submit(new Callable<Object>() {
public Object call() throws Exception {
template.sendBodyAndHeader("direct:start", "", "id", index);
return null;
}
});
}
assertMockEndpointsSatisfied();
executor.shutdownNow();
}
示例2: testAggregateMultipleSourceTest
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testAggregateMultipleSourceTest() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
mock.expectsNoDuplicates(body());
mock.setResultWaitTime(20000);
for (int i = 0; i < 40; i++) {
if (i % 2 == 0) {
template.sendBodyAndHeader("seda:foo", "" + i, "type", "A");
} else if (i % 5 == 0) {
template.sendBodyAndHeader("seda:bar", "" + i, "type", "A");
} else {
template.sendBodyAndHeader("seda:baz", "" + i, "type", "A");
}
}
assertMockEndpointsSatisfied();
}
示例3: doSendMessages
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
private void doSendMessages(int files) throws Exception {
resetMocks();
MockEndpoint mockEndpoint = getMockEndpoint("mock:result");
mockEndpoint.expectedMessageCount(files);
mockEndpoint.expectsNoDuplicates(body());
for (int i = 0; i < files; i++) {
final int index = i;
executorService.submit(new Callable<Object>() {
public Object call() throws Exception {
template.sendBody("direct:start", "Message " + index);
return null;
}
});
}
assertMockEndpointsSatisfied(20, TimeUnit.SECONDS);
}
示例4: testAsyncJmsInOut
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testAsyncJmsInOut() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(100);
mock.expectsNoDuplicates(body());
StopWatch watch = new StopWatch();
for (int i = 0; i < 100; i++) {
template.sendBody("seda:start", "" + i);
}
// just in case we run on slow boxes
assertMockEndpointsSatisfied(20, TimeUnit.SECONDS);
log.info("Took " + watch.stop() + " ms. to process 100 messages request/reply over JMS");
}
示例5: testConnectionResourceRouter
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testConnectionResourceRouter() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(100);
mock.expectsNoDuplicates(body());
StopWatch watch = new StopWatch();
for (int i = 0; i < 100; i++) {
template.sendBody("seda:start", "" + i);
}
// just in case we run on slow boxes
assertMockEndpointsSatisfied(20, TimeUnit.SECONDS);
log.info("Took " + watch.stop() + " ms. to process 100 messages request/reply over JMS");
}
示例6: testSynchronous
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testSynchronous() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(100);
mock.expectsNoDuplicates(body());
StopWatch watch = new StopWatch();
for (int i = 0; i < 100; i++) {
template.sendBody("seda:start", "" + i);
}
// just in case we run on slow boxes
assertMockEndpointsSatisfied(20, TimeUnit.SECONDS);
log.info("Took " + watch.stop() + " ms. to process 100 messages request/reply over JMS");
}
示例7: testAsynchronous
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testAsynchronous() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(100);
mock.expectsNoDuplicates(body());
StopWatch watch = new StopWatch();
for (int i = 0; i < 100; i++) {
template.sendBody("seda:start", "" + i);
}
// just in case we run on slow boxes
assertMockEndpointsSatisfied(20, TimeUnit.SECONDS);
log.info("Took " + watch.stop() + " ms. to process 100 messages request/reply over JMS");
}
示例8: testSplitWithCustomAggregatorStrategy
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testSplitWithCustomAggregatorStrategy() throws Exception {
int files = 10;
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(files);
// no duplicates should be received
mock.expectsNoDuplicates(body());
for (int i = 0; i < files; i++) {
template.sendBody("direct:start", "");
}
assertMockEndpointsSatisfied();
}
示例9: testConcurrentPipeline
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testConcurrentPipeline() throws Exception {
int total = 200;
final int group = total / 20;
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(total);
ExecutorService executor = Executors.newFixedThreadPool(20);
for (int i = 0; i < 20; i++) {
final int threadCount = i;
executor.execute(new Runnable() {
public void run() {
int start = threadCount * group;
for (int i = 0; i < group; i++) {
try {
// do some random sleep to simulate spread in user activity
Thread.sleep(new Random().nextInt(10));
} catch (InterruptedException e) {
// ignore
}
template.sendBody(uri, "" + (start + i));
}
}
});
}
mock.assertIsSatisfied();
mock.expectsNoDuplicates(body());
executor.shutdown();
}
示例10: testConcurrentAppend
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testConcurrentAppend() throws Exception {
// create file with many lines
StringBuilder sb = new StringBuilder();
for (int i = 0; i < size; i++) {
sb.append("Line " + i + LS);
}
template.sendBodyAndHeader("file:target/concurrent", sb.toString(), Exchange.FILE_NAME, "input.txt");
// start route
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(size);
mock.expectsNoDuplicates(body());
mock.setResultWaitTime(30000);
// we need to wait a bit for our slow CI server to make sure the entire file is written on disc
Thread.sleep(1000);
context.startRoute("foo");
assertMockEndpointsSatisfied();
// check the file has correct number of lines
String txt = context.getTypeConverter().convertTo(String.class, new File("target/concurrent/outbox/result.txt"));
assertNotNull(txt);
String[] lines = txt.split(LS);
assertEquals("Should be " + size + " lines", size, lines.length);
// should be unique
Set<String> rows = new LinkedHashSet<String>(Arrays.asList(lines));
assertEquals("Should be " + size + " unique lines", size, rows.size());
log.info(txt);
}