View Javadoc

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