Added: 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestServletConfig.java
URL: 
http://svn.apache.org/viewvc/jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestServletConfig.java?rev=698559&view=auto
==============================================================================
--- 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestServletConfig.java
 (added)
+++ 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestServletConfig.java
 Wed Sep 24 06:20:11 2008
@@ -0,0 +1,149 @@
+/* 
+ * ========================================================================
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * ========================================================================
+ */
+package org.apache.cactus.sample.servlet.unit;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+import javax.servlet.ServletContext;
+
+import org.apache.cactus.ServletTestCase;
+import org.apache.cactus.server.ServletContextWrapper;
+
+/**
+ * Tests that exercise the Cactus Servlet Config wrapper.
+ *
+ * @version $Id: TestServletConfig.java 239054 2004-10-24 01:30:23Z felipeal $
+ */
+public class TestServletConfig extends ServletTestCase
+{
+    /**
+     * Verify that we can add parameters to the config list of parameters
+     * programatically, without having to define them in <code>web.xml</code>.
+     */
+    public void testSetConfigParameter()
+    {
+        config.setInitParameter("testparam", "test value");
+
+        assertEquals("test value", config.getInitParameter("testparam"));
+
+        boolean found = false;
+        Enumeration en = config.getInitParameterNames();
+
+        while (en.hasMoreElements())
+        {
+            String name = (String) en.nextElement();
+
+            if (name.equals("testparam"))
+            {
+                found = true;
+
+                break;
+            }
+        }
+
+        assertTrue("[testparam] not found in parameter names", found);
+    }
+
+    //-------------------------------------------------------------------------
+
+    /**
+     * Verify that calling <code>setInitParameter()</code> with a parameter
+     * already defined in <code>web.xml</code> will override it.
+     */
+    public void testSetConfigParameterOverrideWebXmlParameter()
+    {
+        // Note: "param1" is a parameter that must be defined on the Servlet
+        // redirector, with a value different than "testoverrideparam1".
+        assertTrue(
+            config.getOriginalConfig().getInitParameter("param1") != null);
+        assertTrue(
+            !config.getOriginalConfig().getInitParameter("param1").equals(
+            "testoverrideparam1"));
+
+        config.setInitParameter("param1", "testoverrideparam1");
+
+        Enumeration en = config.getInitParameterNames();
+        int count = 0;
+        
+        while (en.hasMoreElements())
+        {
+            String name = (String) en.nextElement();
+
+            if (name.equals("param1"))
+            {
+                assertEquals("testoverrideparam1",
+                    config.getInitParameter(name));
+                count++;
+            }
+        }
+
+        assertTrue("[param1] was found " + count + " times. Should have "
+            + "been found once.", count == 1);
+    }
+
+    //-------------------------------------------------------------------------
+
+    /**
+     * Verify that we can override the
+     * <code>ServletConfig.getServletName()</code> method.
+     */
+    public void testGetServletNameOverriden()
+    {
+        config.setServletName("MyServlet");
+        assertEquals("MyServlet", config.getServletName());
+        assertTrue(!config.getOriginalConfig().getServletName().equals(
+            config.getServletName()));
+    }
+
+    //-------------------------------------------------------------------------
+
+    /**
+     * Verify that if we don't override the servlet name we get the original
+     * name (i.e. Cactus is effectively transparent).
+     */
+    public void testGetServletNameNoOverride()
+    {
+        assertEquals(config.getOriginalConfig().getServletName(),
+            config.getServletName());
+    }
+
+    //-------------------------------------------------------------------------
+
+    /**
+     * Verify that calls to <code>ServletContext.log()</code> methods can
+     * be retrieved and asserted.
+     */
+    public void testGetLogs()
+    {
+        String message = "some test log";
+        ServletContext context = config.getServletContext();
+
+        context.log(message);
+
+        Vector logs = ((ServletContextWrapper) context).getLogs();
+
+        assertEquals("Found more than one log message", logs.size(), 1);
+        assertTrue("Cannot find expected log message : [" + message + "]", 
+            logs.contains("some test log"));
+    }
+
+}

