dwinterfeldt    01/07/10 20:29:52

  Modified:    src/test/org/apache/struts/taglib/logic TestPresentTag.java
  Log:
  Added tests for cookie, header, and parameter.
  
  Revision  Changes    Path
  1.2       +97 -8     
jakarta-struts/src/test/org/apache/struts/taglib/logic/TestPresentTag.java
  
  Index: TestPresentTag.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/test/org/apache/struts/taglib/logic/TestPresentTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestPresentTag.java       2001/07/11 02:20:51     1.1
  +++ TestPresentTag.java       2001/07/11 03:29:52     1.2
  @@ -69,6 +69,10 @@
    * @author David Winterfeldt
    */
   public class TestPresentTag extends JspTestCase {
  +    protected final static String COOKIE_KEY = 
"org.apache.struts.taglib.logic.COOKIE_KEY";
  +    protected final static String HEADER_KEY = 
"org.apache.struts.taglib.logic.HEADER_KEY";
  +    protected final static String PARAMETER_KEY = 
"org.apache.struts.taglib.logic.PARAMETER_KEY";
  +
       /**
        * Defines the testcase name for JUnit.
        *
  @@ -111,7 +115,6 @@
        pt.setName(testKey);
        pt.setScope("application");
        
  -     
           assertEquals("Value present (not null)", true, pt.condition(true));
       }
   
  @@ -126,7 +129,6 @@
        pt.setName(testKey);
        pt.setScope("application");
        
  -     
           assertEquals("Value not present (null)", false, pt.condition(true));
       }
       
  @@ -143,7 +145,6 @@
        pt.setName(testKey);
        pt.setScope("session");
        
  -     
           assertEquals("Value present (not null)", true, pt.condition(true));
       }
   
  @@ -158,7 +159,6 @@
        pt.setName(testKey);
        pt.setScope("session");
        
  -     
           assertEquals("Value present (not null)", false, pt.condition(true));
       }
       
  @@ -175,7 +175,6 @@
           pt.setPageContext(pageContext);
        pt.setName(testKey);
        
  -     
           assertEquals("Value present (not null)", true, pt.condition(true));
       }
   
  @@ -190,7 +189,6 @@
        pt.setName(testKey);
        pt.setScope("request");
        
  -     
           assertEquals("Value not present (null)", false, pt.condition(true));
       }
       
  @@ -207,7 +205,6 @@
           pt.setPageContext(pageContext);
        pt.setName(testKey);
        
  -     
           assertEquals("Value present (not null)", true, pt.condition(true));
       }
   
  @@ -222,8 +219,100 @@
        pt.setName(testKey);
        pt.setScope("page");
        
  -     
           assertEquals("Value not present (null)", false, pt.condition(true));
       }
   
  +    /**
  +     * Create cookie for testCookiePresent method test.
  +    */
  +    public void beginCookiePresent(ServletTestRequest testRequest) {
  +       testRequest.addCookie(COOKIE_KEY, "cookie value");
  +    }
  +
  +    /**
  +     * Verify that there is an cookie using the <code>PresentTag</code>.
  +    */
  +    public void testCookiePresent() throws ServletException,  
javax.servlet.jsp.JspException {
  +        PresentTag pt = new PresentTag();
  +
  +        pt.setPageContext(pageContext);
  +     pt.setCookie(COOKIE_KEY);
  +
  +        assertEquals("Cookie present", true, pt.condition(true));
  +    }
  +
  +    /**
  +     * Verify that there isn't an cookie using the <code>PresentTag</code>.
  +    */
  +    public void testCookieNotPresent() throws ServletException,  
javax.servlet.jsp.JspException {
  +        PresentTag pt = new PresentTag();
  +
  +        pt.setPageContext(pageContext);
  +     pt.setCookie(COOKIE_KEY);
  +     
  +        assertEquals("Cookie not present", false, pt.condition(true));
  +    }
  +
  +    /**
  +     * Create header for testHeaderPresent method test.
  +    */
  +    public void beginHeaderPresent(ServletTestRequest testRequest) {
  +       testRequest.addHeader(HEADER_KEY, "header value");
  +    }
  +
  +    /**
  +     * Verify that there is an header using the <code>PresentTag</code>.
  +    */
  +    public void testHeaderPresent() throws ServletException,  
javax.servlet.jsp.JspException {
  +        PresentTag pt = new PresentTag();
  +
  +        pt.setPageContext(pageContext);
  +     pt.setHeader(HEADER_KEY);
  +     
  +        assertEquals("Header present", true, pt.condition(true));
  +    }
  +
  +    /**
  +     * Verify that there isn't an header using the <code>PresentTag</code>.
  +    */
  +    public void testHeaderNotPresent() throws ServletException,  
javax.servlet.jsp.JspException {
  +        PresentTag pt = new PresentTag();
  +
  +        pt.setPageContext(pageContext);
  +     pt.setHeader(HEADER_KEY);
  +     
  +        assertEquals("Header not present", false, pt.condition(true));
  +    }
  +
  +    /**
  +     * Create parameter for testParameterPresent method test.
  +    */
  +    public void beginParameterPresent(ServletTestRequest testRequest) {
  +       testRequest.addParameter(PARAMETER_KEY, "parameter value");
  +    }
  +
  +    /**
  +     * Verify that there is an parameter using the <code>PresentTag</code>.
  +    */
  +    public void testParameterPresent() throws ServletException,  
javax.servlet.jsp.JspException {
  +        PresentTag pt = new PresentTag();
  +
  +        pt.setPageContext(pageContext);
  +     pt.setParameter(PARAMETER_KEY);
  +
  +        assertEquals("Parameter present", true, pt.condition(true));
  +    }
  +
  +    /**
  +     * Verify that there isn't an parameter using the <code>PresentTag</code>.
  +    */
  +    public void testParameterNotPresent() throws ServletException,  
javax.servlet.jsp.JspException {
  +        PresentTag pt = new PresentTag();
  +
  +        pt.setPageContext(pageContext);
  +     pt.setParameter(PARAMETER_KEY);
  +     
  +        assertEquals("Parameter not present", false, pt.condition(true));
  +    }    
  +    
   }
  
  
  

Reply via email to