Ejemplo n.º 1
0
  @Test
  public void testOffer() throws Exception {

    RemoteInvoker invoker = new HttpInvoker(URL);
    Application app = new Application();
    app.setCreditScore(700);
    Car car = new Car();
    car.setPrice(18000);
    Offer offer = new Offer();
    offer.setApplication(app);
    offer.setCar(car);
    offer.setAmount(17000);

    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());
  }
  @Test
  public void testOffer() throws Exception {

    // Create a new remote client invoker
    RemoteInvoker invoker = new HttpInvoker(URL);

    // Create request payload
    Offer offer = createOffer(true);

    // Create the request message
    RemoteMessage message = new RemoteMessage();
    message.setService(SERVICE).setOperation("offer").setContent(offer);

    // Invoke the service
    RemoteMessage reply = invoker.invoke(message);
    if (reply.isFault()) {
      Assert.fail("Invocation returned fault: " + reply.getContent());
    }
    Deal deal = (Deal) reply.getContent();
    Assert.assertTrue(deal.isAccepted());
  }
Ejemplo n.º 3
0
  /**
   * Only execution point for this application.
   *
   * @param ignored not used.
   * @throws Exception if something goes wrong.
   */
  public static void main(final String[] ignored) 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 request payload
    Offer offer = createOffer(true);

    // Create the request message
    RemoteMessage message = new RemoteMessage();
    message.setService(SERVICE).setOperation("offer").setContent(offer);

    // Invoke the service
    RemoteMessage reply = invoker.invoke(message);
    if (reply.isFault()) {
      System.err.println("Oops ... something bad happened.  " + reply.getContent());
    } else {
      Deal deal = (Deal) reply.getContent();
      out.println("==================================");
      out.println("Was the offer accepted? " + deal.isAccepted());
      out.println("==================================");
    }
  }