1   /*
2    * $Id: HttpRequestWildcardFilterTestCase.java 7963 2007-08-21 08:53:15Z dirk.olmes $
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.providers.http.filters;
12  
13  import org.mule.extras.client.MuleClient;
14  import org.mule.providers.http.HttpConnector;
15  import org.mule.providers.http.HttpConstants;
16  import org.mule.tck.FunctionalTestCase;
17  import org.mule.umo.UMOMessage;
18  
19  import java.util.HashMap;
20  import java.util.Map;
21  
22  public class HttpRequestWildcardFilterTestCase extends FunctionalTestCase
23  {
24  
25  
26      public HttpRequestWildcardFilterTestCase()
27      {
28          setDisposeManagerPerSuite(true);
29      }
30  
31      protected String getConfigResources()
32      {
33          return "http-wildcard-filter-test.xml";
34      }
35  
36      private static final String HTTP_ENDPOINT = "http://localhost:60201";
37      private static final String TEST_MESSAGE = "Hello=World";
38      private static final String TEST_BAD_MESSAGE = "xyz";
39  
40  
41      public void testHttpPost() throws Exception
42      {
43          MuleClient client = new MuleClient();
44          UMOMessage result = client.send(HTTP_ENDPOINT, TEST_MESSAGE, null);
45  
46          assertEquals(TEST_MESSAGE, result.getPayloadAsString());
47      }
48  
49      public void testHttpGetNotFilter() throws Exception
50      {
51          Map props = new HashMap();
52          props.put(HttpConstants.METHOD_GET, "true");
53          MuleClient client = new MuleClient();
54          UMOMessage result = client.send(HTTP_ENDPOINT, TEST_MESSAGE, props);
55  
56          assertEquals(TEST_MESSAGE, result.getPayloadAsString());
57      }
58  
59      public void testHttpGetFilter() throws Exception
60      {
61          Map props = new HashMap();
62          props.put(HttpConstants.METHOD_GET, "true");
63          MuleClient client = new MuleClient();
64          UMOMessage result = client.send(HTTP_ENDPOINT, TEST_BAD_MESSAGE, props);
65          assertEquals(HttpConstants.SC_NOT_ACCEPTABLE, result.getIntProperty(HttpConnector.HTTP_STATUS_PROPERTY, 0));
66          assertNotNull(result.getExceptionPayload());
67      }
68  }