File | Line |
---|
org\apache\shale\test\base\AbstractJsfTestCase.java | 86 |
org\apache\shale\test\jmock\AbstractJmockJsfTestCase.java | 81 |
setName(name);
}
// ---------------------------------------------------- Overall Test Methods
// Set up instance variables required by this test case.
protected void setUp() throws Exception {
// Set up a new thread context class loader
threadContextClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(new URLClassLoader(new URL[0],
this.getClass().getClassLoader()));
// Set up Servlet API Objects
servletContext = new MockServletContext();
config = new MockServletConfig(servletContext);
session = new MockHttpSession();
session.setServletContext(servletContext);
request = new MockHttpServletRequest(session);
request.setServletContext(servletContext);
response = new MockHttpServletResponse();
// Set up JSF API Objects
FactoryFinder.releaseFactories();
FactoryFinder.setFactory(FactoryFinder.APPLICATION_FACTORY,
"org.apache.shale.test.mock.MockApplicationFactory");
FactoryFinder.setFactory(FactoryFinder.FACES_CONTEXT_FACTORY,
"org.apache.shale.test.mock.MockFacesContextFactory");
FactoryFinder.setFactory(FactoryFinder.LIFECYCLE_FACTORY,
"org.apache.shale.test.mock.MockLifecycleFactory");
FactoryFinder.setFactory(FactoryFinder.RENDER_KIT_FACTORY,
"org.apache.shale.test.mock.MockRenderKitFactory");
externalContext =
new MockExternalContext(servletContext, request, response);
lifecycleFactory = (MockLifecycleFactory)
FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
lifecycle = (MockLifecycle)
lifecycleFactory.getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
facesContextFactory = (MockFacesContextFactory)
FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
facesContext = (MockFacesContext)
facesContextFactory.getFacesContext(servletContext,
request,
response,
lifecycle);
externalContext = (MockExternalContext) facesContext.getExternalContext();
UIViewRoot root = new UIViewRoot();
root.setViewId("/viewId");
root.setRenderKitId(RenderKitFactory.HTML_BASIC_RENDER_KIT);
facesContext.setViewRoot(root);
ApplicationFactory applicationFactory = (ApplicationFactory)
FactoryFinder.getFactory(FactoryFinder.APPLICATION_FACTORY);
application = (MockApplication) applicationFactory.getApplication();
facesContext.setApplication(application);
RenderKitFactory renderKitFactory = (RenderKitFactory)
FactoryFinder.getFactory(FactoryFinder.RENDER_KIT_FACTORY);
renderKit = new MockRenderKit();
renderKitFactory.addRenderKit(RenderKitFactory.HTML_BASIC_RENDER_KIT, renderKit);
}
// Tear down instance variables required by this test case.
protected void tearDown() throws Exception {
application = null;
config = null;
externalContext = null;
facesContext.release();
facesContext = null;
lifecycle = null;
lifecycleFactory = null;
renderKit = null;
request = null;
response = null;
servletContext = null;
session = null;
FactoryFinder.releaseFactories();
Thread.currentThread().setContextClassLoader(threadContextClassLoader);
threadContextClassLoader = null;
}
// ------------------------------------------------------ Instance Variables
// Mock object instances for our tests
protected MockApplication application = null;
protected MockServletConfig config = null;
protected MockExternalContext externalContext = null;
protected MockFacesContext facesContext = null;
protected MockFacesContextFactory facesContextFactory = null;
protected MockLifecycle lifecycle = null;
protected MockLifecycleFactory lifecycleFactory = null;
protected MockRenderKit renderKit = null;
protected MockHttpServletRequest request = null;
protected MockHttpServletResponse response = null;
protected MockServletContext servletContext = null;
protected MockHttpSession session = null;
// Thread context class loader saved and restored after each test
private ClassLoader threadContextClassLoader = null;
} |
File | Line |
---|
org\apache\shale\test\el\MockValueExpression.java | 269 |
org\apache\shale\test\mock\MockValueBinding.java | 330 |
StringBuffer expr = new StringBuffer(ref);
boolean isBlockOn = false;
for (int i = expr.length() - 1; i > -1; i--) {
if (expr.charAt(i) == ' ') {
expr.deleteCharAt(i);
} else if (expr.charAt(i) == ']') {
expr.deleteCharAt(i);
} else if (expr.charAt(i) == '[') {
expr.deleteCharAt(i);
} else if (expr.charAt(i) == '\'') {
if (!isBlockOn) {
expr.deleteCharAt(i);
} else {
names.add(0, expr.substring(i + 1));
expr.delete(i, expr.length());
}
isBlockOn = !isBlockOn;
} else if (expr.charAt(i) == '.' && !isBlockOn) {
names.add(0, expr.substring(i + 1));
expr.delete(i, expr.length());
}
}
if (expr.length() > 0) {
names.add(0, expr.toString());
} |
File | Line |
---|
org\apache\shale\test\mock\MockHttpServletRequest.java | 747 |
org\apache\shale\test\mock\MockServletContext.java | 377 |
}
/** {@inheritDoc} */
public void removeAttribute(String name) {
if (attributes.containsKey(name)) {
Object value = attributes.remove(name);
fireAttributeRemoved(name, value);
}
}
/** {@inheritDoc} */
public void setAttribute(String name, Object value) {
if (name == null) {
throw new IllegalArgumentException("Attribute name cannot be null");
}
if (value == null) {
removeAttribute(name);
return;
}
if (attributes.containsKey(name)) {
Object oldValue = attributes.get(name);
attributes.put(name, value);
fireAttributeReplaced(name, oldValue);
} else {
attributes.put(name, value);
fireAttributeAdded(name, value);
}
} |
File | Line |
---|
org\apache\shale\test\el\FacesPropertyResolverChainWrapper.java | 78 |
org\apache\shale\test\el\FacesPropertyResolverChainWrapper.java | 119 |
public Object getValue(ELContext context, Object base, Object property) {
if ((base == null) || (property == null)) {
return null;
}
context.setPropertyResolved(true);
FacesContext fcontext = (FacesContext) context.getContext(FacesContext.class);
ELContext elContext = fcontext.getELContext();
PropertyResolver pr = fcontext.getApplication().getPropertyResolver();
if ((base instanceof List) || base.getClass().isArray()) {
Integer index = (Integer) fcontext.getApplication().getExpressionFactory().
coerceToType(property, Integer.class);
try {
return pr.getValue(base, index.intValue()); |