Propchange: 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestServletConfig.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestServletContext.java
URL: 
http://svn.apache.org/viewvc/jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestServletContext.java?rev=698559&view=auto
==============================================================================
--- 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestServletContext.java
 (added)
+++ 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestServletContext.java
 Wed Sep 24 06:20:11 2008
@@ -0,0 +1,114 @@
+/* 
+ * ========================================================================
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * ========================================================================
+ */
+package org.apache.cactus.sample.servlet.unit;
+
+import java.util.Enumeration;
+
+import org.apache.cactus.ServletTestCase;
+import org.apache.cactus.server.ServletContextWrapper;
+
+/**
+ * Tests that exercise the Cactus Servlet Context wrapper.
+ *
+ * @version $Id: TestServletContext.java 239054 2004-10-24 01:30:23Z felipeal $
+ */
+public class TestServletContext extends ServletTestCase
+{
+    /**
+     * The Cactus servlet context wrapper. 
+     */
+    private ServletContextWrapper context;
+
+    /**
+     * Common initialization steps for all tests.
+     */
+    public void setUp()
+    {
+        context = (ServletContextWrapper) config.getServletContext();
+    }
+    
+    /**
+     * Verify that we can add parameters to the context list of parameters
+     * programatically, without having to define them in <code>web.xml</code>.
+     */
+    public void testSetContextInitParameterUsingApi()
+    {
+        context.setInitParameter("testparam", "test value");
+
+        assertEquals("test value", context.getInitParameter("testparam"));
+
+        boolean found = false;
+        Enumeration en = context.getInitParameterNames();
+
+        while (en.hasMoreElements())
+        {
+            String name = (String) en.nextElement();
+
+            if (name.equals("testparam"))
+            {
+                found = true;
+
+                break;
+            }
+        }
+
+        assertTrue("[testparam] not found in parameter names", found);
+    }
+
+    //-------------------------------------------------------------------------
+
+    /**
+     * Verify that calling <code>setInitParameter()</code> with a parameter
+     * already defined in <code>web.xml</code> will override it.
+     */
+    public void testSetContextInitParameterOverrideWebXmlParameter()
+    {
+        // Note: "param1" is a parameter that must be already defined in
+        // web.xml (in the context-param element), with a value different
+        // than "testoverrideparam1".
+        assertTrue("'param' context-param should been defined in web.xml",
+            context.getOriginalContext().getInitParameter("param") != null);
+        assertTrue(
+            !context.getOriginalContext().getInitParameter("param").equals(
+            "testoverrideparam"));
+
+        context.setInitParameter("param", "testoverrideparam");
+
+        Enumeration en = context.getInitParameterNames();
+        int count = 0;
+        
+        while (en.hasMoreElements())
+        {
+            String name = (String) en.nextElement();
+
+            if (name.equals("param"))
+            {
+                assertEquals("testoverrideparam",
+                    context.getInitParameter(name));
+                count++;
+            }
+        }
+
+        assertTrue("[param] was found " + count + " times. Should have "
+            + "been found once.", count == 1);
+    }
+
+}

Propchange: 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestServletContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestServletRedirectorOverride.java
URL: 
http://svn.apache.org/viewvc/jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestServletRedirectorOverride.java?rev=698559&view=auto
==============================================================================
--- 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestServletRedirectorOverride.java
 (added)
+++ 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestServletRedirectorOverride.java
 Wed Sep 24 06:20:11 2008
