KickJava   Java API By Example, From Geeks To Geeks.

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


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.servlet.RequestDispatcher JavaDoc;
14 import javax.servlet.ServletException JavaDoc;
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 /**
22  * @author <a HREF="theute@jboss.org">Thomas Heute</a>
23  * $Revision: 1.1 $
24  */

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

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

52    public void testIterateOnce() throws ServletException JavaDoc, IOException JavaDoc
53    {
54       RequestDispatcher JavaDoc 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    /**
68     * If condition is verified
69     * @throws ServletException
70     * @throws IOException
71     */

72    public void testIterateFive() throws ServletException JavaDoc, IOException JavaDoc
73    {
74       RequestDispatcher JavaDoc 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    /**
92     * If condition is verified
93     * @throws ServletException
94     * @throws IOException
95     */

96    public void testDoubleIterate() throws ServletException JavaDoc, IOException JavaDoc
97    {
98       RequestDispatcher JavaDoc 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    /**
115     * If condition is verified
116     * @throws ServletException
117     * @throws IOException
118     */

119    public void testTripleIterate() throws ServletException JavaDoc, IOException JavaDoc
120    {
121       RequestDispatcher JavaDoc 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