You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2006/02/10 22:05:22 UTC
svn commit: r376846 [13/14] - in
/struts/taglib/trunk/src/test-cactus/org/apache/struts/taglib: ./ bean/
bean/resources/ html/ logic/
Modified: struts/taglib/trunk/src/test-cactus/org/apache/struts/taglib/logic/TestGreaterThanTag.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/test-cactus/org/apache/struts/taglib/logic/TestGreaterThanTag.java?rev=376846&r1=376845&r2=376846&view=diff
==============================================================================
--- struts/taglib/trunk/src/test-cactus/org/apache/struts/taglib/logic/TestGreaterThanTag.java (original)
+++ struts/taglib/trunk/src/test-cactus/org/apache/struts/taglib/logic/TestGreaterThanTag.java Fri Feb 10 13:05:03 2006
@@ -17,25 +17,28 @@
*/
package org.apache.struts.taglib.logic;
-import javax.servlet.ServletException;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.PageContext;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.apache.cactus.JspTestCase;
import org.apache.cactus.WebRequest;
import org.apache.struts.util.LabelValueBean;
+import javax.servlet.ServletException;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.PageContext;
+
/**
- * Suite of unit tests for the
- * <code>org.apache.struts.taglib.logic.GreaterThanTag</code> class.
- *
+ * Suite of unit tests for the <code>org.apache.struts.taglib.logic.GreaterThanTag</code>
+ * class.
*/
public class TestGreaterThanTag 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";
+ 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";
protected final static String GREATER_VAL = "6";
protected final static String LESSER_VAL = "4";
@@ -55,7 +58,8 @@
* @param theArgs the arguments. Not used
*/
public static void main(String[] theArgs) {
- junit.awtui.TestRunner.main(new String[] {TestGreaterThanTag.class.getName()});
+ junit.awtui.TestRunner
+ .main(new String[] { TestGreaterThanTag.class.getName() });
}
/**
@@ -71,7 +75,7 @@
/**
* Create cookie for testCookieGreaterThan method test.
- */
+ */
/* FIXME: Cactus does not send cookies?
public void beginCookieGreaterThan(WebRequest testRequest) {
testRequest.addCookie(COOKIE_KEY, GREATER_VAL);
@@ -80,21 +84,21 @@
/**
* Create header for testHeaderGreaterThan method test.
- */
+ */
public void beginHeaderGreaterThan(WebRequest testRequest) {
- testRequest.addHeader(HEADER_KEY, GREATER_VAL);
+ testRequest.addHeader(HEADER_KEY, GREATER_VAL);
}
/**
* Create header for testParameterGreaterThan method test.
- */
+ */
public void beginParameterGreaterThan(WebRequest testRequest) {
- testRequest.addParameter(PARAMETER_KEY, GREATER_VAL);
+ testRequest.addParameter(PARAMETER_KEY, GREATER_VAL);
}
/**
* Verify the value stored in a cookie using <code>GreaterThanTag</code>.
- */
+ */
/* FIXME: Cactus does not send cookies?
public void testCookieGreaterThan() throws ServletException, JspException {
GreaterThanTag gt = new GreaterThanTag();
@@ -110,177 +114,185 @@
/**
* Verify the value stored in header using <code>GreaterThanTag</code>.
- */
- public void testHeaderGreaterThan() throws ServletException, JspException {
+ */
+ public void testHeaderGreaterThan()
+ throws ServletException, JspException {
GreaterThanTag gt = new GreaterThanTag();
gt.setPageContext(pageContext);
gt.setHeader(HEADER_KEY);
gt.setValue(LESSER_VAL);
assertTrue(
- "Header Value (" + GREATER_VAL + ") is greater than value (" + LESSER_VAL + ")",
+ "Header Value (" + GREATER_VAL + ") is greater than value ("
+ + LESSER_VAL + ")",
gt.condition());
}
/**
* Verify the value stored in parameter using <code>GreaterThanTag</code>.
- */
- public void testParameterGreaterThan() throws ServletException, JspException {
+ */
+ public void testParameterGreaterThan()
+ throws ServletException, JspException {
GreaterThanTag gt = new GreaterThanTag();
gt.setPageContext(pageContext);
gt.setParameter(PARAMETER_KEY);
gt.setValue(LESSER_VAL);
assertTrue(
- "Parameter Value (" + GREATER_VAL + ") is greater than value (" + LESSER_VAL + ")",
+ "Parameter Value (" + GREATER_VAL
+ + ") is greater than value (" + LESSER_VAL + ")",
gt.condition());
}
/**
- * Testing <code>GreaterThanTag</code> using name attribute in
- * the application scope.
- */
+ * Testing <code>GreaterThanTag</code> using name attribute in the
+ * application scope.
+ */
public void testApplicationScopeNameGreaterThan()
- throws ServletException, JspException {
+ throws ServletException, JspException {
GreaterThanTag gt = new GreaterThanTag();
- String testKey = "testApplicationScopeNameGreaterThan";
- Integer itgr = new Integer(GREATER_VAL);
+ String testKey = "testApplicationScopeNameGreaterThan";
+ Integer itgr = new Integer(GREATER_VAL);
- pageContext.setAttribute(testKey, itgr, PageContext.APPLICATION_SCOPE);
- gt.setPageContext(pageContext);
- gt.setName(testKey);
- gt.setScope("application");
- gt.setValue(LESSER_VAL);
+ pageContext
+ .setAttribute(testKey, itgr, PageContext.APPLICATION_SCOPE);
+ gt.setPageContext(pageContext);
+ gt.setName(testKey);
+ gt.setScope("application");
+ gt.setValue(LESSER_VAL);
assertTrue(
- "Application scope value from name (" + GREATER_VAL + ") is greater than value (" + LESSER_VAL + ")",
+ "Application scope value from name (" + GREATER_VAL
+ + ") is greater than value (" + LESSER_VAL + ")",
gt.condition());
}
/**
- * Testing <code>GreaterThanTag</code> using name attribute in
- * the session scope.
- */
+ * Testing <code>GreaterThanTag</code> using name attribute in the session
+ * scope.
+ */
public void testSessionScopeNameGreaterThan()
- throws ServletException, JspException {
+ throws ServletException, JspException {
GreaterThanTag gt = new GreaterThanTag();
- String testKey = "testSessionScopeNameGreaterThan";
- Integer itgr = new Integer(GREATER_VAL);
+ String testKey = "testSessionScopeNameGreaterThan";
+ Integer itgr = new Integer(GREATER_VAL);
- pageContext.setAttribute(testKey, itgr, PageContext.SESSION_SCOPE);
- gt.setPageContext(pageContext);
- gt.setName(testKey);
- gt.setScope("session");
- gt.setValue(LESSER_VAL);
+ pageContext.setAttribute(testKey, itgr, PageContext.SESSION_SCOPE);
+ gt.setPageContext(pageContext);
+ gt.setName(testKey);
+ gt.setScope("session");
+ gt.setValue(LESSER_VAL);
assertTrue(
- "Session scope value from name (" + GREATER_VAL + ") is greater than value (" + LESSER_VAL + ")",
+ "Session scope value from name (" + GREATER_VAL
+ + ") is greater than value (" + LESSER_VAL + ")",
gt.condition());
}
/**
- * Testing <code>GreaterThanTag</code> using name attribute in
- * the request scope.
- */
+ * Testing <code>GreaterThanTag</code> using name attribute in the request
+ * scope.
+ */
public void testRequestScopeNameGreaterThan()
- throws ServletException, JspException {
+ throws ServletException, JspException {
GreaterThanTag gt = new GreaterThanTag();
- String testKey = "testRequestScopeNameGreaterThan";
- Integer itgr = new Integer(GREATER_VAL);
+ String testKey = "testRequestScopeNameGreaterThan";
+ Integer itgr = new Integer(GREATER_VAL);
- pageContext.setAttribute(testKey, itgr, PageContext.REQUEST_SCOPE);
- gt.setPageContext(pageContext);
- gt.setName(testKey);
- gt.setScope("request");
- gt.setValue(LESSER_VAL);
+ pageContext.setAttribute(testKey, itgr, PageContext.REQUEST_SCOPE);
+ gt.setPageContext(pageContext);
+ gt.setName(testKey);
+ gt.setScope("request");
+ gt.setValue(LESSER_VAL);
assertTrue(
- "Request scope value from name (" + GREATER_VAL + ") is greater than value (" + LESSER_VAL + ")",
+ "Request scope value from name (" + GREATER_VAL
+ + ") is greater than value (" + LESSER_VAL + ")",
gt.condition());
}
-
-
/**
- * Testing <code>GreaterThanTag</code> using name and property attribute in
- * the application scope.
- */
+ * Testing <code>GreaterThanTag</code> using name and property attribute
+ * in the application scope.
+ */
public void testApplicationScopePropertyGreaterThan()
- throws ServletException, JspException {
+ throws ServletException, JspException {
GreaterThanTag gt = new GreaterThanTag();
- String testKey = "testApplicationScopePropertyGreaterThan";
- LabelValueBean lvb = new LabelValueBean("The Key", GREATER_VAL);
+ String testKey = "testApplicationScopePropertyGreaterThan";
+ LabelValueBean lvb = new LabelValueBean("The Key", GREATER_VAL);
- pageContext.setAttribute(testKey, lvb, PageContext.APPLICATION_SCOPE);
- gt.setPageContext(pageContext);
- gt.setName(testKey);
- gt.setScope("application");
- gt.setProperty("value");
- gt.setValue(LESSER_VAL);
+ pageContext.setAttribute(testKey, lvb, PageContext.APPLICATION_SCOPE);
+ gt.setPageContext(pageContext);
+ gt.setName(testKey);
+ gt.setScope("application");
+ gt.setProperty("value");
+ gt.setValue(LESSER_VAL);
assertTrue(
- "Value (" + LESSER_VAL + ") is greater than value (" + GREATER_VAL + ")",
+ "Value (" + LESSER_VAL + ") is greater than value ("
+ + GREATER_VAL + ")",
gt.condition());
}
/**
- * Testing <code>GreaterThanTag</code> using name and property attribute in
- * the session scope.
- */
+ * Testing <code>GreaterThanTag</code> using name and property attribute
+ * in the session scope.
+ */
public void testSessionScopePropertyGreaterThan()
- throws ServletException, JspException {
+ throws ServletException, JspException {
GreaterThanTag gt = new GreaterThanTag();
- String testKey = "testSessionScopePropertyGreaterThan";
- LabelValueBean lvb = new LabelValueBean("The Key", GREATER_VAL);
+ String testKey = "testSessionScopePropertyGreaterThan";
+ LabelValueBean lvb = new LabelValueBean("The Key", GREATER_VAL);
- pageContext.setAttribute(testKey, lvb, PageContext.SESSION_SCOPE);
- gt.setPageContext(pageContext);
- gt.setName(testKey);
- gt.setScope("session");
- gt.setProperty("value");
- gt.setValue(LESSER_VAL);
+ pageContext.setAttribute(testKey, lvb, PageContext.SESSION_SCOPE);
+ gt.setPageContext(pageContext);
+ gt.setName(testKey);
+ gt.setScope("session");
+ gt.setProperty("value");
+ gt.setValue(LESSER_VAL);
assertTrue(
- "Value (" + LESSER_VAL + ") is greater than value (" + GREATER_VAL + ")",
+ "Value (" + LESSER_VAL + ") is greater than value ("
+ + GREATER_VAL + ")",
gt.condition());
}
/**
- * Testing <code>GreaterThanTag</code> using name and property attribute in
- * the request scope.
- */
+ * Testing <code>GreaterThanTag</code> using name and property attribute
+ * in the request scope.
+ */
public void testRequestScopePropertyGreaterThan()
- throws ServletException, JspException {
+ throws ServletException, JspException {
GreaterThanTag gt = new GreaterThanTag();
- String testKey = "testRequestScopePropertyGreaterThan";
- LabelValueBean lvb = new LabelValueBean("The Key", GREATER_VAL);
+ String testKey = "testRequestScopePropertyGreaterThan";
+ LabelValueBean lvb = new LabelValueBean("The Key", GREATER_VAL);
- pageContext.setAttribute(testKey, lvb, PageContext.REQUEST_SCOPE);
- gt.setPageContext(pageContext);
- gt.setName(testKey);
- gt.setScope("request");
- gt.setProperty("value");
- gt.setValue(LESSER_VAL);
+ pageContext.setAttribute(testKey, lvb, PageContext.REQUEST_SCOPE);
+ gt.setPageContext(pageContext);
+ gt.setName(testKey);
+ gt.setScope("request");
+ gt.setProperty("value");
+ gt.setValue(LESSER_VAL);
assertTrue(
- "Value (" + LESSER_VAL + ") is greater than value (" + GREATER_VAL + ")",
+ "Value (" + LESSER_VAL + ") is greater than value ("
+ + GREATER_VAL + ")",
gt.condition());
}
-
}
Modified: struts/taglib/trunk/src/test-cactus/org/apache/struts/taglib/logic/TestIterateTag.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/test-cactus/org/apache/struts/taglib/logic/TestIterateTag.java?rev=376846&r1=376845&r2=376846&view=diff
==============================================================================
--- struts/taglib/trunk/src/test-cactus/org/apache/struts/taglib/logic/TestIterateTag.java (original)
+++ struts/taglib/trunk/src/test-cactus/org/apache/struts/taglib/logic/TestIterateTag.java Fri Feb 10 13:05:03 2006
@@ -17,33 +17,29 @@
*/
package org.apache.struts.taglib.logic;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.StringTokenizer;
-
-import javax.servlet.ServletException;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.PageContext;
-
import junit.framework.Test;
import junit.framework.TestSuite;
-
import org.apache.cactus.WebResponse;
import org.apache.struts.taglib.SimpleBeanForTesting;
import org.apache.struts.taglib.TaglibTestBase;
+import javax.servlet.ServletException;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.PageContext;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.StringTokenizer;
/**
- * Suite of unit tests for the
- * <code>org.apache.struts.taglib.logic.IterateTag</code> class.
- *
+ * Suite of unit tests for the <code>org.apache.struts.taglib.logic.IterateTag</code>
+ * class.
*/
public class TestIterateTag extends TaglibTestBase {
-
- private int iterations = 2;
-
+
+ private int iterations = 2;
+
/**
* Defines the testcase name for JUnit.
*
@@ -59,7 +55,8 @@
* @param theArgs the arguments. Not used
*/
public static void main(String[] theArgs) {
- junit.awtui.TestRunner.main(new String[] {TestIterateTag.class.getName()});
+ junit.awtui.TestRunner
+ .main(new String[] { TestIterateTag.class.getName() });
}
/**
@@ -72,1308 +69,1278 @@
}
- /**
- * Testing <code>IterateTag</code> using name attribute in
- * the application scope.
- *
- * Tests the equivalent of this tag in a jsp:
- * <logic:iterate id="theId" name="testApplicationScopeNameIterateList"
- * scope="application">
- *
+ /**
+ * Testing <code>IterateTag</code> using name attribute in the application
+ * scope.
+ *
+ * Tests the equivalent of this tag in a jsp: <logic:iterate id="theId"
+ * name="testApplicationScopeNameIterateList" scope="application">
*/
- // ========= Application
- public void testApplicationScopeNameIterateList()
- throws ServletException, JspException, IOException {
-
- String testKey = "testApplicationScopeNameIterateList";
+ // ========= Application
+ public void testApplicationScopeNameIterateList()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testApplicationScopeNameIterateList";
ArrayList lst = new ArrayList();
for (int i = 0; i < iterations; i++) {
- lst.add("test" + i);
- }
-
- pageContext.setAttribute(testKey, lst,
- PageContext.APPLICATION_SCOPE);
+ lst.add("test" + i);
+ }
+
+ pageContext.setAttribute(testKey, lst,
+ PageContext.APPLICATION_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("application");
-
- int iteration = 0;
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print((String)pageContext.getAttribute("theId"));
- iteration++;
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
- assertEquals(iterations, iteration);
- }
-
- public void endApplicationScopeNameIterateList (WebResponse response){
- String output = response.getText();
- String compare = "";
- for (int i = 0; i < iterations; i++) {
- compare += "test" + i;
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(output,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
- // ========= Session
- public void testSessionScopeNameIterateList()
- throws ServletException, JspException, IOException {
-
- String testKey = "testSessionScopeNameIterateList";
+
+ int iteration = 0;
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print((String) pageContext.getAttribute("theId"));
+ iteration++;
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ assertEquals(iterations, iteration);
+ }
+
+ public void endApplicationScopeNameIterateList(WebResponse response) {
+ String output = response.getText();
+ String compare = "";
+ for (int i = 0; i < iterations; i++) {
+ compare += "test" + i;
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(output, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
+ // ========= Session
+ public void testSessionScopeNameIterateList()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testSessionScopeNameIterateList";
ArrayList lst = new ArrayList();
for (int i = 0; i < iterations; i++) {
- lst.add("test" + i);
- }
-
- pageContext.setAttribute(testKey, lst,
- PageContext.SESSION_SCOPE);
+ lst.add("test" + i);
+ }
+
+ pageContext.setAttribute(testKey, lst,
+ PageContext.SESSION_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("session");
-
- int iteration = 0;
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print((String)pageContext.getAttribute("theId"));
- iteration++;
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
- assertEquals(iterations, iteration);
- }
-
- public void endSessionScopeNameIterateList (WebResponse response){
- String output = response.getText();
- String compare = "";
- for (int i = 0; i < iterations; i++) {
- compare += "test" + i;
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
- // ========= Request
- public void testRequestScopeNameIterateList()
- throws ServletException, JspException, IOException {
-
- String testKey = "testRequestScopeNameIterateList";
+
+ int iteration = 0;
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print((String) pageContext.getAttribute("theId"));
+ iteration++;
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ assertEquals(iterations, iteration);
+ }
+
+ public void endSessionScopeNameIterateList(WebResponse response) {
+ String output = response.getText();
+ String compare = "";
+ for (int i = 0; i < iterations; i++) {
+ compare += "test" + i;
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
+ // ========= Request
+ public void testRequestScopeNameIterateList()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testRequestScopeNameIterateList";
ArrayList lst = new ArrayList();
for (int i = 0; i < iterations; i++) {
- lst.add("test" + i);
- }
-
- pageContext.setAttribute(testKey, lst,
- PageContext.REQUEST_SCOPE);
+ lst.add("test" + i);
+ }
+
+ pageContext.setAttribute(testKey, lst,
+ PageContext.REQUEST_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("request");
-
- int iteration = 0;
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print((String)pageContext.getAttribute("theId"));
- iteration++;
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
- assertEquals(iterations, iteration);
- }
-
- public void endRequestScopeNameIterateList (WebResponse response){
- String output = response.getText();
- String compare = "";
- for (int i = 0; i < iterations; i++) {
- compare += "test" + i;
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\r","");
-
- assertEquals(compare, output);
- }
-
-
- /**
- * Testing <code>IterateTag</code> using name attribute in
- * the application scope.
- *
- * Tests the equivalent of this tag in a jsp:
- * <logic:iterate id="theId" name="testApplicationScopeNameIterateList"
- * property="list" scope="application">
- *
+
+ int iteration = 0;
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print((String) pageContext.getAttribute("theId"));
+ iteration++;
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ assertEquals(iterations, iteration);
+ }
+
+ public void endRequestScopeNameIterateList(WebResponse response) {
+ String output = response.getText();
+ String compare = "";
+ for (int i = 0; i < iterations; i++) {
+ compare += "test" + i;
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\r", "");
+
+ assertEquals(compare, output);
+ }
+
+
+ /**
+ * Testing <code>IterateTag</code> using name attribute in the application
+ * scope.
+ *
+ * Tests the equivalent of this tag in a jsp: <logic:iterate id="theId"
+ * name="testApplicationScopeNameIterateList" property="list"
+ * scope="application">
*/
-
- // ========= Application
- public void testApplicationScopePropertyIterateList()
- throws ServletException, JspException, IOException {
-
-
- String testKey = "testApplicationScopePropertyIterate";
+
+ // ========= Application
+ public void testApplicationScopePropertyIterateList()
+ throws ServletException, JspException, IOException {
+
+
+ String testKey = "testApplicationScopePropertyIterate";
ArrayList lst = new ArrayList();
for (int i = 0; i < iterations; i++) {
- lst.add("test" + i);
- }
-
- SimpleBeanForTesting sbft = new SimpleBeanForTesting();
- sbft.setList(lst);
-
- pageContext.setAttribute(testKey, sbft,
- PageContext.APPLICATION_SCOPE);
-
- IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
- /*
- * Tests the equivalent of this tag in a jsp:
- * <logic:iterate id="theId" name="testApplicationScopePropertyIterate"
- * scope="application">
- */
+ lst.add("test" + i);
+ }
+
+ SimpleBeanForTesting sbft = new SimpleBeanForTesting();
+ sbft.setList(lst);
+
+ pageContext.setAttribute(testKey, sbft,
+ PageContext.APPLICATION_SCOPE);
+
+ IterateTag tag = new IterateTag();
+ tag.setPageContext(pageContext);
+ /*
+ * Tests the equivalent of this tag in a jsp:
+ * <logic:iterate id="theId" name="testApplicationScopePropertyIterate"
+ * scope="application">
+ */
tag.setId("theId");
tag.setName(testKey);
tag.setScope("application");
tag.setProperty("list");
-
- int iteration = 0;
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print((String)pageContext.getAttribute("theId"));
- iteration++;
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
- assertEquals(iterations, iteration);
- }
-
- public void endApplicationScopePropertyIterateList (WebResponse response){
- String output = response.getText();
- String compare = "";
- for (int i = 0; i < iterations; i++) {
- compare += "test" + i;
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
-
- // ========= Session
- public void testSessionScopePropertyIteratesList()
- throws ServletException, JspException, IOException {
-
-
- String testKey = "testSessionScopePropertyIterate";
+
+ int iteration = 0;
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print((String) pageContext.getAttribute("theId"));
+ iteration++;
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ assertEquals(iterations, iteration);
+ }
+
+ public void endApplicationScopePropertyIterateList(WebResponse response) {
+ String output = response.getText();
+ String compare = "";
+ for (int i = 0; i < iterations; i++) {
+ compare += "test" + i;
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
+
+ // ========= Session
+ public void testSessionScopePropertyIteratesList()
+ throws ServletException, JspException, IOException {
+
+
+ String testKey = "testSessionScopePropertyIterate";
ArrayList lst = new ArrayList();
for (int i = 0; i < iterations; i++) {
- lst.add("test" + i);
- }
-
- SimpleBeanForTesting sbft = new SimpleBeanForTesting();
- sbft.setList(lst);
-
- pageContext.setAttribute(testKey, sbft,
- PageContext.SESSION_SCOPE);
-
- IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
- /*
- * Tests the equivalent of this tag in a jsp:
- * <logic:iterate id="theId" name="testSessionScopePropertyIterate"
- * scope="session">
- */
+ lst.add("test" + i);
+ }
+
+ SimpleBeanForTesting sbft = new SimpleBeanForTesting();
+ sbft.setList(lst);
+
+ pageContext.setAttribute(testKey, sbft,
+ PageContext.SESSION_SCOPE);
+
+ IterateTag tag = new IterateTag();
+ tag.setPageContext(pageContext);
+ /*
+ * Tests the equivalent of this tag in a jsp:
+ * <logic:iterate id="theId" name="testSessionScopePropertyIterate"
+ * scope="session">
+ */
tag.setId("theId");
tag.setName(testKey);
tag.setScope("session");
tag.setProperty("list");
-
- int iteration = 0;
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print((String)pageContext.getAttribute("theId"));
- iteration++;
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
- assertEquals(iterations, iteration);
- }
-
- public void endSessionScopePropertyIterateList (WebResponse response){
- String output = response.getText();
- String compare = "";
- for (int i = 0; i < iterations; i++) {
- compare += "test" + i;
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
-
- // ========= Request
- public void testRequestScopePropertyIteratesList()
- throws ServletException, JspException, IOException {
-
-
- String testKey = "testRequestScopePropertyIterate";
+
+ int iteration = 0;
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print((String) pageContext.getAttribute("theId"));
+ iteration++;
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ assertEquals(iterations, iteration);
+ }
+
+ public void endSessionScopePropertyIterateList(WebResponse response) {
+ String output = response.getText();
+ String compare = "";
+ for (int i = 0; i < iterations; i++) {
+ compare += "test" + i;
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
+
+ // ========= Request
+ public void testRequestScopePropertyIteratesList()
+ throws ServletException, JspException, IOException {
+
+
+ String testKey = "testRequestScopePropertyIterate";
ArrayList lst = new ArrayList();
for (int i = 0; i < iterations; i++) {
- lst.add("test" + i);
- }
-
- SimpleBeanForTesting sbft = new SimpleBeanForTesting();
- sbft.setList(lst);
-
- pageContext.setAttribute(testKey, sbft,
- PageContext.REQUEST_SCOPE);
-
- IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
- /*
- * Tests the equivalent of this tag in a jsp:
- * <logic:iterate id="theId" name="testRequestScopePropertyIterate"
- * scope="request">
- */
+ lst.add("test" + i);
+ }
+
+ SimpleBeanForTesting sbft = new SimpleBeanForTesting();
+ sbft.setList(lst);
+
+ pageContext.setAttribute(testKey, sbft,
+ PageContext.REQUEST_SCOPE);
+
+ IterateTag tag = new IterateTag();
+ tag.setPageContext(pageContext);
+ /*
+ * Tests the equivalent of this tag in a jsp:
+ * <logic:iterate id="theId" name="testRequestScopePropertyIterate"
+ * scope="request">
+ */
tag.setId("theId");
tag.setName(testKey);
tag.setScope("request");
tag.setProperty("list");
-
- int iteration = 0;
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print((String)pageContext.getAttribute("theId"));
- iteration++;
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
- assertEquals(iterations, iteration);
- }
-
- public void endRequestScopePropertyIterateList (WebResponse response){
- String output = response.getText();
- String compare = "";
- for (int i = 0; i < iterations; i++) {
- compare += "test" + i;
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
+ int iteration = 0;
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print((String) pageContext.getAttribute("theId"));
+ iteration++;
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ assertEquals(iterations, iteration);
+ }
+
+ public void endRequestScopePropertyIterateList(WebResponse response) {
+ String output = response.getText();
+ String compare = "";
+ for (int i = 0; i < iterations; i++) {
+ compare += "test" + i;
+ }
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
- /**
- * Testing <code>IterateTag</code> using name attribute in
- * the application scope.
- *
- * Tests the equivalent of this tag in a jsp:
- * <logic:iterate id="theId" name="testApplicationScopeNameIterateEnumeration"
- * scope="application">
- *
+ assertEquals(compare, output);
+ }
+
+
+ /**
+ * Testing <code>IterateTag</code> using name attribute in the application
+ * scope.
+ *
+ * Tests the equivalent of this tag in a jsp: <logic:iterate id="theId"
+ * name="testApplicationScopeNameIterateEnumeration" scope="application">
*/
- // ========= Application
- public void testApplicationScopeNameIterateEnumeration()
- throws ServletException, JspException, IOException {
-
- String testKey = "testApplicationScopeNameIterateEnumeration";
-
- StringTokenizer st = new StringTokenizer("Application Scope Name Iterate Enumeration");
+ // ========= Application
+ public void testApplicationScopeNameIterateEnumeration()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testApplicationScopeNameIterateEnumeration";
+
+ StringTokenizer st = new StringTokenizer(
+ "Application Scope Name Iterate Enumeration");
- pageContext.setAttribute(testKey, st,
- PageContext.APPLICATION_SCOPE);
+ pageContext.setAttribute(testKey, st,
+ PageContext.APPLICATION_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("application");
-
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print((String)pageContext.getAttribute("theId"));
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
-
- }
-
- public void endApplicationScopeNameIterateEnumeration (WebResponse response){
- String output = response.getText();
- StringTokenizer st = new StringTokenizer("Application Scope Name Iterate Enumeration");
- String compare = "";
-
- while (st.hasMoreTokens()) {
- compare += st.nextToken();
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
- // ========= Session
- public void testSessionScopeNameIterateEnumeration()
- throws ServletException, JspException, IOException {
-
- String testKey = "testSessionScopeNameIterateEnumeration";
-
- StringTokenizer st = new StringTokenizer("Session Scope Name Iterate Enumeration");
- pageContext.setAttribute(testKey, st,
- PageContext.SESSION_SCOPE);
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print((String) pageContext.getAttribute("theId"));
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+
+ }
+
+ public void endApplicationScopeNameIterateEnumeration(
+ WebResponse response) {
+ String output = response.getText();
+ StringTokenizer st = new StringTokenizer(
+ "Application Scope Name Iterate Enumeration");
+ String compare = "";
+
+ while (st.hasMoreTokens()) {
+ compare += st.nextToken();
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
+ // ========= Session
+ public void testSessionScopeNameIterateEnumeration()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testSessionScopeNameIterateEnumeration";
+
+ StringTokenizer st =
+ new StringTokenizer("Session Scope Name Iterate Enumeration");
+
+ pageContext.setAttribute(testKey, st,
+ PageContext.SESSION_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("session");
-
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print((String)pageContext.getAttribute("theId"));
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
-
- }
-
- public void endSessionScopeNameIterateEnumeration (WebResponse response){
- String output = response.getText();
- StringTokenizer st = new StringTokenizer("Session Scope Name Iterate Enumeration");
- String compare = "";
-
- while (st.hasMoreTokens()) {
- compare += st.nextToken();
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
- // ========= Request
- public void testRequestScopeNameIterateEnumeration()
- throws ServletException, JspException, IOException {
-
- String testKey = "testRequestScopeNameIterateEnumeration";
-
- StringTokenizer st = new StringTokenizer("Request Scope Name Iterate Enumeration");
- pageContext.setAttribute(testKey, st,
- PageContext.REQUEST_SCOPE);
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print((String) pageContext.getAttribute("theId"));
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+
+ }
+
+ public void endSessionScopeNameIterateEnumeration(WebResponse response) {
+ String output = response.getText();
+ StringTokenizer st =
+ new StringTokenizer("Session Scope Name Iterate Enumeration");
+ String compare = "";
+
+ while (st.hasMoreTokens()) {
+ compare += st.nextToken();
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
+ // ========= Request
+ public void testRequestScopeNameIterateEnumeration()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testRequestScopeNameIterateEnumeration";
+
+ StringTokenizer st =
+ new StringTokenizer("Request Scope Name Iterate Enumeration");
+
+ pageContext.setAttribute(testKey, st,
+ PageContext.REQUEST_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("request");
-
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print((String)pageContext.getAttribute("theId"));
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
-
- }
-
- public void endRequestScopeNameIterateEnumeration (WebResponse response){
- String output = response.getText();
- StringTokenizer st = new StringTokenizer("Request Scope Name Iterate Enumeration");
- String compare = "";
-
- while (st.hasMoreTokens()) {
- compare += st.nextToken();
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
-
- /**
- * Testing <code>IterateTag</code> using property attribute in
- * the application scope.
- *
- * Tests the equivalent of this tag in a jsp:
- * <logic:iterate id="theId" name="testApplicationScopePropertyIterateEnumeration"
- * scope="application">
- *
+
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print((String) pageContext.getAttribute("theId"));
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+
+ }
+
+ public void endRequestScopeNameIterateEnumeration(WebResponse response) {
+ String output = response.getText();
+ StringTokenizer st =
+ new StringTokenizer("Request Scope Name Iterate Enumeration");
+ String compare = "";
+
+ while (st.hasMoreTokens()) {
+ compare += st.nextToken();
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
+
+ /**
+ * Testing <code>IterateTag</code> using property attribute in the
+ * application scope.
+ *
+ * Tests the equivalent of this tag in a jsp: <logic:iterate id="theId"
+ * name="testApplicationScopePropertyIterateEnumeration"
+ * scope="application">
*/
- // ========= Application
- public void testApplicationScopePropertyIterateEnumeration()
- throws ServletException, JspException, IOException {
-
- String testKey = "testApplicationScopePropertyIterateEnumeration";
-
- StringTokenizer st = new StringTokenizer("Application Scope Property Iterate Enumeration");
+ // ========= Application
+ public void testApplicationScopePropertyIterateEnumeration()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testApplicationScopePropertyIterateEnumeration";
+
+ StringTokenizer st = new StringTokenizer(
+ "Application Scope Property Iterate Enumeration");
- SimpleBeanForTesting sbft = new SimpleBeanForTesting();
- sbft.setEnumeration(st);
+ SimpleBeanForTesting sbft = new SimpleBeanForTesting();
+ sbft.setEnumeration(st);
- pageContext.setAttribute(testKey, sbft,
- PageContext.APPLICATION_SCOPE);
+ pageContext.setAttribute(testKey, sbft,
+ PageContext.APPLICATION_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("application");
tag.setProperty("enumeration");
-
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print((String)pageContext.getAttribute("theId"));
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
-
- }
-
- public void endApplicationScopePropertyIterateEnumeration (WebResponse response){
- String output = response.getText();
- StringTokenizer st = new StringTokenizer("Application Scope Property Iterate Enumeration");
- String compare = "";
-
- while (st.hasMoreTokens()) {
- compare += st.nextToken();
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
- // ========= Session
- public void testSessionScopePropertyIterateEnumeration()
- throws ServletException, JspException, IOException {
-
- String testKey = "testSessionScopePropertyIterateEnumeration";
-
- StringTokenizer st = new StringTokenizer("Session Scope Property Iterate Enumeration");
- SimpleBeanForTesting sbft = new SimpleBeanForTesting();
- sbft.setEnumeration(st);
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print((String) pageContext.getAttribute("theId"));
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+
+ }
+
+ public void endApplicationScopePropertyIterateEnumeration(
+ WebResponse response) {
+ String output = response.getText();
+ StringTokenizer st = new StringTokenizer(
+ "Application Scope Property Iterate Enumeration");
+ String compare = "";
+
+ while (st.hasMoreTokens()) {
+ compare += st.nextToken();
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
+ // ========= Session
+ public void testSessionScopePropertyIterateEnumeration()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testSessionScopePropertyIterateEnumeration";
- pageContext.setAttribute(testKey, sbft,
- PageContext.SESSION_SCOPE);
+ StringTokenizer st = new StringTokenizer(
+ "Session Scope Property Iterate Enumeration");
+
+ SimpleBeanForTesting sbft = new SimpleBeanForTesting();
+ sbft.setEnumeration(st);
+
+ pageContext.setAttribute(testKey, sbft,
+ PageContext.SESSION_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("session");
tag.setProperty("enumeration");
-
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print((String)pageContext.getAttribute("theId"));
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
-
- }
-
- public void endSessionScopePropertyIterateEnumeration (WebResponse response){
- String output = response.getText();
- StringTokenizer st = new StringTokenizer("Session Scope Property Iterate Enumeration");
- String compare = "";
-
- while (st.hasMoreTokens()) {
- compare += st.nextToken();
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
- // ========= Request
- public void testRequestScopePropertyIterateEnumeration()
- throws ServletException, JspException, IOException {
-
- String testKey = "testRequestScopePropertyIterateEnumeration";
-
- StringTokenizer st = new StringTokenizer("Request Scope Property Iterate Enumeration");
- SimpleBeanForTesting sbft = new SimpleBeanForTesting();
- sbft.setEnumeration(st);
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print((String) pageContext.getAttribute("theId"));
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+
+ }
+
+ public void endSessionScopePropertyIterateEnumeration(
+ WebResponse response) {
+ String output = response.getText();
+ StringTokenizer st = new StringTokenizer(
+ "Session Scope Property Iterate Enumeration");
+ String compare = "";
+
+ while (st.hasMoreTokens()) {
+ compare += st.nextToken();
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
+ // ========= Request
+ public void testRequestScopePropertyIterateEnumeration()
+ throws ServletException, JspException, IOException {
- pageContext.setAttribute(testKey, sbft,
- PageContext.REQUEST_SCOPE);
+ String testKey = "testRequestScopePropertyIterateEnumeration";
+
+ StringTokenizer st = new StringTokenizer(
+ "Request Scope Property Iterate Enumeration");
+
+ SimpleBeanForTesting sbft = new SimpleBeanForTesting();
+ sbft.setEnumeration(st);
+
+ pageContext.setAttribute(testKey, sbft,
+ PageContext.REQUEST_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("request");
tag.setProperty("enumeration");
-
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print((String)pageContext.getAttribute("theId"));
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
-
- }
-
- public void endRequestScopePropertyIterateEnumeration (WebResponse response){
- String output = response.getText();
- StringTokenizer st = new StringTokenizer("Request Scope Property Iterate Enumeration");
- String compare = "";
-
- while (st.hasMoreTokens()) {
- compare += st.nextToken();
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print((String) pageContext.getAttribute("theId"));
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ }
+ public void endRequestScopePropertyIterateEnumeration(
+ WebResponse response) {
+ String output = response.getText();
+ StringTokenizer st = new StringTokenizer(
+ "Request Scope Property Iterate Enumeration");
+ String compare = "";
+
+ while (st.hasMoreTokens()) {
+ compare += st.nextToken();
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
- /**
- * Testing <code>IterateTag</code> using name attribute in
- * the application scope.
- *
- * Tests the equivalent of this tag in a jsp:
- * <logic:iterate id="theId" name="testApplicationScopeNameIterateMap"
- * scope="application">
- *
+ assertEquals(compare, output);
+ }
+
+
+ /**
+ * Testing <code>IterateTag</code> using name attribute in the application
+ * scope.
+ *
+ * Tests the equivalent of this tag in a jsp: <logic:iterate id="theId"
+ * name="testApplicationScopeNameIterateMap" scope="application">
*/
- // ========= Application
- public void testApplicationScopeNameIterateMap()
- throws ServletException, JspException, IOException {
-
- String testKey = "testApplicationScopeNameIterateMap";
+ // ========= Application
+ public void testApplicationScopeNameIterateMap()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testApplicationScopeNameIterateMap";
HashMap map = new HashMap();
for (int i = 0; i < iterations; i++) {
- map.put("test" + i,"test" + i);
- }
-
- pageContext.setAttribute(testKey, map,
- PageContext.APPLICATION_SCOPE);
+ map.put("test" + i, "test" + i);
+ }
+
+ pageContext.setAttribute(testKey, map,
+ PageContext.APPLICATION_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("application");
-
- int iteration = 0;
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print(pageContext.getAttribute("theId"));
- iteration++;
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
- assertEquals(iterations, iteration);
- }
-
- public void endApplicationScopeNameIterateMap (WebResponse response){
- String output = response.getText();
- String compare = "";
- for (int i = 0; i < iterations; i++) {
- compare += "test" + i;
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
- // ========= Session
- public void testSessionScopeNameIterateMap()
- throws ServletException, JspException, IOException {
-
- String testKey = "testSessionScopeNameIterateMap";
+
+ int iteration = 0;
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print(pageContext.getAttribute("theId"));
+ iteration++;
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ assertEquals(iterations, iteration);
+ }
+
+ public void endApplicationScopeNameIterateMap(WebResponse response) {
+ String output = response.getText();
+ String compare = "";
+ for (int i = 0; i < iterations; i++) {
+ compare += "test" + i;
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
+ // ========= Session
+ public void testSessionScopeNameIterateMap()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testSessionScopeNameIterateMap";
HashMap map = new HashMap();
for (int i = 0; i < iterations; i++) {
- map.put("test" + i,"test" + i);
- }
-
- pageContext.setAttribute(testKey, map,
- PageContext.SESSION_SCOPE);
+ map.put("test" + i, "test" + i);
+ }
+
+ pageContext.setAttribute(testKey, map,
+ PageContext.SESSION_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("session");
-
- int iteration = 0;
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print(pageContext.getAttribute("theId"));
- iteration++;
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
- assertEquals(iterations, iteration);
- }
-
- public void endSessionScopeNameIterateMap (WebResponse response){
- String output = response.getText();
- String compare = "";
- for (int i = 0; i < iterations; i++) {
- compare += "test" + i;
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
- // ========= Request
- public void testRequestScopeNameIterateMap()
- throws ServletException, JspException, IOException {
-
- String testKey = "testRequestScopeNameIterateMap";
+
+ int iteration = 0;
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print(pageContext.getAttribute("theId"));
+ iteration++;
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ assertEquals(iterations, iteration);
+ }
+
+ public void endSessionScopeNameIterateMap(WebResponse response) {
+ String output = response.getText();
+ String compare = "";
+ for (int i = 0; i < iterations; i++) {
+ compare += "test" + i;
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
+ // ========= Request
+ public void testRequestScopeNameIterateMap()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testRequestScopeNameIterateMap";
HashMap map = new HashMap();
for (int i = 0; i < iterations; i++) {
- map.put("test" + i,"test" + i);
- }
-
- pageContext.setAttribute(testKey, map,
- PageContext.REQUEST_SCOPE);
+ map.put("test" + i, "test" + i);
+ }
+
+ pageContext.setAttribute(testKey, map,
+ PageContext.REQUEST_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("request");
-
- int iteration = 0;
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print(pageContext.getAttribute("theId"));
- iteration++;
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
- assertEquals(iterations, iteration);
- }
-
- public void endRequestScopeNameIterateMap (WebResponse response){
- String output = response.getText();
- String compare = "";
- for (int i = 0; i < iterations; i++) {
- compare += "test" + i;
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
+ int iteration = 0;
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print(pageContext.getAttribute("theId"));
+ iteration++;
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ assertEquals(iterations, iteration);
+ }
+
+ public void endRequestScopeNameIterateMap(WebResponse response) {
+ String output = response.getText();
+ String compare = "";
+ for (int i = 0; i < iterations; i++) {
+ compare += "test" + i;
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
- /**
- * Testing <code>IterateTag</code> using property attribute in
- * the application scope.
- *
- * Tests the equivalent of this tag in a jsp:
- * <logic:iterate id="theId" name="testApplicationScopePropertyIterateMap"
- * scope="application">
- *
+ /**
+ * Testing <code>IterateTag</code> using property attribute in the
+ * application scope.
+ *
+ * Tests the equivalent of this tag in a jsp: <logic:iterate id="theId"
+ * name="testApplicationScopePropertyIterateMap" scope="application">
*/
- // ========= Application
- public void testApplicationScopePropertyIterateMap()
- throws ServletException, JspException, IOException {
-
- String testKey = "testApplicationScopePropertyIterateMap";
+ // ========= Application
+ public void testApplicationScopePropertyIterateMap()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testApplicationScopePropertyIterateMap";
HashMap map = new HashMap();
for (int i = 0; i < iterations; i++) {
- map.put("test" + i,"test" + i);
- }
-
- SimpleBeanForTesting sbft = new SimpleBeanForTesting();
- sbft.setMap(map);
-
- pageContext.setAttribute(testKey, sbft,
- PageContext.APPLICATION_SCOPE);
+ map.put("test" + i, "test" + i);
+ }
+
+ SimpleBeanForTesting sbft = new SimpleBeanForTesting();
+ sbft.setMap(map);
+
+ pageContext.setAttribute(testKey, sbft,
+ PageContext.APPLICATION_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("application");
tag.setProperty("map");
-
- int iteration = 0;
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print(pageContext.getAttribute("theId"));
- iteration++;
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
- assertEquals(iterations, iteration);
- }
-
- public void endApplicationScopePropertyIterateMap (WebResponse response){
- String output = response.getText();
- String compare = "";
- for (int i = 0; i < iterations; i++) {
- compare += "test" + i;
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
- // ========= Session
- public void testSessionScopePropertyIterateMap()
- throws ServletException, JspException, IOException {
-
- String testKey = "testSessionScopePropertyIterateMap";
+
+ int iteration = 0;
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print(pageContext.getAttribute("theId"));
+ iteration++;
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ assertEquals(iterations, iteration);
+ }
+
+ public void endApplicationScopePropertyIterateMap(WebResponse response) {
+ String output = response.getText();
+ String compare = "";
+ for (int i = 0; i < iterations; i++) {
+ compare += "test" + i;
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
+ // ========= Session
+ public void testSessionScopePropertyIterateMap()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testSessionScopePropertyIterateMap";
HashMap map = new HashMap();
for (int i = 0; i < iterations; i++) {
- map.put("test" + i,"test" + i);
- }
+ map.put("test" + i, "test" + i);
+ }
+
+ SimpleBeanForTesting sbft = new SimpleBeanForTesting();
+ sbft.setMap(map);
- SimpleBeanForTesting sbft = new SimpleBeanForTesting();
- sbft.setMap(map);
-
- pageContext.setAttribute(testKey, sbft,
- PageContext.SESSION_SCOPE);
+ pageContext.setAttribute(testKey, sbft,
+ PageContext.SESSION_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("session");
tag.setProperty("map");
-
- int iteration = 0;
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print(pageContext.getAttribute("theId"));
- iteration++;
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
- assertEquals(iterations, iteration);
- }
-
- public void endSessionScopePropertyIterateMap (WebResponse response){
- String output = response.getText();
- String compare = "";
- for (int i = 0; i < iterations; i++) {
- compare += "test" + i;
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
- // ========= Request
- public void testRequestScopePropertyIterateMap()
- throws ServletException, JspException, IOException {
-
- String testKey = "testRequestScopePropertyIterateMap";
+
+ int iteration = 0;
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print(pageContext.getAttribute("theId"));
+ iteration++;
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ assertEquals(iterations, iteration);
+ }
+
+ public void endSessionScopePropertyIterateMap(WebResponse response) {
+ String output = response.getText();
+ String compare = "";
+ for (int i = 0; i < iterations; i++) {
+ compare += "test" + i;
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
+ // ========= Request
+ public void testRequestScopePropertyIterateMap()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testRequestScopePropertyIterateMap";
HashMap map = new HashMap();
for (int i = 0; i < iterations; i++) {
- map.put("test" + i,"test" + i);
- }
-
- SimpleBeanForTesting sbft = new SimpleBeanForTesting();
- sbft.setMap(map);
-
- pageContext.setAttribute(testKey, sbft,
- PageContext.REQUEST_SCOPE);
+ map.put("test" + i, "test" + i);
+ }
+
+ SimpleBeanForTesting sbft = new SimpleBeanForTesting();
+ sbft.setMap(map);
+
+ pageContext.setAttribute(testKey, sbft,
+ PageContext.REQUEST_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("request");
tag.setProperty("map");
-
- int iteration = 0;
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print(pageContext.getAttribute("theId"));
- iteration++;
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
- assertEquals(iterations, iteration);
- }
-
- public void endRequestScopePropertyIterateMap (WebResponse response){
- String output = response.getText();
- String compare = "";
- for (int i = 0; i < iterations; i++) {
- compare += "test" + i;
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
+ int iteration = 0;
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print(pageContext.getAttribute("theId"));
+ iteration++;
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ assertEquals(iterations, iteration);
+ }
+ public void endRequestScopePropertyIterateMap(WebResponse response) {
+ String output = response.getText();
+ String compare = "";
+ for (int i = 0; i < iterations; i++) {
+ compare += "test" + i;
+ }
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
- /**
- * Testing <code>IterateTag</code> using name attribute in
- * the application scope.
- *
- * Tests the equivalent of this tag in a jsp:
- * <logic:iterate id="theId" name="testApplicationScopeNameIterateArray"
- * scope="application">
- *
+
+ /**
+ * Testing <code>IterateTag</code> using name attribute in the application
+ * scope.
+ *
+ * Tests the equivalent of this tag in a jsp: <logic:iterate id="theId"
+ * name="testApplicationScopeNameIterateArray" scope="application">
*/
- // ========= Application
- public void testApplicationScopeNameIterateArray()
- throws ServletException, JspException, IOException {
-
- String testKey = "testApplicationScopeNameIterateArray";
+ // ========= Application
+ public void testApplicationScopeNameIterateArray()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testApplicationScopeNameIterateArray";
String[] tst = new String[iterations];
- for (int i = 0; i < tst.length; i++) {
- tst[i] = "test" + i;
- }
-
- pageContext.setAttribute(testKey, tst,
- PageContext.APPLICATION_SCOPE);
+ for (int i = 0; i < tst.length; i++) {
+ tst[i] = "test" + i;
+ }
+
+ pageContext.setAttribute(testKey, tst,
+ PageContext.APPLICATION_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("application");
-
- int iteration = 0;
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print(pageContext.getAttribute("theId"));
- iteration++;
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
- assertEquals(iterations, iteration);
- }
- public void endApplicationScopeNameIterateArray (WebResponse response){
- String output = response.getText();
+ int iteration = 0;
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print(pageContext.getAttribute("theId"));
+ iteration++;
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ assertEquals(iterations, iteration);
+ }
+
+ public void endApplicationScopeNameIterateArray(WebResponse response) {
+ String output = response.getText();
String[] tst = new String[iterations];
- for (int i = 0; i < tst.length; i++) {
- tst[i] = "test" + i;
- }
-
- String compare = "";
- for (int i = 0; i < iterations; i++) {
- compare += tst[i];
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
- // ========= Session
- public void testSessionScopeNameIterateArray()
- throws ServletException, JspException, IOException {
-
- String testKey = "testSessionScopeNameIterateArray";
+ for (int i = 0; i < tst.length; i++) {
+ tst[i] = "test" + i;
+ }
+
+ String compare = "";
+ for (int i = 0; i < iterations; i++) {
+ compare += tst[i];
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
+ // ========= Session
+ public void testSessionScopeNameIterateArray()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testSessionScopeNameIterateArray";
String[] tst = new String[iterations];
- for (int i = 0; i < tst.length; i++) {
- tst[i] = "test" + i;
- }
-
- pageContext.setAttribute(testKey, tst,
- PageContext.SESSION_SCOPE);
+ for (int i = 0; i < tst.length; i++) {
+ tst[i] = "test" + i;
+ }
+
+ pageContext.setAttribute(testKey, tst,
+ PageContext.SESSION_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("session");
-
- int iteration = 0;
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print(pageContext.getAttribute("theId"));
- iteration++;
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
- assertEquals(iterations, iteration);
- }
- public void endSessionScopeNameIterateArray (WebResponse response){
- String output = response.getText();
+ int iteration = 0;
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print(pageContext.getAttribute("theId"));
+ iteration++;
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ assertEquals(iterations, iteration);
+ }
+
+ public void endSessionScopeNameIterateArray(WebResponse response) {
+ String output = response.getText();
String[] tst = new String[iterations];
- for (int i = 0; i < tst.length; i++) {
- tst[i] = "test" + i;
- }
-
- String compare = "";
- for (int i = 0; i < iterations; i++) {
- compare += tst[i];
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
- // ========= Request
- public void testRequestScopeNameIterateArray()
- throws ServletException, JspException, IOException {
-
- String testKey = "testRequestScopeNameIterateArray";
+ for (int i = 0; i < tst.length; i++) {
+ tst[i] = "test" + i;
+ }
+
+ String compare = "";
+ for (int i = 0; i < iterations; i++) {
+ compare += tst[i];
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
+ // ========= Request
+ public void testRequestScopeNameIterateArray()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testRequestScopeNameIterateArray";
String[] tst = new String[iterations];
- for (int i = 0; i < tst.length; i++) {
- tst[i] = "test" + i;
- }
-
- pageContext.setAttribute(testKey, tst,
- PageContext.REQUEST_SCOPE);
+ for (int i = 0; i < tst.length; i++) {
+ tst[i] = "test" + i;
+ }
+
+ pageContext.setAttribute(testKey, tst,
+ PageContext.REQUEST_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("request");
-
- int iteration = 0;
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print(pageContext.getAttribute("theId"));
- iteration++;
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
- assertEquals(iterations, iteration);
- }
- public void endRequestScopeNameIterateArray (WebResponse response){
- String output = response.getText();
+ int iteration = 0;
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print(pageContext.getAttribute("theId"));
+ iteration++;
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ assertEquals(iterations, iteration);
+ }
+
+ public void endRequestScopeNameIterateArray(WebResponse response) {
+ String output = response.getText();
String[] tst = new String[iterations];
- for (int i = 0; i < tst.length; i++) {
- tst[i] = "test" + i;
- }
-
- String compare = "";
- for (int i = 0; i < iterations; i++) {
- compare += tst[i];
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
-
- /**
- * Testing <code>IterateTag</code> using property attribute in
- * the application scope.
- *
- * Tests the equivalent of this tag in a jsp:
- * <logic:iterate id="theId" name="testApplicationScopePropertyIterateArray"
- * scope="application">
- *
+ for (int i = 0; i < tst.length; i++) {
+ tst[i] = "test" + i;
+ }
+
+ String compare = "";
+ for (int i = 0; i < iterations; i++) {
+ compare += tst[i];
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
+
+ /**
+ * Testing <code>IterateTag</code> using property attribute in the
+ * application scope.
+ *
+ * Tests the equivalent of this tag in a jsp: <logic:iterate id="theId"
+ * name="testApplicationScopePropertyIterateArray" scope="application">
*/
- // ========= Application
- public void testApplicationScopePropertyIterateArray()
- throws ServletException, JspException, IOException {
-
- String testKey = "testApplicationScopePropertyIterateArray";
+ // ========= Application
+ public void testApplicationScopePropertyIterateArray()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testApplicationScopePropertyIterateArray";
String[] tst = new String[iterations];
- for (int i = 0; i < tst.length; i++) {
- tst[i] = "test" + i;
- }
- SimpleBeanForTesting sbft = new SimpleBeanForTesting();
- sbft.setArray(tst);
-
- pageContext.setAttribute(testKey, sbft,
- PageContext.APPLICATION_SCOPE);
+ for (int i = 0; i < tst.length; i++) {
+ tst[i] = "test" + i;
+ }
+ SimpleBeanForTesting sbft = new SimpleBeanForTesting();
+ sbft.setArray(tst);
+
+ pageContext.setAttribute(testKey, sbft,
+ PageContext.APPLICATION_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("application");
tag.setProperty("array");
-
- int iteration = 0;
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print(pageContext.getAttribute("theId"));
- iteration++;
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
- assertEquals(iterations, iteration);
- }
- public void endApplicationScopePropertyIterateArray (WebResponse response){
- String output = response.getText();
+ int iteration = 0;
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print(pageContext.getAttribute("theId"));
+ iteration++;
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ assertEquals(iterations, iteration);
+ }
+
+ public void endApplicationScopePropertyIterateArray(
+ WebResponse response) {
+ String output = response.getText();
String[] tst = new String[iterations];
- for (int i = 0; i < tst.length; i++) {
- tst[i] = "test" + i;
- }
-
- String compare = "";
- for (int i = 0; i < iterations; i++) {
- compare += tst[i];
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
- // ========= Session
- public void testSessionScopePropertyIterateArray()
- throws ServletException, JspException, IOException {
-
- String testKey = "testSessionScopePropertyIterateArray";
+ for (int i = 0; i < tst.length; i++) {
+ tst[i] = "test" + i;
+ }
+
+ String compare = "";
+ for (int i = 0; i < iterations; i++) {
+ compare += tst[i];
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
+ // ========= Session
+ public void testSessionScopePropertyIterateArray()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testSessionScopePropertyIterateArray";
String[] tst = new String[iterations];
- for (int i = 0; i < tst.length; i++) {
- tst[i] = "test" + i;
- }
+ for (int i = 0; i < tst.length; i++) {
+ tst[i] = "test" + i;
+ }
- SimpleBeanForTesting sbft = new SimpleBeanForTesting();
- sbft.setArray(tst);
+ SimpleBeanForTesting sbft = new SimpleBeanForTesting();
+ sbft.setArray(tst);
- pageContext.setAttribute(testKey, sbft,
- PageContext.SESSION_SCOPE);
+ pageContext.setAttribute(testKey, sbft,
+ PageContext.SESSION_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("session");
tag.setProperty("array");
-
- int iteration = 0;
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print(pageContext.getAttribute("theId"));
- iteration++;
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
- assertEquals(iterations, iteration);
- }
- public void endSessionScopePropertyIterateArray (WebResponse response){
- String output = response.getText();
+ int iteration = 0;
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print(pageContext.getAttribute("theId"));
+ iteration++;
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ assertEquals(iterations, iteration);
+ }
+
+ public void endSessionScopePropertyIterateArray(WebResponse response) {
+ String output = response.getText();
String[] tst = new String[iterations];
- for (int i = 0; i < tst.length; i++) {
- tst[i] = "test" + i;
- }
-
- String compare = "";
- for (int i = 0; i < iterations; i++) {
- compare += tst[i];
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
- // ========= Request
- public void testRequestScopePropertyIterateArray()
- throws ServletException, JspException, IOException {
-
- String testKey = "testRequestScopePropertyIterateArray";
+ for (int i = 0; i < tst.length; i++) {
+ tst[i] = "test" + i;
+ }
+
+ String compare = "";
+ for (int i = 0; i < iterations; i++) {
+ compare += tst[i];
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
+ // ========= Request
+ public void testRequestScopePropertyIterateArray()
+ throws ServletException, JspException, IOException {
+
+ String testKey = "testRequestScopePropertyIterateArray";
String[] tst = new String[iterations];
- for (int i = 0; i < tst.length; i++) {
- tst[i] = "test" + i;
- }
-
- SimpleBeanForTesting sbft = new SimpleBeanForTesting();
- sbft.setArray(tst);
+ for (int i = 0; i < tst.length; i++) {
+ tst[i] = "test" + i;
+ }
+
+ SimpleBeanForTesting sbft = new SimpleBeanForTesting();
+ sbft.setArray(tst);
- pageContext.setAttribute(testKey, sbft,
- PageContext.REQUEST_SCOPE);
+ pageContext.setAttribute(testKey, sbft,
+ PageContext.REQUEST_SCOPE);
IterateTag tag = new IterateTag();
- tag.setPageContext(pageContext);
+ tag.setPageContext(pageContext);
tag.setId("theId");
tag.setName(testKey);
tag.setScope("request");
tag.setProperty("array");
-
- int iteration = 0;
- tag.doStartTag();
- tag.doInitBody();
- do
- {
- out.print(pageContext.getAttribute("theId"));
- iteration++;
-
- } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
- tag.doEndTag();
- assertEquals(iterations, iteration);
- }
- public void endRequestScopePropertyIterateArray (WebResponse response){
- String output = response.getText();
+ int iteration = 0;
+ tag.doStartTag();
+ tag.doInitBody();
+ do {
+ out.print(pageContext.getAttribute("theId"));
+ iteration++;
+
+ } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
+ tag.doEndTag();
+ assertEquals(iterations, iteration);
+ }
+
+ public void endRequestScopePropertyIterateArray(WebResponse response) {
+ String output = response.getText();
String[] tst = new String[iterations];
- for (int i = 0; i < tst.length; i++) {
- tst[i] = "test" + i;
- }
-
- String compare = "";
- for (int i = 0; i < iterations; i++) {
- compare += tst[i];
- }
-
- //fix for introduced carriage return / line feeds
- output = replace(compare,"\r","");
- output = replace(output,"\n","");
-
- assertEquals(compare, output);
- }
-
+ for (int i = 0; i < tst.length; i++) {
+ tst[i] = "test" + i;
+ }
+
+ String compare = "";
+ for (int i = 0; i < iterations; i++) {
+ compare += tst[i];
+ }
+
+ //fix for introduced carriage return / line feeds
+ output = replace(compare, "\r", "");
+ output = replace(output, "\n", "");
+
+ assertEquals(compare, output);
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org