1   /*
2    * $Id: RestErrorExpressionTestCase.java 10538 2008-01-25 14:43:19Z marie.rizzo $
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.transport.http.components;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.FunctionalTestCase;
16  import org.mule.transport.NullPayload;
17  
18  public class RestErrorExpressionTestCase extends FunctionalTestCase
19  {
20      protected static String TEST_MESSAGE = "Test Http Request";
21  
22      public static class EchoComponent
23      {   
24          public String Echo(String echo) throws Exception
25          {   
26              return echo;
27          }
28      }
29  
30      protected String getConfigResources()
31      {
32          return "http-rest-error-expression-functional-test.xml";
33      }
34  
35      public void testErrorExpressionOnRegexFilterFail() throws Exception
36      {
37          MuleClient client = new MuleClient();
38          MuleMessage result = client.send("restServiceEndpoint", TEST_MESSAGE, null);
39          assertTrue(result.getPayload() instanceof NullPayload);
40      }
41  
42      public void testErrorExpressionOnRegexFilterPass() throws Exception
43      {
44          MuleClient client = new MuleClient();
45          MuleMessage result = client.send("restServiceEndpoint2", TEST_MESSAGE, null);
46          assertEquals("echo=" + TEST_MESSAGE,result.getPayloadAsString());
47      }
48  }