View Javadoc

1   /*
2    * $Id: JettyHttpStemTestCase.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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      @Override
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(muleContext);
30          doTest(client, "http://localhost:60230/foo", "Hello World");
31          doTest(client, "http://localhost:60230/foo/bar", "Hello World");
32          doTest(client, "http://localhost:60230/foo/bestmatch", "Hello World Best Match");
33      }
34  
35      protected void doTest(MuleClient client, String url, String value) throws Exception
36      {
37          MuleMessage result = client.send(url, "Hello", null);
38          assertEquals(value, result.getPayloadAsString());
39          final int status = result.getInboundProperty(HttpConnector.HTTP_STATUS_PROPERTY, 0);
40          assertEquals(200, status);
41      }
42  }