1   /*
2    * $Id: JettyTestCase.java 7976 2007-08-21 14:26:13Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.examples.webapp;
12  
13  import org.mortbay.http.HttpContext;
14  import org.mortbay.jetty.Server;
15  import org.mortbay.jetty.servlet.WebApplicationContext;
16  
17  /**
18  * This is a work in progress.  We may be better off using the maven-jetty-plugin in the "integration-tests"
19  * phase of the m2 lifecycle to test the WAR. 
20  */
21  public class JettyTestCase extends AbstractWebappTestCase
22  {
23      public static final String WEBAPP_WAR_FILE = "/home/travis/mule/examples/webapp/target/mule-examples.war";
24      public static final String WEBAPP_CONTEXT_PATH = "/mule-examples";
25      public static final int JETTY_PORT = 8090;
26      
27      Server jetty = null;
28      
29      protected void doSetUp() throws Exception
30      {
31          super.doSetUp();
32  
33          if (jetty == null)
34          {
35              // Jetty 5.x
36              jetty = new Server();
37              WebApplicationContext wc = new WebApplicationContext(WEBAPP_WAR_FILE);
38              wc.setContextPath(WEBAPP_CONTEXT_PATH);
39              wc.setWAR(WEBAPP_WAR_FILE);
40              jetty.addContext(wc);
41              
42              // Jetty 6.x 
43              //jetty = new Server(JETTY_PORT);
44              //jetty.addHandler(new WebAppContext(WEBAPP_WAR_FILE, WEBAPP_CONTEXT_PATH));
45      
46              jetty.start();
47          }
48      }
49  
50      protected void suitePreTearDown() throws Exception
51      {
52          super.suitePreTearDown();
53          if (jetty != null)
54          {
55              jetty.stop();
56          }
57      }
58  }