1 16 17 package org.springframework.mock.web.portlet; 18 19 import java.io.IOException ; 20 21 import javax.portlet.PortletException; 22 import javax.portlet.PortletRequestDispatcher; 23 import javax.portlet.RenderRequest; 24 import javax.portlet.RenderResponse; 25 26 import org.apache.commons.logging.Log; 27 import org.apache.commons.logging.LogFactory; 28 29 import org.springframework.util.Assert; 30 31 38 public class MockPortletRequestDispatcher implements PortletRequestDispatcher { 39 40 private final Log logger = LogFactory.getLog(getClass()); 41 42 private final String url; 43 44 45 49 public MockPortletRequestDispatcher(String url) { 50 Assert.notNull(url, "URL must not be null"); 51 this.url = url; 52 } 53 54 55 public void include(RenderRequest request, RenderResponse response) throws PortletException, IOException { 56 Assert.notNull(request, "Request must not be null"); 57 Assert.notNull(response, "Response must not be null"); 58 if (!(response instanceof MockRenderResponse)) { 59 throw new IllegalArgumentException ("MockPortletRequestDispatcher requires MockRenderResponse"); 60 } 61 ((MockRenderResponse) response).setIncludedUrl(this.url); 62 if (logger.isDebugEnabled()) { 63 logger.debug("MockPortletRequestDispatcher: including URL [" + this.url + "]"); 64 } 65 } 66 67 } 68 | Popular Tags |