View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transport.ajax;
8   
9   import org.mule.transport.ajax.container.MuleAjaxServlet;
10  import org.mule.transport.servlet.MuleServletContextListener;
11  
12  import org.mortbay.jetty.Server;
13  import org.mortbay.jetty.servlet.Context;
14  import org.mortbay.jetty.servlet.ServletHolder;
15  
16  public class AjaxContainerFunctionalJsonBindingsTestCase extends AjaxFunctionalJsonBindingsTestCase
17  {
18  
19      private Server httpServer;
20  
21       @Override
22      protected String getConfigResources()
23      {
24          return "ajax-container-functional-json-bindings-test.xml";
25      }
26  
27      @Override
28      protected void doSetUp() throws Exception
29      {
30          // FIXME DZ: we don't use the inherited SERVER_PORT here because it's not set
31          // at this point and we can't move super.doSetUp() above this
32          httpServer = new Server(dynamicPort.getNumber());
33  
34          Context c = new Context(httpServer, "/", Context.SESSIONS);
35          c.addServlet(new ServletHolder(new MuleAjaxServlet()), "/ajax/*");
36          c.addEventListener(new MuleServletContextListener(muleContext, null));
37  
38          httpServer.start();
39  
40          super.doSetUp();
41      }
42  
43      @Override
44      protected void doTearDown() throws Exception
45      {
46          super.doTearDown();
47          if (httpServer != null)
48          {
49              httpServer.stop();
50          }
51      }
52  }