Пример #1
0
 @Test
 public void canSupplySingleCodecToEndpointPipeline() throws Exception {
   String poem = new Poetry().getPoem();
   MockEndpoint mock = getMockEndpoint("mock:single-codec");
   mock.expectedBodiesReceived(poem);
   sendBody("direct:single-codec", poem);
   mock.await(1, TimeUnit.SECONDS);
   mock.assertIsSatisfied();
 }
  @Test
  public void testProduce() throws InterruptedException {
    resultEndpoint.expectedBodiesReceived(VALUE);
    resultEndpoint.setExpectedMessageCount(1);

    template.asyncSendBody(disruptorUri, VALUE);

    resultEndpoint.await(5, TimeUnit.SECONDS);
    resultEndpoint.assertIsSatisfied();
  }
  @Test
  public void testUnMarshallingJsonComplete() throws InterruptedException, IOException {
    out.setExpectedMessageCount(1);
    String s = readFile(NOTIFICATION_JSON, Charset.defaultCharset());
    in.sendBody(s);
    out.await(5, TimeUnit.SECONDS);
    out.assertIsSatisfied();
    List<Exchange> exchanges = out.getExchanges();

    for (Exchange exchange : exchanges) {
      Message message = exchange.getIn();
      Notification notif = message.getBody(Notification.class);
      validateNotification(notif);
    }
  }
  @Test
  public void testUnMarshallingJsonSimple() throws InterruptedException, IOException {
    out.setExpectedMessageCount(1);
    String s = readFile(NOTIFICATION_BASIC_JSON, Charset.defaultCharset());
    in.sendBody(s);
    out.await(5, TimeUnit.SECONDS);
    out.assertIsSatisfied();
    List<Exchange> exchanges = out.getExchanges();

    for (Exchange exchange : exchanges) {
      Message message = exchange.getIn();
      Notification notif = message.getBody(Notification.class);
      assertEquals(
          "filterId does not match", "e3c045ec-8028-48ce-9373-93e5b01c690c", notif.getFilterId());
      assertEquals(
          "filterName does not match",
          "Pester Michael about Critical events",
          notif.getFilterName());
      assertEquals(
          "notificationId does not match",
          "4ba705f6-690c-4877-b041-791b84e1e032",
          notif.getNotificationId());
    }
  }