1 9 package org.jboss.portal.test.core; 10 11 import java.io.IOException ; 12 13 import javax.portlet.PortletRequest; 14 import javax.servlet.RequestDispatcher ; 15 import javax.servlet.ServletException ; 16 17 import org.apache.cactus.ServletTestCase; 18 import org.apache.cactus.WebResponse; 19 import org.jboss.portal.common.context.DelegateContext; 20 import org.jboss.portal.core.servlet.jsp.PortalJsp; 21 import org.jboss.portal.portlet.impl.ActionRequestImpl; 22 23 26 public class IfTagTestCase 27 extends ServletTestCase 28 29 { 30 36 public void testIfFalse() throws ServletException , IOException 37 { 38 RequestDispatcher rd = config.getServletContext().getRequestDispatcher("/WEB-INF/jsp/test/testIf01.jsp"); 39 rd.forward(request, response); 40 } 41 42 public void endIfFalse(WebResponse webResponse) 43 { 44 assertEquals("", webResponse.getText().trim()); 45 } 46 47 53 public void testIfTrue() throws ServletException , IOException 54 { 55 RequestDispatcher rd = config.getServletContext().getRequestDispatcher("/WEB-INF/jsp/test/testIf01.jsp"); 56 DelegateContext context = new DelegateContext(); 57 context.next("IfCond"); 58 59 PortletRequest req = new ActionRequestImpl(null, null, null, null, null, null, request); 60 req.setAttribute(PortalJsp.CTX_REQUEST, context); 61 request.setAttribute("javax.portlet.request", req); 62 63 rd.forward(request, response); 64 } 65 66 public void endIfTrue(WebResponse webResponse) 67 { 68 assertEquals("Some text", webResponse.getText().trim()); 69 } 70 71 } | Popular Tags |