1 15 package org.apache.tapestry.portlet; 16 17 import javax.portlet.ActionResponse; 18 import javax.portlet.PortletMode; 19 import javax.portlet.PortletRequest; 20 import javax.portlet.WindowState; 21 22 import org.apache.hivemind.test.HiveMindTestCase; 23 import org.apache.tapestry.IPage; 24 import org.apache.tapestry.IRequestCycle; 25 import org.apache.tapestry.services.ServiceConstants; 26 import org.easymock.MockControl; 27 28 34 public class TestPortletResponseRenderer extends HiveMindTestCase 35 { 36 private ActionResponse newResponse() 37 { 38 return (ActionResponse) newMock(ActionResponse.class); 39 } 40 41 private IPage newPage(String name) 42 { 43 MockControl control = newControl(IPage.class); 44 IPage page = (IPage) control.getMock(); 45 46 page.getPageName(); 47 control.setReturnValue(name); 48 49 return page; 50 } 51 52 private IRequestCycle newCycle(IPage page) 53 { 54 MockControl control = newControl(IRequestCycle.class); 55 IRequestCycle cycle = (IRequestCycle) control.getMock(); 56 57 cycle.getPage(); 58 control.setReturnValue(page); 59 60 return cycle; 61 } 62 63 public void testSuccess() throws Exception 64 { 65 IPage page = newPage("Frodo"); 66 IRequestCycle cycle = newCycle(page); 67 68 MockControl requestc = newControl(PortletRequest.class); 69 PortletRequest request = (PortletRequest) requestc.getMock(); 70 71 request.getPortletMode(); 72 requestc.setReturnValue(PortletMode.VIEW); 73 74 request.getWindowState(); 75 requestc.setReturnValue(WindowState.NORMAL); 76 77 ActionResponse response = newResponse(); 78 79 response.setRenderParameter(ServiceConstants.SERVICE, PortletConstants.RENDER_SERVICE); 80 response.setRenderParameter(ServiceConstants.PAGE, "Frodo"); 81 response.setRenderParameter(PortletConstants.PORTLET_MODE, "view"); 82 response.setRenderParameter(PortletConstants.WINDOW_STATE, "normal"); 83 84 replayControls(); 85 86 PortletResponseRenderer renderer = new PortletResponseRenderer(); 87 renderer.setResponse(response); 88 renderer.setRequest(request); 89 90 renderer.renderResponse(cycle); 91 92 verifyControls(); 93 } 94 } | Popular Tags |