1 package org.exoplatform.services.portletcontainer.imp; 2 3 4 import javax.servlet.http.HttpServletRequest ; 5 import javax.servlet.http.HttpServletResponse ; 6 import org.exoplatform.services.portletcontainer.PortletContainerException; 7 import org.exoplatform.services.portletcontainer.impl.portletAPIImp.pool.EmptyResponse; 8 import org.exoplatform.services.portletcontainer.pci.ExoWindowID; 9 import org.exoplatform.services.portletcontainer.pci.RenderOutput; 10 import org.exoplatform.test.mocks.servlet.MockHttpSession; 11 import org.exoplatform.test.mocks.servlet.MockServletRequest; 12 import org.exoplatform.test.mocks.servlet.MockServletResponse; 13 import java.util.HashMap ; 14 import java.util.Locale ; 15 import java.util.Map ; 16 17 21 22 29 public class TestPortletURL extends BaseTest{ 30 31 public TestPortletURL(String s) { 32 super(s); 33 } 34 35 36 44 public void testSetParameterMethods() throws PortletContainerException { 45 HttpServletRequest request = new MockServletRequest(new MockHttpSession(), Locale.US, true); 46 HttpServletResponse response = new MockServletResponse(new EmptyResponse()); 47 ((ExoWindowID)input.getWindowID()).setPortletName("PortletToTestPortletURL"); 48 RenderOutput o = portletContainer.render(request, response, input); 49 assertNull(o.getTitle()); 50 assertTrue(new String (o.getContent()).startsWith("Everything is ok")); 51 } 52 53 59 public void testAvailibilityOfRenderParameters() throws PortletContainerException { 60 HttpServletRequest request = new MockServletRequest(new MockHttpSession(), Locale.US, true); 61 HttpServletResponse response = new MockServletResponse(new EmptyResponse()); 62 Map renderMap = new HashMap (); 63 renderMap.put("testParam", "testParamValue"); 64 ((ExoWindowID)input.getWindowID()).setPortletName("PortletToTestPortletURL2"); 65 input.setRenderParameters(renderMap); 66 RenderOutput o = portletContainer.render(request, response, input); 67 assertNull(o.getTitle()); 68 assertTrue(new String (o.getContent()).startsWith("Everything is ok")); 69 } 70 71 77 public void testParameterEncoding() throws PortletContainerException { 78 HttpServletRequest request = new MockServletRequest(new MockHttpSession(), Locale.US,false); 79 HttpServletResponse response = new MockServletResponse(new EmptyResponse()); 80 ((ExoWindowID)input.getWindowID()).setPortletName("PortletToTestParameterEncoding"); 81 RenderOutput o = portletContainer.render(request, response, input); 82 assertTrue(new String (o.getContent()).startsWith("Everything is ok")); 83 } 84 85 92 public void testModeSupport() throws PortletContainerException { 93 HttpServletRequest request = new MockServletRequest(new MockHttpSession(), Locale.US, true); 94 HttpServletResponse response = new MockServletResponse(new EmptyResponse()); 95 ((ExoWindowID)input.getWindowID()).setPortletName("PortletToTestModeSupport"); 96 RenderOutput o = portletContainer.render(request, response, input); 97 assertEquals("Exception occured", o.getTitle()); 98 assertEquals("javax.portlet.PortletModeException: The mode edit is not supported by that portlet", 99 new String (o.getContent())); 100 } 101 102 109 public void testWindowStateSupport() throws PortletContainerException { 110 HttpServletRequest request = new MockServletRequest(new MockHttpSession(), Locale.US, true); 111 HttpServletResponse response = new MockServletResponse(new EmptyResponse()); 112 ((ExoWindowID)input.getWindowID()).setPortletName("PortletToTestStateSupport"); 113 RenderOutput o = portletContainer.render(request, response, input); 114 assertEquals("Exception occured", o.getTitle()); 115 assertEquals("javax.portlet.WindowStateException: The window state detached is not supported by the portlet container", 116 new String (o.getContent())); 117 } 118 119 125 public void testPortletURLSecurity() throws PortletContainerException { 126 HttpServletRequest request = new MockServletRequest(new MockHttpSession(), Locale.US, true); 127 HttpServletResponse response = new MockServletResponse(new EmptyResponse()); 128 ((ExoWindowID)input.getWindowID()).setPortletName("PortletToTestPortletURLSecurity"); 129 RenderOutput o = portletContainer.render(request, response, input); 130 assertTrue(new String (o.getContent()).startsWith("Everything is ok")); 131 } 132 133 } 134 | Popular Tags |