View Javadoc

1   /*
2    * $Id: WebappsTestCase.java 20435 2010-12-02 11:50:43Z dirk.olmes $
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;
12  
13  import org.mule.DefaultMuleMessage;
14  import org.mule.api.MuleMessage;
15  import org.mule.client.DefaultLocalMuleClient;
16  import org.mule.tck.FunctionalTestCase;
17  import org.mule.transport.http.HttpConnector;
18  
19  import java.io.File;
20  import java.util.HashMap;
21  import java.util.Map;
22  
23  import org.apache.commons.io.FileUtils;
24  
25  public class WebappsTestCase extends FunctionalTestCase
26  {
27  
28      public WebappsTestCase() throws Exception
29      {
30          File webapps = new File("target/webapps");
31          FileUtils.deleteDirectory(webapps);
32          webapps.mkdir();
33          
34          FileUtils.copyFile(new File("src/test/resources/test.war"), new File(webapps, "test.war"));
35      }
36      
37      public void testWebapps() throws Exception
38      {
39          Map<String,Object> props = new HashMap<String,Object>();
40          props.put(HttpConnector.HTTP_METHOD_PROPERTY, "GET");
41          
42          DefaultLocalMuleClient client = new DefaultLocalMuleClient(muleContext);
43          MuleMessage result = client.send("http://localhost:63081/test/hello", 
44              new DefaultMuleMessage("", muleContext),
45              props);
46          
47          assertEquals("Hello", result.getPayloadAsString());
48      }
49      
50      @Override
51      protected String getConfigResources()
52      {
53          return "jetty-webapps.xml";
54      }
55  
56  
57  }