1 /* 2 * $Id: JettyTestCase.java 11394 2008-03-17 15:18:29Z tcarlson $ 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.example.webapp; 12 13 import junit.framework.TestCase; 14 15 import org.mortbay.jetty.Server; 16 import org.mortbay.jetty.webapp.WebAppContext; 17 18 /** 19 * This tests runs in Maven's "integration-test" phase, after the .war has been built. 20 * It starts up the .war inside Jetty and runs tests against the Mule instance. 21 * Note that the MuleClient does not work in this case because we have no access to the 22 * MuleContext (which is inside the Jetty container). 23 */ 24 public class JettyTestCase extends TestCase // TODO MULE-2768 25 { 26 public static final String WEBAPP_WAR_FILE = "./target/mule-example.war"; 27 public static final String WEBAPP_CONTEXT_PATH = "/mule-example"; 28 public static final int JETTY_PORT = 8090; 29 30 private Server jetty = null; 31 32 @Override 33 protected void setUp() throws Exception 34 { 35 super.setUp(); 36 37 if (jetty == null) 38 { 39 jetty = new Server(JETTY_PORT); 40 jetty.addHandler(new WebAppContext(WEBAPP_WAR_FILE, WEBAPP_CONTEXT_PATH)); 41 42 jetty.start(); 43 } 44 } 45 46 @Override 47 protected void tearDown() throws Exception 48 { 49 if (jetty != null) 50 { 51 jetty.stop(); 52 } 53 super.tearDown(); 54 } 55 56 public void testSanity() throws Exception 57 { 58 // empty 59 } 60 61 // This test fails, I'm not sure how we could get the MuleContext from the Web Container. 62 //public void testMuleContextAvailable() throws Exception 63 //{ 64 // MuleContext mc = MuleServer.getMuleContext(); 65 // assertNotNull("MuleContext should have been set by MuleXmlConfigurationBuilder", mc); 66 // assertTrue("MuleContext not initialised", mc.isInitialised()); 67 // assertTrue("MuleContext not started", mc.isStarted()); 68 //} 69 70 // TODO Add the tests from AbstractWebappTestCase, but without using the MuleClient because 71 // MuleClient needs the MuleContext (at least for sending to vm endpoints). 72 }