try { RemoteInvoker invoker = new HttpInvoker(urls.get(i));
@Override public RemoteMessage invoke(RemoteMessage request) throws IOException { RemoteEndpoint ep = _loadBalancer.selectEndpoint(request.getService()); if (ep == null) { throw RemoteMessages.MESSAGES.noRemoteEndpointFound(request.getService().toString()); } return new HttpInvoker(ep.getEndpoint()).invoke(request); }
@Test public void testDeployment() throws Exception { // Create a new remote client invoker String port = System.getProperty("org.switchyard.component.sca.client.port", "8080"); RemoteInvoker invoker = new HttpInvoker("http://localhost:" + port + "/switchyard-remote"); // Create the request message RemoteMessage message = new RemoteMessage(); message.setService(SERVICE).setOperation("acceptMessage").setContent("test"); // Invoke the service invoker.invoke(message); }
@Test public void testDeployment() throws Exception { RemoteInvoker invoker = new HttpInvoker(URL); // Create request payload Order order = new Order(); order.setItem("Turkey"); order.setQuantity(1); // Create the request message RemoteMessage message = new RemoteMessage(); message.setService(SERVICE).setOperation("submitOrder").setContent(order); // Invoke the service RemoteMessage reply = invoker.invoke(message); System.out.println(">>>>> " + reply.getContent().toString()); OrderAck orderAck = (OrderAck) reply.getContent(); Assert.assertEquals(true, orderAck.isAccepted()); Assert.assertEquals("Order Accepted", orderAck.getStatusDescription()); Assert.assertEquals("PO-19838-XYZ", orderAck.getOrderId()); }
@Test public void testDeployment() throws Exception { String port = System.getProperty("org.switchyard.component.sca.client.port", "8080"); RemoteInvoker invoker = new HttpInvoker("http://localhost:" + port + "/switchyard-remote"); // Create request payload Order order = new Order(); order.setItemId("Turkey"); order.setOrderId("Xmas Dinner"); order.setQuantity(1); // Create the request message RemoteMessage message = new RemoteMessage(); message.setService(SERVICE).setOperation("submitOrder").setContent(order); // Invoke the service RemoteMessage reply = invoker.invoke(message); Assert.assertFalse(reply.isFault()); OrderAck orderAck = (OrderAck) reply.getContent(); Assert.assertTrue(orderAck.isAccepted()); }
@Test public void testOffer() throws Exception { RemoteInvoker invoker = new HttpInvoker(URL); Application app = new Application(); app.setName("Magesh"); app.setCreditScore(812); Car car = new Car(); car.setPrice(9600); Offer offer = new Offer(); offer.setApplication(app); offer.setCar(car); offer.setAmount(9000); RemoteMessage message = new RemoteMessage(); message.setService(SERVICE) .setOperation("offer") .setContent(offer); // Invoke the service RemoteMessage reply = invoker.invoke(message); Deal deal = (Deal)reply.getContent(); Assert.assertTrue(deal.isAccepted()); } }