@@ -0,0 +1,89 @@
+/* 
+ * ========================================================================
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * ========================================================================
+ */
+package org.apache.cactus.sample.servlet.unit;
+
+import org.apache.cactus.ServletTestCase;
+import org.apache.cactus.WebRequest;
+
+/**
+ * Test that it is possible to override a servlet redirector as defined in
+ * <code>cactus.properties</code> on a per test case basis.
+ *
+ * @version $Id: TestServletRedirectorOverride.java 238816 2004-02-29 
16:36:46Z vmassol $
+ */
+public class TestServletRedirectorOverride extends ServletTestCase
+{
+    /**
+     * Verify that it is possible to override the default redirector.
+     *
+     * @param theRequest the request object that serves to initialize the
+     *                   HTTP connection to the server redirector.
+     */
+    public void beginRedirectorOverride1(WebRequest theRequest)
+    {
+        theRequest.setRedirectorName("ServletRedirectorOverride");
+    }
+
+    /**
+     * Verify that it is possible to override the default redirector.
+     */
+    public void testRedirectorOverride1()
+    {
+        assertEquals("value2 used for testing", 
+            config.getInitParameter("param2"));
+    }
+
+    //-------------------------------------------------------------------------
+
+    /**
+     * Verify that it is possible to set back the original redirector
+     * again.
+     *
+     * @param theRequest the request object that serves to initialize the
+     *                   HTTP connection to the server redirector.
+     */
+    public void beginRedirectorOverride2(WebRequest theRequest)
+    {
+        theRequest.setRedirectorName("ServletRedirector");
+    }
+
+    /**
+     * Verify that it is possible to set back the original redirector
+     * again.
+     */
+    public void testRedirectorOverride2()
+    {
+        assertEquals("value1 used for testing", 
+            config.getInitParameter("param1"));
+    }
+
+    //-------------------------------------------------------------------------
+
+    /**
+     * Verify that when no redirector is overriden the default redirector
+     * is the expected one.
+     */
+    public void testRedirectorOverride3()
+    {
+        assertEquals("value1 used for testing", 
+            config.getInitParameter("param1"));
+    }
+}

Propchange: 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestServletRedirectorOverride.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestSetURL.java
URL: 
http://svn.apache.org/viewvc/jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestSetURL.java?rev=698559&view=auto
==============================================================================
--- 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestSetURL.java
 (added)
+++ 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestSetURL.java
 Wed Sep 24 06:20:11 2008
