You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by vm...@apache.org on 2003/05/25 16:35:32 UTC

cvs commit: jakarta-cactus/samples/servlet/src/test-cactus/share/org/apache/cactus/sample/unit TestServletConfig.java

vmassol     2003/05/25 07:35:32

  Modified:    samples/servlet/src/test-cactus/share/org/apache/cactus/sample/unit
                        TestServletConfig.java
  Log:
  Improved test coverage :-)
  
  Revision  Changes    Path
  1.6       +53 -2     jakarta-cactus/samples/servlet/src/test-cactus/share/org/apache/cactus/sample/unit/TestServletConfig.java
  
  Index: TestServletConfig.java
  ===================================================================
  RCS file: /home/cvs/jakarta-cactus/samples/servlet/src/test-cactus/share/org/apache/cactus/sample/unit/TestServletConfig.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestServletConfig.java	24 May 2003 16:48:13 -0000	1.5
  +++ TestServletConfig.java	25 May 2003 14:35:32 -0000	1.6
  @@ -104,13 +104,64 @@
       //-------------------------------------------------------------------------
   
       /**
  +     * 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 enum = config.getInitParameterNames();
  +        int count = 0;
  +        
  +        while (enum.hasMoreElements())
  +        {
  +            String name = (String) enum.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 testGetServletName()
  +    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());
       }
   
       //-------------------------------------------------------------------------
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org