1   /*
2    * $Id: JettyHttpStemTestCase.java 12323 2008-07-13 20:07:11Z rossmason $
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.servlet.jetty.functional;
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.http.HttpConnector;
17  
18  
19  public class JettyHttpStemTestCase extends FunctionalTestCase
20  {
21  
22      protected String getConfigResources()
23      {
24          return "jetty-http-stem-test.xml";
25      }
26  
27      public void testStemMatchingHttp() throws Exception
28      {
29          MuleClient client = new MuleClient();
30          doTest(client, "http://localhost:60200/foo");
31          doTest(client, "http://localhost:60200/foo/bar");
32      }
33  
34      public void testStemMatchingWthoutWildcards() throws Exception
35      {
36          MuleClient client = new MuleClient();
37          doTest(client, "http://localhost:60202/foo");
38          try
39          {
40              doTest(client, "http://localhost:60202/foo/bar");
41              fail("endpoint not using a wildcard, the request should not be matched");
42          }
43          catch (Throwable e)
44          {
45              //Expected
46          }
47      }
48  
49      protected void doTest(MuleClient client, String url) throws Exception
50      {
51          MuleMessage result = client.send(url, "Hello", null);
52          assertEquals("Hello World", result.getPayloadAsString());
53          assertEquals(200, result.getIntProperty(HttpConnector.HTTP_STATUS_PROPERTY, 0));
54      }
55  
56  }