View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  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,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.myfaces.view.facelets.tag.ui;
20  
21  import java.io.IOException;
22  import java.util.ArrayList;
23  import java.util.List;
24  
25  import javax.el.ELContext;
26  import javax.el.ELException;
27  import javax.el.ValueExpression;
28  import javax.faces.FacesException;
29  import javax.faces.component.ContextCallback;
30  import javax.faces.component.UIComponent;
31  import javax.faces.component.UIViewRoot;
32  import javax.faces.component.visit.VisitCallback;
33  import javax.faces.component.visit.VisitContext;
34  import javax.faces.component.visit.VisitResult;
35  import javax.faces.context.FacesContext;
36  import javax.faces.context.ResponseWriter;
37  
38  import org.apache.myfaces.view.facelets.FaceletTestCase;
39  import org.apache.myfaces.view.facelets.bean.Company;
40  import org.apache.myfaces.view.facelets.bean.Example;
41  import org.apache.myfaces.view.facelets.component.UIRepeat;
42  import org.apache.myfaces.view.facelets.util.FastWriter;
43  import org.junit.Assert;
44  import org.junit.Test;
45  
46  /**
47   * Tests for UIRepeat.
48   * 
49   * @author Jakob Korherr (latest modification by $Author: lu4242 $)
50   * @version $Revision: 1523314 $ $Date: 2013-09-14 15:31:46 -0500 (Sat, 14 Sep 2013) $
51   */
52  public class RepeatTestCase extends FaceletTestCase 
53  {
54  
55      @Test
56      public void testRepeat() throws Exception 
57      {
58          Company c = Example.createCompany();
59          facesContext.getExternalContext().getRequestMap().put("company", c);
60          
61          UIViewRoot root = facesContext.getViewRoot();
62          vdl.buildView(facesContext, root, "repeat.xml");
63          
64          FastWriter fw = new FastWriter();
65          ResponseWriter rw = facesContext.getResponseWriter();
66          rw = rw.cloneWithWriter(fw);
67          facesContext.setResponseWriter(rw);
68          root.encodeAll(facesContext);
69          String content = fw.toString();
70          
71          int hrIndex = content.indexOf("<dt>HR</dt>");
72          Assert.assertNotSame(-1, hrIndex);
73          int rdIndex = content.indexOf("<dt>RD</dt>", hrIndex);
74          Assert.assertNotSame(-1, rdIndex);
75  
76          int empIndex1 = content.indexOf(
77              "<dd class=\"3\">Ellen, Sue</dd><dd class=\"4\">Scooner, Mary</dd>", hrIndex);
78          Assert.assertNotSame(-1, empIndex1);
79          int empIndex2 = content.indexOf(
80              "<dd class=\"6\">Burns, Ed</dd><dd class=\"7\">Lubke, Ryan</dd><dd class=\"8\">Kitain, Roger</dd>",
81              rdIndex);
82          Assert.assertNotSame(-1, empIndex2);
83          
84          int hrIndex2 = content.indexOf("<li class=\"HR\">HR</li>");
85          Assert.assertNotSame(-1, hrIndex2);
86          int rdIndex2 = content.indexOf("<li class=\"RD\">RD</li>", hrIndex2);
87          Assert.assertNotSame(-1, rdIndex2);
88      }
89      
90      /**
91       * Tests UIRepeat.invokeOnComponent() including var and varStatus properties.
92       * @throws IOException
93       */
94      @Test
95      @SuppressWarnings("unchecked")
96      public void testInvokeOnComponent() throws IOException
97      {
98          // put the values for ui:repeat on the request map
99          final String[] repeatValues = new String[]{ "a", "b", "c" };
100         externalContext.getRequestMap().put("repeatValues", repeatValues);
101         
102         // build testUIRepeat.xhtml
103         UIViewRoot root = facesContext.getViewRoot();
104         vdl.buildView(facesContext, root, "testUIRepeat.xhtml");
105         
106         // get the component instances
107         UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat");
108         UIComponent outputText = repeat.getChildren().get(0);
109         
110         // create the ContextCallback
111         TestContextCallback callback = new TestContextCallback(facesContext);
112         
113         // save some values in #{row} and #{status} and test the
114         // automatic saving and restoring of them
115         final String var = "row";
116         final String varStatus = "status";
117         final String varValue = "someVarValue";
118         final String statusValue = "someStatusValue";
119         externalContext.getRequestMap().put(var, varValue);
120         externalContext.getRequestMap().put(varStatus, statusValue);
121         
122         // invokeOnComponent on UIRepeat itself
123         String invokeId = "form:repeat";
124         Assert.assertTrue(root.invokeOnComponent(facesContext, invokeId, callback));
125         Assert.assertEquals(repeat, callback._lastTarget);
126         Assert.assertEquals(varValue, callback._rowValue); // previous set varValue
127         Assert.assertEquals(statusValue, callback._repeatStatus); // previous set statusValue
128         
129         // invokeOnComponent on a child of UIRepeat in the first row
130         invokeId = "form:repeat:0:outputText";
131         Assert.assertTrue(root.invokeOnComponent(facesContext, invokeId, callback));
132         Assert.assertEquals(outputText, callback._lastTarget);
133         Assert.assertEquals(repeatValues[0], callback._rowValue);
134         Assert.assertEquals(0, callback._index);
135         Assert.assertEquals(true, callback._first);
136         Assert.assertEquals(false, callback._last);
137         Assert.assertEquals(true, callback._even);
138         
139         // invokeOnComponent on a child of UIRepeat in the second row
140         invokeId = "form:repeat:1:outputText";
141         Assert.assertTrue(root.invokeOnComponent(facesContext, invokeId, callback));
142         Assert.assertEquals(outputText, callback._lastTarget);
143         Assert.assertEquals(repeatValues[1], callback._rowValue);
144         Assert.assertEquals(1, callback._index);
145         Assert.assertEquals(false, callback._first);
146         Assert.assertEquals(false, callback._last);
147         Assert.assertEquals(false, callback._even);
148         
149         // invokeOnComponent on a child of UIRepeat in the third row
150         invokeId = "form:repeat:2:outputText";
151         Assert.assertTrue(root.invokeOnComponent(facesContext, invokeId, callback));
152         Assert.assertEquals(outputText, callback._lastTarget);
153         Assert.assertEquals(repeatValues[2], callback._rowValue);
154         Assert.assertEquals(2, callback._index);
155         Assert.assertEquals(false, callback._first);
156         Assert.assertEquals(true, callback._last);
157         Assert.assertEquals(true, callback._even);
158         
159         // invokeOnComponent on a child of UIRepeat with invalid row (-1)
160         invokeId = "form:repeat:outputText";
161         Assert.assertTrue(root.invokeOnComponent(facesContext, invokeId, callback));
162         
163         // after all these calls to invokeOnComponent, row and status still
164         // have to be the same like before
165         Assert.assertEquals(varValue, externalContext.getRequestMap().get(var));
166         Assert.assertEquals(statusValue, externalContext.getRequestMap().get(varStatus));
167         
168         // remove the values from the request map
169         externalContext.getRequestMap().remove("repeatValues");
170         externalContext.getRequestMap().remove(var);
171         externalContext.getRequestMap().remove(varStatus);
172     }
173     
174     /**
175      * ContextCallback to test invokeOnComponent() including var and varStatus properties.
176      * @author Jakob Korherr
177      */
178     private static class TestContextCallback implements ContextCallback
179     {
180         
181         private UIComponent _lastTarget;
182         private Object _rowValue;
183         private Object _repeatStatus;
184         private Object _index;
185         private Object _first, _last, _even;
186         private ValueExpression _rowValueExpression;
187         private ValueExpression _statusValueExpression;
188         private ValueExpression _indexValueExpression;
189         private ValueExpression _firstValueExpression;
190         private ValueExpression _lastValueExpression;
191         private ValueExpression _evenValueExpression;
192 
193         public TestContextCallback(FacesContext context)
194         {
195             _rowValueExpression = context.getApplication().getExpressionFactory()
196                     .createValueExpression(context.getELContext(), "#{row}", Object.class);
197             _statusValueExpression = context.getApplication().getExpressionFactory()
198                     .createValueExpression(context.getELContext(), "#{status}", Object.class);
199             _indexValueExpression = context.getApplication().getExpressionFactory()
200                     .createValueExpression(context.getELContext(), "#{status.index}", Object.class);
201             _firstValueExpression = context.getApplication().getExpressionFactory()
202                     .createValueExpression(context.getELContext(), "#{status.first}", Object.class);
203             _lastValueExpression = context.getApplication().getExpressionFactory()
204                     .createValueExpression(context.getELContext(), "#{status.last}", Object.class);
205             _evenValueExpression = context.getApplication().getExpressionFactory()
206                     .createValueExpression(context.getELContext(), "#{status.even}", Object.class);
207         }
208         
209         public void invokeContextCallback(FacesContext context, UIComponent target)
210         {
211             _lastTarget = target;
212             
213             // evaluate ValueExpressions
214             ELContext elCtx = context.getELContext();
215             _rowValue = _rowValueExpression.getValue(elCtx);
216             _repeatStatus = _statusValueExpression.getValue(elCtx);
217             try
218             {
219                 _index = _indexValueExpression.getValue(elCtx);
220                 _first = _firstValueExpression.getValue(elCtx);
221                 _last = _lastValueExpression.getValue(elCtx);
222                 _even = _evenValueExpression.getValue(elCtx);
223             }
224             catch (ELException ele)
225             {
226                 // repeatStatus is some other object, so these values are all null
227                 _index = _first = _last = _even = null;
228             }
229         }
230         
231     }
232     
233     /**
234      * Tests UIRepeat.visitTree().
235      * @throws IOException
236      */
237     @Test
238     @SuppressWarnings("unchecked")
239     public void testVisitTree() throws IOException
240     {
241      // put the values for ui:repeat on the request map
242         final String[] repeatValues = new String[]{ "a", "b", "c" };
243         externalContext.getRequestMap().put("repeatValues", repeatValues);
244         
245         // build testUIRepeat.xhtml
246         UIViewRoot root = facesContext.getViewRoot();
247         vdl.buildView(facesContext, root, "testUIRepeat.xhtml");
248         
249         // get the component instances
250         UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat");
251         
252         // create the VisitCallback
253         TestVisitCallback testVisitCallback = new TestVisitCallback(facesContext, repeatValues);
254         
255         // save some values in #{row} and #{status} and test the
256         // automatic saving and restoring of them
257         final String var = "row";
258         final String varStatus = "status";
259         final String varValue = "someVarValue";
260         final String statusValue = "someStatusValue";
261         externalContext.getRequestMap().put(var, varValue);
262         externalContext.getRequestMap().put(varStatus, statusValue);
263         
264         // perform visit
265         repeat.visitTree(VisitContext.createVisitContext(facesContext), testVisitCallback);
266         
267         // created expected List
268         List<String> expectedClientIds = new ArrayList<String>();
269         expectedClientIds.add("form:repeat");
270         expectedClientIds.add("form:repeat:0:outputText");
271         expectedClientIds.add("form:repeat:1:outputText");
272         expectedClientIds.add("form:repeat:2:outputText");
273         
274         // see if we got the expected result
275         Assert.assertEquals(expectedClientIds, testVisitCallback._visitedClientIds);
276         
277         // after the tree visit, row and status still
278         // have to be the same like before
279         Assert.assertEquals(varValue, externalContext.getRequestMap().get(var));
280         Assert.assertEquals(statusValue, externalContext.getRequestMap().get(varStatus));
281         
282         // remove the values from the request map
283         externalContext.getRequestMap().remove("repeatValues");
284         externalContext.getRequestMap().remove(var);
285         externalContext.getRequestMap().remove(varStatus);
286     }
287 
288     /**
289      * VisitCallback to test visitTree().
290      * @author Jakob Korherr
291      */
292     private static class TestVisitCallback implements VisitCallback
293     {
294         
295         private List<String> _visitedClientIds;
296         private ValueExpression _rowValueExpression;
297         private ValueExpression _indexValueExpression;
298         private String[] _repeatValues;
299         
300         public TestVisitCallback(FacesContext context, String[] repeatValues)
301         {
302             _repeatValues = repeatValues;
303             _visitedClientIds = new ArrayList<String>();
304             _rowValueExpression = context.getApplication().getExpressionFactory()
305                     .createValueExpression(context.getELContext(), "#{row}", Object.class);
306             _indexValueExpression = context.getApplication().getExpressionFactory()
307                     .createValueExpression(context.getELContext(), "#{status.index}", Object.class);
308         }
309 
310         public VisitResult visit(VisitContext context, UIComponent target)
311         {
312             final String clientId = target.getClientId(context.getFacesContext());
313             if (_visitedClientIds.contains(clientId))
314             {
315                 Assert.fail("Component with clientId " + clientId + " visited twice!");
316             }
317             else
318             {
319                 _visitedClientIds.add(clientId);
320                 
321                 if (!(target instanceof UIRepeat))
322                 {
323                     // test #{row} and #{status.index}
324                     ELContext elCtx = context.getFacesContext().getELContext();
325                     
326                     Object indexObject = _indexValueExpression.getValue(elCtx);
327                     // indexObject has to be an Integer
328                     Assert.assertTrue(indexObject instanceof Integer);
329                     Integer index = (Integer) indexObject;
330                     
331                     // the index has to be part of the clientId
332                     Assert.assertTrue(clientId.contains("" + index));
333                     
334                     Object rowValue = _rowValueExpression.getValue(elCtx);
335                     // #{row} has to be the repeatValue for the current index
336                     Assert.assertEquals(_repeatValues[index], rowValue);
337                 }
338             }
339             
340             return VisitResult.ACCEPT;
341         }
342         
343     }
344     
345     @Test
346     public void testRepeatOffset() throws Exception 
347     {
348         final String[] repeatValues = new String[] {"B1", "B2", "B3", "B4", "B5", "B6", "B7"};
349         facesContext.getExternalContext().getRequestMap().put("repeatValues", repeatValues);
350         
351         UIViewRoot root = facesContext.getViewRoot();
352         vdl.buildView(facesContext, root, "ui_repeat_offset.xhtml");
353         
354         UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat");
355         Assert.assertNotNull(repeat);
356         
357         FastWriter fw = new FastWriter();
358         ResponseWriter rw = facesContext.getResponseWriter();
359         rw = rw.cloneWithWriter(fw);
360         facesContext.setResponseWriter(rw);
361         
362         repeat.encodeAll(facesContext);
363         String content = fw.toString();
364         
365         // offset="2" size="1" should render only 1 row
366         int itemIndex1 = content.indexOf("B1");
367         Assert.assertEquals(-1, itemIndex1);
368         int itemIndex2 = content.indexOf("B2");
369         Assert.assertEquals(-1, itemIndex2);
370         
371         String item1 = "B3";
372         int itemIndex3 = content.indexOf(item1);
373         Assert.assertNotSame(-1, itemIndex3);
374         String item2 = "B4";
375         // the second item should not be there
376         Assert.assertEquals(-1, content.indexOf(item2, itemIndex1+2));
377     }
378     
379     @Test
380     public void testRepeatOffset_0() throws Exception 
381     {
382         final String[] repeatValues = new String[] {"B1", "B2", "B3", "B4", "B5", "B6", "B7"};
383         facesContext.getExternalContext().getRequestMap().put("repeatValues", repeatValues);
384         
385         UIViewRoot root = facesContext.getViewRoot();
386         vdl.buildView(facesContext, root, "ui_repeat_offset.xhtml");
387         
388         UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat0");
389         Assert.assertNotNull(repeat);
390         
391         FastWriter fw = new FastWriter();
392         ResponseWriter rw = facesContext.getResponseWriter();
393         rw = rw.cloneWithWriter(fw);
394         facesContext.setResponseWriter(rw);
395         
396         repeat.encodeAll(facesContext);
397         
398         String content = fw.toString();
399 
400         int itemIndex1 = content.indexOf("B1");
401         Assert.assertNotSame(-1, itemIndex1);
402         int itemIndex2 = content.indexOf("B2");
403         Assert.assertNotSame(-1, itemIndex2);
404         int itemIndex3 = content.indexOf("B3");
405         Assert.assertEquals(-1, itemIndex3);
406     }
407 
408     @Test
409     public void testRepeatOffset_0_7() throws Exception 
410     {
411         final String[] repeatValues = new String[] {"B1", "B2", "B3", "B4", "B5", "B6", "B7"};
412         facesContext.getExternalContext().getRequestMap().put("repeatValues", repeatValues);
413         
414         UIViewRoot root = facesContext.getViewRoot();
415         vdl.buildView(facesContext, root, "ui_repeat_offset.xhtml");
416         
417         UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat0_7");
418         Assert.assertNotNull(repeat);
419         
420         FastWriter fw = new FastWriter();
421         ResponseWriter rw = facesContext.getResponseWriter();
422         rw = rw.cloneWithWriter(fw);
423         facesContext.setResponseWriter(rw);
424         
425         repeat.encodeAll(facesContext);
426         
427         String content = fw.toString();
428 
429         int itemIndex1 = content.indexOf("B1");
430         Assert.assertNotSame(-1, itemIndex1);
431         int itemIndex2 = content.indexOf("B2", itemIndex1);
432         Assert.assertNotSame(-1, itemIndex2);
433         int itemIndex3 = content.indexOf("B3", itemIndex2);
434         Assert.assertNotSame(-1, itemIndex3);
435         int itemIndex4 = content.indexOf("B4", itemIndex3);
436         Assert.assertNotSame(-1, itemIndex4);
437         int itemIndex5 = content.indexOf("B5", itemIndex4);
438         Assert.assertNotSame(-1, itemIndex5);
439         int itemIndex6 = content.indexOf("B6", itemIndex5);
440         Assert.assertNotSame(-1, itemIndex6);
441         int itemIndex7 = content.indexOf("B7", itemIndex6);
442         Assert.assertNotSame(-1, itemIndex7);
443     }
444     
445     @Test
446     public void testRepeatOffset_0_8() throws Exception 
447     {
448         final String[] repeatValues = new String[] {"B1", "B2", "B3", "B4", "B5", "B6", "B7"};
449         facesContext.getExternalContext().getRequestMap().put("repeatValues", repeatValues);
450         
451         UIViewRoot root = facesContext.getViewRoot();
452         vdl.buildView(facesContext, root, "ui_repeat_offset.xhtml");
453         
454         UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat0_8");
455         Assert.assertNotNull(repeat);
456         
457         FastWriter fw = new FastWriter();
458         ResponseWriter rw = facesContext.getResponseWriter();
459         rw = rw.cloneWithWriter(fw);
460         facesContext.setResponseWriter(rw);
461         
462         try
463         {
464             repeat.encodeAll(facesContext);
465             Assert.fail();
466         }
467         catch(FacesException e)
468         {
469             // size cannot be greater than collection size
470         }
471     }
472     
473     @Test
474     public void testRepeatOffset_1() throws Exception 
475     {
476         final String[] repeatValues = new String[] {"B1", "B2", "B3", "B4", "B5", "B6", "B7"};
477         facesContext.getExternalContext().getRequestMap().put("repeatValues", repeatValues);
478         
479         UIViewRoot root = facesContext.getViewRoot();
480         vdl.buildView(facesContext, root, "ui_repeat_offset.xhtml");
481         
482         UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat1");
483         Assert.assertNotNull(repeat);
484         
485         FastWriter fw = new FastWriter();
486         ResponseWriter rw = facesContext.getResponseWriter();
487         rw = rw.cloneWithWriter(fw);
488         facesContext.setResponseWriter(rw);
489         
490         repeat.encodeAll(facesContext);
491         
492         String content = fw.toString();
493 
494         int itemIndex1 = content.indexOf("B1");
495         Assert.assertEquals(-1, itemIndex1);
496         int itemIndex2 = content.indexOf("B2");
497         Assert.assertNotSame(-1, itemIndex2);
498         int itemIndex3 = content.indexOf("B3", itemIndex2);
499         Assert.assertNotSame(-1, itemIndex3);
500         int itemIndex4 = content.indexOf("B4", itemIndex3);
501         Assert.assertNotSame(-1, itemIndex4);
502         int itemIndex5 = content.indexOf("B5", itemIndex4);
503         Assert.assertEquals(-1, itemIndex5);
504     }
505 
506     @Test
507     public void testRepeatOffset_1_7() throws Exception 
508     {
509         final String[] repeatValues = new String[] {"B1", "B2", "B3", "B4", "B5", "B6", "B7"};
510         facesContext.getExternalContext().getRequestMap().put("repeatValues", repeatValues);
511         
512         UIViewRoot root = facesContext.getViewRoot();
513         vdl.buildView(facesContext, root, "ui_repeat_offset.xhtml");
514         
515         UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat1_7");
516         Assert.assertNotNull(repeat);
517         
518         FastWriter fw = new FastWriter();
519         ResponseWriter rw = facesContext.getResponseWriter();
520         rw = rw.cloneWithWriter(fw);
521         facesContext.setResponseWriter(rw);
522         
523         repeat.encodeAll(facesContext);
524         
525         String content = fw.toString();
526 
527         int itemIndex1 = content.indexOf("B1");
528         Assert.assertEquals(-1, itemIndex1);
529         int itemIndex2 = content.indexOf("B2");
530         Assert.assertNotSame(-1, itemIndex2);
531         int itemIndex3 = content.indexOf("B3", itemIndex2);
532         Assert.assertNotSame(-1, itemIndex3);
533         int itemIndex4 = content.indexOf("B4", itemIndex3);
534         Assert.assertNotSame(-1, itemIndex4);
535         int itemIndex5 = content.indexOf("B5", itemIndex4);
536         Assert.assertNotSame(-1, itemIndex5);
537         int itemIndex6 = content.indexOf("B6", itemIndex5);
538         Assert.assertNotSame(-1, itemIndex6);
539         int itemIndex7 = content.indexOf("B7", itemIndex6);
540         Assert.assertNotSame(-1, itemIndex7);
541     }
542     
543     @Test
544     public void testRepeatOffset_1_8() throws Exception 
545     {
546         final String[] repeatValues = new String[] {"B1", "B2", "B3", "B4", "B5", "B6", "B7"};
547         facesContext.getExternalContext().getRequestMap().put("repeatValues", repeatValues);
548         
549         UIViewRoot root = facesContext.getViewRoot();
550         vdl.buildView(facesContext, root, "ui_repeat_offset.xhtml");
551         
552         UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat1_8");
553         Assert.assertNotNull(repeat);
554         
555         FastWriter fw = new FastWriter();
556         ResponseWriter rw = facesContext.getResponseWriter();
557         rw = rw.cloneWithWriter(fw);
558         facesContext.setResponseWriter(rw);
559         
560         try
561         {
562             repeat.encodeAll(facesContext);
563             Assert.fail();
564         }
565         catch(FacesException e)
566         {
567             // size cannot be greater than collection size
568         }
569     }
570 
571     @Test
572     public void testRepeatOffset2() throws Exception 
573     {
574         final String[] repeatValues = new String[] {"B1", "B2", "B3", "B4", "B5", "B6", "B7"};
575         facesContext.getExternalContext().getRequestMap().put("repeatValues", repeatValues);
576         
577         UIViewRoot root = facesContext.getViewRoot();
578         vdl.buildView(facesContext, root, "ui_repeat_offset2.xhtml");
579         
580         UIRepeat repeat = (UIRepeat) root.findComponent("form:repeat");
581         Assert.assertNotNull(repeat);
582         
583         FastWriter fw = new FastWriter();
584         ResponseWriter rw = facesContext.getResponseWriter();
585         rw = rw.cloneWithWriter(fw);
586         facesContext.setResponseWriter(rw);
587         
588         repeat.encodeAll(facesContext);
589         
590         String content = fw.toString();
591 
592         int itemIndex1 = content.indexOf("B1");
593         Assert.assertEquals(-1, itemIndex1);
594         int itemIndex2 = content.indexOf("B2");
595         Assert.assertEquals(-1, itemIndex2);
596         int itemIndex3 = content.indexOf("B3");
597         Assert.assertNotSame(-1, itemIndex3);
598         int itemIndex4 = content.indexOf("B4", itemIndex3);
599         Assert.assertNotSame(-1, itemIndex4);
600         int itemIndex5 = content.indexOf("B5", itemIndex4);
601         Assert.assertNotSame(-1, itemIndex5);
602         int itemIndex6 = content.indexOf("B6", itemIndex5);
603         Assert.assertNotSame(-1, itemIndex6);
604         int itemIndex7 = content.indexOf("B7", itemIndex6);
605         Assert.assertNotSame(-1, itemIndex7);
606         
607         //System.out.println(fw);
608     }
609 }