public void testGetFacesContextPortlet() {
FacesContextFactoryImpl factory = new FacesContextFactoryImpl(facesContextFactory);
MockPortletContext portletContext = new MockPortletContext(servletContext);
MockActionRequest portletRequest = new MockActionRequest(portletContext);
MockActionResponse portletResponse = new MockActionResponse();
PortletStateHolder portletStateHolder = PortletStateHolder.init(new MockPortletContext(servletContext));
PortletWindowState portletState = new PortletWindowState(){
@Override
public BridgeConfig getBridgeConfig() {
return new BridgeConfig(){
public Map<String, String> getDefaultViewIdMap() {
HashMap<String, String> viewIdMap = new HashMap<String,String>();
viewIdMap.put("view", "/foo.xhtml");
return viewIdMap;
}
public Set<ExcludedRequestAttribute> getExcludedAttributes() {
// TODO Auto-generated method stub
return null;
}
public List<String> getFacesServletMappings() {
// TODO Auto-generated method stub
return null;
}
public String getInitParameter(String name) {
// TODO Auto-generated method stub
return null;
}
public PortletConfig getPortletConfig() {
// TODO Auto-generated method stub
return null;
}
public String getPortletName() {
// TODO Auto-generated method stub
return null;
}
public boolean isPreserveActionParams() {
// TODO Auto-generated method stub
return false;
}
public Map<Class<? extends Throwable>, String> getErrorPages() {
// TODO Auto-generated method stub
return null;
}
public Lifecycle getFacesLifecycle() {
return null;
}
};
}
};
portletStateHolder.addWindowState(STATE_ID, portletState);
PortletBridgeContext bridgeContext = portletState.createBridgeContext();
portletRequest.setAttribute(PortletBridgeContext.REQUEST_PARAMETER_NAME, bridgeContext);
FacesContext context = factory.getFacesContext(portletContext,
portletRequest, portletResponse, lifecycle);
assertTrue((context instanceof FacesContextImpl));