public class MockFacesContext extends javax.faces.context.FacesContext
Usage:
MockFacesContext facesContext = new MockFacesContext() { public Object evaluateExpressionGet(FacesContext context, String expression, Class expectedType) throws ELException { if ("#{myTestExpression}".equals(expression)) { return myTestResult; } return null; } }; facesContext.setCurrent(); assertNotNull(FacesContext.getCurrentInstance());
Modifier and Type | Field and Description |
---|---|
protected javax.faces.application.Application |
app |
protected Map<String,Object> |
expressions |
protected Map<String,Object> |
variables |
Constructor and Description |
---|
MockFacesContext() |
Modifier and Type | Method and Description |
---|---|
void |
addMessage(String clientId,
javax.faces.application.FacesMessage message) |
protected Object |
evaluateExpression(javax.faces.context.FacesContext context,
String expression) |
Object |
evaluateExpressionGet(javax.faces.context.FacesContext context,
String expression,
Class expectedType)
Deprecated.
|
javax.faces.application.Application |
getApplication() |
Iterator<String> |
getClientIdsWithMessages() |
javax.el.ELContext |
getELContext() |
javax.faces.context.ExternalContext |
getExternalContext() |
javax.faces.application.FacesMessage.Severity |
getMaximumSeverity() |
Iterator<javax.faces.application.FacesMessage> |
getMessages() |
Iterator<javax.faces.application.FacesMessage> |
getMessages(String clientId) |
javax.faces.render.RenderKit |
getRenderKit() |
boolean |
getRenderResponse() |
boolean |
getResponseComplete() |
javax.faces.context.ResponseStream |
getResponseStream() |
javax.faces.context.ResponseWriter |
getResponseWriter() |
javax.faces.component.UIViewRoot |
getViewRoot() |
void |
mapExpression(String expr,
Object res) |
void |
mapVariable(String key,
Object value) |
void |
release() |
void |
relieveCurrent() |
void |
renderResponse() |
void |
resetExpressions() |
void |
resetVariables() |
void |
responseComplete() |
void |
setCurrent() |
void |
setResponseStream(javax.faces.context.ResponseStream responseStream) |
void |
setResponseWriter(javax.faces.context.ResponseWriter responseWriter) |
void |
setViewRoot(javax.faces.component.UIViewRoot root) |
getAttributes, getCurrentInstance, getCurrentPhaseId, getExceptionHandler, getMessageList, getMessageList, getNamingContainerSeparatorChar, getPartialViewContext, getResourceLibraryContracts, isPostback, isProcessingEvents, isProjectStage, isReleased, isValidationFailed, setCurrentInstance, setCurrentPhaseId, setExceptionHandler, setProcessingEvents, setResourceLibraryContracts, validationFailed
protected javax.faces.application.Application app
protected Map<String,Object> expressions
public MockFacesContext()
public void mapVariable(String key, Object value)
public void resetVariables()
public void mapExpression(String expr, Object res)
public void resetExpressions()
public void setCurrent()
public void relieveCurrent()
public javax.faces.application.Application getApplication()
getApplication
in class javax.faces.context.FacesContext
public javax.el.ELContext getELContext()
getELContext
in class javax.faces.context.FacesContext
protected Object evaluateExpression(javax.faces.context.FacesContext context, String expression)
@Deprecated public Object evaluateExpressionGet(javax.faces.context.FacesContext context, String expression, Class expectedType) throws javax.el.ELException
javax.el.ELException
public void addMessage(String clientId, javax.faces.application.FacesMessage message)
addMessage
in class javax.faces.context.FacesContext
public Iterator<String> getClientIdsWithMessages()
getClientIdsWithMessages
in class javax.faces.context.FacesContext
public javax.faces.context.ExternalContext getExternalContext()
getExternalContext
in class javax.faces.context.FacesContext
public javax.faces.application.FacesMessage.Severity getMaximumSeverity()
getMaximumSeverity
in class javax.faces.context.FacesContext
public Iterator<javax.faces.application.FacesMessage> getMessages()
getMessages
in class javax.faces.context.FacesContext
public Iterator<javax.faces.application.FacesMessage> getMessages(String clientId)
getMessages
in class javax.faces.context.FacesContext
public javax.faces.render.RenderKit getRenderKit()
getRenderKit
in class javax.faces.context.FacesContext
public boolean getRenderResponse()
getRenderResponse
in class javax.faces.context.FacesContext
public boolean getResponseComplete()
getResponseComplete
in class javax.faces.context.FacesContext
public javax.faces.context.ResponseStream getResponseStream()
getResponseStream
in class javax.faces.context.FacesContext
public javax.faces.context.ResponseWriter getResponseWriter()
getResponseWriter
in class javax.faces.context.FacesContext
public javax.faces.component.UIViewRoot getViewRoot()
getViewRoot
in class javax.faces.context.FacesContext
public void release()
release
in class javax.faces.context.FacesContext
public void renderResponse()
renderResponse
in class javax.faces.context.FacesContext
public void responseComplete()
responseComplete
in class javax.faces.context.FacesContext
public void setResponseStream(javax.faces.context.ResponseStream responseStream)
setResponseStream
in class javax.faces.context.FacesContext
public void setResponseWriter(javax.faces.context.ResponseWriter responseWriter)
setResponseWriter
in class javax.faces.context.FacesContext
public void setViewRoot(javax.faces.component.UIViewRoot root)
setViewRoot
in class javax.faces.context.FacesContext
Copyright © 2015 Nuxeo SA. All rights reserved.