Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.platform.ui.web.jsf
Class MockFacesContext

java.lang.Object
  extended by javax.faces.context.FacesContext
      extended by org.nuxeo.ecm.platform.ui.web.jsf.MockFacesContext

public abstract class MockFacesContext
extends FacesContext

Mock faces context that can be used to resolve expressions in tests.

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());
 

Author:
Anahide Tchertchian

Nested Class Summary
 class MockFacesContext.MockApplication
           
 
Constructor Summary
MockFacesContext()
           
 
Method Summary
 void addMessage(String clientId, FacesMessage message)
           
abstract  Object evaluateExpressionGet(FacesContext context, String expression, Class expectedType)
           
 Application getApplication()
           
 Iterator<String> getClientIdsWithMessages()
           
 ExternalContext getExternalContext()
           
 FacesMessage.Severity getMaximumSeverity()
           
 Iterator<FacesMessage> getMessages()
           
 Iterator<FacesMessage> getMessages(String clientId)
           
 RenderKit getRenderKit()
           
 boolean getRenderResponse()
           
 boolean getResponseComplete()
           
 ResponseStream getResponseStream()
           
 ResponseWriter getResponseWriter()
           
 UIViewRoot getViewRoot()
           
 void release()
           
 void relieveCurrent()
           
 void renderResponse()
           
 void responseComplete()
           
 void setCurrent()
           
 void setResponseStream(ResponseStream responseStream)
           
 void setResponseWriter(ResponseWriter responseWriter)
           
 void setViewRoot(UIViewRoot root)
           
 
Methods inherited from class javax.faces.context.FacesContext
getCurrentInstance, getELContext
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MockFacesContext

public MockFacesContext()
Method Detail

setCurrent

public void setCurrent()

relieveCurrent

public void relieveCurrent()

getApplication

public Application getApplication()
Specified by:
getApplication in class FacesContext

evaluateExpressionGet

public abstract Object evaluateExpressionGet(FacesContext context,
                                             String expression,
                                             Class expectedType)
                                      throws ELException
Throws:
ELException

addMessage

public void addMessage(String clientId,
                       FacesMessage message)
Specified by:
addMessage in class FacesContext

getClientIdsWithMessages

public Iterator<String> getClientIdsWithMessages()
Specified by:
getClientIdsWithMessages in class FacesContext

getExternalContext

public ExternalContext getExternalContext()
Specified by:
getExternalContext in class FacesContext

getMaximumSeverity

public FacesMessage.Severity getMaximumSeverity()
Specified by:
getMaximumSeverity in class FacesContext

getMessages

public Iterator<FacesMessage> getMessages()
Specified by:
getMessages in class FacesContext

getMessages

public Iterator<FacesMessage> getMessages(String clientId)
Specified by:
getMessages in class FacesContext

getRenderKit

public RenderKit getRenderKit()
Specified by:
getRenderKit in class FacesContext

getRenderResponse

public boolean getRenderResponse()
Specified by:
getRenderResponse in class FacesContext

getResponseComplete

public boolean getResponseComplete()
Specified by:
getResponseComplete in class FacesContext

getResponseStream

public ResponseStream getResponseStream()
Specified by:
getResponseStream in class FacesContext

getResponseWriter

public ResponseWriter getResponseWriter()
Specified by:
getResponseWriter in class FacesContext

getViewRoot

public UIViewRoot getViewRoot()
Specified by:
getViewRoot in class FacesContext

release

public void release()
Specified by:
release in class FacesContext

renderResponse

public void renderResponse()
Specified by:
renderResponse in class FacesContext

responseComplete

public void responseComplete()
Specified by:
responseComplete in class FacesContext

setResponseStream

public void setResponseStream(ResponseStream responseStream)
Specified by:
setResponseStream in class FacesContext

setResponseWriter

public void setResponseWriter(ResponseWriter responseWriter)
Specified by:
setResponseWriter in class FacesContext

setViewRoot

public void setViewRoot(UIViewRoot root)
Specified by:
setViewRoot in class FacesContext

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.