本文整理匯總了Java中org.apache.camel.component.mock.MockEndpoint.expectedBodiesReceived方法的典型用法代碼示例。如果您正苦於以下問題:Java MockEndpoint.expectedBodiesReceived方法的具體用法?Java MockEndpoint.expectedBodiesReceived怎麽用?Java MockEndpoint.expectedBodiesReceived使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.camel.component.mock.MockEndpoint
的用法示例。
在下文中一共展示了MockEndpoint.expectedBodiesReceived方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testJmsMessageWithSelector
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testJmsMessageWithSelector() throws Exception {
MockEndpoint endpointA = getMockEndpoint("mock:a");
MockEndpoint endpointB = getMockEndpoint("mock:b");
MockEndpoint endpointC = getMockEndpoint("mock:c");
endpointA.expectedBodiesReceivedInAnyOrder("A blue car!", "A blue car, again!");
endpointA.expectedHeaderReceived("color", "blue");
endpointB.expectedHeaderReceived("color", "red");
endpointB.expectedBodiesReceived("A red car!");
endpointC.expectedBodiesReceived("Message1", "Message2");
endpointC.expectedMessageCount(2);
template.sendBodyAndHeader("sjms:queue:hello", "A blue car!", "color", "blue");
template.sendBodyAndHeader("sjms:queue:hello", "A red car!", "color", "red");
template.sendBodyAndHeader("sjms:queue:hello", "A blue car, again!", "color", "blue");
template.sendBodyAndHeader("sjms:queue:hello", "Message1", "SIZE_NUMBER", 1505);
template.sendBodyAndHeader("sjms:queue:hello", "Message3", "SIZE_NUMBER", 1300);
template.sendBodyAndHeader("sjms:queue:hello", "Message2", "SIZE_NUMBER", 1600);
assertMockEndpointsSatisfied();
}
示例2: testTCPEncodeUTF8InputIsBytes
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testTCPEncodeUTF8InputIsBytes() throws Exception {
final String uri = String.format("mina2:tcp://localhost:%1$s?encoding=UTF-8&sync=false", getPort());
context.addRoutes(new RouteBuilder() {
public void configure() {
from(uri).to("mock:result");
}
});
MockEndpoint endpoint = getMockEndpoint("mock:result");
// include a UTF-8 char in the text \u0E08 is a Thai elephant
byte[] body = "Hello Thai Elephant \u0E08".getBytes("UTF-8");
endpoint.expectedMessageCount(1);
endpoint.expectedBodiesReceived(body);
template.sendBody(uri, body);
assertMockEndpointsSatisfied();
}
示例3: testThreadUsedForEveryAggregatorWhenDefaultExecutorServiceUsed
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testThreadUsedForEveryAggregatorWhenDefaultExecutorServiceUsed() throws Exception {
assertTrue("There should be a thread for every aggregator when using defaults",
AggregateTimeoutWithExecutorServiceTest.aggregateThreadsCount() >= AggregateTimeoutWithExecutorServiceTest.NUM_AGGREGATORS);
// sanity check to make sure were testing routes that work
for (int i = 0; i < AggregateTimeoutWithExecutorServiceTest.NUM_AGGREGATORS; ++i) {
MockEndpoint result = getMockEndpoint("mock:result" + i);
// by default the use latest aggregation strategy is used so we get message 4
result.expectedBodiesReceived("Message 4");
}
for (int i = 0; i < AggregateTimeoutWithExecutorServiceTest.NUM_AGGREGATORS; ++i) {
for (int j = 0; j < 5; j++) {
template.sendBodyAndHeader("direct:start" + i, "Message " + j, "id", "1");
}
}
assertMockEndpointsSatisfied();
}
示例4: 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();
}
示例5: testSend
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testSend() throws Exception {
final MockEndpoint mock = getMockEndpoint("mock:result");
final String body = "hello";
mock.expectedMessageCount(1);
mock.expectedBodiesReceived(body.toUpperCase());
template().sendBody("direct:start", body);
mock.assertIsSatisfied();
}
示例6: testSend
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testSend() throws Exception {
final MockEndpoint mock = getMockEndpoint("mock:result");
final String body = "hello";
final String expected = Base64.getEncoder().encodeToString(body.toUpperCase().getBytes());
mock.expectedMessageCount(1);
mock.expectedBodiesReceived(expected);
template().sendBody("direct:start", body);
mock.assertIsSatisfied();
}
示例7: testDefaultSplitWithCollection
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testDefaultSplitWithCollection() throws Exception {
final MockEndpoint mock = getMockEndpoint("mock:result");
final String[] values = { "a","b","c" };
mock.expectedMessageCount(values.length);
mock.expectedBodiesReceived(values);
template().sendBody("direct:start", Arrays.asList(values));
mock.assertIsSatisfied();
}
示例8: testDefaultSplitWithPojo
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testDefaultSplitWithPojo() throws Exception {
final MockEndpoint mock = getMockEndpoint("mock:result");
final String value = "a";
mock.expectedMessageCount(1);
mock.expectedBodiesReceived(value);
template().sendBody("direct:start", value);
mock.assertIsSatisfied();
}
示例9: testTokenizerSplit
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testTokenizerSplit() throws Exception {
final MockEndpoint mock = getMockEndpoint("mock:result");
final String values = "a,b,c";
final String[] result = values.split(",");
mock.expectedMessageCount(result.length);
mock.expectedBodiesReceived(result);
template().sendBody("direct:start", values);
mock.assertIsSatisfied();
}
示例10: testSend
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testSend() throws Exception {
final MockEndpoint mock = getMockEndpoint("mock:result");
final String body = "hello";
final String expected = Base64.getEncoder().encodeToString("HELLO WORLD!".toUpperCase().getBytes());
mock.expectedMessageCount(1);
mock.expectedBodiesReceived(expected);
template().sendBody("direct:start", body);
mock.assertIsSatisfied();
}
示例11: testSend
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testSend() throws Exception {
final MockEndpoint mock = getMockEndpoint("mock:result");
final String body = "hello";
final String expected = body.toUpperCase();
mock.expectedMessageCount(1);
mock.expectedBodiesReceived(expected);
template().sendBody("direct:start", body);
mock.assertIsSatisfied();
}
示例12: testTwoMessages
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testTwoMessages() throws Exception {
MockEndpoint resultEndpoint = context.getEndpoint("mock:test", MockEndpoint.class);
resultEndpoint.expectedBodiesReceived("test", "test2");
Subscriber<String> subscriber = camel.to("mock:test", String.class);
Flux.just("test", "test2").subscribe(subscriber);
resultEndpoint.assertIsSatisfied();
}
示例13: testEndpoint
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testEndpoint() throws Exception {
// these tests does not run well on Windows
if (isPlatform("windows")) {
return;
}
MockEndpoint mockEndpointA = resolveMandatoryEndpoint("mock:a", MockEndpoint.class);
mockEndpointA.expectedBodiesReceived(expectedBody);
MockEndpoint mockEndpointB = resolveMandatoryEndpoint("mock:b", MockEndpoint.class);
mockEndpointB.expectedBodiesReceived(expectedBody);
invokeHttpEndpoint();
mockEndpointA.assertIsSatisfied();
mockEndpointB.assertIsSatisfied();
List<Exchange> list = mockEndpointA.getReceivedExchanges();
Exchange exchange = list.get(0);
assertNotNull("exchange", exchange);
Message in = exchange.getIn();
assertNotNull("in", in);
Map<String, Object> headers = in.getHeaders();
log.info("Headers: " + headers);
assertTrue("Should be more than one header but was: " + headers, headers.size() > 0);
}
示例14: testFTPClientConfig
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testFTPClientConfig() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.expectedBodiesReceived("Hello World");
assertMockEndpointsSatisfied();
}
示例15: testRemove
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testRemove() throws Exception {
// JMX tests dont work well on AIX CI servers (hangs them)
if (isPlatform("aix")) {
return;
}
MBeanServer mbeanServer = getMBeanServer();
ObjectName on = getRouteObjectName(mbeanServer);
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");
template.sendBodyAndHeader("file://target/managed", "Hello World", Exchange.FILE_NAME, "hello.txt");
assertMockEndpointsSatisfied();
// should be started
String state = (String) mbeanServer.getAttribute(on, "State");
assertEquals("Should be started", ServiceStatus.Started.name(), state);
// stop
mbeanServer.invoke(on, "stop", null, null);
state = (String) mbeanServer.getAttribute(on, "State");
assertEquals("Should be stopped", ServiceStatus.Stopped.name(), state);
// remove
mbeanServer.invoke(on, "remove", null, null);
// should not be registered anymore
boolean registered = mbeanServer.isRegistered(on);
assertFalse("Route mbean should have been unregistered", registered);
// and no more routes
Set<ObjectName> set = mbeanServer.queryNames(new ObjectName("*:type=routes,*"), null);
assertEquals(0, set.size());
}