1 5 package org.exoplatform.test.mocks.portlet; 6 7 import java.util.ResourceBundle ; 8 9 import javax.portlet.* ; 10 import javax.servlet.http.*; 11 import org.apache.commons.lang.StringUtils; 12 import org.exoplatform.faces.context.*; 13 import org.exoplatform.test.mocks.jsf.*; 14 15 21 public class MockPortletExternalContext 22 extends MockExternalContext implements PortletExternalContext { 23 private MockPortletConfig portletConfig_ ; 24 private MockPortletContext portletContext_ ; 25 private MockPortletRequest portletRequest_ ; 26 27 public MockPortletExternalContext() { 28 portletContext_ = new MockPortletContext() ; 29 portletConfig_ = new MockPortletConfig(portletContext_) ; 30 portletRequest_ = new MockPortletRequest() ; 31 } 32 33 public void init(HttpServletRequest request, HttpServletResponse response) { 34 super.init(request, response) ; 35 } 36 37 public PortletPreferences getPortletPreferences() { 38 return portletRequest_.getPreferences() ; 39 } 40 41 public Object getRequest() { return portletRequest_ ; } 42 43 public MockPortletConfig getMockPortletConfig() { 44 return portletConfig_ ; 45 } 46 47 public MockPortletContext getMockPortletContext() { 48 return portletContext_ ; 49 } 50 51 public String encodeActionURL( String s ) { 52 if (s == null || s.length() == 0) { 53 s = request_.getRequestURI() ; 54 if(s.indexOf("?") < 0) s += "?junk=junk" ; 55 return s ; 56 }else if ("http://".startsWith(s)) { 57 return s ; 58 } else { 59 String baseURL = request_.getRequestURI() ; 60 return baseURL + "?viewId=" + s ; 62 } 63 } 64 65 public PortletConfig getConfig() { return portletConfig_ ; } 66 public ResourceBundle getApplicationResourceBundle() { return null ; } 67 } | Popular Tags |