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