@@ -0,0 +1,225 @@
+/* 
+ * ========================================================================
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * ========================================================================
+ */
+package org.apache.cactus.sample.servlet.unit;
+
+import org.apache.cactus.ServletTestCase;
+import org.apache.cactus.WebRequest;
+
+/**
+ * Test the [EMAIL PROTECTED] WebRequest#setURL} method.
+ *
+ * @version $Id: TestSetURL.java 238816 2004-02-29 16:36:46Z vmassol $
+ */
+public class TestSetURL extends ServletTestCase
+{
+    /**
+     * Verify that we can simulate the basic parts of the URL : server name,
+     * default server port of 80, root servlet context, URI.
+     *
+     * @param theRequest the request object that serves to initialize the
+     *                   HTTP connection to the server redirector.
+     */
+    public void beginSimulatedURLBasics(WebRequest theRequest)
+    {
+        theRequest.setURL("jakarta.apache.org", "", "/test/test.jsp", null, 
+            null);
+    }
+
+    /**
+     * Verify that we can simulate the basic parts of the URL : server name,
+     * default server port of 80, no servlet context, servlet path.
+     */
+    public void testSimulatedURLBasics()
+    {
+        assertEquals("/test/test.jsp", request.getRequestURI());
+        assertEquals("jakarta.apache.org", request.getServerName());
+        assertEquals(80, request.getServerPort());
+        assertEquals("", request.getContextPath());
+    }
+
+    //-------------------------------------------------------------------------
+
+    /**
+     * Verify that we can simulate different parts of the URL.
+     *
+     * @param theRequest the request object that serves to initialize the
+     *                   HTTP connection to the server redirector.
+     */
+    public void beginSimulatedURL1(WebRequest theRequest)
+    {
+        theRequest.setURL("jakarta.apache.org", "/mywebapp", "/test/test.jsp", 
+            null, null);
+    }
+
+    /**
+     * Verify that we can simulate different parts of the URL.
+     */
+    public void testSimulatedURL1()
+    {
+        assertEquals("/mywebapp/test/test.jsp", request.getRequestURI());
+        assertEquals("jakarta.apache.org", request.getServerName());
+        assertEquals(80, request.getServerPort());
+        assertEquals("/mywebapp", request.getContextPath());
+    }
+
+    //-------------------------------------------------------------------------
+
+    /**
+     * Verify that we can simulate different parts of the URL.
+     *
+     * @param theRequest the request object that serves to initialize the
+     *                   HTTP connection to the server redirector.
+     */
+    public void beginSimulatedURL2(WebRequest theRequest)
+    {
+        theRequest.setURL("jakarta.apache.org", "/catalog", "/lawn", 
+            "/index.html", null);
+    }
+
+    /**
+     * Verify that we can simulate different parts of the URL.
+     */
+    public void testSimulatedURL2()
+    {
+        assertEquals("jakarta.apache.org", request.getServerName());
+        assertEquals("/catalog/lawn/index.html", request.getRequestURI());
+        assertEquals(80, request.getServerPort());
+        assertEquals("/catalog", request.getContextPath());
+        assertEquals("/lawn", request.getServletPath());
+        assertEquals("/index.html", request.getPathInfo());
+    }
+
+    //-------------------------------------------------------------------------
+
+    /**
+     * Verify that we can simulate different parts of the URL.
+     *
+     * @param theRequest the request object that serves to initialize the
+     *                   HTTP connection to the server redirector.
+     */
+    public void beginSimulatedURL3(WebRequest theRequest)
+    {
+        theRequest.setURL("jakarta.apache.org", "/catalog", "/garden", 
+            "/implements/", null);
+    }
+
+    /**
+     * Verify that we can simulate different parts of the URL.
+     */
+    public void testSimulatedURL3()
+    {
+        assertEquals("jakarta.apache.org", request.getServerName());
+        assertEquals("/catalog/garden/implements/", request.getRequestURI());
+        assertEquals(80, request.getServerPort());
+        assertEquals("/catalog", request.getContextPath());
+        assertEquals("/garden", request.getServletPath());
+        assertEquals("/implements/", request.getPathInfo());
+    }
+
+    //-------------------------------------------------------------------------
+
+    /**
+     * Verify that we can simulate different parts of the URL.
+     *
+     * @param theRequest the request object that serves to initialize the
+     *                   HTTP connection to the server redirector.
+     */
+    public void beginSimulatedURL4(WebRequest theRequest)
+    {
+        theRequest.setURL("jakarta.apache.org", "/catalog", 
+            "/help/feedback.jsp", null, null);
+    }
+
+    /**
+     * Verify that we can simulate different parts of the URL.
+     */
+    public void testSimulatedURL4()
+    {
+        assertEquals("jakarta.apache.org", request.getServerName());
+        assertEquals("/catalog/help/feedback.jsp", request.getRequestURI());
+        assertEquals(80, request.getServerPort());
+        assertEquals("/catalog", request.getContextPath());
+        assertEquals("/help/feedback.jsp", request.getServletPath());
+    }
+
+    //-------------------------------------------------------------------------
+
+    /**
+     * Verify that we can simulate different parts of the URL. Also verify
+     * that HTTP parameters put in the simulation URL will be
+     * available on the server side as real HTTP parameters.
+     *
+     * @param theRequest the request object that serves to initialize the
+     *                   HTTP connection to the server redirector.
+     */
+    public void beginSimulatedURL5(WebRequest theRequest)
+    {
+        theRequest.setURL("jakarta.apache.org", "/catalog", 
+            "/help/feedback.jsp", null, "PARAM1=param1&PARAM2=&PARAM3=param3");
+    }
+
+    /**
+     * Verify that we can simulate different parts of the URL. Also verify
+     * that HTTP parameters put in the simulation URL will be
+     * available on the server side as real HTTP parameters.
+     */
+    public void testSimulatedURL5()
+    {
+        assertEquals("jakarta.apache.org", request.getServerName());
+        assertEquals("/catalog/help/feedback.jsp", request.getRequestURI());
+        assertEquals(80, request.getServerPort());
+        assertEquals("/catalog", request.getContextPath());
+        assertEquals("/help/feedback.jsp", request.getServletPath());
+        assertEquals("PARAM1=param1&PARAM2=&PARAM3=param3", 
+            request.getQueryString());
+        assertEquals(request.getParameter("PARAM1"), "param1");
+        assertEquals(request.getParameter("PARAM2"), "");
+        assertEquals(request.getParameter("PARAM3"), "param3");
+    }
+
+    //-------------------------------------------------------------------------
+
+    /**
+     * Verify values used by the framework when all values defined in 
+     * <code>setURL()</code> are null.
+     *
+     * @param theRequest the request object that serves to initialize the
+     *                   HTTP connection to the server redirector.
+     */
+    public void beginSimulatedURLNullValues(WebRequest theRequest)
+    {
+        theRequest.setURL(null, null, null, null, null);
+    }
+
+    /**
+     * Verify values used by the framework when all values defined in 
+     * <code>setURL()</code> are null.
+     */
+    public void testSimulatedURLNullValues()
+    {
+        assertNotNull(request.getServerName());
+        assertTrue(request.getServerPort() > 0);
+        assertNotNull(request.getContextPath());       
+        assertNotNull(request.getServletPath());       
+        assertNull(request.getPathInfo());       
+        assertNull(request.getQueryString());       
+    }
+}

