Package org.apache.cactus

Examples of org.apache.cactus.ServletTestCase


     * @see TestCase#setUp
     */
    protected void setUp()
    {
        // let the generator initialize
        UniqueGenerator.generate(new ServletTestCase("foo"));
    }
View Full Code Here


     * Simulates several simultaneous id generations using threads.
     * Verifies that there are no duplicates among the generated ids.
     */
    public void testThatSimultaneouslyGeneratedIdsAreUnique()
    {
        final ServletTestCase aTestCase = new ServletTestCase("foo");

        Thread[] threads = new Thread[10];
        final List results = Collections.synchronizedList(new ArrayList());
        for (int i = 0; i < threads.length; i++)
        {
View Full Code Here

     * Sanity check to verify that different IDs are generated for different
     * instances of the test class.
     */
    public void testThatGeneratedIdsForDifferentTestCasesAreUnique()
    {
        final ServletTestCase firstTestCase = new ServletTestCase("foo");
        final ServletTestCase secondTestCase = new ServletTestCase("foo");
       
        String firstId = UniqueGenerator.generate(firstTestCase, 0);
        String secondId = UniqueGenerator.generate(secondTestCase, 0);

        assertFalse("IDs not unique", firstId.equals(secondId));
View Full Code Here

     * Sanity check to verify that different IDs are generated for different
     * test methods/names.
     */
    public void testThatGeneratedIdsForDifferentTestMethodsAreUnique()
    {
        final ServletTestCase aTestCase = new ServletTestCase("foo");
       
        String firstId = UniqueGenerator.generate(aTestCase, 0);
        aTestCase.setName("bar");
        String secondId = UniqueGenerator.generate(aTestCase, 0);

        assertFalse("IDs not unique", firstId.equals(secondId));
    }
View Full Code Here

        if (!(theTestInstance instanceof ServletTestCase))
        {
            return;
        }
       
        ServletTestCase servletInstance = (ServletTestCase) theTestInstance;
        ServletImplicitObjects servletImplicitObjects =
            (ServletImplicitObjects) this.webImplicitObjects;

        // Sets the request field of the test case class
        // ---------------------------------------------
        // Extract from the HTTP request the URL to simulate (if any)
        HttpServletRequest request =
            servletImplicitObjects.getHttpServletRequest();

        ServletURL url = ServletURL.loadFromRequest(request);

        Field requestField = servletInstance.getClass().getField("request");

        requestField.set(servletInstance,
            new HttpServletRequestWrapper(request, url));

        // Set the response field of the test case class
        // ---------------------------------------------
        Field responseField = servletInstance.getClass().getField("response");

        responseField.set(servletInstance,
            servletImplicitObjects.getHttpServletResponse());

        // Set the config field of the test case class
        // -------------------------------------------
        Field configField = servletInstance.getClass().getField("config");

        configField.set(servletInstance, new ServletConfigWrapper(
            servletImplicitObjects.getServletConfig()));

        // Set the session field of the test case class
        // --------------------------------------------
        // Create a Session object if the auto session flag is on
        if (isAutoSession())
        {
            HttpSession session = servletImplicitObjects.getHttpServletRequest()
                .getSession(true);

            Field sessionField = servletInstance.getClass().getField("session");

            sessionField.set(servletInstance, session);
        }
    }
View Full Code Here

     * @see AbstractWebTestCaller#setTestCaseFields(AbstractTestCase)
     */
    protected void setTestCaseFields(AbstractTestCase theTestInstance)
        throws Exception
    {
        ServletTestCase servletInstance = (ServletTestCase) theTestInstance;
        ServletImplicitObjects servletImplicitObjects =
            (ServletImplicitObjects) this.webImplicitObjects;

        // Sets the request field of the test case class
        // ---------------------------------------------

        // Extract from the HTTP request the URL to simulate (if any)
        HttpServletRequest request =
            servletImplicitObjects.getHttpServletRequest();

        ServletURL url = ServletURL.loadFromRequest(request);

        Field requestField = servletInstance.getClass().getField("request");
        requestField.set(servletInstance,
            new HttpServletRequestWrapper(request, url));

        // Set the response field of the test case class
        // ---------------------------------------------

        Field responseField = servletInstance.getClass().getField("response");
        responseField.set(servletInstance,
            servletImplicitObjects.getHttpServletResponse());

        // Set the config field of the test case class
        // -------------------------------------------

        Field configField = servletInstance.getClass().getField("config");
        configField.set(servletInstance,
            new ServletConfigWrapper(
                servletImplicitObjects.getServletConfig()));

        // Set the session field of the test case class
        // --------------------------------------------

        // Create a Session object if the auto session flag is on
        if (isAutoSession()) {

            HttpSession session =
                servletImplicitObjects.getHttpServletRequest().getSession(true);

            Field sessionField = servletInstance.getClass().getField("session");
            sessionField.set(servletInstance, session);

        }
    }
View Full Code Here

     * @see TestCase#setUp
     */
    protected void setUp()
    {
        // let the generator initialize
        UniqueGenerator.generate(new ServletTestCase("foo"));
    }
View Full Code Here

     * Simulates several simultaneous id generations using threads.
     * Verifies that there are no duplicates among the generated ids.
     */
    public void testThatSimultaneouslyGeneratedIdsAreUnique()
    {
        final ServletTestCase aTestCase = new ServletTestCase("foo");

        Thread[] threads = new Thread[10];
        final List results = Collections.synchronizedList(new ArrayList());
        for (int i = 0; i < threads.length; i++)
        {
View Full Code Here

     * Sanity check to verify that different IDs are generated for different
     * instances of the test class.
     */
    public void testThatGeneratedIdsForDifferentTestCasesAreUnique()
    {
        final ServletTestCase firstTestCase = new ServletTestCase("foo");
        final ServletTestCase secondTestCase = new ServletTestCase("foo");
       
        String firstId = UniqueGenerator.generate(firstTestCase, 0);
        String secondId = UniqueGenerator.generate(secondTestCase, 0);

        assertFalse("IDs not unique", firstId.equals(secondId));
View Full Code Here

     * Sanity check to verify that different IDs are generated for different
     * test methods/names.
     */
    public void testThatGeneratedIdsForDifferentTestMethodsAreUnique()
    {
        final ServletTestCase aTestCase = new ServletTestCase("foo");
       
        String firstId = UniqueGenerator.generate(aTestCase, 0);
        aTestCase.setName("bar");
        String secondId = UniqueGenerator.generate(aTestCase, 0);

        assertFalse("IDs not unique", firstId.equals(secondId));
    }
View Full Code Here

TOP

Related Classes of org.apache.cactus.ServletTestCase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.