jmitchell 2003/02/05 20:22:45 Modified: src/test/org/apache/struts/taglib/logic TestPresentTag.java Log: A few more tests and fix existing one. Revision Changes Path 1.12 +55 -6 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.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- TestPresentTag.java 5 Feb 2003 06:26:41 -0000 1.11 +++ TestPresentTag.java 6 Feb 2003 04:22:45 -0000 1.12 @@ -53,7 +53,7 @@ * */ package org.apache.struts.taglib.logic; - + import javax.servlet.ServletException; import javax.servlet.jsp.JspException; import javax.servlet.jsp.PageContext; @@ -245,18 +245,20 @@ pt.setScope("application"); pt.setProperty("value"); - assertEquals("Property Value present (not null)", true, pt.condition(true)); + assertEquals("Property present (not null)", true, pt.condition(true)); } /** - * Verify that there is an application scope object is not in scope using the <code>PresentTag</code>. + * Verify that there is a LabelValueBean in application scope + * and test to see if it has a getValue() that returns null + * using the <code>PresentTag</code>. */ public void testApplicationScopePropertyNotPresent() throws ServletException, JspException { PresentTag pt = new PresentTag(); - String testKey = "testApplicationScopePropertyNotPresent"; + String testKey = "testApplicationScopePropertyPresent"; - String testStringValue = null; //"The Value"; + String testStringValue = null; LabelValueBean lvb = new LabelValueBean("The Key", testStringValue); pageContext.setAttribute( @@ -268,10 +270,57 @@ pt.setScope("application"); pt.setProperty("value"); - assertEquals("Property Value not present (null)", true, pt.condition(true)); + assertEquals("Property present (not null)", false, pt.condition(true)); + } + + /** + * Verify that there is a LabelValueBean in Request scope + * and test to see if it has a getValue() using the <code>PresentTag</code>. + */ + public void testRequestScopePropertyPresent() + throws ServletException, JspException { + PresentTag pt = new PresentTag(); + String testKey = "testRequestScopePropertyPresent"; + String testStringValue = "The Value"; + LabelValueBean lvb = new LabelValueBean("The Key", testStringValue); + + pageContext.setAttribute( + testKey, + lvb, + PageContext.REQUEST_SCOPE); + pt.setPageContext(pageContext); + pt.setName(testKey); + pt.setScope("request"); + + pt.setProperty("value"); + assertEquals("Property present (not null)", true, pt.condition(true)); } + /** + * Verify that there is a LabelValueBean in Request scope + * and test to see if it has a getValue() that returns null + * using the <code>PresentTag</code>. + */ + public void testRequestScopePropertyNotPresent() + throws ServletException, JspException { + PresentTag pt = new PresentTag(); + String testKey = "testRequestScopePropertyPresent"; + + String testStringValue = null; + LabelValueBean lvb = new LabelValueBean("The Key", testStringValue); + + pageContext.setAttribute( + testKey, + lvb, + PageContext.REQUEST_SCOPE); + pt.setPageContext(pageContext); + pt.setName(testKey); + pt.setScope("request"); + + pt.setProperty("value"); + assertEquals("Property present (not null)", false, pt.condition(true)); + } /** * Create cookie for testCookiePresent method test.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]