本文整理匯總了Java中org.apache.camel.component.mock.MockEndpoint.whenAnyExchangeReceived方法的典型用法代碼示例。如果您正苦於以下問題:Java MockEndpoint.whenAnyExchangeReceived方法的具體用法?Java MockEndpoint.whenAnyExchangeReceived怎麽用?Java MockEndpoint.whenAnyExchangeReceived使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.camel.component.mock.MockEndpoint
的用法示例。
在下文中一共展示了MockEndpoint.whenAnyExchangeReceived方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testEnd1FailureTest
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testEnd1FailureTest() throws Exception {
MockEndpoint end1 = getMockEndpoint("mock:end1");
end1.whenAnyExchangeReceived(new Processor() {
public void process(Exchange exchange) throws Exception {
throw new RuntimeException("Simulated Exception");
}
});
getMockEndpoint("mock:end2").expectedMessageCount(1);
getMockEndpoint("mock:end3").expectedMessageCount(0);
getMockEndpoint("mock:end4").expectedMessageCount(1);
String result = template.requestBody("direct:start", "Hello World!", String.class);
assertEquals("Stop!", result);
assertMockEndpointsSatisfied();
}
示例2: testEnd2FailureTest
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testEnd2FailureTest() throws Exception {
MockEndpoint end2 = getMockEndpoint("mock:end2");
end2.whenAnyExchangeReceived(new Processor() {
public void process(Exchange exchange) throws Exception {
throw new RuntimeException("Simulated Exception");
}
});
getMockEndpoint("mock:end1").expectedMessageCount(1);
getMockEndpoint("mock:end3").expectedMessageCount(0);
getMockEndpoint("mock:end4").expectedMessageCount(1);
String result = template.requestBody("direct:start", "Hello World!", String.class);
assertEquals("Stop!", result);
assertMockEndpointsSatisfied();
}
示例3: testEnd3FailureTest
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testEnd3FailureTest() throws Exception {
MockEndpoint end3 = getMockEndpoint("mock:end3");
end3.whenAnyExchangeReceived(new Processor() {
public void process(Exchange exchange) throws Exception {
throw new RuntimeException("Simulated Exception");
}
});
getMockEndpoint("mock:end1").expectedMessageCount(1);
getMockEndpoint("mock:end2").expectedMessageCount(1);
getMockEndpoint("mock:end4").expectedMessageCount(1);
String result = template.requestBody("direct:start", "Hello World!", String.class);
assertEquals("Stop!", result);
assertMockEndpointsSatisfied();
}
示例4: testEnd1FailureTest
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testEnd1FailureTest() throws Exception {
MockEndpoint end1 = getMockEndpoint("mock:end1");
end1.whenAnyExchangeReceived(new Processor() {
public void process(Exchange exchange) throws Exception {
throw new RuntimeException("Simulated Exception");
}
});
getMockEndpoint("mock:end2").expectedMessageCount(0);
getMockEndpoint("mock:end3").expectedMessageCount(0);
getMockEndpoint("mock:end4").expectedMessageCount(1);
String result = template.requestBody("direct:start", "Hello World!", String.class);
assertEquals("Stop!", result);
assertMockEndpointsSatisfied();
}
示例5: testEnd1FailureTest
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testEnd1FailureTest() throws Exception {
MockEndpoint end1 = getMockEndpoint("mock:end1");
end1.whenAnyExchangeReceived(new Processor() {
public void process(Exchange exchange) throws Exception {
throw new RuntimeException("Simulated Exception");
}
});
// we run in parallel so the task could have been submitted so we either get 0 or 1 messages at mock:end2
getMockEndpoint("mock:end2").expectedMinimumMessageCount(0);
getMockEndpoint("mock:end3").expectedMessageCount(0);
getMockEndpoint("mock:end4").expectedMessageCount(1);
String result = template.requestBody("direct:start", "Hello World!", String.class);
assertEquals("Stop!", result);
assertMockEndpointsSatisfied();
}
示例6: testEnd2FailureTest
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testEnd2FailureTest() throws Exception {
MockEndpoint end2 = getMockEndpoint("mock:end2");
end2.whenAnyExchangeReceived(new Processor() {
public void process(Exchange exchange) throws Exception {
throw new RuntimeException("Simulated Exception");
}
});
// we run in parallel so the task could have been submitted so we either get 0 or 1 messages at mock:end1
getMockEndpoint("mock:end1").expectedMinimumMessageCount(0);
getMockEndpoint("mock:end3").expectedMessageCount(0);
getMockEndpoint("mock:end4").expectedMessageCount(1);
String result = template.requestBody("direct:start", "Hello World!", String.class);
assertEquals("Stop!", result);
assertMockEndpointsSatisfied();
}
示例7: testMulticastParallel
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testMulticastParallel() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(10);
mock.whenAnyExchangeReceived(new Processor() {
public void process(Exchange exchange) throws Exception {
// they should all be BA as B is faster than A
assertEquals("BA", exchange.getIn().getBody(String.class));
}
});
for (int i = 0; i < 10; i++) {
template.sendBody("direct:start", "Hello");
}
assertMockEndpointsSatisfied();
}
示例8: testBFail
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testBFail() throws Exception {
MockEndpoint result = getMockEndpoint("mock:result");
result.expectedMessageCount(1);
MockEndpoint endpointB = getMockEndpoint("mock:endpointB");
endpointB.whenAnyExchangeReceived(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
throw new IllegalArgumentException("Fake exception");
}
});
template.sendBody("direct:start", "dummy");
assertMockEndpointsSatisfied();
Exchange received = result.getReceivedExchanges().get(0);
assertThat("no exception", received.isFailed(), is(false));
}
示例9: testAFail
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testAFail() throws Exception {
MockEndpoint result = getMockEndpoint("mock:result");
result.expectedMessageCount(1);
MockEndpoint endpointA = getMockEndpoint("mock:endpointA");
endpointA.whenAnyExchangeReceived(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
throw new IllegalArgumentException("Fake exception");
}
});
template.sendBody("direct:start", "dummy");
assertMockEndpointsSatisfied();
Exchange received = result.getReceivedExchanges().get(0);
assertThat("no exception", received.isFailed(), is(false));
}
示例10: testIOError
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testIOError() throws Exception {
getMockEndpoint("mock:io").expectedMessageCount(0);
getMockEndpoint("mock:intercepted").expectedMessageCount(2);
getMockEndpoint("mock:foo").expectedMessageCount(2);
getMockEndpoint("mock:result").expectedMessageCount(0);
MockEndpoint foo = getMockEndpoint("mock:foo");
foo.whenAnyExchangeReceived(new Processor() {
public void process(Exchange exchange) throws Exception {
throw new IOException("Forced");
}
});
template.sendBody("direct:start", "Hello World");
template.sendBody("direct:start", "Bye World");
assertMockEndpointsSatisfied();
}
示例11: testMulticastParallel
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testMulticastParallel() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(20);
mock.whenAnyExchangeReceived(new Processor() {
public void process(Exchange exchange) throws Exception {
// they should all be AB even though A is slower than B
assertEquals("AB", exchange.getIn().getBody(String.class));
}
});
for (int i = 0; i < 20; i++) {
template.sendBody("direct:start", "Hello");
}
assertMockEndpointsSatisfied();
}
示例12: testSendObservableToEndpoint
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testSendObservableToEndpoint() throws Exception {
Order[] expectedBodies = {new Order("o1", 1.10), new Order("o2", 2.20), new Order("o3", 3.30)};
Observable<Order> someObservable = Observable.from(expectedBodies);
final MockEndpoint mockEndpoint = camelContext.getEndpoint("mock:results", MockEndpoint.class);
mockEndpoint.expectedBodiesReceived((Object[]) expectedBodies);
mockEndpoint.whenAnyExchangeReceived(exchange -> exchange.addOnCompletion(onCompletion));
// lets send events on the observable to the camel endpoint
reactiveCamel.sendTo(someObservable, "mock:results");
mockEndpoint.assertIsSatisfied();
Assert.assertEquals(3, onCompletion.getDone());
}
示例13: testConsumeAll
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testConsumeAll() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:resultAll");
mock.expectedMinimumMessageCount(1);
mock.whenAnyExchangeReceived(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Object body = exchange.getIn().getBody();
assertTrue(body instanceof List);
}
});
mock.await(1, TimeUnit.SECONDS);
assertMockEndpointsSatisfied();
}
示例14: testConsumeUnprepared
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testConsumeUnprepared() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:resultUnprepared");
mock.expectedMinimumMessageCount(1);
mock.whenAnyExchangeReceived(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Object body = exchange.getIn().getBody();
assertTrue(body instanceof List);
}
});
mock.await(1, TimeUnit.SECONDS);
assertMockEndpointsSatisfied();
}
示例15: testConsumeOne
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testConsumeOne() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:resultOne");
mock.expectedMinimumMessageCount(1);
mock.whenAnyExchangeReceived(new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Object body = exchange.getIn().getBody();
assertTrue(body instanceof Row);
}
});
mock.await(1, TimeUnit.SECONDS);
assertMockEndpointsSatisfied();
}