本文整理匯總了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);
}