protected void setUp( ) throws Exception { super.setUp(); // Create mocks mockServices = mock( ContainerServices.class ); mockCCPPProfileService = mock( CCPPProfileService.class ); mockPortalContext = mock( PortalContext.class ); mockPortletContext = mock( PortletContext.class ); mockPortletURLProvider = mock(PortletURLProvider.class); mockContainer = mock( PortletContainerImpl.class, new Class[] { String.class, ContainerServices.class }, new Object[] { "Mock Pluto Container", (ContainerServices) mockServices.proxy() } ); window = (PortletWindow) mock( PortletWindow.class ).proxy(); mockHttpServletRequest = mock( HttpServletRequest.class ); mockPortletRequestContext = mock ( PortletRequestContext.class ); mockPortletResponseContext = mock ( PortletRenderResponseContext.class ); mock ( CacheControl.class ); // Constructor expectations for RenderRequestImpl // mockContainer.expects( atLeastOnce() ).method( "getOptionalContainerServices" ).will( returnValue( mockOptionalServices.proxy() ) ); // mockServices.expects( once() ).method( "getPortalContext" ).will( returnValue( mockPortalContext.proxy() ) ); }
/** * Create a new MockPortletRequest. * @param portalContext the PortalContext that the request runs in * @param portletContext the PortletContext that the request runs in */ public MockPortletRequest(PortalContext portalContext, PortletContext portletContext) { this.portalContext = (portalContext != null ? portalContext : new MockPortalContext()); this.portletContext = (portletContext != null ? portletContext : new MockPortletContext()); this.responseContentTypes.add("text/html"); this.locales.add(Locale.ENGLISH); this.attributes.put(LIFECYCLE_PHASE, getLifecyclePhase()); }
/** * Create a new MockPortletRequest. * * @param portalContext the PortalContext that the request runs in * @param portletContext the PortletContext that the request runs in */ public MockPortletRequest(PortalContext portalContext, PortletContext portletContext) { this.portalContext = (portalContext != null ? portalContext : new MockPortalContext()); this.portletContext = (portletContext != null ? portletContext : new MockPortletContext()); this.responseContentTypes.add("text/html"); this.locales.add(Locale.ENGLISH); this.attributes.put(LIFECYCLE_PHASE, getLifecyclePhase()); }
/** */ public PortalContextWrapper(PortalContext wrapped) { if (wrapped == null) { throw new java.lang.IllegalArgumentException("Object to wrap is null"); } this.wrapped = wrapped; }
/** * Sets the wrapped object. * * @param wrapped the wrapped object to set. * @throws java.lang.IllegalArgumentException if the request is null. */ public void setWrapped(PortalContext wrapped) { if (wrapped == null) { throw new java.lang.IllegalArgumentException("Object to wrap is null"); } this.wrapped = wrapped; }
@Override public PortalContext getPortalContext() { String meth = "getPortalContext"; Object[] args = {}; PortalContext ret = pcntxt; retVal = ret; checkArgs(meth, args); return ret; }
/** * Default Constructor. * @param config */ public PortalContextImpl(DriverConfiguration config) { this.config = config; reset(); // we now support render headers properties.put(PortalContext.MARKUP_HEAD_ELEMENT_SUPPORT, "true"); }
/** * Constructor for just passing in the required services. * @param context * @param portletRequestContextService * @param eventCoordinationService * @param filterManagerService * @param portletURLListenerService */ public PortalDriverServicesImpl(PortalContext context, PortletRequestContextService portletRequestContextService, EventCoordinationService eventCoordinationService, FilterManagerService filterManagerService, PortletURLListenerService portletURLListenerService) { this(context, portletRequestContextService, eventCoordinationService, filterManagerService, portletURLListenerService, null); }
/** * Constructor for passing in the required services and optional container services. * @param context * @param portletRequestContextService * @param eventCoordinationService * @param filterManagerService * @param portletURLListenerService * @param optionalServices Optional services (if this is null, default services are used) */ public PortalDriverServicesImpl(PortalContext context, PortletRequestContextService portletRequestContextService, EventCoordinationService eventCoordinationService, FilterManagerService filterManagerService, PortletURLListenerService portletURLListenerService, OptionalContainerServices optionalServices) { this(context, portletRequestContextService, eventCoordinationService, filterManagerService, portletURLListenerService, optionalServices, null, null, null); }
/** * Constructor for passing in the required services and optional container services. * @param context * @param portletRequestContextService * @param eventCoordinationService * @param filterManagerService * @param portletURLListenerService * @param optionalServices Optional services (if this is null, default services are used) */ public PortalDriverServicesImpl(PortalContext context, PortletRequestContextService portletRequestContextService, EventCoordinationService eventCoordinationService, FilterManagerService filterManagerService, PortletURLListenerService portletURLListenerService, OptionalContainerServices optionalServices, PortletContextService portletContextService, PortletRegistryService portletRegistryService, PortalAdministrationService portalAdministrationService) { // set required first this.context = context; this.eventCoordinationService = eventCoordinationService; this.portletRequestContextService = portletRequestContextService; this.filterManagerService = filterManagerService; this.portletURLListenerService = portletURLListenerService; // now optional if ( optionalServices != null ) { ccppProfileService = optionalServices.getCCPPProfileService(); portletPreferencesService = optionalServices.getPortletPreferencesService(); portletInvokerService = optionalServices.getPortletInvokerService(); portletEnvironmentService = optionalServices.getPortletEnvironmentService(); userInfoService = optionalServices.getUserInfoService(); namespaceMapper = optionalServices.getNamespaceMapper(); rdService = optionalServices.getRequestDispatcherService(); } // and finally driver this.portletContextService = portletContextService; this.portletRegistryService = portletRegistryService; this.portalAdministrationService = portalAdministrationService; createDefaultServicesIfNeeded(); }
@Override protected Object resolveStandardArgument(Class<?> parameterType, NativeWebRequest webRequest) throws Exception { PortletRequest request = webRequest.getNativeRequest(PortletRequest.class); PortletResponse response = webRequest.getNativeResponse(PortletResponse.class); if (PortletRequest.class.isAssignableFrom(parameterType) || MultipartRequest.class.isAssignableFrom(parameterType)) { Object nativeRequest = webRequest.getNativeRequest(parameterType); if (nativeRequest == null) { throw new IllegalStateException( "Current request is not of type [" + parameterType.getName() + "]: " + request); } return nativeRequest; } else if (PortletResponse.class.isAssignableFrom(parameterType)) { Object nativeResponse = webRequest.getNativeResponse(parameterType); if (nativeResponse == null) { throw new IllegalStateException( "Current response is not of type [" + parameterType.getName() + "]: " + response); } return nativeResponse; } else if (PortletSession.class.isAssignableFrom(parameterType)) { return request.getPortletSession(); } else if (PortletPreferences.class.isAssignableFrom(parameterType)) { return request.getPreferences(); } else if (PortletMode.class.isAssignableFrom(parameterType)) { return request.getPortletMode(); } else if (WindowState.class.isAssignableFrom(parameterType)) { return request.getWindowState(); } else if (PortalContext.class.isAssignableFrom(parameterType)) { return request.getPortalContext(); } else if (Principal.class.isAssignableFrom(parameterType)) { return request.getUserPrincipal(); } else if (Locale.class == parameterType) { return request.getLocale(); } else if (InputStream.class.isAssignableFrom(parameterType)) { if (!(request instanceof ClientDataRequest)) { throw new IllegalStateException("InputStream can only get obtained for Action/ResourceRequest"); } return ((ClientDataRequest) request).getPortletInputStream(); } else if (Reader.class.isAssignableFrom(parameterType)) { if (!(request instanceof ClientDataRequest)) { throw new IllegalStateException("Reader can only get obtained for Action/ResourceRequest"); } return ((ClientDataRequest) request).getReader(); } else if (OutputStream.class.isAssignableFrom(parameterType)) { if (!(response instanceof MimeResponse)) { throw new IllegalStateException("OutputStream can only get obtained for Render/ResourceResponse"); } return ((MimeResponse) response).getPortletOutputStream(); } else if (Writer.class.isAssignableFrom(parameterType)) { if (!(response instanceof MimeResponse)) { throw new IllegalStateException("Writer can only get obtained for Render/ResourceResponse"); } return ((MimeResponse) response).getWriter(); } else if (Event.class == parameterType) { if (!(request instanceof EventRequest)) { throw new IllegalStateException("Event can only get obtained from EventRequest"); } return ((EventRequest) request).getEvent(); } return super.resolveStandardArgument(parameterType, webRequest); }
@Override public PortalContext getPortalContext() { return this.portalContext; }
public PortalContext getPortalContext() { return portalContext; }
public void setPortalContext(PortalContext portalContext) { this.portalContext = portalContext; }
public PortalContext getPortalContext() { return context; }
@Override protected Object resolveStandardArgument(Class<?> parameterType, NativeWebRequest webRequest) throws Exception { PortletRequest request = webRequest.getNativeRequest(PortletRequest.class); PortletResponse response = webRequest.getNativeResponse(PortletResponse.class); if (PortletRequest.class.isAssignableFrom(parameterType) || MultipartRequest.class.isAssignableFrom(parameterType)) { Object nativeRequest = webRequest.getNativeRequest(parameterType); if (nativeRequest == null) { throw new IllegalStateException( "Current request is not of type [" + parameterType.getName() + "]: " + request); } return nativeRequest; } else if (PortletResponse.class.isAssignableFrom(parameterType)) { Object nativeResponse = webRequest.getNativeResponse(parameterType); if (nativeResponse == null) { throw new IllegalStateException( "Current response is not of type [" + parameterType.getName() + "]: " + response); } return nativeResponse; } else if (PortletSession.class.isAssignableFrom(parameterType)) { return request.getPortletSession(); } else if (PortletPreferences.class.isAssignableFrom(parameterType)) { return request.getPreferences(); } else if (PortletMode.class.isAssignableFrom(parameterType)) { return request.getPortletMode(); } else if (WindowState.class.isAssignableFrom(parameterType)) { return request.getWindowState(); } else if (PortalContext.class.isAssignableFrom(parameterType)) { return request.getPortalContext(); } else if (Principal.class.isAssignableFrom(parameterType)) { return request.getUserPrincipal(); } else if (Locale.class.equals(parameterType)) { return request.getLocale(); } else if (InputStream.class.isAssignableFrom(parameterType)) { if (!(request instanceof ClientDataRequest)) { throw new IllegalStateException("InputStream can only get obtained for Action/ResourceRequest"); } return ((ClientDataRequest) request).getPortletInputStream(); } else if (Reader.class.isAssignableFrom(parameterType)) { if (!(request instanceof ClientDataRequest)) { throw new IllegalStateException("Reader can only get obtained for Action/ResourceRequest"); } return ((ClientDataRequest) request).getReader(); } else if (OutputStream.class.isAssignableFrom(parameterType)) { if (!(response instanceof MimeResponse)) { throw new IllegalStateException("OutputStream can only get obtained for Render/ResourceResponse"); } return ((MimeResponse) response).getPortletOutputStream(); } else if (Writer.class.isAssignableFrom(parameterType)) { if (!(response instanceof MimeResponse)) { throw new IllegalStateException("Writer can only get obtained for Render/ResourceResponse"); } return ((MimeResponse) response).getWriter(); } else if (Event.class.equals(parameterType)) { if (!(request instanceof EventRequest)) { throw new IllegalStateException("Event can only get obtained from EventRequest"); } return ((EventRequest) request).getEvent(); } return super.resolveStandardArgument(parameterType, webRequest); }
public PortalContext getPortalContext() { return this.portalContext; }
@Override public PortalContext getPortalContext() { return portalContext; }
protected PortalContext getPortalContext() { return getPortletContainer().getContainerServices().getPortalContext(); }
@Override public PortalContext getPortalContext() { return null; }
public PortalContext getPortalContext() { return driverServices.getPortalContext(); }
/** * @see org.apache.pluto.container.ContainerServices#getPortalContext() */ public PortalContext getPortalContext() { return context; }
/** * Create a new MockPortletURL for the given URL type. * @param portalContext the PortalContext defining the supported * PortletModes and WindowStates * @param urlType the URL type, for example "render" or "action" * @see #URL_TYPE_RENDER * @see #URL_TYPE_ACTION */ public MockPortletURL(PortalContext portalContext, String urlType) { Assert.notNull(portalContext, "PortalContext is required"); this.portalContext = portalContext; this.urlType = urlType; }
/** * Create a new MockClientDataRequest. * @param portalContext the PortalContext that the request runs in * @param portletContext the PortletContext that the request runs in */ public MockClientDataRequest(PortalContext portalContext, PortletContext portletContext) { super(portalContext, portletContext); }
/** * Create a new MockResourceRequest. * @param portalContext the PortalContext that the request runs in * @param portletContext the PortletContext that the request runs in */ public MockResourceRequest(PortalContext portalContext, PortletContext portletContext) { super(portalContext, portletContext); }
/** * Create a new MockEventRequest. * @param event the event that this request wraps * @param portalContext the PortletContext that the request runs in * @param portletContext the PortletContext that the request runs in */ public MockEventRequest(Event event, PortalContext portalContext, PortletContext portletContext) { super(portalContext, portletContext); this.event = event; }
/** * Create a new MockPortletResponse. * @param portalContext the PortalContext defining the supported * PortletModes and WindowStates */ public MockPortletResponse(PortalContext portalContext) { this.portalContext = (portalContext != null ? portalContext : new MockPortalContext()); }
/** * Return the PortalContext that this MockPortletResponse runs in, * defining the supported PortletModes and WindowStates. */ public PortalContext getPortalContext() { return this.portalContext; }
/** * Create a new MockRenderResponse. * @param portalContext the PortalContext defining the supported * PortletModes and WindowStates */ public MockRenderResponse(PortalContext portalContext) { super(portalContext); }