View Javadoc

1   /*
2    * $Id$
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.test.routing;
12  
13  import org.mule.api.ExceptionPayload;
14  import org.mule.api.MessagingException;
15  import org.mule.api.MuleMessage;
16  import org.mule.module.client.MuleClient;
17  import org.mule.tck.FunctionalTestCase;
18  
19  public class FirstSuccessfulTestCase extends FunctionalTestCase
20  {
21      @Override
22      protected String getConfigResources()
23      {
24          return "first-successful-test.xml";
25      }
26  
27      public void testFirstSuccessful() throws Exception
28      {
29          MuleClient client = new MuleClient(muleContext);
30          MuleMessage response = client.send("vm://input", "XYZ", null);
31          assertEquals("XYZ is a string", response.getPayloadAsString());
32          response = client.send("vm://input", Integer.valueOf(9), null);
33          assertEquals("9 is an integer", response.getPayloadAsString());
34          response = client.send("vm://input", Long.valueOf(42), null);
35          assertEquals("42 is a number", response.getPayloadAsString());
36          response = client.send("vm://input", Boolean.TRUE, null);
37          ExceptionPayload ep = response.getExceptionPayload();
38          assertNotNull(ep);
39          Throwable ex = ep.getException();
40          assertTrue(ex instanceof MessagingException);
41      }
42  
43  }