KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > pluto > portalImpl > portlet > test > DispatcherRenderParameterTest


1 /*
2  * Copyright 2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.pluto.portalImpl.portlet.test;
17
18 import java.io.IOException JavaDoc;
19
20 import javax.portlet.PortletContext;
21 import javax.portlet.PortletException;
22 import javax.portlet.PortletRequest;
23 import javax.portlet.PortletRequestDispatcher;
24 import javax.portlet.PortletResponse;
25 import javax.portlet.RenderRequest;
26 import javax.portlet.RenderResponse;
27
28 /**
29  * <B>TODO</B>: Document
30  * @author <a HREF="ddewolf@apache.org">David H. DeWolf</a>
31  * @version 1.0
32  * @since Mar 9, 2005
33  */

34 public class DispatcherRenderParameterTest
35     extends AbstractReflectivePortletTest {
36
37     public static final String JavaDoc KEY_A = "includedTestKey";
38     public static final String JavaDoc VAL_A = "includedTestVal";
39     public static final String JavaDoc KEY_B = "bTestKey";
40     public static final String JavaDoc VAL_B = "bTestVal";
41     public static final String JavaDoc RESULT_KEY = "org.apache.pluto.testsuite.RESULTKEY";
42     
43
44     public DispatcherRenderParameterTest() {
45
46     }
47
48     public String JavaDoc getTestSuiteName() {
49         return "Dispatcher Render Parameter Test";
50     }
51     
52     protected TestResult checkIncludedParameterTest(PortletContext ctx,
53                                                     PortletRequest req,
54                                                     PortletResponse res)
55     throws IOException JavaDoc, PortletException {
56         PortletRequestDispatcher disp =
57             ctx.getRequestDispatcher("/tests/include?"+KEY_A+"="+VAL_A+"&"+KEY_B+"="+VAL_B);
58         
59         disp.include((RenderRequest)req, (RenderResponse)res);
60
61         TestResult result = new TestResult();
62         result.setName("Dispatcher Render Parameter Test");
63         result.setDesc("Ensure query parameters added during dispatching are attached to the request.");
64         if(req.getAttribute(RESULT_KEY)!=null && Boolean.TRUE.equals(req.getAttribute(RESULT_KEY))) {
65             result.setReturnCode(TestResult.PASSED);
66         }
67         else {
68             result.setReturnCode(TestResult.FAILED);
69             result.setResults("Unable to find expected parameter");
70         }
71         return result;
72     }
73     
74
75 }
76
77
Popular Tags