本文整理匯總了Java中org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied方法的典型用法代碼示例。如果您正苦於以下問題:Java MockEndpoint.assertIsSatisfied方法的具體用法?Java MockEndpoint.assertIsSatisfied怎麽用?Java MockEndpoint.assertIsSatisfied使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.camel.component.mock.MockEndpoint
的用法示例。
在下文中一共展示了MockEndpoint.assertIsSatisfied方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testMocksAreValid
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
@DirtiesContext
public void testMocksAreValid() throws Exception {
result.setExpectedCount(1);
ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
producerTemplate.sendBody("direct:start", Util.generateMockTwitterStatus());
MockEndpoint.assertIsSatisfied(camelContext);
Object body = result.getExchanges().get(0).getIn().getBody();
assertEquals(String.class, body.getClass());
ObjectMapper mapper = new ObjectMapper();
JsonNode outJson = mapper.readTree((String)body);
assertEquals("Bob", outJson.get("FirstName").asText());
assertEquals("Vila", outJson.get("LastName").asText());
assertEquals("bobvila1982", outJson.get("Title").asText());
assertEquals("Let's build a house!", outJson.get("Description").asText());
}
示例2: testMocksAreValid
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
@DirtiesContext
public void testMocksAreValid() throws Exception {
result.setExpectedCount(1);
ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
producerTemplate.sendBody("direct:start", Util.generateMockTwitterStatus());
MockEndpoint.assertIsSatisfied(camelContext);
Object body = result.getExchanges().get(0).getIn().getBody();
assertEquals(String.class, body.getClass());
ObjectMapper mapper = new ObjectMapper();
JsonNode sfJson = mapper.readTree((String)body);
assertNotNull(sfJson.get("TwitterScreenName__c"));
assertEquals("bobvila1982", sfJson.get("TwitterScreenName__c").asText());
}
示例3: testSeparateNotSucceed
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
@DirtiesContext
public void testSeparateNotSucceed() throws Exception {
result.setExpectedCount(1);
ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
Status s = Util.generateMockTwitterStatus();
when(s.getUser().getName()).thenReturn("BobVila");
producerTemplate.sendBody("direct:start", s);
MockEndpoint.assertIsSatisfied(camelContext);
Object body = result.getExchanges().get(0).getIn().getBody();
assertEquals(String.class, body.getClass());
ObjectMapper mapper = new ObjectMapper();
JsonNode outJson = mapper.readTree((String)body);
assertEquals("BobVila", outJson.get("FirstName").asText());
assertNull(outJson.get("LastName"));
assertEquals("bobvila1982", outJson.get("Title").asText());
assertEquals("Let's build a house!", outJson.get("Description").asText());
}
示例4: testStep
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testStep() throws Exception {
List<String> allMessages = new ArrayList<>(matchingMessages);
allMessages.addAll(notMatchingMessages);
matchedEndpoint.expectedBodiesReceived(matchingMessages);
allMessagesEndpoint.expectedBodiesReceived(allMessages);
for (Object body : allMessages) {
template.sendBody(START_URI, body);
}
MockEndpoint[] mockEndpoints = {
matchedEndpoint, allMessagesEndpoint
};
MockEndpoint.assertIsSatisfied(mockEndpoints);
logMessagesReceived(mockEndpoints);
}
示例5: testStep
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testStep() throws Exception {
List<String> allMessages = new ArrayList<>(matchedJames);
allMessages.addAll(matchedJimmi);
allMessages.addAll(otherwiseMessages);
matchedEndpoint.expectedBodiesReceived(matchedJames);
matchedJimmiEndpoint.expectedBodiesReceived(matchedJimmi);
otherwiseEndpoint.expectedBodiesReceived(otherwiseMessages);
allMessagesEndpoint.expectedBodiesReceived(allMessages);
for (Object body : allMessages) {
template.sendBody(START_URI, body);
}
MockEndpoint[] mockEndpoints = {
matchedEndpoint, matchedJimmiEndpoint, otherwiseEndpoint, allMessagesEndpoint
};
MockEndpoint.assertIsSatisfied(mockEndpoints);
logMessagesReceived(mockEndpoints);
}
示例6: testConsumeMultipleTopics
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testConsumeMultipleTopics() throws Exception {
MQTT mqtt = new MQTT();
BlockingConnection publisherConnection = mqtt.blockingConnection();
Topic topic1 = new Topic(TEST_TOPIC, QoS.AT_MOST_ONCE);
Topic topic2 = new Topic(TEST_TOPIC_2, QoS.AT_MOST_ONCE);
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(numberOfMessages * 2);
publisherConnection.connect();
String payload;
for (int i = 0; i < numberOfMessages; i++) {
payload = "Topic 1, Message " + i;
publisherConnection.publish(topic1.name().toString(), payload.getBytes(), QoS.AT_LEAST_ONCE, false);
payload = "Topic 2, Message " + i;
publisherConnection.publish(topic2.name().toString(), payload.getBytes(), QoS.AT_LEAST_ONCE, false);
}
mock.await(5, TimeUnit.SECONDS);
mock.assertIsSatisfied();
}
示例7: testBindy
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testBindy() throws Exception {
CamelContext ctx = new DefaultCamelContext();
ctx.addRoutes(createRoute()); // new ReconciliationRoute()
ctx.start();
String addressLine1 = "8506 SIX FORKS ROAD,";
MockEndpoint mock = ctx.getEndpoint("mock:result", MockEndpoint.class);
mock.expectedPropertyReceived("addressLine1", addressLine1);
String csvLine = "\"PROBLEM SOLVER\",\"" + addressLine1
+ "\",\"SUITE 104\",\"RALEIGH\",\"NC\",\"27615\",\"US\"";
ProducerTemplate template = ctx.createProducerTemplate();
template.sendBody("direct:fromCsv", csvLine.trim());
mock.assertIsSatisfied();
// The algorithm of BindyCvsDataFormat.unquoteTokens(..) does not handle
// separator at end of a field
// addressLine1 results in the next field being appended -> '8506 SIX
// FORKS ROAD,,SUITE 104'
}
示例8: testSelectOneWithClass
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testSelectOneWithClass() throws Exception {
camel1.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("sql:select * from projects where id=3?outputType=SelectOne&outputClass=org.apache.camel.component.sql.ProjectModel")
.to("mock:result");
}
});
camel1.start();
MockEndpoint mock = (MockEndpoint) camel1.getEndpoint("mock:result");
mock.expectedMessageCount(1);
mock.assertIsSatisfied(2000);
List<Exchange> exchanges = mock.getReceivedExchanges();
Assert.assertThat(exchanges.size(), CoreMatchers.is(1));
ProjectModel result = exchanges.get(0).getIn().getBody(ProjectModel.class);
Assert.assertThat(result.getId(), CoreMatchers.is(3));
Assert.assertThat(result.getProject(), CoreMatchers.is("Linux"));
Assert.assertThat(result.getLicense(), CoreMatchers.is("XXX"));
}
示例9: testNotCached
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testNotCached() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodbye>world!</goodbye>");
template.sendBody("direct:a", "<hello>world!</hello>");
mock.assertIsSatisfied();
// now replace the file with a new XSL transformation
template.sendBodyAndHeader("file://target/test-classes/org/apache/camel/component/xslt?fileExist=Override", NEW_XSL, Exchange.FILE_NAME, "hello.xsl");
mock.reset();
// we expect the new output as the cache is not enabled, so it's "goodnight" and not "goodbye"
mock.expectedBodiesReceived("<?xml version=\"1.0\" encoding=\"UTF-8\"?><goodnight>world!</goodnight>");
template.sendBody("direct:a", "<hello>world!</hello>");
mock.assertIsSatisfied();
}
示例10: marshalAndUnmarshalGeneric
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
private void marshalAndUnmarshalGeneric(String inURI, String outURI) throws InterruptedException {
GenericRecord input = new GenericData.Record(schema);
input.put("name", "ceposta");
MockEndpoint mock = getMockEndpoint("mock:reverse");
mock.expectedMessageCount(1);
mock.message(0).body().isInstanceOf(GenericRecord.class);
mock.message(0).body().isEqualTo(input);
Object marshalled = template.requestBody(inURI, input);
template.sendBody(outURI, marshalled);
mock.assertIsSatisfied();
GenericRecord output = mock.getReceivedExchanges().get(0).getIn().getBody(GenericRecord.class);
assertEquals(input, output);
}
示例11: testMarshalAndUnmarshalMap
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testMarshalAndUnmarshalMap() throws Exception {
Map<String, Object> in = new HashMap<String, Object>();
in.put("name", "Camel");
MockEndpoint mock = getMockEndpoint("mock:reverse");
mock.expectedMessageCount(1);
mock.message(0).body().isInstanceOf(Map.class);
mock.message(0).body().isEqualTo(in);
Object marshalled = template.requestBody("direct:in", in);
String marshalledAsString = context.getTypeConverter().convertTo(String.class, marshalled);
assertEquals("<HashMap><name>Camel</name></HashMap>", marshalledAsString);
template.sendBody("direct:back", marshalled);
mock.assertIsSatisfied();
}
示例12: testForwardingJmsMessageIgnoresHeadersMQDoesntLike
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
public void testForwardingJmsMessageIgnoresHeadersMQDoesntLike() throws Exception {
MockEndpoint endpoint = getMockEndpoint("mock:result");
endpoint.expectedMessageCount(1);
Map<String, Object> headers = new HashMap<String, Object>();
headers.put("JMSXAppID", "ABC");
template.sendBodyAndHeaders("activemq:test.a", "Hello World!", headers);
endpoint.assertIsSatisfied();
Exchange exchange = endpoint.getReceivedExchanges().get(0);
Message in = exchange.getIn();
assertMessageHeader(in, "JMSXAppID", null);
log.info("Received message: " + in);
}
示例13: testThirdClash
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testThirdClash() throws Exception {
CamelContext third = new DefaultCamelContext();
third.addRoutes(createRouteBuilderForThirdContext());
try {
third.start();
fail("Should have thrown exception");
} catch (IllegalStateException e) {
assertEquals("A consumer Consumer[direct-vm://foo] already exists from CamelContext: camel-1. Multiple consumers not supported", e.getMessage());
}
// stop first camel context then
context.stop();
// and start the 3rd which should work now
third.start();
MockEndpoint mock = third.getEndpoint("mock:third", MockEndpoint.class);
mock.expectedMessageCount(1);
template2.sendBody("direct:start", "Hello World");
mock.assertIsSatisfied();
third.stop();
}
示例14: testInterceptorWithPredicateAndProceed
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
public void testInterceptorWithPredicateAndProceed() throws Exception {
context.addRoutes(new RouteBuilder() {
public void configure() throws Exception {
interceptFrom().when(header("user").isEqualTo("test")).to("mock:test");
from("seda:order").to("mock:ok");
}
});
MockEndpoint mockTest = getMockEndpoint("mock:test");
mockTest.expectedBodiesReceived("Camel in Action");
MockEndpoint mockOk = getMockEndpoint("mock:ok");
mockOk.expectedBodiesReceived("Camel in Action");
template.sendBodyAndHeader("seda:order", "Camel in Action", "user", "test");
mockTest.assertIsSatisfied();
mockOk.assertIsSatisfied();
}
示例15: testMocksAreValid
import org.apache.camel.component.mock.MockEndpoint; //導入方法依賴的package包/類
@Test
@DirtiesContext
public void testMocksAreValid() throws Exception {
result.setExpectedCount(1);
final ProducerTemplate producerTemplate = camelContext.createProducerTemplate();
producerTemplate.sendBody("direct:start", new ByteArrayInputStream("{\"field1\":\"value1\"}".getBytes()));
MockEndpoint.assertIsSatisfied(camelContext);
final Object body = result.getExchanges().get(0).getIn().getBody();
assertEquals(Pojo.class, body.getClass());
assertEquals("value1", ((Pojo) body).getField1());
}