vmassol 01/09/24 04:13:20
Modified: src/sample/servlet22/org/apache/cactus TestAll.java
src/sample/servlet23/org/apache/cactus TestAll.java
Added: src/sample/share/org/apache/cactus/sample SampleBodyTag.java
SampleTag.java TestSampleBodyTag.java
TestSampleTag.java
Log:
Sample taglib unit testing (tests commented out in TestAll.java as they do not yet
pass on all servlet engines). On behalf of Nicholas Lesiecki.
Revision Changes Path
1.3 +6 -1
jakarta-cactus/src/sample/servlet22/org/apache/cactus/TestAll.java
Index: TestAll.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/src/sample/servlet22/org/apache/cactus/TestAll.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestAll.java 2001/09/14 20:22:07 1.2
+++ TestAll.java 2001/09/24 11:13:20 1.3
@@ -61,7 +61,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a>
*
- * @version $Id: TestAll.java,v 1.2 2001/09/14 20:22:07 pier Exp $
+ * @version $Id: TestAll.java,v 1.3 2001/09/24 11:13:20 vmassol Exp $
*/
public class TestAll extends TestCase
{
@@ -101,6 +101,11 @@
// Functional tests
suite.addTest(org.apache.cactus.sample.TestSampleServlet.suite());
suite.addTest(org.apache.cactus.sample.TestSampleServletConfig.suite());
+ suite.addTest(org.apache.cactus.sample.TestSampleTag.suite());
+
+ // TODO: Will need to be uncommented once the test run fine on
+ // all servlet engined (it is failing on Tomcat 4.x, Orion 1.x)
+ //suite.addTest(org.apache.cactus.sample.TestSampleBodyTag.suite());
// Unit tests requiring a servlet engine
1.3 +6 -1
jakarta-cactus/src/sample/servlet23/org/apache/cactus/TestAll.java
Index: TestAll.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/src/sample/servlet23/org/apache/cactus/TestAll.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TestAll.java 2001/09/14 20:23:09 1.2
+++ TestAll.java 2001/09/24 11:13:20 1.3
@@ -61,7 +61,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a>
*
- * @version $Id: TestAll.java,v 1.2 2001/09/14 20:23:09 pier Exp $
+ * @version $Id: TestAll.java,v 1.3 2001/09/24 11:13:20 vmassol Exp $
*/
public class TestAll extends TestCase
{
@@ -102,6 +102,11 @@
suite.addTest(org.apache.cactus.sample.TestSampleServlet.suite());
suite.addTest(org.apache.cactus.sample.TestSampleServletConfig.suite());
suite.addTest(org.apache.cactus.sample.TestSampleFilter.suite());
+ suite.addTest(org.apache.cactus.sample.TestSampleTag.suite());
+
+ // TODO: Will need to be uncommented once the test run fine on
+ // all servlet engined (it is failing on Tomcat 4.x, Orion 1.x)
+ //suite.addTest(org.apache.cactus.sample.TestSampleBodyTag.suite());
// Unit tests requiring a servlet engine
1.1
jakarta-cactus/src/sample/share/org/apache/cactus/sample/SampleBodyTag.java
Index: SampleBodyTag.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Cactus", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cactus.sample;
import java.util.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
/**
* Sample tag that interacts with its body. The tag acts as a filter for its
* body. "Target" and "Replacement" Strings are defined by the tag's attributes
* and each "occurrence" of the target is replaced by the "replacement".
*
* @author <a href="mailto:[EMAIL PROTECTED]">Nicholas Lesiecki</a>
*
* @version $Id: SampleBodyTag.java,v 1.1 2001/09/24 11:13:20 vmassol Exp $
*/
public class SampleBodyTag extends BodyTagSupport
{
/**
* The substring to be replaced in the body.
*/
private String target;
/**
* The substring that will replace the target in the body.
*/
private String replacement;
/**
* Sets the substring to be replaced in the body.
*
* @param theTarget the substring to be replaced in the body
*/
public void setTarget(String theTarget)
{
this.target = theTarget;
}
/**
* Sets the substring that will replace the target in the body.
*/
public void setReplacement(String theReplacement)
{
this.replacement = theReplacement;
}
/**
* Performs the replacement.
*/
public int doAfterBody() throws JspTagException
{
String contentString = this.bodyContent.getString();
StringBuffer contentBuffer = new StringBuffer(contentString);
int beginIndex = -1;
int targetLength = this.target.length();
// while instances of target still exist
while ((beginIndex = contentString.indexOf(this.target)) > -1){
int endIndex = beginIndex + targetLength;
contentBuffer.replace(beginIndex, endIndex, this.replacement);
contentString = contentBuffer.toString();
}
// write out the changed body
JspWriter pageWriter = this.bodyContent.getEnclosingWriter();
try {
pageWriter.write(contentString);
} catch (IOException e){
throw new JspTagException(e.getMessage());
}
return SKIP_BODY;
}
public void release()
{
this.target = null;
this.replacement = null;
}
}
1.1
jakarta-cactus/src/sample/share/org/apache/cactus/sample/SampleTag.java
Index: SampleTag.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Cactus", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cactus.sample;
import java.util.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import java.io.*;
/**
* Sample tag that implements simple tag logic.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Nicholas Lesiecki</a>
*
* @version $Id: SampleTag.java,v 1.1 2001/09/24 11:13:20 vmassol Exp $
*/
public class SampleTag extends TagSupport
{
/**
* Determines whether the tag's body should be shown.
*/
private boolean showBody;
/**
* Determines whether page should continue after the tag.
*/
private boolean stopPage;
/** Determines whether the tag's body should be shown.
* @param showBody a String equaling 'true' will be taken as
* <code>true</code>. Anything else will be
* taken as <code>false</code>.
*/
public void setShowBody(String showBody)
{
showBody = showBody.toLowerCase();
this.showBody = "true".equals(showBody);
}
/** Determines whether page should stop after the tag.
* @param showBody a String equaling 'true' will be taken as
* <code>true</code>. Anything else will be
* taken as <code>false</code>.
*/
public void setStopPage(String stopPage)
{
this.stopPage = "true".equals(stopPage);
}
/**
* Prints the names and values of everything in page scope to the response,
* along with the body (if showBody is set to <code>true</code>).
*/
public int doStartTag() throws JspTagException
{
Enumeration names =
pageContext.getAttributeNamesInScope(PageContext.PAGE_SCOPE);
JspWriter out = pageContext.getOut();
try {
out.println("The following attributes exist in page scope: <BR>");
while (names.hasMoreElements()) {
String name = (String)names.nextElement();
Object attribute = pageContext.getAttribute(name);
out.println(name + " = " + attribute + " <BR>");
}
if (this.showBody) {
out.println("Body Content Follows: <BR>");
return EVAL_BODY_INCLUDE;
}
} catch (IOException e) {
throw new JspTagException(e.getMessage());
}
return SKIP_BODY;
}
/**
* Does two things:
* <ul>
* <li>Stops the page if the corresponding attribute has been set</li>
* <li>Prints a message another tag encloses this one.</li>
* </ul>
*/
public int doEndTag() throws JspTagException
{
//get the parent if any
Tag parent = this.getParent();
if (parent != null) {
try {
JspWriter out = this.pageContext.getOut();
out.println("This tag has a parent. <BR>");
} catch (IOException e) {
throw new JspTagException(e.getMessage());
}
}
if (this.stopPage){
return Tag.SKIP_PAGE;
}
return Tag.EVAL_PAGE;
}
}
1.1
jakarta-cactus/src/sample/share/org/apache/cactus/sample/TestSampleBodyTag.java
Index: TestSampleBodyTag.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Cactus", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cactus.sample;
import java.util.*;
import java.io.*;
import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;
import junit.framework.*;
import org.apache.cactus.*;
import org.apache.cactus.util.*;
/**
* Tests of the <code>SampleBodyTag</code> class.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Nciholas Lesiecki</a>
*
* @version $Id: TestSampleBodyTag.java,v 1.1 2001/09/24 11:13:20 vmassol Exp $
*/
public class TestSampleBodyTag extends JspTestCase
{
/**
* Defines the testcase name for JUnit.
*
* @param theName the testcase's name.
*/
public TestSampleBodyTag(String theName)
{
super(theName);
}
/**
* Start the tests.
*
* @param theArgs the arguments. Not used
*/
public static void main(String[] theArgs)
{
junit.ui.TestRunner.main(new String[] {
TestSampleBodyTag.class.getName()});
}
/**
* @return a test suite (<code>TestSuite</code>) that includes all methods
* starting with "test"
*/
public static Test suite()
{
// All methods starting with "test" will be executed in the test suite.
return new TestSuite(TestSampleBodyTag.class);
}
//-------------------------------------------------------------------------
private SampleBodyTag tag;
private BodyContent tagContent;
/**
* In addition to creating the tag instance and adding the pageContext to
* it, this method creates a BodyContent object and passes it to the tag.
*/
public void setUp()
{
this.tag = new SampleBodyTag();
this.tag.setPageContext(this.pageContext);
//create the BodyContent object and call the setter on the tag instance
this.tagContent = this.pageContext.pushBody();
this.tag.setBodyContent(this.tagContent);
}
//-------------------------------------------------------------------------
/**
* Sets the replacement target and replacement String on the tag, then calls
* doAfterBody(). Most of the assertion work is done in endReplacement().
*/
public void testReplacement() throws Exception
{
//set the target and the String to replace it with
this.tag.setTarget("@target@");
this.tag.setReplacement("replacement");
//add the tag's body by writing to the BodyContent object created in
//setUp()
this.tagContent.println("@target@ is now @target@");
this.tagContent.println("@target@");
//none of the other life cycle methods need to be implemented, so they
//do not need to be called.
int result = this.tag.doAfterBody();
assertEquals(BodyTag.SKIP_BODY, result);
}
/**
* Verifies that the target String has indeed been replaced in the tag's
* body.
*/
public void endReplacement(WebResponse theResponse)
{
String[] contentArray = theResponse.getTextAsArray();
assert("Response contains [" + contentArray.length + "]. It should " +
"have contained 2 lines !", contentArray.length == 2);
String firstLine = contentArray[0];
String secondLine = contentArray[1];
assert("Line [" + firstLine + "] should have contained the [" +
"replacement is now replacement] string",
firstLine.indexOf("replacement is now replacement") > -1);
assert("Line [" + secondLine + "] should have contained the [" +
"replacement] string", secondLine.indexOf("replacement") > -1);
}
}
1.1
jakarta-cactus/src/sample/share/org/apache/cactus/sample/TestSampleTag.java
Index: TestSampleTag.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Cactus", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.cactus.sample;
import javax.servlet.jsp.tagext.*;
import junit.framework.*;
import org.apache.cactus.*;
/**
* Tests of the <code>SampleTag</code> class.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Nicholas Lesiecki</a>
*
* @version $Id: TestSampleTag.java,v 1.1 2001/09/24 11:13:20 vmassol Exp $
*/
public class TestSampleTag extends JspTestCase
{
/**
* Defines the testcase name for JUnit.
*
* @param theName the testcase's name.
*/
public TestSampleTag(String theName)
{
super(theName);
}
/**
* Start the tests.
*
* @param theArgs the arguments. Not used
*/
public static void main(String[] theArgs)
{
junit.ui.TestRunner.main(new String[] {
TestSampleTag.class.getName()});
}
/**
* @return a test suite (<code>TestSuite</code>) that includes all methods
* starting with "test"
*/
public static Test suite()
{
// All methods starting with "test" will be executed in the test suite.
return new TestSuite(TestSampleTag.class);
}
//-------------------------------------------------------------------------
private SampleTag tag;
public void setUp()
{
this.tag = new SampleTag();
this.tag.setPageContext(this.pageContext);
}
//-------------------------------------------------------------------------
/**
* Tests whether doStartTag() will skip the body if the corresponding tag
* attribute is set. Also tests whether an attribute put into page scope
* before the tag executes will be output to the response.
*/
public void testDoStartTag() throws Exception
{
//put something in page scope to see if it shows up in the response...
this.pageContext.setAttribute("test-key", "test-value");
this.tag.setShowBody("false");
int result = this.tag.doStartTag();
//body should not show up
assertEquals(Tag.SKIP_BODY, result);
}
/**
* Verifies that the output includes the output from doStartTag (a message
* from the tag and the attribute set into page scope).
*/
public void endDoStartTag(WebResponse theResponse)
{
// check that two of the lines output by the tag showed up in
// the response
assertContains(theResponse,
"The following attributes exist in page scope: <BR>");
assertContains(theResponse, "test-key = test-value <BR>");
}
//-------------------------------------------------------------------------
/**
* Test whether the tag's body will be shown if the corresponding attribute
* is set.
*/
public void testDoStartTagInclude() throws Exception
{
this.tag.setShowBody("true");
int result = this.tag.doStartTag();
//body should show up
assertEquals(Tag.EVAL_BODY_INCLUDE, result);
}
/**
* The tag prints a message before the body is included, here we check that
* the message shows up.
*/
public void endDoStartTagInclude(WebResponse theResponse)
{
// check that the pre-body message printed by the tag shows up
assertContains(theResponse, "Body Content Follows: <BR>");
}
//-------------------------------------------------------------------------
/**
* Checks if the tag will continue the page correctly if its stopPage
* property is set to false.
*/
public void testDoEndTagContinue() throws Exception
{
this.tag.setParent(new SampleTag());
this.tag.setStopPage("false");
int result = this.tag.doEndTag();
assertEquals(Tag.EVAL_PAGE, result);
}
/**
* Checks whether the tag has printed a message indicating that it has a
* parent tag.
*/
public void endDoEndTagContinue(WebResponse theResponse)
{
assertContains(theResponse, "This tag has a parent. <BR>");
}
//-------------------------------------------------------------------------
/**
* Checks if the tag will signal that page processing should stop if
* stopPage is set to "true"
*/
public void testDoEndTagStop() throws Exception
{
//no parent set
this.tag.setStopPage("true");
int result = this.tag.doEndTag();
assertEquals(Tag.SKIP_PAGE, result);
}
/**
* Checks whether the tag has printed a message indicating that it has a
* parent tag. (In this case it should not.)
*/
public void endDoEndTagStop(WebResponse theResponse)
{
String target = theResponse.getText();
boolean containsMessage = target.indexOf("This tag has a parent. <BR>") > 0;
assert(!containsMessage);
}
//--------------------------------------------------------------------------
/**
* Convenience function that asserts that a substring can be found in a
* target String.
*/
public void assertContains(WebResponse theResponse, String theSubstring)
{
String target = theResponse.getText();
if (target.indexOf(theSubstring) < 0){
fail("Response did not contain the substring: [" +
theSubstring + "]");
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]