当前位置: 首页>>代码示例>>Java>>正文


Java MockEndpoint.expectedMinimumMessageCount方法代码示例

本文整理汇总了Java中org.apache.camel.component.mock.MockEndpoint.expectedMinimumMessageCount方法的典型用法代码示例。如果您正苦于以下问题:Java MockEndpoint.expectedMinimumMessageCount方法的具体用法?Java MockEndpoint.expectedMinimumMessageCount怎么用?Java MockEndpoint.expectedMinimumMessageCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.camel.component.mock.MockEndpoint的用法示例。


在下文中一共展示了MockEndpoint.expectedMinimumMessageCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCachePutAll

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testCachePutAll() throws Exception {
    final Cache<Object, Object> cache = getTestCache();
    final Map<String, String> map = generateRandomMapOfString(3);

    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(1);
    mock.expectedHeaderReceived(EhcacheConstants.ACTION_HAS_RESULT, false);
    mock.expectedHeaderReceived(EhcacheConstants.ACTION_SUCCEEDED, true);

    fluentTemplate()
        .withHeader(EhcacheConstants.ACTION, EhcacheConstants.ACTION_PUT_ALL)
        .withBody(map)
        .to("direct://start")
        .send();

    assertMockEndpointsSatisfied();

    map.forEach((k, v) -> {
        assertTrue(cache.containsKey(k));
        assertEquals(v, cache.get(k));
    });
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:EhcacheProducerTest.java

示例2: testOutputType

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testOutputType() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(3);

    assertMockEndpointsSatisfied();

    List<Exchange> exchanges = mock.getReceivedExchanges();
    assertTrue(exchanges.size() >= 3);

    Map<String, Object> row = assertIsInstanceOf(Map.class, exchanges.get(0).getIn().getBody());
    assertEquals(1, row.get("ID"));
    assertEquals("Camel", row.get("PROJECT"));
    assertEquals("ASF", row.get("LICENSE"));
    row = assertIsInstanceOf(Map.class, exchanges.get(1).getIn().getBody());
    assertEquals(2, row.get("ID"));
    assertEquals("AMQ", row.get("PROJECT"));
    assertEquals("ASF", row.get("LICENSE"));
    row = assertIsInstanceOf(Map.class, exchanges.get(2).getIn().getBody());
    assertEquals(3, row.get("ID"));
    assertEquals("Linux", row.get("PROJECT"));
    assertEquals("XXX", row.get("LICENSE"));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:SqlConsumerOutputTypeSelectListTest.java

示例3: testScanFile

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testScanFile() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(2);
    mock.message(0).header(StreamConstants.STREAM_INDEX).isEqualTo(0);
    mock.message(0).header(StreamConstants.STREAM_COMPLETE).isEqualTo(false);
    mock.message(1).header(StreamConstants.STREAM_INDEX).isEqualTo(1);
    // a scanStream=true is never finished
    mock.message(1).header(StreamConstants.STREAM_COMPLETE).isEqualTo(false);

    FileOutputStream fos = new FileOutputStream(file);
    try {
        fos.write("Hello\n".getBytes());
        Thread.sleep(150);
        fos.write("World\n".getBytes());
    } finally {
        fos.close();
    }
    
    assertMockEndpointsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:ScanStreamFileTest.java

示例4: testFooWine

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testFooWine() throws Exception {
	MockEndpoint mock = getMockEndpoint("mock:result");

	mock.expectedMinimumMessageCount(2);
    mock.setAssertPeriod(500);
    
    assertMockEndpointsSatisfied();
    
    List<Exchange> exchanges = mock.getReceivedExchanges();
    int drinks = 0;
    for (Exchange exchange : exchanges) {
        drinks += 2;
        Message message = exchange.getIn();
        String body = message.getBody().toString();
			
        assertEquals("Total " + drinks + " of wine ordered", body);
    }
}
 
开发者ID:fabric8io,项目名称:django-examples,代码行数:20,代码来源:FooWineTest.java

示例5: testMain

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
public void testMain() throws Exception {
    // lets make a simple route
    Main main = new Main();
    main.addRouteBuilder(new MyRouteBuilder());
    main.enableTrace();
    main.bind("foo", new Integer(31));
    main.start();

    List<CamelContext> contextList = main.getCamelContexts();
    assertNotNull(contextList);
    assertEquals("Did not get the expected count of Camel contexts", 1, contextList.size());
    CamelContext camelContext = contextList.get(0);
    assertEquals("Could not find the registry bound object", 31, camelContext.getRegistry().lookupByName("foo"));

    MockEndpoint endpoint = camelContext.getEndpoint("mock:results", MockEndpoint.class);
    endpoint.expectedMinimumMessageCount(1);

    main.getCamelTemplate().sendBody("direct:start", "<message>1</message>");

    endpoint.assertIsSatisfied();

    main.stop();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:MainTest.java

示例6: testMaxMessagesPerPoll

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
public void testMaxMessagesPerPoll() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    // we should poll at most 2
    mock.expectedMinimumMessageCount(2);
    mock.message(0).exchangeProperty(Exchange.BATCH_SIZE).isEqualTo(2);
    mock.message(1).exchangeProperty(Exchange.BATCH_SIZE).isEqualTo(2);

    template.sendBodyAndHeader(fileUrl, "Bye World", Exchange.FILE_NAME, "bye.txt");
    template.sendBodyAndHeader(fileUrl, "Hello World", Exchange.FILE_NAME, "hello.txt");
    template.sendBodyAndHeader(fileUrl, "Godday World", Exchange.FILE_NAME, "godday.txt");

    // start route
    context.startRoute("foo");

    assertMockEndpointsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:FileConsumeMaxMessagesPerPollTest.java

示例7: testCreateMessage

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testCreateMessage() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(1);
    
    String messageBodyToCreate = "Hi from Camel!";
    template.sendBody("direct:start", messageBodyToCreate);
    
    assertMockEndpointsSatisfied();
    
    Exchange exchange = mock.getExchanges().get(0);
    Messages messages = exchange.getIn().getBody(Messages.class);

    assertEquals(1, messages.getMessages().size());
    assertEquals(messageBodyToCreate, messages.getMessages().get(0).getBody().getPlain());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:YammerMessageProducerRouteTest.java

示例8: testSendLotsOfMessagesSimultaneouslyButOnly3GetThrough

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
public void testSendLotsOfMessagesSimultaneouslyButOnly3GetThrough() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(3);
    mock.setResultWaitTime(4000);

    final List<Exchange> sentExchanges = Collections.synchronizedList(new ArrayList<Exchange>());
    ExecutorService executor = Executors.newFixedThreadPool(5);
    for (int i = 0; i < 5; i++) {
        executor.execute(new Runnable() {
            public void run() {
                try {
                    sendExchangesThroughDroppingThrottler(sentExchanges, 35);
                } catch (Exception e) {
                    // ignore
                }
            }
        });
    }

    mock.assertIsSatisfied();
    executor.shutdownNow();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:SamplingThrottlerTest.java

示例9: camelConnectorTest

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void camelConnectorTest() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");

    mock.expectedMinimumMessageCount(1);
    mock.expectedBodiesReceived("{\"c\":60}");

    mock.assertIsSatisfied();
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:10,代码来源:SqlStoredStartConnectorComponentTest.java

示例10: testSimpleRouting

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testSimpleRouting() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(1);

    template.asyncSendBody("direct:plc4x", "irrelevant");

    assertMockEndpointsSatisfied(2, TimeUnit.SECONDS);
}
 
开发者ID:apache,项目名称:incubator-plc4x,代码行数:10,代码来源:PLC4XComponentTest.java

示例11: sendsComplexMessageWithSpecifiedToHeader

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void sendsComplexMessageWithSpecifiedToHeader() throws Exception {
	MockEndpoint mock = getMockEndpoint("mock:result");
	mock.expectedMinimumMessageCount(1);
	final Map<String, String> body = new HashMap<String, String>();
	body.put("facilityEquipmentnumber", "10213788");
	body.put("stationName", "Arnstadt Hbf");
	body.put("facilityDescription", "Aufzug zu Bstg 2/3");
	body.put("facilityState", "INACTIVE");
	final Map<String, Object> headers = new HashMap<String, Object>();
	headers.put(GcmConstants.TO, "/topics/foo");
	sendBody("direct:foo", body, headers);
	assertMockEndpointsSatisfied();
}
 
开发者ID:highsource,项目名称:camel-google-cloud-messaging,代码行数:15,代码来源:GcmEndpointTest.java

示例12: testAsyncStress

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
public void testAsyncStress() throws Exception {
    // do not test on windows
    if (isPlatform("windows")) {
        return;
    }

    // test by starting the unit test FileAsyncStressFileDropper in another JVM

    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(250);

    assertMockEndpointsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:FileAsyncStressManually.java

示例13: testMetrics

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testMetrics() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(1);
    template1.sendBody(new Object());
    assertMockEndpointsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:MetricsComponentRouteTest.java

示例14: testFTPConsumerAsyncStress

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testFTPConsumerAsyncStress() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    // give some time to run on slower boxes
    mock.setResultWaitTime(30000);
    mock.expectedMinimumMessageCount(50);

    assertMockEndpointsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:FtpConsumerAsyncStressTest.java

示例15: testQuartzPersistentStore

import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testQuartzPersistentStore() throws Exception {
    // skip testing on aix
    if (isPlatform("aix")) {
        return;
    }

    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMinimumMessageCount(2);

    assertMockEndpointsSatisfied();

    // restart route
    context().stopRoute("myRoute");
    mock.reset();
    mock.expectedMessageCount(0);

    // wait a bit
    Thread.sleep(2000);

    assertMockEndpointsSatisfied();

    // start route, and we got messages again
    mock.reset();
    mock.expectedMinimumMessageCount(2);

    context().startRoute("myRoute");

    assertMockEndpointsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:31,代码来源:SpringQuartzPersistentStoreRestartRouteTest.java


注:本文中的org.apache.camel.component.mock.MockEndpoint.expectedMinimumMessageCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。