本文整理匯總了Java中org.apache.camel.component.mock.MockEndpoint.assertIsNotSatisfied方法的典型用法代碼示例。如果您正苦於以下問題:Java MockEndpoint.assertIsNotSatisfied方法的具體用法?Java MockEndpoint.assertIsNotSatisfied怎麽用?Java MockEndpoint.assertIsNotSatisfied使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.camel.component.mock.MockEndpoint
的用法示例。
在下文中一共展示了MockEndpoint.assertIsNotSatisfied方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testConvertToStringCharsetFail
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testConvertToStringCharsetFail() throws Exception {
// does not work on AIX
String osName = System.getProperty("os.name").toLowerCase(Locale.ENGLISH);
boolean aix = osName.indexOf("aix") > -1;
if (aix) {
return;
}
String body = "Hell\u00F6 W\u00F6rld";
MockEndpoint result = getMockEndpoint("mock:result");
result.expectedBodiesReceived(body);
template.sendBody("direct:charset3", new ByteArrayInputStream(body.getBytes("utf-8")));
// should NOT be okay as we expected utf-8 but got it in utf-16
result.assertIsNotSatisfied();
}
示例2: testCustomPolicy
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testCustomPolicy() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("Hello World");
mock.setResultWaitTime(2000);
template.sendBody("seda:foo", "Hello World");
// wait 2 sec but the route is not started
mock.assertIsNotSatisfied();
// now start it using our policy
policy.startRoute();
// now the message should be routed
mock.assertIsSatisfied();
}
示例3: testDeleteOnFailure
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testDeleteOnFailure() throws Exception {
shouldIdie = true;
final long jobId = 111;
final byte[] payload = Helper.stringToBytes(testMessage);
final Job jobMock = mock(Job.class);
when(jobMock.getJobId()).thenReturn(jobId);
when(jobMock.getData()).thenReturn(payload);
when(client.reserve(anyInt()))
.thenReturn(jobMock)
.thenReturn(null);
MockEndpoint result = getMockEndpoint("mock:result");
result.expectedMinimumMessageCount(1);
result.assertIsNotSatisfied(1000);
verify(client, atLeastOnce()).reserve(anyInt());
verify(client, atLeast(1)).delete(jobId);
}
示例4: testMockValueBuilderNotSatisfied
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testMockValueBuilderNotSatisfied() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.message(0).exchangeProperty("foo").convertTo(String.class).contains("4");
template.sendBody("direct:start", "Hello World");
mock.assertIsNotSatisfied();
}
示例5: testHeaders
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testHeaders() throws Exception {
MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
// this one does NOT add by only SET so what happens is that header1 value1 is the only tested
resultEndpoint.expectedHeaderReceived("header2", "value2");
resultEndpoint.expectedHeaderReceived("header1", "value1");
template.sendBody("direct:test", null);
resultEndpoint.assertIsNotSatisfied();
}
示例6: testConvertToBytesCharsetFail
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testConvertToBytesCharsetFail() throws Exception {
byte[] body = "Hello World".getBytes("utf-8");
MockEndpoint result = getMockEndpoint("mock:result");
result.expectedBodiesReceived(body);
template.sendBody("direct:charset2", "Hello World");
// should NOT be okay as we expected utf-8 but got it in utf-16
result.assertIsNotSatisfied();
}
示例7: testThreadsRejectedExecutionCallerNotRuns
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testThreadsRejectedExecutionCallerNotRuns() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
// use a custom pool which rejects any new tasks while currently in progress
// this should force the ThreadsProcessor to run the tasks itself
ExecutorService pool = new ThreadPoolExecutor(1, 1, 0, TimeUnit.SECONDS, new SynchronousQueue<Runnable>());
from("seda:start")
.to("log:before")
// will use our custom pool
.threads().executorService(pool).callerRunsWhenRejected(false)
.delay(1000)
.to("log:after")
.to("mock:result");
}
});
context.start();
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(3);
// wait at most 5 seconds
mock.setResultWaitTime(5000);
template.sendBody("seda:start", "Hello World");
template.sendBody("seda:start", "Hi World");
template.sendBody("seda:start", "Bye World");
// should not be possible to route all 3
mock.assertIsNotSatisfied();
// only 1 should arrive
assertEquals(1, mock.getReceivedCounter());
}
示例8: testShutdownAndStartRoute
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testShutdownAndStartRoute() 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);
// calling the shutdown
mbeanServer.invoke(on, "shutdown", null, null);
// the managed route object should be removed
assertFalse("The managed route should be removed", mbeanServer.isRegistered(on));
mock.reset();
mock.expectedBodiesReceived("Bye World");
// wait 3 seconds while route is stopped to verify that file was not consumed
mock.setResultWaitTime(3000);
template.sendBodyAndHeader("file://target/managed", "Bye World", Exchange.FILE_NAME, "bye.txt");
// route is stopped so we do not get the file
mock.assertIsNotSatisfied();
}
示例9: testXmppChatWithDelayedConnection
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testXmppChatWithDelayedConnection() throws Exception {
MockEndpoint consumerEndpoint = context.getEndpoint("mock:out", MockEndpoint.class);
MockEndpoint simpleEndpoint = context.getEndpoint("mock:simple", MockEndpoint.class);
consumerEndpoint.setExpectedMessageCount(1);
consumerEndpoint.expectedBodiesReceived("Hello again!");
simpleEndpoint.setExpectedMessageCount(1);
MockEndpoint errorEndpoint = context.getEndpoint("mock:error", MockEndpoint.class);
errorEndpoint.setExpectedMessageCount(1);
// this request should fail XMPP delivery because the server is not available
template.sendBody("direct:start", "Hello!");
consumerEndpoint.assertIsNotSatisfied();
errorEndpoint.assertIsSatisfied();
// this request should be received because it is not going through the XMPP endpoints
// verifying that the non-xmpp routes are started
template.sendBody("direct:simple", "Hello simple!");
simpleEndpoint.assertIsSatisfied();
EmbeddedXmppTestServer.instance().startXmppEndpoint();
// wait for the connection to be established
Thread.sleep(2000);
// this request should succeed now that the server is available
template.sendBody("direct:start", "Hello again!");
consumerEndpoint.assertIsSatisfied();
}
示例10: testXmppChatWithRobustConnection
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testXmppChatWithRobustConnection() throws Exception {
// does not work well on aix or solaris
if (isPlatform("aix") || isPlatform("sunos")) {
return;
}
MockEndpoint consumerEndpoint = context.getEndpoint("mock:out", MockEndpoint.class);
MockEndpoint errorEndpoint = context.getEndpoint("mock:error", MockEndpoint.class);
// the sleep may not be sufficient so assume around 9 or so messages
consumerEndpoint.setMinimumExpectedMessageCount(9);
errorEndpoint.setExpectedMessageCount(5);
for (int i = 0; i < 5; i++) {
template.sendBody("direct:start", "Test message [ " + i + " ]");
}
consumerEndpoint.assertIsNotSatisfied();
errorEndpoint.assertIsNotSatisfied();
EmbeddedXmppTestServer.instance().stopXmppEndpoint();
Thread.sleep(2000);
for (int i = 0; i < 5; i++) {
template.sendBody("direct:start", "Test message [ " + i + " ]");
}
errorEndpoint.assertIsSatisfied();
consumerEndpoint.assertIsNotSatisfied();
EmbeddedXmppTestServer.instance().startXmppEndpoint();
Thread.sleep(2000);
for (int i = 0; i < 5; i++) {
template.sendBody("direct:start", "Test message [ " + i + " ]");
}
consumerEndpoint.assertIsSatisfied();
}
示例11: testUnSortedEntries
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testUnSortedEntries() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:unsorted");
mock.expectsAscending(ExpressionBuilder.beanExpression("myBean", "getPubDate"));
mock.expectedMessageCount(10);
mock.setResultWaitTime(2000L);
mock.assertIsNotSatisfied(2000L);
}
示例12: testSuspendAndResume
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testSuspendAndResume() 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, "suspend", null, null);
state = (String) mbeanServer.getAttribute(on, "State");
assertEquals("Should be suspended", ServiceStatus.Suspended.name(), state);
mock.reset();
mock.expectedBodiesReceived("Bye World");
// wait 3 seconds while route is stopped to verify that file was not consumed
mock.setResultWaitTime(3000);
template.sendBodyAndHeader("file://target/managed", "Bye World", Exchange.FILE_NAME, "bye.txt");
// route is stopped so we do not get the file
mock.assertIsNotSatisfied();
// prepare mock for starting route
mock.reset();
mock.expectedBodiesReceived("Bye World");
// start
mbeanServer.invoke(on, "resume", null, null);
state = (String) mbeanServer.getAttribute(on, "State");
assertEquals("Should be started", ServiceStatus.Started.name(), state);
// this time the file is consumed
mock.assertIsSatisfied();
ManagedSuspendableRouteMBean route = context.getManagedRoute("foo", ManagedSuspendableRouteMBean.class);
assertNotNull(route);
assertEquals(2, route.getExchangesCompleted());
}
示例13: testStopAndStartRoute
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testStopAndStartRoute() 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);
String id = (String) mbeanServer.getAttribute(on, "RouteId");
assertEquals("foo", id);
String description = (String) mbeanServer.getAttribute(on, "Description");
assertEquals("This is the foo route", description);
// stop
mbeanServer.invoke(on, "stop", null, null);
state = (String) mbeanServer.getAttribute(on, "State");
assertEquals("Should be stopped", ServiceStatus.Stopped.name(), state);
mock.reset();
mock.expectedBodiesReceived("Bye World");
// wait 3 seconds while route is stopped to verify that file was not consumed
mock.setResultWaitTime(3000);
template.sendBodyAndHeader("file://target/managed", "Bye World", Exchange.FILE_NAME, "bye.txt");
// route is stopped so we do not get the file
mock.assertIsNotSatisfied();
// prepare mock for starting route
mock.reset();
mock.expectedBodiesReceived("Bye World");
// start
mbeanServer.invoke(on, "start", null, null);
state = (String) mbeanServer.getAttribute(on, "State");
assertEquals("Should be started", ServiceStatus.Started.name(), state);
// this time the file is consumed
mock.assertIsSatisfied();
}