KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > test > core > IfTagTestCase


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.test.core;
10
11 import java.io.IOException JavaDoc;
12
13 import javax.portlet.PortletRequest;
14 import javax.servlet.RequestDispatcher JavaDoc;
15 import javax.servlet.ServletException JavaDoc;
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 /**
24  * @author <a HREF="theute@jboss.org">Thomas Heute </a> $Revision: 1.1 $
25  */

26 public class IfTagTestCase
27       extends ServletTestCase
28
29 {
30    /**
31     * If condition is not verified
32     *
33     * @throws ServletException
34     * @throws IOException
35     */

36    public void testIfFalse() throws ServletException JavaDoc, IOException JavaDoc
37    {
38       RequestDispatcher JavaDoc 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    /**
48     * If condition is verified
49     *
50     * @throws ServletException
51     * @throws IOException
52     */

53    public void testIfTrue() throws ServletException JavaDoc, IOException JavaDoc
54    {
55       RequestDispatcher JavaDoc 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