Propchange: 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestSetURL.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestSetURLSpecific.java
URL: 
http://svn.apache.org/viewvc/jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestSetURLSpecific.java?rev=698559&view=auto
==============================================================================
--- 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestSetURLSpecific.java
 (added)
+++ 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestSetURLSpecific.java
 Wed Sep 24 06:20:11 2008
@@ -0,0 +1,86 @@
+/* 
+ * ========================================================================
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * ========================================================================
+ */
+package org.apache.cactus.sample.servlet.unit;
+
+import org.apache.cactus.ServletTestCase;
+import org.apache.cactus.WebRequest;
+
+/**
+ * Test the J2EE 1.3 specifics of the [EMAIL PROTECTED] WebRequest#setURL} 
method
+ * (specifically verify calls to <code>getRequestURL</code>).
+ *
+ * @version $Id: TestSetURLSpecific.java 238816 2004-02-29 16:36:46Z vmassol $
+ */
+public class TestSetURLSpecific extends ServletTestCase
+{
+    /**
+     * Verify that when <code>setURL()</code> is called with a null
+     * pathinfo parameter, the call to <code>getRequestURL</code> works
+     * properly.
+     *
+     * @param theRequest the request object that serves to initialize the
+     *                   HTTP connection to the server redirector.
+     */
+    public void beginSimulatedURLGetRequestURLWhenNull(WebRequest theRequest)
+    {
+        theRequest.setURL("jakarta.apache.org", "", "/test/test.jsp", null, 
+            null);
+    }
+
+    /**
+     * Verify that when <code>setURL()</code> is called with a null
+     * pathinfo parameter, the call to <code>getRequestURL</code> works
+     * properly.
+     */
+    public void testSimulatedURLGetRequestURLWhenNull()
+    {
+        assertEquals("http://jakarta.apache.org:80/test/test.jsp";, 
+            request.getRequestURL().toString());
+    }
+
+    //-------------------------------------------------------------------------
+
+    /**
+     * Verify that when <code>setURL()</code> is called with a not null
+     * pathinfo parameter, the call to <code>getRequestURL</code> works
+     * properly.
+     *
+     * @param theRequest the request object that serves to initialize the
+     *                   HTTP connection to the server redirector.
+     */
+    public void beginSimulatedURLGetRequestURLWhenNotNull(
+        WebRequest theRequest)
+    {
+        theRequest.setURL("jakarta.apache.org", "/catalog", "/lawn", 
+                "/index.html", null);
+    }
+
+    /**
+     * Verify that when <code>setURL()</code> is called with a not null
+     * pathinfo parameter, the call to <code>getRequestURL</code> works
+     * properly.
+     */
+    public void testSimulatedURLGetRequestURLWhenNotNull()
+    {
+        assertEquals("http://jakarta.apache.org:80/catalog/lawn/index.html";, 
+            request.getRequestURL().toString());
+    }
+}

