本文整理汇总了Java中org.apache.camel.component.mock.MockEndpoint.setAssertPeriod方法的典型用法代码示例。如果您正苦于以下问题:Java MockEndpoint.setAssertPeriod方法的具体用法?Java MockEndpoint.setAssertPeriod怎么用?Java MockEndpoint.setAssertPeriod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.component.mock.MockEndpoint
的用法示例。
在下文中一共展示了MockEndpoint.setAssertPeriod方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: testBeverage
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testBeverage() 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 gintonic ordered", body);
}
}
示例3: testGroupLines
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testGroupLines() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
mock.setAssertPeriod(1000);
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);
mock.message(1).header(StreamConstants.STREAM_COMPLETE).isEqualTo(true);
assertMockEndpointsSatisfied();
List<?> list = mock.getExchanges().get(0).getIn().getBody(List.class);
assertEquals(3, list.size());
assertEquals("A", list.get(0));
assertEquals("B", list.get(1));
assertEquals("C", list.get(2));
List<?> list2 = mock.getExchanges().get(1).getIn().getBody(List.class);
assertEquals(3, list2.size());
assertEquals("D", list2.get(0));
assertEquals("E", list2.get(1));
assertEquals("F", list2.get(2));
}
示例4: testGroupLines
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testGroupLines() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
mock.setAssertPeriod(1000);
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);
mock.message(1).header(StreamConstants.STREAM_COMPLETE).isEqualTo(true);
assertMockEndpointsSatisfied();
Object result = mock.getExchanges().get(0).getIn().getBody();
assertEquals("Get a wrong result.", "A\nB\nC\nD\n", result);
// we did not have 4 lines but since its the last it was triggered anyway
Object result2 = mock.getExchanges().get(1).getIn().getBody();
assertEquals("Get a wrong result.", "E\nF\n", result2);
}
示例5: testGroupLines
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testGroupLines() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(2);
mock.setAssertPeriod(1000);
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);
mock.message(1).header(StreamConstants.STREAM_COMPLETE).isEqualTo(true);
assertMockEndpointsSatisfied();
Object result = mock.getExchanges().get(0).getIn().getBody();
assertEquals("Get a wrong result.", "A\nB\nC\n", result);
Object result2 = mock.getExchanges().get(1).getIn().getBody();
assertEquals("Get a wrong result.", "D\nE\nF\n", result2);
}
示例6: testFooBar
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testFooBar() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(2);
mock.setAssertPeriod(500);
assertMockEndpointsSatisfied();
}
示例7: testPurgeWhenStopping
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
public void testPurgeWhenStopping() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
for (int i = 0; i < 100; i++) {
template.sendBody("seda:foo", "Message " + i);
}
context.startRoute("myRoute");
latch.await(5, TimeUnit.SECONDS);
context.stopRoute("myRoute");
mock.setAssertPeriod(2000);
mock.assertIsSatisfied();
}
示例8: testRepeatCount
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
public void testRepeatCount() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(3);
mock.setAssertPeriod(500);
mock.message(0).header(Exchange.TIMER_COUNTER).isEqualTo(1);
mock.message(1).header(Exchange.TIMER_COUNTER).isEqualTo(2);
mock.message(2).header(Exchange.TIMER_COUNTER).isEqualTo(3);
// we should only get 3 messages as we have a repeat count limit at 3
assertMockEndpointsSatisfied();
}
示例9: testInOutRepeatSequentialInvocations
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testInOutRepeatSequentialInvocations() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:finished");
mock.setAssertPeriod(2000);
mock.expectedMessageCount(1);
String outPayload = template.requestBody("direct:test", "test", String.class);
assertEquals("Some reply", outPayload);
mock.assertIsSatisfied();
}
示例10: testInOutParallel
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
@Test
public void testInOutParallel() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:received");
mock.setAssertPeriod(2000);
mock.expectedMessageCount(5);
String outPayload = template.requestBody("direct:test", "test", String.class);
assertEquals("Fully done", outPayload);
mock.assertIsSatisfied();
}
示例11: setAssertPeriod
import org.apache.camel.component.mock.MockEndpoint; //导入方法依赖的package包/类
/**
* Sets the assert period on all the Mock endpoints
*/
protected void setAssertPeriod(long period) {
MockEndpoint.setAssertPeriod(context, period);
}