本文整理汇总了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));
});
}
示例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"));
}
示例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();
}
示例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);
}
}
示例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();
}
示例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();
}
示例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());
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}