コード例 #1
0
ファイル: Step1Test.java プロジェクト: howcroft/learning
  @Test
  public void sanityCheck() throws Exception {

    // Mock providers for services called from IntakeService
    MockHandler lookUpService = testKit.registerInOutService("CustomerLookup").replyWithOut(null);
    MockHandler preQualService = testKit.replaceService("PreQualificationService").forwardInToOut();

    service.operation("intake").sendInOnly(createApplication());

    // validate that our downstream service references were called
    Assert.assertEquals(1, lookUpService.getMessages().size());
    Assert.assertEquals(1, preQualService.getMessages().size());
  }
コード例 #2
0
ファイル: HttpGatewayTest.java プロジェクト: rnc/components
 @Test
 public void httpGatewayServiceTest() throws Exception {
   String response =
       httpMixIn.sendString("http://localhost:8080/http", "magesh", HTTPMixIn.HTTP_POST);
   Assert.assertEquals(1, mockService.getMessages().size());
   Assert.assertEquals("magesh", response);
 }
コード例 #3
0
  /** Triggers the 'GreetingService' by sending a HornetQ Mesage to the 'GreetingServiceQueue' */
  @Test
  public void triggerGreetingService() throws Exception {
    final String payload = "dummy payload";
    final MockHandler greetingService = _testKit.registerInOnlyService("GreetingService");

    final ClientProducer producer =
        _mixIn.getClientSession().createProducer("jms.queue.GreetingServiceQueue");
    final ClientMessage message = _mixIn.createMessage(payload);
    producer.send(message);

    Thread.sleep(1000);

    final Exchange recievedExchange = greetingService.getMessages().iterator().next();
    assertThat(recievedExchange.getMessage().getContent(String.class), is(equalTo(payload)));
    HornetQUtil.closeClientProducer(producer);
  }
コード例 #4
0
  @Test
  public void wrongOperationSelectorTest() {
    MockHandler mock = new MockHandler().forwardInToOut();
    JavaService metadata = JavaService.fromClass(TestService.class);
    _serviceDomain.registerService(_serviceName, metadata, mock);
    _serviceDomain.registerServiceReference(_serviceName, metadata);
    InboundHandler<?> handler =
        createInboundHandler(
            _serviceName,
            "direct:input",
            new V1StaticOperationSelectorModel().setOperationName("missing"));
    handler.start();

    sendBody("direct:input", PAYLOAD);
    assertTrue(mock.getMessages().isEmpty());
    handler.stop();
  }
コード例 #5
0
  @Test
  public void contextMapperMapToTest() {
    MockHandler mock = new MockHandler().forwardInToOut();
    _serviceDomain.registerService(_serviceName, _metadata, mock);
    _serviceDomain.registerServiceReference(_serviceName, _metadata);
    InboundHandler<?> handler =
        createInboundHandler(
            _serviceName,
            "direct:input",
            new V1ContextMapperModel().setClazz(Mapper.class.getName()));
    handler.start();

    sendBody("direct:input", PAYLOAD);
    mock.waitForOKMessage();
    List<Exchange> exchanges = new ArrayList<Exchange>();
    mock.getMessages().drainTo(exchanges);
    assertEquals(1, exchanges.size());
    assertEquals(Mapper.VALUE, exchanges.get(0).getContext().getPropertyValue(Mapper.PROPERTY));

    handler.stop();
  }
コード例 #6
0
  @Test
  public void messageComposerComposeTest() {
    MockHandler mock = new MockHandler().forwardInToOut();
    _serviceDomain.registerService(_serviceName, _metadata, mock);
    _serviceDomain.registerServiceReference(_serviceName, _metadata);
    InboundHandler<?> handler =
        createInboundHandler(
            _serviceName,
            "direct:input",
            new V1MessageComposerModel().setClazz(Composer.class.getName()));
    handler.start();

    sendBody("direct:input", PAYLOAD);
    mock.waitForOKMessage();
    List<Exchange> exchanges = new ArrayList<Exchange>();
    mock.getMessages().drainTo(exchanges);
    assertEquals(1, exchanges.size());
    assertEquals(Composer.COMPOSE_PREFIX + PAYLOAD, exchanges.get(0).getMessage().getContent());

    handler.stop();
  }
コード例 #7
0
  @Test
  public void operationSelectorTest() {
    MockHandler mock = new MockHandler().forwardInToOut();
    _serviceDomain.registerService(_serviceName, _metadata, mock);
    _serviceDomain.registerServiceReference(_serviceName, _metadata);
    InboundHandler<?> handler =
        createInboundHandler(
            _serviceName,
            "direct:input",
            new V1StaticOperationSelectorModel().setOperationName(OPERATION_NAME));
    handler.start();

    sendBody("direct:input", PAYLOAD);
    mock.waitForOKMessage();
    List<Exchange> exchanges = new ArrayList<Exchange>();
    mock.getMessages().drainTo(exchanges);
    assertEquals(1, exchanges.size());
    assertEquals(OPERATION_NAME, exchanges.get(0).getContract().getProviderOperation().getName());

    handler.stop();
  }