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, validationFailedprotected 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.FacesContextpublic javax.el.ELContext getELContext()
getELContext in class javax.faces.context.FacesContextprotected 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.ELExceptionpublic void addMessage(String clientId, javax.faces.application.FacesMessage message)
addMessage in class javax.faces.context.FacesContextpublic Iterator<String> getClientIdsWithMessages()
getClientIdsWithMessages in class javax.faces.context.FacesContextpublic javax.faces.context.ExternalContext getExternalContext()
getExternalContext in class javax.faces.context.FacesContextpublic javax.faces.application.FacesMessage.Severity getMaximumSeverity()
getMaximumSeverity in class javax.faces.context.FacesContextpublic Iterator<javax.faces.application.FacesMessage> getMessages()
getMessages in class javax.faces.context.FacesContextpublic Iterator<javax.faces.application.FacesMessage> getMessages(String clientId)
getMessages in class javax.faces.context.FacesContextpublic javax.faces.render.RenderKit getRenderKit()
getRenderKit in class javax.faces.context.FacesContextpublic boolean getRenderResponse()
getRenderResponse in class javax.faces.context.FacesContextpublic boolean getResponseComplete()
getResponseComplete in class javax.faces.context.FacesContextpublic javax.faces.context.ResponseStream getResponseStream()
getResponseStream in class javax.faces.context.FacesContextpublic javax.faces.context.ResponseWriter getResponseWriter()
getResponseWriter in class javax.faces.context.FacesContextpublic javax.faces.component.UIViewRoot getViewRoot()
getViewRoot in class javax.faces.context.FacesContextpublic void release()
release in class javax.faces.context.FacesContextpublic void renderResponse()
renderResponse in class javax.faces.context.FacesContextpublic void responseComplete()
responseComplete in class javax.faces.context.FacesContextpublic void setResponseStream(javax.faces.context.ResponseStream responseStream)
setResponseStream in class javax.faces.context.FacesContextpublic void setResponseWriter(javax.faces.context.ResponseWriter responseWriter)
setResponseWriter in class javax.faces.context.FacesContextpublic void setViewRoot(javax.faces.component.UIViewRoot root)
setViewRoot in class javax.faces.context.FacesContextCopyright © 2019 Nuxeo. All rights reserved.