當前位置: 首頁>>代碼示例>>Java>>正文


Java MockEndpoint.expectsNoDuplicates方法代碼示例

本文整理匯總了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();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:21,代碼來源:MulticastParallelStressTest.java

示例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();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:19,代碼來源:AggregateMultipleSourceTest.java

示例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);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:19,代碼來源:JmsRequestReplyTempQueueMultipleConsumersTest.java

示例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");
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:18,代碼來源:AsyncJmsInOutTest.java

示例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");
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:18,代碼來源:ConnectionResourceIT.java

示例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");
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:18,代碼來源:SyncJmsInOutTempDestIT.java

示例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");
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:18,代碼來源:AsyncJmsInOutTempDestIT.java

示例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();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:14,代碼來源:SplitWithCustomAggregationStrategyTest.java

示例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();
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:30,代碼來源:PipelineConcurrentTest.java

示例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);
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:35,代碼來源:FileConcurrentWriteAppendSameFileTest.java


注:本文中的org.apache.camel.component.mock.MockEndpoint.expectsNoDuplicates方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。