View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.test.usecases.routing.lookup;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  
13  import org.junit.Test;
14  
15  import static org.junit.Assert.assertFalse;
16  import static org.junit.Assert.assertNotNull;
17  import static org.junit.Assert.assertTrue;
18  
19  /**
20   * The router looks up a list of endpoints from an XML file and passes them to the <recipient-list-exception-based-router>
21   */
22  public class EndpointLookupRouterTestCase extends FunctionalTestCase
23  {
24      
25      @Override
26      protected String getConfigResources()
27      {
28          return "org/mule/test/usecases/routing/lookup/router-config.xml, org/mule/test/usecases/routing/lookup/services.xml";
29      }
30  
31      @Test
32      public void testRouterSuccess() throws Exception
33      {
34          MuleClient client = new MuleClient(muleContext);
35          MuleMessage reply = client.send("vm://router", "GetID", null);
36          assertNotNull(reply);
37          assertTrue(reply.getPayloadAsString().contains("<ErrorStatus>Success</ErrorStatus>"));
38      }
39  
40      @Test
41      public void testRouterFailure() throws Exception
42      {
43          MuleClient client = new MuleClient(muleContext);
44          MuleMessage reply = client.send("vm://routerBad", "GetID", null);
45          assertNotNull(reply);
46          assertFalse(reply.getPayloadAsString().contains("<ErrorStatus>Success</ErrorStatus>"));
47      }
48  }
49  
50