KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > test > portlet > portletmode > TestDuringRenderPortlet


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

11 package org.jboss.portal.test.portlet.portletmode;
12
13 import org.jboss.portal.junit.result.AssertResult;
14 import org.jboss.portal.test.portlet.AbstractPortlet;
15
16 import javax.portlet.RenderRequest;
17 import javax.portlet.RenderResponse;
18 import javax.portlet.PortletException;
19 import javax.portlet.PortletSecurityException;
20 import javax.portlet.PortletURL;
21 import javax.portlet.PortletMode;
22 import java.io.IOException JavaDoc;
23
24 /**
25  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
26  * @version $Revision: 1.2 $
27  */

28 public class TestDuringRenderPortlet extends AbstractPortlet
29 {
30
31    public void render(final RenderRequest request, final RenderResponse response) throws PortletException, PortletSecurityException, IOException JavaDoc
32    {
33       AssertResult result = new AssertResult();
34       result.execute(new AssertResult.Test()
35       {
36          public void run() throws Exception JavaDoc
37          {
38             // Test null returns false
39
assertFalse(request.isPortletModeAllowed(null));
40
41             // Test that we can use set the portlet mode on render URL
42
// before having set the content type on the response
43
PortletURL url1 = response.createRenderURL();
44             url1.setPortletMode(PortletMode.VIEW);
45
46             // Test we can set null portlet mode
47
url1.setPortletMode(null);
48
49             // Test that we can use set the portlet mode on action URL
50
// before having set the content type on the response
51
PortletURL url2 = response.createActionURL();
52             url2.setPortletMode(PortletMode.VIEW);
53
54             // Test we can set null portlet mode
55
url2.setPortletMode(null);
56          }
57       });
58       sendResult(response, result);
59    }
60
61 }
62
Popular Tags