use of org.switchyard.test.MockHandler in project quickstarts by jboss-switchyard.
the class CamelJMSBindingTest method sendTextMessageToJMSQueue.
@Test
public void sendTextMessageToJMSQueue() throws Exception {
final String payload = "dummy payload";
// replace existing implementation for testing purposes
_testKit.removeService("GreetingService");
final MockHandler greetingService = _testKit.registerInOnlyService("GreetingService");
sendTextToQueue(payload, QUEUE_NAME);
// Allow for the JMS Message to be processed.
Thread.sleep(3000);
final LinkedBlockingQueue<Exchange> recievedMessages = greetingService.getMessages();
assertThat(recievedMessages, is(notNullValue()));
final Exchange recievedExchange = recievedMessages.iterator().next();
assertThat(recievedExchange.getMessage().getContent(String.class), is(equalTo(payload)));
}
use of org.switchyard.test.MockHandler in project quickstarts by jboss-switchyard.
the class CamelServiceTest method testXQueryRouting.
@Test
public void testXQueryRouting() throws Exception {
_testKit.removeService("HelloService");
_testKit.removeService("GoodbyeService");
MockHandler helloService = _testKit.registerInOnlyService("HelloService");
MockHandler goodbyeService = _testKit.registerInOnlyService("GoodbyeService");
greet.sendInOnly(REQUEST_HELLO);
greet.sendInOnly(REQUEST_GOODBYE);
Thread.sleep(1000);
LinkedBlockingQueue<Exchange> helloReceived = helloService.getMessages();
Assert.assertNotNull(helloReceived);
Exchange helloExchange = helloReceived.iterator().next();
Assert.assertTrue(helloExchange.getMessage().getContent(String.class).matches(".*Douglas.*"));
LinkedBlockingQueue<Exchange> goodbyeReceived = goodbyeService.getMessages();
Assert.assertNotNull(goodbyeReceived);
Exchange goodbyeExchange = goodbyeReceived.iterator().next();
Assert.assertTrue(goodbyeExchange.getMessage().getContent(String.class).matches(".*Garfield.*"));
}
use of org.switchyard.test.MockHandler in project quickstarts by jboss-switchyard.
the class DealerTest method acceptValidOffer.
@Test
public void acceptValidOffer() throws Exception {
Car car = new Car();
car.setPrice(500.00);
Application app = new Application();
app.setCreditScore(650);
Offer offer = new Offer();
offer.setCar(car);
offer.setApplication(app);
offer.setAmount(450.00);
// configure our proxy for the service reference
MockHandler creditService = testKit.replaceService("CreditCheck");
Application reply = new Application();
reply.setApproved(true);
creditService.replyWithOut(reply);
// Invoke the service
Deal deal = service.operation("offer").sendInOut(offer).getContent(Deal.class);
// verify the deal is rejected
Assert.assertTrue(deal.isAccepted());
}
use of org.switchyard.test.MockHandler in project quickstarts by jboss-switchyard.
the class CamelSqlRetrieveTest method shouldRetrieveGreetings.
@Test
public void shouldRetrieveGreetings() throws Exception {
_testKit.removeService("GreetingService");
MockHandler handler = new MockHandler();
ServiceInterface metadata = JavaService.fromClass(GreetingService.class);
_testKit.getServiceDomain().registerService(_testKit.createQName("GreetingService"), metadata, handler);
PreparedStatement statement = connection.prepareStatement("INSERT INTO greetings (receiver, sender) VALUES (?,?)");
statement.setString(1, RECEIVER);
statement.setString(2, SENDER);
assertEquals(1, statement.executeUpdate());
PreparedStatement statement2 = connection.prepareStatement("INSERT INTO greetings (receiver, sender) VALUES (?,?)");
statement2.setString(1, RECEIVER_2);
statement2.setString(2, SENDER_2);
assertEquals(1, statement2.executeUpdate());
Set<Greeting> greetings = getContents(handler);
assertEquals(2, greetings.size());
assertEquals(true, checkGreeting(RECEIVER, SENDER, greetings));
assertEquals(true, checkGreeting(RECEIVER_2, SENDER_2, greetings));
}
use of org.switchyard.test.MockHandler in project quickstarts by jboss-switchyard.
the class DealerTest method acceptValidOffer.
@Test
public void acceptValidOffer() throws Exception {
Car car = new Car();
car.setPrice(500.00);
Application app = new Application();
app.setCreditScore(650);
Offer offer = new Offer();
offer.setCar(car);
offer.setApplication(app);
offer.setAmount(450.00);
// configure our proxy for the service reference
testKit.replaceService("DealLogger");
MockHandler creditService = testKit.replaceService("CreditCheckService");
Application reply = new Application();
reply.setApproved(true);
creditService.replyWithOut(reply);
// Invoke the service
Deal deal = service.operation("offer").sendInOut(offer).getContent(Deal.class);
// verify the deal is rejected
Assert.assertTrue(deal.isAccepted());
}
Aggregations