KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > portletcontainer > imp > TestMessageMechanism


1 package org.exoplatform.services.portletcontainer.imp;
2
3
4 import javax.portlet.PortletMode;
5 import javax.servlet.http.HttpServletResponse JavaDoc;
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 JavaDoc;
13
14 /**
15  * Copyright 2001-2003 The eXo platform SARL All rights reserved.
16  * Please look at license.txt in info directory for more license detail.
17  **/

18
19 /**
20  * Created by the Exo Development team.
21  * Author : Mestrallet Benjamin
22  * benjmestrallet@users.sourceforge.net
23  * Date: 19 nov. 2003
24  * Time: 01:12:05
25  */

26 public class TestMessageMechanism extends BaseTest{
27
28     public TestMessageMechanism(String JavaDoc s) {
29         super(s);
30     }
31
32   public void setUp() throws Exception JavaDoc {
33     super.setUp();
34   }
35
36     public void testSendMessage() throws PortletContainerException {
37         MockServletRequest request = new MockServletRequest(new MockHttpSession(), Locale.US, true);
38         HttpServletResponse JavaDoc 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 JavaDoc[])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 JavaDoc 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 JavaDoc(o.getContent()));
52     }
53
54 }
55
Popular Tags