Propchange: 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestSetURLSpecific.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestSetUpTearDown.java
URL: 
http://svn.apache.org/viewvc/jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestSetUpTearDown.java?rev=698559&view=auto
==============================================================================
--- 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestSetUpTearDown.java
 (added)
+++ 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestSetUpTearDown.java
 Wed Sep 24 06:20:11 2008
@@ -0,0 +1,84 @@
+/* 
+ * ========================================================================
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * ========================================================================
+ */
+package org.apache.cactus.sample.servlet.unit;
+
+import org.apache.cactus.ServletTestCase;
+import org.apache.cactus.WebResponse;
+
+/**
+ * Test that <code>setUp()</code> and <code>tearDown()</code> methods are 
+ * called and can access implicit objects in <code>ServletTestCase</code>.
+ *
+ * @version $Id: TestSetUpTearDown.java 238816 2004-02-29 16:36:46Z vmassol $
+ */
+public class TestSetUpTearDown extends ServletTestCase
+{
+    /**
+     * Put a value in the session to verify that this method is called prior
+     * to the test, and that it can access servlet implicit objects.
+     */
+    protected void setUp()
+    {
+        session.setAttribute("setUpFlag", "a setUp test flag");
+    }
+
+    /**
+     * Verify that <code>setUp()</code> has been called and that it put a
+     * value in the session object.
+     */
+    public void testSetUp()
+    {
+        assertEquals("a setUp test flag", session.getAttribute("setUpFlag"));
+    }
+
+    //-------------------------------------------------------------------------
+
+    /**
+     * Set an HTTP response header to verify that this method is called after
+     * the test, and that it can access servlet implicit objects.
+     */
+    protected void tearDown()
+    {
+        response.setHeader("Teardownheader", "tear down header");
+    }
+
+    /**
+     * Verify that <code>tearDown()</code> has been called and that it created
+     * an HTTP reponse header.
+     */
+    public void testTearDown()
+    {
+    }
+
+    /**
+     * Verify that <code>tearDown()</code> has been called and that it created
+     * an HTTP reponse header.
+     *
+     * @param theResponse the HTTP connection that was used to call the
+     *                    server redirector. It contains the returned HTTP
+     *                    response.
+     */
+    public void endTearDown(WebResponse theResponse)
+    {
+        assertEquals("tear down header", 
+            theResponse.getConnection().getHeaderField("Teardownheader"));
+    }
+}

Propchange: 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestSetUpTearDown.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestShareAll.java
URL: 
http://svn.apache.org/viewvc/jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestShareAll.java?rev=698559&view=auto
==============================================================================
--- 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestShareAll.java
 (added)
+++ 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestShareAll.java
 Wed Sep 24 06:20:11 2008
