??????????

package junitbook.container;

import org.apache.cactus.ServletTestCase;
import org.apache.cactus.WebRequest;

public class TestSampleServletIntegration extends ServletTestCase
{
    private SampleServlet servlet;  

    public static Test suite()
    {
        System.setProperty("cactus.contextURL"?? "http://localhost:8080/test");// ???????????????

        TestSuite suite = new TestSuite("All tests with Jetty");
        suite.addTestSuite(TestSampleServletIntegration.class);
        return new Jetty5XTestSetup(suite);
    }

    protected void setUp()
    {
        servlet = new SampleServlet();
    }
  
    public void testIsAuthenticatedAuthenticated()
    {
        session.setAttribute("authenticated"?? "true");
      
        assertTrue(servlet.isAuthenticated(request));
    }

    public void testIsAuthenticatedNotAuthenticated()
    {
        assertFalse(servlet.isAuthenticated(request));
    }

    public void beginIsAuthenticatedNoSession(WebRequest request)
    {
        request.setAutomaticSession(false);
    }
  
    public void testIsAuthenticatedNoSession()
    {
        assertFalse(servlet.isAuthenticated(request));
    }
}

?????м?????????

????1.??????????ServletTestCase????????session??request??response?????????

????2.jetty?????????????汾?????cactus???а涼?????????jetty????lib??????????????????д?????????????????????????????java.lang.NoSuchMethodException: org.mortbay.jetty.nio.SelectChannelConnector.setPort(java.lang.String)????????????jetty???а??У?setPort????????int????????????????cactus??????????

????3.???????commons codec???jar

????4.???jetty??5.x????Jetty5XTestSetup???????6.x????Jetty6XTestSetup????????????cactus??????jetty5.1.9??org.mortbay.jetty-5.1.9.jar??????????Jetty5XTestSetup??

??????Щ??jetty????????????仹??о?????????????struts2??