View Javadoc

1   /*
2    * $Id: AjaxRPCContainerFunctionalTestCase.java 19866 2010-10-08 20:17:09Z dzapata $
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.ajax;
12  
13  import org.mule.transport.ajax.container.MuleAjaxServlet;
14  import org.mule.transport.servlet.MuleServletContextListener;
15  
16  import org.mortbay.jetty.Server;
17  import org.mortbay.jetty.servlet.Context;
18  import org.mortbay.jetty.servlet.ServletHolder;
19  
20  public class AjaxRPCContainerFunctionalTestCase extends AjaxRPCFunctionalTestCase
21  {
22      private Server httpServer;
23  
24      @Override
25      protected void doSetUp() throws Exception
26      {
27          // FIXME DZ: we don't use the inherited SERVER_PORT here because it's not set
28          // at this point and we can't move super.doSetUp() above this        
29          httpServer = new Server(getPorts().get(0));
30  
31          Context c = new Context(httpServer, "/", Context.SESSIONS);
32          c.addServlet(new ServletHolder(new MuleAjaxServlet()), "/ajax/*");
33          c.addEventListener(new MuleServletContextListener(muleContext, null));
34  
35          httpServer.start();
36  
37          super.doSetUp();
38      }
39  
40      @Override
41      protected void doTearDown() throws Exception
42      {
43          super.doTearDown();
44          if (httpServer != null)
45          {
46              httpServer.stop();
47          }
48      }
49  
50      @Override
51      protected String getConfigResources()
52      {
53          return "ajax-container-rpc-test.xml";
54      }
55  }