@@ -0,0 +1,76 @@
+/* 
+ * ========================================================================
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * ========================================================================
+ */
+package org.apache.cactus.sample.servlet.unit;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+/**
+ * Test suite containing all test cases that should be run on all J2EE 
+ * APIs.
+ *
+ * @version $Id: TestShareAll.java 238816 2004-02-29 16:36:46Z vmassol $
+ */
+public abstract class TestShareAll
+{
+    /**
+     * @return a test suite (<code>TestSuite</code>) that includes all shared
+     *          tests
+     */
+    public static Test suite()
+    {
+        TestSuite suite = new TestSuite(
+            "Cactus unit tests for all J2EE APIs");
+
+        // Note: This test needs to run first. See the comments in the
+        // test class for more information on why
+        suite.addTestSuite(TestClientServerSynchronization.class);
+
+        // Lifecycle tests
+        suite.addTestSuite(TestGlobalBeginEnd.class);
+
+        // ServletTestCase related tests
+        suite.addTestSuite(TestServerSideExceptions.class);
+        suite.addTestSuite(TestSetUpTearDown.class);
+        suite.addTestSuite(TestSetURL.class);
+        suite.addTestSuite(TestTearDownException.class);
+        //suite.addTestSuite(TestBasicAuthentication.class);
+        suite.addTestSuite(TestHttpUnitIntegration.class);
+        suite.addTestSuite(TestHtmlUnitIntegration.class);
+        suite.addTestSuite(TestServletRedirectorOverride.class);
+        suite.addTestSuite(TestHttpParameters.class);
+        suite.addTest(TestHttpSession.suite());
+        suite.addTestSuite(TestHttpResponse.class);
+        suite.addTestSuite(TestCookie.class);
+        suite.addTestSuite(TestRequestDispatcher.class);
+        suite.addTestSuite(TestHttpHeaders.class);
+        suite.addTestSuite(TestHttpRequest.class);
+        suite.addTestSuite(TestServletConfig.class);
+        suite.addTestSuite(TestServletContext.class);
+        suite.addTest(TestJUnitTestCaseWrapper.suite());
+        
+        // JspTestCase related tests
+        suite.addTestSuite(TestJspOut.class);
+        suite.addTestSuite(TestJspPageContext.class);
+
+        return suite;
+    }
+}

Propchange: 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestShareAll.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestTearDownException.java
URL: 
http://svn.apache.org/viewvc/jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestTearDownException.java?rev=698559&view=auto
==============================================================================
--- 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestTearDownException.java
 (added)
+++ 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestTearDownException.java
 Wed Sep 24 06:20:11 2008
@@ -0,0 +1,72 @@
+/* 
+ * ========================================================================
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * ========================================================================
+ */
+package org.apache.cactus.sample.servlet.unit;
+
+import org.apache.cactus.ServletTestCase;
+
+import junit.framework.AssertionFailedError;
+
+/**
+ * Test that <code>tearDown()</code> is called even when an exception
+ * occurs during the test.
+ *
+ * @version $Id: TestTearDownException.java 238816 2004-02-29 16:36:46Z 
vmassol $
+ */
+public class TestTearDownException extends ServletTestCase
+{
+    /**
+     * Intercepts running test cases to check for normal exceptions.
+     */
+    public void runBare()
+    {
+        try
+        {
+            super.runBare();
+        }
+        catch (Throwable e)
+        {
+            assertEquals("testTearDown() worked", e.getMessage());
+        }
+    }
+
+    //-------------------------------------------------------------------------
+
+    /**
+     * Verify that the <code>tearDown()</code> is always called even when there
+     * is an exception raised during the test.
+     * 
+     * @exception Exception on test failure
+     */
+    public void testTearDown() throws Exception
+    {
+        // Provoke an exception
+        fail("provoked error");
+    }
+
+    /**
+     * Verify that the <code>tearDown()</code> is always called even when there
+     * is an exception raised during the test.
+     */
+    public void tearDown()
+    {
+        throw new AssertionFailedError("testTearDown() worked");
+    }
+}

Propchange: 
jakarta/cactus/trunk/samples/servlet/src/test/java/org/apache/cactus/sample/servlet/unit/TestTearDownException.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to