1 9 package org.jboss.portal.test.core; 10 11 import java.io.IOException ; 12 13 import javax.servlet.RequestDispatcher ; 14 import javax.servlet.ServletException ; 15 16 import org.apache.cactus.ServletTestCase; 17 import org.apache.cactus.WebResponse; 18 import org.jboss.portal.common.context.DelegateContext; 19 import org.jboss.portal.core.servlet.jsp.PortalJsp; 20 21 25 public class IterateTagTestCase 26 extends ServletTestCase 27 28 29 { 30 35 public void testIterateNone() throws ServletException , IOException 36 { 37 RequestDispatcher rd = config.getServletContext(). 38 getRequestDispatcher("/WEB-INF/jsp/test/testIterate01.jsp"); 39 rd.forward(request, response); 40 } 41 42 public void endIterateNone(WebResponse webResponse) 43 { 44 assertEquals("", webResponse.getText().trim()); 45 } 46 47 52 public void testIterateOnce() throws ServletException , IOException 53 { 54 RequestDispatcher rd = config.getServletContext(). 55 getRequestDispatcher("/WEB-INF/jsp/test/testIterate01.jsp"); 56 DelegateContext context = new DelegateContext(); 57 context.next("row"); 58 request.setAttribute(PortalJsp.CTX_REQUEST, context); 59 rd.forward(request, response); 60 } 61 62 public void endIterateOnce(WebResponse webResponse) 63 { 64 assertEquals("Some text", webResponse.getText().trim()); 65 } 66 67 72 public void testIterateFive() throws ServletException , IOException 73 { 74 RequestDispatcher rd = config.getServletContext(). 75 getRequestDispatcher("/WEB-INF/jsp/test/testIterate01.jsp"); 76 DelegateContext context = new DelegateContext(); 77 context.next("row"); 78 context.next("row"); 79 context.next("row"); 80 context.next("row"); 81 context.next("row"); 82 request.setAttribute(PortalJsp.CTX_REQUEST, context); 83 rd.forward(request, response); 84 } 85 86 public void endIterateFive(WebResponse webResponse) 87 { 88 assertEquals("Some textSome textSome textSome textSome text", webResponse.getText().trim()); 89 } 90 91 96 public void testDoubleIterate() throws ServletException , IOException 97 { 98 RequestDispatcher rd = config.getServletContext(). 99 getRequestDispatcher("/WEB-INF/jsp/test/testIterate02.jsp"); 100 DelegateContext context = new DelegateContext(); 101 DelegateContext row1 = context.next("row"); 102 DelegateContext row2 = context.next("row"); 103 DelegateContext col1 = row2.next("col"); 104 DelegateContext col2 = row2.next("col"); 105 request.setAttribute(PortalJsp.CTX_REQUEST, context); 106 rd.forward(request, response); 107 } 108 109 public void endDoubleIterate(WebResponse webResponse) 110 { 111 assertEquals("ACABBC", webResponse.getText().trim()); 112 } 113 114 119 public void testTripleIterate() throws ServletException , IOException 120 { 121 RequestDispatcher rd = config.getServletContext(). 122 getRequestDispatcher("/WEB-INF/jsp/test/testIterate03.jsp"); 123 DelegateContext context = new DelegateContext(); 124 DelegateContext row1 = context.next("row"); 125 DelegateContext row2 = context.next("row"); 126 DelegateContext col1 = row2.next("col"); 127 DelegateContext col2 = row2.next("col"); 128 DelegateContext foo1 = col2.next("foo"); 129 request.setAttribute(PortalJsp.CTX_REQUEST, context); 130 rd.forward(request, response); 131 } 132 133 public void endTripleIterate(WebResponse webResponse) 134 { 135 assertEquals("ADABBCD", webResponse.getText().trim()); 136 } 137 } 138 | Popular Tags |