View Javadoc

1   /*
2    * $Id: AjaxContainerFunctionalJsonBindingsTestCase.java 22460 2011-07-20 07:44:33Z claude.mamo $
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 java.util.Arrays;
17  import java.util.Collection;
18  
19  import org.junit.runners.Parameterized.Parameters;
20  import org.mortbay.jetty.Server;
21  import org.mortbay.jetty.servlet.Context;
22  import org.mortbay.jetty.servlet.ServletHolder;
23  
24  public class AjaxContainerFunctionalJsonBindingsTestCase extends AjaxFunctionalJsonBindingsTestCase
25  {
26  
27      public AjaxContainerFunctionalJsonBindingsTestCase(ConfigVariant variant, String configResources)
28      {
29          super(variant, configResources);     
30      }
31  
32      private Server httpServer;
33  
34      @Parameters
35      public static Collection<Object[]> parameters()
36      {
37          return Arrays.asList(new Object[][]{
38              {ConfigVariant.SERVICE, "ajax-container-functional-json-bindings-test-service.xml"},
39              {ConfigVariant.FLOW, "ajax-container-functional-json-bindings-test-flow.xml"}});
40      }
41  
42      @Override
43      protected void doSetUp() throws Exception
44      {
45          // FIXME DZ: we don't use the inherited SERVER_PORT here because it's not set
46          // at this point and we can't move super.doSetUp() above this
47          httpServer = new Server(dynamicPort.getNumber());
48  
49          Context c = new Context(httpServer, "/", Context.SESSIONS);
50          c.addServlet(new ServletHolder(new MuleAjaxServlet()), "/ajax/*");
51          c.addEventListener(new MuleServletContextListener(muleContext, null));
52  
53          httpServer.start();
54  
55          super.doSetUp();
56      }
57  
58      @Override
59      protected void doTearDown() throws Exception
60      {
61          super.doTearDown();
62          if (httpServer != null)
63          {
64              httpServer.stop();
65          }
66      }
67  }