1 package org.exoplatform.services.portletcontainer.imp; 2 3 4 import javax.portlet.PortletMode; 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.*; 9 import org.exoplatform.test.mocks.servlet.MockHttpSession; 10 import org.exoplatform.test.mocks.servlet.MockServletRequest; 11 import org.exoplatform.test.mocks.servlet.MockServletResponse; 12 import java.util.Locale ; 13 14 18 19 26 public class TestMessageMechanism extends BaseTest{ 27 28 public TestMessageMechanism(String s) { 29 super(s); 30 } 31 32 public void setUp() throws Exception { 33 super.setUp(); 34 } 35 36 public void testSendMessage() throws PortletContainerException { 37 MockServletRequest request = new MockServletRequest(new MockHttpSession(), Locale.US, true); 38 HttpServletResponse response = new MockServletResponse(new EmptyResponse()); 39 ((ExoWindowID)actionInput.getWindowID()).setPortletName("PortletThatSendsMessage"); 40 actionInput.setPortletMode(new PortletMode("config")); 41 ActionOutput aO = portletContainer.processAction(request, response, actionInput); 42 assertEquals("Everything is ok", ((String [])aO.getRenderParameters().get("status"))[0]); 43 } 44 45 public void testSendMessageInRender() throws PortletContainerException { 46 MockServletRequest request = new MockServletRequest(new MockHttpSession(), Locale.US, true); 47 HttpServletResponse response = new MockServletResponse(new EmptyResponse()); 48 ((ExoWindowID)actionInput.getWindowID()).setPortletName("PortletThatSendsMessage"); 49 RenderOutput o = portletContainer.render(request, response, input); 50 assertEquals("Exception occured", o.getTitle()); 51 assertEquals("javax.portlet.PortletException", new String (o.getContent())); 52 } 53 54 } 55 | Popular Tags |