KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > taglib > logic > TestIterateTag


1 /*
2  * $Id: TestIterateTag.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.struts.taglib.logic;
19
20 import java.io.IOException JavaDoc;
21 import java.util.ArrayList JavaDoc;
22 import java.util.HashMap JavaDoc;
23 import java.util.StringTokenizer JavaDoc;
24
25 import javax.servlet.ServletException JavaDoc;
26 import javax.servlet.jsp.JspException JavaDoc;
27 import javax.servlet.jsp.PageContext JavaDoc;
28
29 import junit.framework.Test;
30 import junit.framework.TestSuite;
31
32 import org.apache.cactus.WebResponse;
33 import org.apache.struts.taglib.SimpleBeanForTesting;
34 import org.apache.struts.taglib.TaglibTestBase;
35
36
37
38 /**
39  * Suite of unit tests for the
40  * <code>org.apache.struts.taglib.logic.IterateTag</code> class.
41  *
42  */

43 public class TestIterateTag extends TaglibTestBase {
44     
45     private int iterations = 2;
46     
47     /**
48      * Defines the testcase name for JUnit.
49      *
50      * @param theName the testcase's name.
51      */

52     public TestIterateTag(String JavaDoc theName) {
53         super(theName);
54     }
55
56     /**
57      * Start the tests.
58      *
59      * @param theArgs the arguments. Not used
60      */

61     public static void main(String JavaDoc[] theArgs) {
62         junit.awtui.TestRunner.main(new String JavaDoc[] {TestIterateTag.class.getName()});
63     }
64
65     /**
66      * @return a test suite (<code>TestSuite</code>) that includes all methods
67      * starting with "test"
68      */

69     public static Test suite() {
70         // All methods starting with "test" will be executed in the test suite.
71
return new TestSuite(TestIterateTag.class);
72     }
73
74
75    /**
76      * Testing <code>IterateTag</code> using name attribute in
77      * the application scope.
78      *
79      * Tests the equivalent of this tag in a jsp:
80      * <logic:iterate id="theId" name="testApplicationScopeNameIterateList"
81      * scope="application">
82      *
83      */

84
85     // ========= Application
86
public void testApplicationScopeNameIterateList()
87         throws ServletException JavaDoc, JspException JavaDoc, IOException JavaDoc {
88         
89         String JavaDoc testKey = "testApplicationScopeNameIterateList";
90
91         ArrayList JavaDoc lst = new ArrayList JavaDoc();
92         for (int i = 0; i < iterations; i++) {
93             lst.add("test" + i);
94         }
95         
96         pageContext.setAttribute(testKey, lst,
97                                     PageContext.APPLICATION_SCOPE);
98
99         IterateTag tag = new IterateTag();
100         tag.setPageContext(pageContext);
101         tag.setId("theId");
102         tag.setName(testKey);
103         tag.setScope("application");
104         
105         int iteration = 0;
106         tag.doStartTag();
107         tag.doInitBody();
108         do
109         {
110             out.print((String JavaDoc)pageContext.getAttribute("theId"));
111             iteration++;
112         
113         } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
114         tag.doEndTag();
115         assertEquals(iterations, iteration);
116     }
117
118     public void endApplicationScopeNameIterateList (WebResponse response){
119         String JavaDoc output = response.getText();
120         String JavaDoc compare = "";
121         for (int i = 0; i < iterations; i++) {
122             compare += "test" + i;
123         }
124
125         //fix for introduced carriage return / line feeds
126
output = replace(output,"\r","");
127         output = replace(output,"\n","");
128
129         assertEquals(compare, output);
130     }
131     
132     // ========= Session
133
public void testSessionScopeNameIterateList()
134         throws ServletException JavaDoc, JspException JavaDoc, IOException JavaDoc {
135         
136         String JavaDoc testKey = "testSessionScopeNameIterateList";
137
138         ArrayList JavaDoc lst = new ArrayList JavaDoc();
139         for (int i = 0; i < iterations; i++) {
140             lst.add("test" + i);
141         }
142         
143         pageContext.setAttribute(testKey, lst,
144                                     PageContext.SESSION_SCOPE);
145
146         IterateTag tag = new IterateTag();
147         tag.setPageContext(pageContext);
148         tag.setId("theId");
149         tag.setName(testKey);
150         tag.setScope("session");
151         
152         int iteration = 0;
153         tag.doStartTag();
154         tag.doInitBody();
155         do
156         {
157             out.print((String JavaDoc)pageContext.getAttribute("theId"));
158             iteration++;
159         
160         } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
161         tag.doEndTag();
162         assertEquals(iterations, iteration);
163     }
164
165     public void endSessionScopeNameIterateList (WebResponse response){
166         String JavaDoc output = response.getText();
167         String JavaDoc compare = "";
168         for (int i = 0; i < iterations; i++) {
169             compare += "test" + i;
170         }
171
172         //fix for introduced carriage return / line feeds
173
output = replace(compare,"\r","");
174         output = replace(output,"\n","");
175
176         assertEquals(compare, output);
177     }
178
179     // ========= Request
180
public void testRequestScopeNameIterateList()
181         throws ServletException JavaDoc, JspException JavaDoc, IOException JavaDoc {
182         
183         String JavaDoc testKey = "testRequestScopeNameIterateList";
184
185         ArrayList JavaDoc lst = new ArrayList JavaDoc();
186         for (int i = 0; i < iterations; i++) {
187             lst.add("test" + i);
188         }
189         
190         pageContext.setAttribute(testKey, lst,
191                                     PageContext.REQUEST_SCOPE);
192
193         IterateTag tag = new IterateTag();
194         tag.setPageContext(pageContext);
195         tag.setId("theId");
196         tag.setName(testKey);
197         tag.setScope("request");
198         
199         int iteration = 0;
200         tag.doStartTag();
201         tag.doInitBody();
202         do
203         {
204             out.print((String JavaDoc)pageContext.getAttribute("theId"));
205             iteration++;
206         
207         } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
208         tag.doEndTag();
209         assertEquals(iterations, iteration);
210     }
211
212     public void endRequestScopeNameIterateList (WebResponse response){
213         String JavaDoc output = response.getText();
214         String JavaDoc compare = "";
215         for (int i = 0; i < iterations; i++) {
216             compare += "test" + i;
217         }
218
219         //fix for introduced carriage return / line feeds
220
output = replace(compare,"\r","");
221         output = replace(output,"\r","");
222
223         assertEquals(compare, output);
224     }
225
226
227    /**
228      * Testing <code>IterateTag</code> using name attribute in
229      * the application scope.
230      *
231      * Tests the equivalent of this tag in a jsp:
232      * <logic:iterate id="theId" name="testApplicationScopeNameIterateList"
233      * property="list" scope="application">
234      *
235      */

236     
237     // ========= Application
238
public void testApplicationScopePropertyIterateList()
239         throws ServletException JavaDoc, JspException JavaDoc, IOException JavaDoc {
240         
241         
242         String JavaDoc testKey = "testApplicationScopePropertyIterate";
243
244         ArrayList JavaDoc lst = new ArrayList JavaDoc();
245         for (int i = 0; i < iterations; i++) {
246             lst.add("test" + i);
247         }
248         
249         SimpleBeanForTesting sbft = new SimpleBeanForTesting();
250         sbft.setList(lst);
251         
252         pageContext.setAttribute(testKey, sbft,
253                                     PageContext.APPLICATION_SCOPE);
254
255         IterateTag tag = new IterateTag();
256         tag.setPageContext(pageContext);
257         /*
258          * Tests the equivalent of this tag in a jsp:
259          * <logic:iterate id="theId" name="testApplicationScopePropertyIterate"
260          * scope="application">
261          */

262         tag.setId("theId");
263         tag.setName(testKey);
264         tag.setScope("application");
265         tag.setProperty("list");
266         
267         int iteration = 0;
268         tag.doStartTag();
269         tag.doInitBody();
270         do
271         {
272             out.print((String JavaDoc)pageContext.getAttribute("theId"));
273             iteration++;
274         
275         } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
276         tag.doEndTag();
277         assertEquals(iterations, iteration);
278     }
279
280     public void endApplicationScopePropertyIterateList (WebResponse response){
281         String JavaDoc output = response.getText();
282         String JavaDoc compare = "";
283         for (int i = 0; i < iterations; i++) {
284             compare += "test" + i;
285         }
286         
287         //fix for introduced carriage return / line feeds
288
output = replace(compare,"\r","");
289         output = replace(output,"\n","");
290         
291         assertEquals(compare, output);
292     }
293
294     
295     // ========= Session
296
public void testSessionScopePropertyIteratesList()
297         throws ServletException JavaDoc, JspException JavaDoc, IOException JavaDoc {
298         
299         
300         String JavaDoc testKey = "testSessionScopePropertyIterate";
301
302         ArrayList JavaDoc lst = new ArrayList JavaDoc();
303         for (int i = 0; i < iterations; i++) {
304             lst.add("test" + i);
305         }
306         
307         SimpleBeanForTesting sbft = new SimpleBeanForTesting();
308         sbft.setList(lst);
309         
310         pageContext.setAttribute(testKey, sbft,
311                                     PageContext.SESSION_SCOPE);
312
313         IterateTag tag = new IterateTag();
314         tag.setPageContext(pageContext);
315         /*
316          * Tests the equivalent of this tag in a jsp:
317          * <logic:iterate id="theId" name="testSessionScopePropertyIterate"
318          * scope="session">
319          */

320         tag.setId("theId");
321         tag.setName(testKey);
322         tag.setScope("session");
323         tag.setProperty("list");
324         
325         int iteration = 0;
326         tag.doStartTag();
327         tag.doInitBody();
328         do
329         {
330             out.print((String JavaDoc)pageContext.getAttribute("theId"));
331             iteration++;
332         
333         } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
334         tag.doEndTag();
335         assertEquals(iterations, iteration);
336     }
337
338     public void endSessionScopePropertyIterateList (WebResponse response){
339         String JavaDoc output = response.getText();
340         String JavaDoc compare = "";
341         for (int i = 0; i < iterations; i++) {
342             compare += "test" + i;
343         }
344         
345         //fix for introduced carriage return / line feeds
346
output = replace(compare,"\r","");
347         output = replace(output,"\n","");
348         
349         assertEquals(compare, output);
350     }
351
352     
353     // ========= Request
354
public void testRequestScopePropertyIteratesList()
355         throws ServletException JavaDoc, JspException JavaDoc, IOException JavaDoc {
356         
357         
358         String JavaDoc testKey = "testRequestScopePropertyIterate";
359
360         ArrayList JavaDoc lst = new ArrayList JavaDoc();
361         for (int i = 0; i < iterations; i++) {
362             lst.add("test" + i);
363         }
364         
365         SimpleBeanForTesting sbft = new SimpleBeanForTesting();
366         sbft.setList(lst);
367         
368         pageContext.setAttribute(testKey, sbft,
369                                     PageContext.REQUEST_SCOPE);
370
371         IterateTag tag = new IterateTag();
372         tag.setPageContext(pageContext);
373         /*
374          * Tests the equivalent of this tag in a jsp:
375          * <logic:iterate id="theId" name="testRequestScopePropertyIterate"
376          * scope="request">
377          */

378         tag.setId("theId");
379         tag.setName(testKey);
380         tag.setScope("request");
381         tag.setProperty("list");
382         
383         int iteration = 0;
384         tag.doStartTag();
385         tag.doInitBody();
386         do
387         {
388             out.print((String JavaDoc)pageContext.getAttribute("theId"));
389             iteration++;
390         
391         } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
392         tag.doEndTag();
393         assertEquals(iterations, iteration);
394     }
395
396     public void endRequestScopePropertyIterateList (WebResponse response){
397         String JavaDoc output = response.getText();
398         String JavaDoc compare = "";
399         for (int i = 0; i < iterations; i++) {
400             compare += "test" + i;
401         }
402         
403         //fix for introduced carriage return / line feeds
404
output = replace(compare,"\r","");
405         output = replace(output,"\n","");
406         
407         assertEquals(compare, output);
408     }
409
410
411
412    /**
413      * Testing <code>IterateTag</code> using name attribute in
414      * the application scope.
415      *
416      * Tests the equivalent of this tag in a jsp:
417      * <logic:iterate id="theId" name="testApplicationScopeNameIterateEnumeration"
418      * scope="application">
419      *
420      */

421
422     // ========= Application
423
public void testApplicationScopeNameIterateEnumeration()
424         throws ServletException JavaDoc, JspException JavaDoc, IOException JavaDoc {
425         
426         String JavaDoc testKey = "testApplicationScopeNameIterateEnumeration";
427         
428         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Application Scope Name Iterate Enumeration");
429
430         pageContext.setAttribute(testKey, st,
431                                     PageContext.APPLICATION_SCOPE);
432
433         IterateTag tag = new IterateTag();
434         tag.setPageContext(pageContext);
435         tag.setId("theId");
436         tag.setName(testKey);
437         tag.setScope("application");
438         
439         tag.doStartTag();
440         tag.doInitBody();
441         do
442         {
443             out.print((String JavaDoc)pageContext.getAttribute("theId"));
444         
445         } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
446         tag.doEndTag();
447
448     }
449
450     public void endApplicationScopeNameIterateEnumeration (WebResponse response){
451         String JavaDoc output = response.getText();
452         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Application Scope Name Iterate Enumeration");
453         String JavaDoc compare = "";
454         
455         while (st.hasMoreTokens()) {
456             compare += st.nextToken();
457         }
458         
459         //fix for introduced carriage return / line feeds
460
output = replace(compare,"\r","");
461         output = replace(output,"\n","");
462
463         assertEquals(compare, output);
464     }
465
466     // ========= Session
467
public void testSessionScopeNameIterateEnumeration()
468         throws ServletException JavaDoc, JspException JavaDoc, IOException JavaDoc {
469         
470         String JavaDoc testKey = "testSessionScopeNameIterateEnumeration";
471         
472         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Session Scope Name Iterate Enumeration");
473
474         pageContext.setAttribute(testKey, st,
475                                     PageContext.SESSION_SCOPE);
476
477         IterateTag tag = new IterateTag();
478         tag.setPageContext(pageContext);
479         tag.setId("theId");
480         tag.setName(testKey);
481         tag.setScope("session");
482         
483         tag.doStartTag();
484         tag.doInitBody();
485         do
486         {
487             out.print((String JavaDoc)pageContext.getAttribute("theId"));
488         
489         } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
490         tag.doEndTag();
491
492     }
493
494     public void endSessionScopeNameIterateEnumeration (WebResponse response){
495         String JavaDoc output = response.getText();
496         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Session Scope Name Iterate Enumeration");
497         String JavaDoc compare = "";
498         
499         while (st.hasMoreTokens()) {
500             compare += st.nextToken();
501         }
502         
503         //fix for introduced carriage return / line feeds
504
output = replace(compare,"\r","");
505         output = replace(output,"\n","");
506
507         assertEquals(compare, output);
508     }
509
510     // ========= Request
511
public void testRequestScopeNameIterateEnumeration()
512         throws ServletException JavaDoc, JspException JavaDoc, IOException JavaDoc {
513         
514         String JavaDoc testKey = "testRequestScopeNameIterateEnumeration";
515         
516         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Request Scope Name Iterate Enumeration");
517
518         pageContext.setAttribute(testKey, st,
519                                     PageContext.REQUEST_SCOPE);
520
521         IterateTag tag = new IterateTag();
522         tag.setPageContext(pageContext);
523         tag.setId("theId");
524         tag.setName(testKey);
525         tag.setScope("request");
526         
527         tag.doStartTag();
528         tag.doInitBody();
529         do
530         {
531             out.print((String JavaDoc)pageContext.getAttribute("theId"));
532         
533         } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
534         tag.doEndTag();
535
536     }
537
538     public void endRequestScopeNameIterateEnumeration (WebResponse response){
539         String JavaDoc output = response.getText();
540         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Request Scope Name Iterate Enumeration");
541         String JavaDoc compare = "";
542         
543         while (st.hasMoreTokens()) {
544             compare += st.nextToken();
545         }
546         
547         //fix for introduced carriage return / line feeds
548
output = replace(compare,"\r","");
549         output = replace(output,"\n","");
550
551         assertEquals(compare, output);
552     }
553
554
555    /**
556      * Testing <code>IterateTag</code> using property attribute in
557      * the application scope.
558      *
559      * Tests the equivalent of this tag in a jsp:
560      * <logic:iterate id="theId" name="testApplicationScopePropertyIterateEnumeration"
561      * scope="application">
562      *
563      */

564
565     // ========= Application
566
public void testApplicationScopePropertyIterateEnumeration()
567         throws ServletException JavaDoc, JspException JavaDoc, IOException JavaDoc {
568         
569         String JavaDoc testKey = "testApplicationScopePropertyIterateEnumeration";
570         
571         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Application Scope Property Iterate Enumeration");
572
573         SimpleBeanForTesting sbft = new SimpleBeanForTesting();
574         sbft.setEnumeration(st);
575
576         pageContext.setAttribute(testKey, sbft,
577                                     PageContext.APPLICATION_SCOPE);
578
579         IterateTag tag = new IterateTag();
580         tag.setPageContext(pageContext);
581         tag.setId("theId");
582         tag.setName(testKey);
583         tag.setScope("application");
584         tag.setProperty("enumeration");
585         
586         tag.doStartTag();
587         tag.doInitBody();
588         do
589         {
590             out.print((String JavaDoc)pageContext.getAttribute("theId"));
591         
592         } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
593         tag.doEndTag();
594
595     }
596
597     public void endApplicationScopePropertyIterateEnumeration (WebResponse response){
598         String JavaDoc output = response.getText();
599         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Application Scope Property Iterate Enumeration");
600         String JavaDoc compare = "";
601         
602         while (st.hasMoreTokens()) {
603             compare += st.nextToken();
604         }
605         
606         //fix for introduced carriage return / line feeds
607
output = replace(compare,"\r","");
608         output = replace(output,"\n","");
609
610         assertEquals(compare, output);
611     }
612
613     // ========= Session
614
public void testSessionScopePropertyIterateEnumeration()
615         throws ServletException JavaDoc, JspException JavaDoc, IOException JavaDoc {
616         
617         String JavaDoc testKey = "testSessionScopePropertyIterateEnumeration";
618         
619         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Session Scope Property Iterate Enumeration");
620
621         SimpleBeanForTesting sbft = new SimpleBeanForTesting();
622         sbft.setEnumeration(st);
623
624         pageContext.setAttribute(testKey, sbft,
625                                     PageContext.SESSION_SCOPE);
626
627         IterateTag tag = new IterateTag();
628         tag.setPageContext(pageContext);
629         tag.setId("theId");
630         tag.setName(testKey);
631         tag.setScope("session");
632         tag.setProperty("enumeration");
633         
634         tag.doStartTag();
635         tag.doInitBody();
636         do
637         {
638             out.print((String JavaDoc)pageContext.getAttribute("theId"));
639         
640         } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
641         tag.doEndTag();
642
643     }
644
645     public void endSessionScopePropertyIterateEnumeration (WebResponse response){
646         String JavaDoc output = response.getText();
647         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Session Scope Property Iterate Enumeration");
648         String JavaDoc compare = "";
649         
650         while (st.hasMoreTokens()) {
651             compare += st.nextToken();
652         }
653         
654         //fix for introduced carriage return / line feeds
655
output = replace(compare,"\r","");
656         output = replace(output,"\n","");
657
658         assertEquals(compare, output);
659     }
660
661     // ========= Request
662
public void testRequestScopePropertyIterateEnumeration()
663         throws ServletException JavaDoc, JspException JavaDoc, IOException JavaDoc {
664         
665         String JavaDoc testKey = "testRequestScopePropertyIterateEnumeration";
666         
667         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Request Scope Property Iterate Enumeration");
668
669         SimpleBeanForTesting sbft = new SimpleBeanForTesting();
670         sbft.setEnumeration(st);
671
672         pageContext.setAttribute(testKey, sbft,
673                                     PageContext.REQUEST_SCOPE);
674
675         IterateTag tag = new IterateTag();
676         tag.setPageContext(pageContext);
677         tag.setId("theId");
678         tag.setName(testKey);
679         tag.setScope("request");
680         tag.setProperty("enumeration");
681         
682         tag.doStartTag();
683         tag.doInitBody();
684         do
685         {
686             out.print((String JavaDoc)pageContext.getAttribute("theId"));
687         
688         } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
689         tag.doEndTag();
690
691     }
692
693     public void endRequestScopePropertyIterateEnumeration (WebResponse response){
694         String JavaDoc output = response.getText();
695         StringTokenizer JavaDoc st = new StringTokenizer JavaDoc("Request Scope Property Iterate Enumeration");
696         String JavaDoc compare = "";
697         
698         while (st.hasMoreTokens()) {
699             compare += st.nextToken();
700         }
701         
702         //fix for introduced carriage return / line feeds
703
output = replace(compare,"\r","");
704         output = replace(output,"\n","");
705
706         assertEquals(compare, output);
707     }
708
709
710
711
712
713    /**
714      * Testing <code>IterateTag</code> using name attribute in
715      * the application scope.
716      *
717      * Tests the equivalent of this tag in a jsp:
718      * <logic:iterate id="theId" name="testApplicationScopeNameIterateMap"
719      * scope="application">
720      *
721      */

722
723     // ========= Application
724
public void testApplicationScopeNameIterateMap()
725         throws ServletException JavaDoc, JspException JavaDoc, IOException JavaDoc {
726         
727         String JavaDoc testKey = "testApplicationScopeNameIterateMap";
728
729         HashMap JavaDoc map = new HashMap JavaDoc();
730         for (int i = 0; i < iterations; i++) {
731             map.put("test" + i,"test" + i);
732         }
733         
734         pageContext.setAttribute(testKey, map,
735                                     PageContext.APPLICATION_SCOPE);
736
737         IterateTag tag = new IterateTag();
738         tag.setPageContext(pageContext);
739         tag.setId("theId");
740         tag.setName(testKey);
741         tag.setScope("application");
742         
743         int iteration = 0;
744         tag.doStartTag();
745         tag.doInitBody();
746         do
747         {
748             out.print(pageContext.getAttribute("theId"));
749             iteration++;
750         
751         } while (tag.doAfterBody() == IterateTag.EVAL_BODY_TAG);
752         tag.doEndTag();
753         assertEquals(iterations, iteration);
754     }
755
756     public void endApplicationScopeNameIterateMap (WebResponse response){
757         String JavaDoc output = response.getText();
758         String JavaDoc compare = "";
759         for (int i = 0; i < iterations; i++) {
760             compare += "test" + i;
761         }
762
763         //fix for introduced carriage return / line feeds
764
output = replace(compare,"\r","");
765         output = replace(output,"\n","");
766
767         assertEquals(compare, output);
768     }
769     
770     // ========= Session
771
public void testSessionScopeNameIterateMap()
772         throws ServletException JavaDoc, JspException JavaDoc, IOException JavaDoc {
773         
774         String JavaDoc testKey = "testSessionScopeNameIterateMap";
775
776         HashMap JavaDoc map = new HashMap JavaDoc();
777         for (int i = 0; i < iterations; i++) {
778             map.put("test" + i,"test" + i);
779         }
780         
781         pageContext.setAttribute(testKey, map,
782                                     PageContext.SESSION_SCOPE);
783
784         IterateTag tag = new IterateTag();
785         tag.setPageContext(pageContext);
786         tag.setId("theId");
787         tag.setName(testKey);
788         tag.setScope("session");
789         
790         int iteration = 0;
791         tag.doStartTag();
792         tag.doInitBody();
793         do
794       &n