@Override
  public void handleMessage(final Exchange exchange) throws HandlerException {
    _messages.offer(exchange);

    if (_behavior == null
        || exchange
            .getContract()
            .getProviderOperation()
            .getExchangePattern()
            .equals(ExchangePattern.IN_ONLY)) {
      return;
    }

    switch (_behavior) {
      case FORWARD_IN_TO_OUT:
        exchange.send(exchange.getMessage().copy());
        break;
      case FORWARD_IN_TO_FAULT:
        exchange.sendFault(exchange.getMessage().copy());
        break;
      case REPLY_WITH_OUT:
        exchange.send(exchange.createMessage().setContent(_replyContent));
        break;
      case REPLY_WITH_FAULT:
        exchange.sendFault(exchange.createMessage().setContent(_replyContent));
        break;
    }
  }
Beispiel #2
0
 @Test
 public void testSendFaultOnNewExchange() {
   Exchange exchange = new ExchangeImpl(_domain, _dispatch);
   try {
     exchange.sendFault(exchange.createMessage());
     Assert.fail("Sending a fault on a new exchange is not allowed");
   } catch (IllegalStateException illEx) {
     return;
   }
 }
Beispiel #3
0
 @Test
 public void testNullSendFault() {
   Exchange exchange = new ExchangeImpl(_domain, _dispatch);
   try {
     exchange.sendFault(null);
     Assert.fail("Expected IllegalArgumentException.");
   } catch (IllegalArgumentException e) {
     Assert.assertEquals("Invalid null 'message' argument in method call.", e.getMessage());
   }
 }