Ejemplo n.º 1
0
  public void testDispatchReceiveSimple() throws Exception {
    MuleClient client = new MuleClient();
    client.dispatch("endpoint1", TEST_MESSAGE, null);

    MuleMessage result = client.request("vm://middle", 5000L);
    assertEquals(TEST_MESSAGE + " Received", result.getPayloadAsString());
  }
Ejemplo n.º 2
0
 public void testDelegateClass() throws Exception {
   MuleClient client = new MuleClient();
   client.dispatch(INPUT_DC_QUEUE_NAME, "test", null);
   MuleMessage message = client.request(OUTPUT_DC_QUEUE_NAME, TIMEOUT);
   assertNotNull(message);
   assertEquals(message.getPayload(), DEFUALT_OUTPUT_MESSAGE);
   client.dispose();
 }
  @Test
  public void testEndpointAuthenticated() throws Exception {
    MuleClient client = new MuleClient(muleContext);

    client.dispatch("jms:/messages.in", DECRYPTED_MESSAGE, null);
    MuleMessage result = client.request("jms:/messages.out", 15000);
    assertThat(result.getPayload(), is(not(instanceOf(ExceptionPayload.class))));
    assertThat(result.getPayloadAsString(), equalTo(DECRYPTED_MESSAGE));
  }
Ejemplo n.º 4
0
 public void testWithInjectedDelegate() throws Exception {
   MuleClient client = new MuleClient();
   client.dispatch(INPUT_DI_QUEUE_NAME, DEFAULT_INPUT_MESSAGE, null);
   MuleMessage reply = client.request(OUTPUT_DI_QUEUE_NAME, TIMEOUT);
   assertNotNull(reply);
   assertNull(reply.getExceptionPayload());
   // same as original input
   assertEquals(DEFAULT_INPUT_MESSAGE, reply.getPayload());
 }
 protected Object request(MuleClient client, String endpoint, Class<?> clazz)
     throws MuleException {
   MuleMessage message = client.request(endpoint, TIMEOUT);
   assertNotNull(message);
   assertNotNull(message.getPayload());
   assertTrue(
       message.getPayload().getClass().getName(),
       clazz.isAssignableFrom(message.getPayload().getClass()));
   return message.getPayload();
 }
Ejemplo n.º 6
0
  public void testTransformersOnProtocol() throws Exception {
    MuleClient client = new MuleClient();
    client.dispatch("protocolTransformerClient", msg, null);

    MuleMessage result = client.request("vm://in", 3000);
    assertNotNull(result);
    String resString = result.getPayloadAsString();
    System.out.println(resString);
    assertTrue(resString.indexOf("<transformed xmlns=\"http://foo\"><soap:Envelope") != -1);
  }
Ejemplo n.º 7
0
  public void testDispatchReceiveComplexObjects() throws Exception {
    MuleClient client = new MuleClient();
    FruitBowl bowl = new FruitBowl(new Apple(), new Banana());
    bowl.getApple().setWashed(true);
    client.dispatch("endpoint2", bowl, null);

    MuleMessage result = client.request("vm://middle2", 5000L);
    assertTrue(result.getPayload() instanceof FruitBowl);
    assertTrue(((FruitBowl) result.getPayload()).hasApple());
    assertTrue(((FruitBowl) result.getPayload()).getApple().isWashed());
    assertTrue(((FruitBowl) result.getPayload()).hasBanana());
  }