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.JspTestCase; 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 TagLibTestCase 26 extends JspTestCase 27 { 28 public void test01() throws ServletException , IOException 29 { 30 RequestDispatcher rd = config.getServletContext(). 31 getRequestDispatcher("/WEB-INF/jsp/test/testTaglib01.jsp"); 32 rd.forward(request, response); 33 } 34 35 public void end01(WebResponse webResponse) 36 { 37 assertEquals(":::", webResponse.getText().replaceAll("[ \n\t]", "")); 38 } 39 40 public void test02() throws ServletException , IOException 41 { 42 RequestDispatcher rd = config.getServletContext(). 43 getRequestDispatcher("/WEB-INF/jsp/test/testTaglib01.jsp"); 44 DelegateContext context = new DelegateContext(); 45 context.put("foo", "FOO"); 46 context.put("bar", "BAR"); 47 request.setAttribute(PortalJsp.CTX_REQUEST, context); 48 49 rd.forward(request, response); 50 } 51 52 public void end02(WebResponse webResponse) 53 { 54 assertEquals("FOO:FOO:BAR:BAR", webResponse.getText().replaceAll("[ \n\t]", "")); 55 } 56 57 public void test03() throws ServletException , IOException 58 { 59 RequestDispatcher rd = config.getServletContext(). 60 getRequestDispatcher("/WEB-INF/jsp/test/testTaglib01.jsp"); 61 DelegateContext context = new DelegateContext(); 62 context.put("foo", "FOO"); 63 context.put("bar", "BAR"); 64 context.next("row1"); 65 request.setAttribute(PortalJsp.CTX_REQUEST, context); 66 67 rd.forward(request, response); 68 } 69 70 public void end03(WebResponse webResponse) 71 { 72 assertEquals("FOO:FOO::BAR:BAR", webResponse.getText().replaceAll("[ \n\t]", "")); 73 } 74 75 public void test04() throws ServletException , IOException 76 { 77 RequestDispatcher rd = config.getServletContext(). 78 getRequestDispatcher("/WEB-INF/jsp/test/testTaglib01.jsp"); 79 DelegateContext context = new DelegateContext(); 80 context.put("foo", "FOO"); 81 context.put("bar", "BAR"); 82 DelegateContext row1 = context.next("row1"); 83 row1.put("value1", "VALUE"); 84 request.setAttribute(PortalJsp.CTX_REQUEST, context); 85 86 rd.forward(request, response); 87 } 88 89 public void end04(WebResponse webResponse) 90 { 91 assertEquals("FOO:FOO:VALUE:BAR:BAR", webResponse.getText().replaceAll("[ \n\t]", "")); 92 } 93 } 94 | Popular Tags |