IN PROGRESS - issue SWF-388: Extract all JSF-related code into a separate component project
http://opensource.atlassian.com/projects/spring/browse/SWF-388
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright 2004-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.webflow.executor.jsf;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.faces.webflow.FlowNavigationHandlerArgumentExtractor;
|
||||
import org.springframework.faces.webflow.JsfExternalContext;
|
||||
import org.springframework.webflow.executor.support.FlowExecutorArgumentExtractionException;
|
||||
|
||||
public class FlowNavigationHandlerArgumentExtractorTests extends TestCase {
|
||||
|
||||
private FlowNavigationHandlerArgumentExtractor extractor;
|
||||
|
||||
private MockFacesContext facesContext;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
extractor = new FlowNavigationHandlerArgumentExtractor();
|
||||
facesContext = new MockFacesContext();
|
||||
facesContext.setExternalContext(new MockJsfExternalContext());
|
||||
}
|
||||
|
||||
public void testExtractFlowId() {
|
||||
JsfExternalContext context = new JsfExternalContext(facesContext);
|
||||
context.handleNavigationCalled("action", "flowId:foo");
|
||||
String flowId = extractor.extractFlowId(context);
|
||||
assertEquals("Wrong flow id", "foo", flowId);
|
||||
}
|
||||
|
||||
public void testExtractFlowIdWrongFormat() {
|
||||
JsfExternalContext context = new JsfExternalContext(facesContext);
|
||||
context.handleNavigationCalled("action", "bogus:foo");
|
||||
try {
|
||||
extractor.extractFlowId(context);
|
||||
fail();
|
||||
} catch (FlowExecutorArgumentExtractionException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testExtractEventId() {
|
||||
JsfExternalContext context = new JsfExternalContext(facesContext);
|
||||
context.handleNavigationCalled("action", "submit");
|
||||
String eventId = extractor.extractEventId(context);
|
||||
assertEquals("Wrong event id", "submit", eventId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright 2004-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.webflow.executor.jsf;
|
||||
|
||||
import javax.faces.el.EvaluationException;
|
||||
import javax.faces.el.PropertyNotFoundException;
|
||||
import javax.faces.el.PropertyResolver;
|
||||
import javax.faces.el.ReferenceSyntaxException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.easymock.EasyMock;
|
||||
import org.springframework.faces.el.FlowPropertyResolver;
|
||||
import org.springframework.webflow.execution.FlowExecution;
|
||||
import org.springframework.webflow.test.MockFlowSession;
|
||||
|
||||
/**
|
||||
* @author Colin Sampaleanu
|
||||
* @since 1.0
|
||||
*/
|
||||
public class FlowPropertyResolverTests extends TestCase {
|
||||
|
||||
private FlowPropertyResolver resolver;
|
||||
|
||||
private FlowExecution flowEx;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
resolver = new FlowPropertyResolver(new OriginalPropertyResolver());
|
||||
flowEx = (FlowExecution) EasyMock.createMock(FlowExecution.class);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
resolver = null;
|
||||
}
|
||||
|
||||
public void testGetTypeBaseIndex() {
|
||||
Class type = resolver.getType(flowEx, 22);
|
||||
assertNull("can't get property from flow via index", type);
|
||||
}
|
||||
|
||||
public void testGetTypeBaseProperty() {
|
||||
MockFlowSession flowSession = new MockFlowSession();
|
||||
flowSession.getScope().put("name", "joe");
|
||||
flowEx.getActiveSession();
|
||||
EasyMock.expectLastCall().andReturn(flowSession);
|
||||
EasyMock.replay(new Object[] { flowEx });
|
||||
Class type = resolver.getType(flowEx, "name");
|
||||
assertTrue("returned type must match property type", type.equals(String.class));
|
||||
}
|
||||
|
||||
public void testGetValueBaseIndex() {
|
||||
try {
|
||||
resolver.getValue(flowEx, 2);
|
||||
fail("not legal to get flow property by index");
|
||||
} catch (ReferenceSyntaxException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetValueBaseProperty() {
|
||||
MockFlowSession flowSession = new MockFlowSession();
|
||||
flowSession.getScope().put("name", "joe");
|
||||
flowEx.getActiveSession();
|
||||
EasyMock.expectLastCall().andReturn(flowSession);
|
||||
EasyMock.replay(new Object[] { flowEx });
|
||||
Object value = resolver.getValue(flowEx, "name");
|
||||
assertTrue("must return expected property", value.equals("joe"));
|
||||
}
|
||||
|
||||
public void testSetValueBaseIndex() {
|
||||
try {
|
||||
resolver.setValue(flowEx, 2, "whatever");
|
||||
fail("not legal to set flow property by index");
|
||||
} catch (ReferenceSyntaxException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testSetValueBaseProperty() {
|
||||
MockFlowSession flowSession = new MockFlowSession();
|
||||
flowEx.getActiveSession();
|
||||
EasyMock.expectLastCall().andReturn(flowSession);
|
||||
EasyMock.replay(new Object[] { flowEx });
|
||||
resolver.setValue(flowEx, "name", "joe");
|
||||
assertTrue(flowSession.getScope().get("name").equals("joe"));
|
||||
}
|
||||
|
||||
private static class OriginalPropertyResolver extends PropertyResolver {
|
||||
|
||||
public Class getType(Object base, int index) throws EvaluationException, PropertyNotFoundException {
|
||||
return Object.class;
|
||||
}
|
||||
|
||||
public Class getType(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
|
||||
return Object.class;
|
||||
}
|
||||
|
||||
public Object getValue(Object base, int index) throws EvaluationException, PropertyNotFoundException {
|
||||
return new String("Some value");
|
||||
}
|
||||
|
||||
public Object getValue(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
|
||||
return new String("Some value");
|
||||
}
|
||||
|
||||
public boolean isReadOnly(Object base, int index) throws EvaluationException, PropertyNotFoundException {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isReadOnly(Object base, Object property) throws EvaluationException, PropertyNotFoundException {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setValue(Object base, int index, Object value) throws EvaluationException,
|
||||
PropertyNotFoundException {
|
||||
}
|
||||
|
||||
public void setValue(Object base, Object property, Object value) throws EvaluationException,
|
||||
PropertyNotFoundException {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright 2004-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.webflow.executor.jsf;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.faces.webflow.FlowExecutionHolder;
|
||||
import org.springframework.faces.webflow.FlowSystemCleanupFilter;
|
||||
import org.springframework.mock.web.MockFilterChain;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
import org.springframework.webflow.context.ExternalContextHolder;
|
||||
import org.springframework.webflow.engine.impl.FlowExecutionImpl;
|
||||
import org.springframework.webflow.execution.FlowExecutionContextHolder;
|
||||
import org.springframework.webflow.test.MockExternalContext;
|
||||
|
||||
public class FlowSystemCleanupFilterTests extends TestCase {
|
||||
|
||||
private FlowSystemCleanupFilter filter;
|
||||
|
||||
private ServletRequest request;
|
||||
|
||||
private ServletResponse response;
|
||||
|
||||
private FilterChain chain;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
filter = new FlowSystemCleanupFilter();
|
||||
request = new MockHttpServletRequest();
|
||||
request.setAttribute(getFlowExecutionHolderKey(), new FlowExecutionHolder(new FlowExecutionImpl()));
|
||||
response = new MockHttpServletResponse();
|
||||
chain = new MockFilterChain();
|
||||
FlowExecutionContextHolder.setFlowExecutionContext(new FlowExecutionImpl());
|
||||
ExternalContextHolder.setExternalContext(new MockExternalContext());
|
||||
}
|
||||
|
||||
public void testCleanup() throws ServletException, IOException {
|
||||
filter.doFilter(request, response, chain);
|
||||
|
||||
assertNull("Should have cleaned up the flow execution", request.getAttribute(getFlowExecutionHolderKey()));
|
||||
try {
|
||||
FlowExecutionContextHolder.getFlowExecutionContext();
|
||||
fail("Should have an empty holder");
|
||||
} catch (IllegalStateException e) {
|
||||
}
|
||||
try {
|
||||
ExternalContextHolder.getExternalContext();
|
||||
fail("Should have an empty holder");
|
||||
} catch (IllegalStateException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public void testExceptionThrown() throws ServletException, IOException {
|
||||
try {
|
||||
filter.doFilter(request, response, new ExceptionThrowingMockFilterChain());
|
||||
} catch (RuntimeException e) {
|
||||
assertNull("Should have cleaned up the flow execution", request.getAttribute(getFlowExecutionHolderKey()));
|
||||
try {
|
||||
FlowExecutionContextHolder.getFlowExecutionContext();
|
||||
fail("Should have an empty holder");
|
||||
} catch (IllegalStateException e1) {
|
||||
}
|
||||
try {
|
||||
ExternalContextHolder.getExternalContext();
|
||||
fail("Should have an empty holder");
|
||||
} catch (IllegalStateException e1) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static String getFlowExecutionHolderKey() {
|
||||
return FlowExecutionHolder.class.getName();
|
||||
}
|
||||
|
||||
private class ExceptionThrowingMockFilterChain extends MockFilterChain {
|
||||
|
||||
public void doFilter(ServletRequest request, ServletResponse response) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright 2004-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.webflow.executor.jsf;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.el.EvaluationException;
|
||||
import javax.faces.el.VariableResolver;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.easymock.EasyMock;
|
||||
import org.springframework.faces.el.FlowVariableResolver;
|
||||
import org.springframework.faces.webflow.FlowExecutionHolder;
|
||||
import org.springframework.faces.webflow.FlowExecutionHolderUtils;
|
||||
import org.springframework.webflow.execution.FlowExecution;
|
||||
import org.springframework.webflow.execution.repository.FlowExecutionKey;
|
||||
|
||||
/**
|
||||
* Unit tests for the FlowVariableResolver class.
|
||||
*
|
||||
* @author Ulrik Sandberg
|
||||
*/
|
||||
public class FlowVariableResolverTests extends TestCase {
|
||||
|
||||
private FlowVariableResolver tested;
|
||||
|
||||
private TestableVariableResolver variableResolver;
|
||||
|
||||
private MockFacesContext mockFacesContext;
|
||||
|
||||
private MockJsfExternalContext mockJsfExternalContext;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
mockFacesContext = new MockFacesContext();
|
||||
mockJsfExternalContext = new MockJsfExternalContext();
|
||||
mockFacesContext.setExternalContext(mockJsfExternalContext);
|
||||
variableResolver = new TestableVariableResolver();
|
||||
tested = new FlowVariableResolver(variableResolver);
|
||||
}
|
||||
|
||||
public void testResolveVariableNotFlowScope() {
|
||||
Object result = tested.resolveVariable(mockFacesContext, "some name");
|
||||
assertTrue("not resolved using delegate", variableResolver.resolvedUsingDelegate);
|
||||
assertSame(variableResolver.expected, result);
|
||||
}
|
||||
|
||||
public void testResolveVariableFlowScopeWithNoThreadLocal() {
|
||||
try {
|
||||
tested.resolveVariable(mockFacesContext, "flowScope");
|
||||
fail("EvaluationException expected");
|
||||
} catch (EvaluationException expected) {
|
||||
|
||||
}
|
||||
assertFalse("resolved using delegate", variableResolver.resolvedUsingDelegate);
|
||||
}
|
||||
|
||||
public void testResolveVariableFlowScopeWithThreadLocal() {
|
||||
FlowExecution flowExecutionMock = (FlowExecution) EasyMock.createMock(FlowExecution.class);
|
||||
FlowExecutionKey key = null;
|
||||
FlowExecutionHolder holder = new FlowExecutionHolder(key, flowExecutionMock, null);
|
||||
FlowExecutionHolderUtils.setFlowExecutionHolder(holder, mockFacesContext);
|
||||
EasyMock.replay(new Object[] { flowExecutionMock });
|
||||
|
||||
Object result = tested.resolveVariable(mockFacesContext, "flowScope");
|
||||
|
||||
EasyMock.verify(new Object[] { flowExecutionMock });
|
||||
assertFalse("resolved using delegate", variableResolver.resolvedUsingDelegate);
|
||||
assertSame(flowExecutionMock, result);
|
||||
}
|
||||
|
||||
private static class TestableVariableResolver extends VariableResolver {
|
||||
private boolean resolvedUsingDelegate;
|
||||
|
||||
private Object expected = new Object();
|
||||
|
||||
public Object resolveVariable(FacesContext arg0, String arg1) throws EvaluationException {
|
||||
resolvedUsingDelegate = true;
|
||||
return expected;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package org.springframework.webflow.executor.jsf;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
|
||||
import javax.faces.el.ValueBinding;
|
||||
|
||||
import org.easymock.EasyMock;
|
||||
import org.jboss.el.ExpressionFactoryImpl;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.faces.el.DelegatingFlowVariableResolver;
|
||||
import org.springframework.faces.el.FlowPropertyResolver;
|
||||
import org.springframework.faces.el.FlowVariableResolver;
|
||||
import org.springframework.faces.el.Jsf11ELExpressionParser;
|
||||
import org.springframework.faces.webflow.FlowExecutionHolder;
|
||||
import org.springframework.faces.webflow.FlowExecutionHolderUtils;
|
||||
import org.springframework.faces.webflow.FlowNavigationHandler;
|
||||
import org.springframework.faces.webflow.FlowPhaseListener;
|
||||
import org.springframework.util.ResourceUtils;
|
||||
import org.springframework.web.context.support.GenericWebApplicationContext;
|
||||
import org.springframework.web.jsf.DelegatingVariableResolver;
|
||||
import org.springframework.webflow.definition.registry.FlowDefinitionResource;
|
||||
import org.springframework.webflow.execution.FlowExecutionException;
|
||||
import org.springframework.webflow.execution.ViewSelection;
|
||||
import org.springframework.webflow.test.MockFlowServiceLocator;
|
||||
import org.springframework.webflow.test.execution.AbstractXmlFlowExecutionTests;
|
||||
|
||||
public class JSF11ManagedBeanAccessTests extends AbstractXmlFlowExecutionTests {
|
||||
|
||||
JSFMockHelper jsf;
|
||||
JSFManagedBean jsfBean;
|
||||
JSFModel jsfModel;
|
||||
FlowPhaseListener flowPhaseListener;
|
||||
FlowNavigationHandler flowNavigationHandler;
|
||||
MockService service;
|
||||
GenericWebApplicationContext ctx;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
service = (MockService) EasyMock.createMock(MockService.class);
|
||||
jsf = new JSFMockHelper();
|
||||
jsf.setUp();
|
||||
configureJSFForSWF();
|
||||
}
|
||||
|
||||
private void configureJSFForSWF() {
|
||||
DelegatingVariableResolver dvr = new DelegatingVariableResolver(jsf.application().getVariableResolver());
|
||||
DelegatingFlowVariableResolver dfvr = new DelegatingFlowVariableResolver(dvr);
|
||||
FlowVariableResolver fvr = new FlowVariableResolver(dfvr);
|
||||
jsf.application().setVariableResolver(fvr);
|
||||
FlowPropertyResolver fpr = new FlowPropertyResolver(jsf.application().getPropertyResolver());
|
||||
jsf.application().setPropertyResolver(fpr);
|
||||
|
||||
flowNavigationHandler = new FlowNavigationHandler(jsf.application().getNavigationHandler());
|
||||
jsf.application().setNavigationHandler(flowNavigationHandler);
|
||||
|
||||
jsf.externalContext().getRequestMap().put("JsfBean", new JSFManagedBean());
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
jsf.tearDown();
|
||||
}
|
||||
|
||||
public void testManagedBeanExpression() {
|
||||
ValueBinding vb = jsf.application().createValueBinding("#{JsfBean}");
|
||||
jsfBean = (JSFManagedBean) vb.getValue(jsf.facesContext());
|
||||
assertNotNull(jsfBean);
|
||||
}
|
||||
|
||||
public void testSWFExplicitlyScopedPropertyInjection() {
|
||||
testManagedBeanExpression();
|
||||
startFlow();
|
||||
|
||||
ValueBinding propBinding = jsf.application().createValueBinding("#{flowScope.jsfModel}");
|
||||
jsfModel = (JSFModel) propBinding.getValue(jsf.facesContext());
|
||||
assertNotNull(jsfModel);
|
||||
}
|
||||
|
||||
public void testManagedBeanPropertyAsArgument() {
|
||||
testManagedBeanExpression();
|
||||
jsfBean.setProp1("arg");
|
||||
service.doSomething(jsfBean.getProp1());
|
||||
EasyMock.replay(new Object[] { service });
|
||||
|
||||
startFlow();
|
||||
signalEvent("event1");
|
||||
EasyMock.verify(new Object[] { service });
|
||||
assertCurrentStateEquals("viewState2");
|
||||
}
|
||||
|
||||
public void testEvalManagedBeanMethod() {
|
||||
testManagedBeanExpression();
|
||||
startFlow();
|
||||
|
||||
ValueBinding propBinding = jsf.application().createValueBinding("#{flowScope.jsfModel}");
|
||||
jsfModel = (JSFModel) propBinding.getValue(jsf.facesContext());
|
||||
assertNotNull(jsfModel);
|
||||
jsfModel.setValue("foo");
|
||||
|
||||
signalEvent("event2");
|
||||
assertFalse(jsfBean.getValues().isEmpty());
|
||||
String addedValue = jsfBean.getValues().get(0).toString();
|
||||
assertEquals(jsfModel.getValue(), addedValue);
|
||||
assertCurrentStateEquals("viewState2");
|
||||
}
|
||||
|
||||
public void testSWFScopedPropertyInjection() {
|
||||
startFlow();
|
||||
|
||||
ValueBinding propBinding = jsf.application().createValueBinding("#{flowScopedModel}");
|
||||
jsfModel = (JSFModel) propBinding.getValue(jsf.facesContext());
|
||||
assertNotNull("This test won't pass until custom scopes are implemented.", jsfModel);
|
||||
}
|
||||
|
||||
protected ViewSelection startFlow() throws FlowExecutionException {
|
||||
ViewSelection view = super.startFlow();
|
||||
FlowExecutionHolder holder = new FlowExecutionHolder(getFlowExecution());
|
||||
FlowExecutionHolderUtils.setFlowExecutionHolder(holder, jsf.facesContext());
|
||||
holder.setViewSelection(view);
|
||||
return view;
|
||||
}
|
||||
|
||||
protected FlowDefinitionResource getFlowDefinitionResource() {
|
||||
try {
|
||||
return createFlowDefinitionResource(ResourceUtils.getFile(
|
||||
"classpath:org/springframework/webflow/executor/jsf/jsf-flow.xml").getPath());
|
||||
} catch (FileNotFoundException e) {
|
||||
fail(e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void registerMockServices(MockFlowServiceLocator serviceRegistry) {
|
||||
serviceRegistry.setExpressionParser(new Jsf11ELExpressionParser(new ExpressionFactoryImpl()));
|
||||
serviceRegistry.registerBean("serviceBean", service);
|
||||
|
||||
ctx = new GenericWebApplicationContext();
|
||||
XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx);
|
||||
xmlReader.loadBeanDefinitions(new ClassPathResource(
|
||||
"org/springframework/webflow/executor/jsf/jsf-flow-beans.xml"));
|
||||
ctx.refresh();
|
||||
|
||||
jsf.externalContext().getApplicationMap().put(
|
||||
GenericWebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ctx);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.springframework.webflow.executor.jsf;
|
||||
|
||||
import org.jboss.el.ExpressionFactoryImpl;
|
||||
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.faces.el.Jsf12ELExpressionParser;
|
||||
import org.springframework.web.context.support.GenericWebApplicationContext;
|
||||
import org.springframework.webflow.test.MockFlowServiceLocator;
|
||||
|
||||
public class JSF12ManagedBeanAccessTests extends JSF11ManagedBeanAccessTests {
|
||||
|
||||
protected void registerMockServices(MockFlowServiceLocator serviceRegistry) {
|
||||
serviceRegistry.setExpressionParser(new Jsf12ELExpressionParser(new ExpressionFactoryImpl()));
|
||||
serviceRegistry.registerBean("serviceBean", service);
|
||||
|
||||
ctx = new GenericWebApplicationContext();
|
||||
XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx);
|
||||
xmlReader.loadBeanDefinitions(new ClassPathResource(
|
||||
"org/springframework/webflow/executor/jsf/jsf-flow-beans.xml"));
|
||||
ctx.refresh();
|
||||
|
||||
jsf.externalContext().getApplicationMap().put(
|
||||
GenericWebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ctx);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.springframework.webflow.executor.jsf;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class JSFManagedBean {
|
||||
|
||||
String prop1;
|
||||
JSFModel model;
|
||||
List values = new ArrayList();
|
||||
|
||||
public JSFModel getModel() {
|
||||
return model;
|
||||
}
|
||||
|
||||
public void setModel(JSFModel model) {
|
||||
this.model = model;
|
||||
}
|
||||
|
||||
public String getProp1() {
|
||||
return prop1;
|
||||
}
|
||||
|
||||
public void setProp1(String prop1) {
|
||||
this.prop1 = prop1;
|
||||
}
|
||||
|
||||
public void addValue(String value) {
|
||||
values.add(value);
|
||||
}
|
||||
|
||||
public List getValues() {
|
||||
return values;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package org.springframework.webflow.executor.jsf;
|
||||
|
||||
import org.apache.shale.test.base.AbstractJsfTestCase;
|
||||
import org.apache.shale.test.mock.MockApplication;
|
||||
import org.apache.shale.test.mock.MockExternalContext;
|
||||
import org.apache.shale.test.mock.MockFacesContextFactory;
|
||||
import org.apache.shale.test.mock.MockHttpServletRequest;
|
||||
import org.apache.shale.test.mock.MockHttpServletResponse;
|
||||
import org.apache.shale.test.mock.MockHttpSession;
|
||||
import org.apache.shale.test.mock.MockLifecycle;
|
||||
import org.apache.shale.test.mock.MockLifecycleFactory;
|
||||
import org.apache.shale.test.mock.MockRenderKit;
|
||||
import org.apache.shale.test.mock.MockServletConfig;
|
||||
import org.apache.shale.test.mock.MockFacesContext;
|
||||
import org.apache.shale.test.mock.MockServletContext;
|
||||
|
||||
/**
|
||||
* Helper for using the mock JSF environment provided by shale-test inside unit tests that do not extend
|
||||
* {@link AbstractJsfTestCase}
|
||||
* @author Jeremy Grelle
|
||||
*
|
||||
*/
|
||||
public class JSFMockHelper {
|
||||
|
||||
private JSFMock mock = new JSFMock();
|
||||
|
||||
public MockApplication application() {
|
||||
return mock.application();
|
||||
}
|
||||
|
||||
public MockServletConfig config() {
|
||||
return mock.config();
|
||||
}
|
||||
|
||||
public MockExternalContext externalContext() {
|
||||
return mock.externalContext();
|
||||
}
|
||||
|
||||
public MockFacesContext facesContext() {
|
||||
return mock.facesContext();
|
||||
}
|
||||
|
||||
public MockFacesContextFactory facesContextFactory() {
|
||||
return mock.facesContextFactory();
|
||||
}
|
||||
|
||||
public MockLifecycle lifecycle() {
|
||||
return mock.lifecycle();
|
||||
}
|
||||
|
||||
public MockLifecycleFactory lifecycleFactory() {
|
||||
return mock.lifecycleFactory();
|
||||
}
|
||||
|
||||
public MockRenderKit renderKit() {
|
||||
return mock.renderKit();
|
||||
}
|
||||
|
||||
public MockHttpServletRequest request() {
|
||||
return mock.request();
|
||||
}
|
||||
|
||||
public MockHttpServletResponse response() {
|
||||
return mock.response();
|
||||
}
|
||||
|
||||
public MockServletContext servletContext() {
|
||||
return mock.servletContext();
|
||||
}
|
||||
|
||||
public MockHttpSession session() {
|
||||
return mock.session();
|
||||
}
|
||||
|
||||
public void setUp() throws Exception {
|
||||
mock.setUp();
|
||||
}
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
mock.tearDown();
|
||||
}
|
||||
|
||||
private static class JSFMock extends AbstractJsfTestCase {
|
||||
|
||||
public JSFMock() {
|
||||
super("JSFMock");
|
||||
}
|
||||
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public MockApplication application() {
|
||||
return application;
|
||||
}
|
||||
|
||||
public MockServletConfig config() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public MockExternalContext externalContext() {
|
||||
return externalContext;
|
||||
}
|
||||
|
||||
public MockFacesContext facesContext() {
|
||||
return facesContext;
|
||||
}
|
||||
|
||||
public MockFacesContextFactory facesContextFactory() {
|
||||
return facesContextFactory;
|
||||
}
|
||||
|
||||
public MockLifecycle lifecycle() {
|
||||
return lifecycle;
|
||||
}
|
||||
|
||||
public MockLifecycleFactory lifecycleFactory() {
|
||||
return lifecycleFactory;
|
||||
}
|
||||
|
||||
public MockRenderKit renderKit() {
|
||||
return renderKit;
|
||||
}
|
||||
|
||||
public MockHttpServletRequest request() {
|
||||
return request;
|
||||
}
|
||||
|
||||
public MockHttpServletResponse response() {
|
||||
return response;
|
||||
}
|
||||
|
||||
public MockServletContext servletContext() {
|
||||
return servletContext;
|
||||
}
|
||||
|
||||
public MockHttpSession session() {
|
||||
return session;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.springframework.webflow.executor.jsf;
|
||||
|
||||
public class JSFModel {
|
||||
String value;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
/*
|
||||
* Copyright 2004-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.webflow.executor.jsf;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.faces.FacesException;
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.application.NavigationHandler;
|
||||
import javax.faces.application.StateManager;
|
||||
import javax.faces.application.ViewHandler;
|
||||
import javax.faces.component.UIComponent;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.convert.Converter;
|
||||
import javax.faces.el.MethodBinding;
|
||||
import javax.faces.el.PropertyResolver;
|
||||
import javax.faces.el.ReferenceSyntaxException;
|
||||
import javax.faces.el.ValueBinding;
|
||||
import javax.faces.el.VariableResolver;
|
||||
import javax.faces.event.ActionListener;
|
||||
import javax.faces.validator.Validator;
|
||||
|
||||
public class MockApplication extends Application {
|
||||
private ViewHandler viewHandler;
|
||||
|
||||
public ActionListener getActionListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setActionListener(ActionListener listener) {
|
||||
}
|
||||
|
||||
public Locale getDefaultLocale() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setDefaultLocale(Locale locale) {
|
||||
}
|
||||
|
||||
public String getDefaultRenderKitId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setDefaultRenderKitId(String renderKitId) {
|
||||
}
|
||||
|
||||
public String getMessageBundle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setMessageBundle(String bundle) {
|
||||
}
|
||||
|
||||
public NavigationHandler getNavigationHandler() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setNavigationHandler(NavigationHandler handler) {
|
||||
}
|
||||
|
||||
public PropertyResolver getPropertyResolver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setPropertyResolver(PropertyResolver resolver) {
|
||||
}
|
||||
|
||||
public VariableResolver getVariableResolver() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setVariableResolver(VariableResolver resolver) {
|
||||
}
|
||||
|
||||
public ViewHandler getViewHandler() {
|
||||
return viewHandler;
|
||||
}
|
||||
|
||||
public void setViewHandler(ViewHandler handler) {
|
||||
viewHandler = handler;
|
||||
}
|
||||
|
||||
public StateManager getStateManager() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setStateManager(StateManager manager) {
|
||||
}
|
||||
|
||||
public void addComponent(String componentType, String componentClass) {
|
||||
}
|
||||
|
||||
public UIComponent createComponent(String componentType) throws FacesException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public UIComponent createComponent(ValueBinding componentBinding, FacesContext context, String componentType)
|
||||
throws FacesException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getComponentTypes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addConverter(String converterId, String converterClass) {
|
||||
}
|
||||
|
||||
public void addConverter(Class targetClass, String converterClass) {
|
||||
}
|
||||
|
||||
public Converter createConverter(String converterId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Converter createConverter(Class targetClass) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getConverterIds() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getConverterTypes() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public MethodBinding createMethodBinding(String ref, Class[] params) throws ReferenceSyntaxException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getSupportedLocales() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setSupportedLocales(Collection locales) {
|
||||
}
|
||||
|
||||
public void addValidator(String validatorId, String validatorClass) {
|
||||
}
|
||||
|
||||
public Validator createValidator(String validatorId) throws FacesException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getValidatorIds() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ValueBinding createValueBinding(String ref) throws ReferenceSyntaxException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright 2004-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.webflow.executor.jsf;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.faces.application.Application;
|
||||
import javax.faces.application.FacesMessage;
|
||||
import javax.faces.application.FacesMessage.Severity;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.ExternalContext;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.ResponseStream;
|
||||
import javax.faces.context.ResponseWriter;
|
||||
import javax.faces.render.RenderKit;
|
||||
|
||||
/**
|
||||
* Mock implementation of the <code>FacesContext</code> class to facilitate standalone Action unit tests.
|
||||
* <p>
|
||||
* NOT intended to be used for anything but standalone unit tests. This is a simple state holder, a <i>stub</i>
|
||||
* implementation, at least if you follow <a href="http://www.martinfowler.com/articles/mocksArentStubs.html">Martin
|
||||
* Fowler's</a> reasoning. This class is called <i>Mock</i>FacesContext to be consistent with the naming convention in
|
||||
* the rest of the Spring framework (e.g. MockHttpServletRequest, ...).
|
||||
*
|
||||
* @see javax.faces.context.FacesContext
|
||||
*
|
||||
* @author Ulrik Sandberg
|
||||
*/
|
||||
public class MockFacesContext extends FacesContext {
|
||||
private ExternalContext externalContext;
|
||||
|
||||
private Application application;
|
||||
|
||||
private UIViewRoot viewRoot;
|
||||
|
||||
public Application getApplication() {
|
||||
return application;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the application to be used by this faces context.
|
||||
* @param application the applicaiton to set.
|
||||
*/
|
||||
public void setApplication(Application application) {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
public Iterator getClientIdsWithMessages() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ExternalContext getExternalContext() {
|
||||
return externalContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the external context of this faces context.
|
||||
* @param externalContext the external context to set.
|
||||
*/
|
||||
public void setExternalContext(ExternalContext externalContext) {
|
||||
this.externalContext = externalContext;
|
||||
}
|
||||
|
||||
public Severity getMaximumSeverity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getMessages() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getMessages(String arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public RenderKit getRenderKit() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean getRenderResponse() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean getResponseComplete() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public ResponseStream getResponseStream() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setResponseStream(ResponseStream arg0) {
|
||||
|
||||
}
|
||||
|
||||
public ResponseWriter getResponseWriter() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setResponseWriter(ResponseWriter arg0) {
|
||||
}
|
||||
|
||||
public UIViewRoot getViewRoot() {
|
||||
return viewRoot;
|
||||
}
|
||||
|
||||
public void setViewRoot(UIViewRoot viewRoot) {
|
||||
this.viewRoot = viewRoot;
|
||||
}
|
||||
|
||||
public void addMessage(String arg0, FacesMessage arg1) {
|
||||
}
|
||||
|
||||
public void release() {
|
||||
}
|
||||
|
||||
public void renderResponse() {
|
||||
}
|
||||
|
||||
public void responseComplete() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,190 @@
|
||||
/*
|
||||
* Copyright 2004-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.webflow.executor.jsf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.security.Principal;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.faces.context.ExternalContext;
|
||||
|
||||
public class MockJsfExternalContext extends ExternalContext {
|
||||
|
||||
private Map applicationMap = new HashMap();
|
||||
|
||||
private Map sessionMap = new HashMap();
|
||||
|
||||
private Map requestMap = new HashMap();
|
||||
|
||||
private Map requestParameterMap = Collections.EMPTY_MAP;
|
||||
|
||||
public void dispatch(String arg0) throws IOException {
|
||||
}
|
||||
|
||||
public String encodeActionURL(String arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String encodeNamespace(String arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String encodeResourceURL(String arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map getApplicationMap() {
|
||||
return applicationMap;
|
||||
}
|
||||
|
||||
public String getAuthType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object getContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getInitParameter(String arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map getInitParameterMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getRemoteUser() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object getRequest() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getRequestContextPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map getRequestCookieMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map getRequestHeaderMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map getRequestHeaderValuesMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Locale getRequestLocale() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Iterator getRequestLocales() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map getRequestMap() {
|
||||
return requestMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the request map for this external context.
|
||||
* @param requestMap The requestMap to set.
|
||||
*/
|
||||
public void setRequestMap(Map requestMap) {
|
||||
this.requestMap = requestMap;
|
||||
}
|
||||
|
||||
public Map getRequestParameterMap() {
|
||||
return requestParameterMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the request parameter map for this external context.
|
||||
* @param requestParameterMap the request parameter map to set.
|
||||
*/
|
||||
public void setRequestParameterMap(Map requestParameterMap) {
|
||||
this.requestParameterMap = requestParameterMap;
|
||||
}
|
||||
|
||||
public Iterator getRequestParameterNames() {
|
||||
return requestParameterMap.keySet().iterator();
|
||||
}
|
||||
|
||||
public Map getRequestParameterValuesMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getRequestPathInfo() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getRequestServletPath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public URL getResource(String arg0) throws MalformedURLException {
|
||||
return null;
|
||||
}
|
||||
|
||||
public InputStream getResourceAsStream(String arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Set getResourcePaths(String arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object getResponse() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object getSession(boolean arg0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Map getSessionMap() {
|
||||
return sessionMap;
|
||||
}
|
||||
|
||||
public Principal getUserPrincipal() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isUserInRole(String arg0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void log(String arg0) {
|
||||
}
|
||||
|
||||
public void log(String arg0, Throwable arg1) {
|
||||
}
|
||||
|
||||
public void redirect(String arg0) throws IOException {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package org.springframework.webflow.executor.jsf;
|
||||
|
||||
public interface MockService {
|
||||
|
||||
public void doSomething(String arg);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2004-2007 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.springframework.webflow.executor.jsf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.faces.FacesException;
|
||||
import javax.faces.application.ViewHandler;
|
||||
import javax.faces.component.UIViewRoot;
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
public class MockViewHandler extends ViewHandler {
|
||||
private UIViewRoot viewRoot;
|
||||
|
||||
public Locale calculateLocale(FacesContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String calculateRenderKitId(FacesContext context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public UIViewRoot createView(FacesContext context, String viewId) {
|
||||
return viewRoot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the view root that this mpck is supposed to create.
|
||||
* @param viewRoot the view to set.
|
||||
*/
|
||||
public void setCreateView(UIViewRoot viewRoot) {
|
||||
this.viewRoot = viewRoot;
|
||||
}
|
||||
|
||||
public String getActionURL(FacesContext context, String viewId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getResourceURL(FacesContext context, String path) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void renderView(FacesContext context, UIViewRoot viewToRender) throws IOException, FacesException {
|
||||
}
|
||||
|
||||
public UIViewRoot restoreView(FacesContext context, String viewId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void writeState(FacesContext context) throws IOException {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:flow="http://www.springframework.org/schema/webflow-config"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://www.springframework.org/schema/webflow-config
|
||||
http://www.springframework.org/schema/webflow-config/spring-webflow-config-1.1.xsd">
|
||||
|
||||
<flow:enable-scopes/>
|
||||
|
||||
<bean name="jsfModel" class="org.springframework.webflow.executor.jsf.JSFModel" scope="prototype"/>
|
||||
|
||||
<bean name="flowScopedModel" class="org.springframework.webflow.executor.jsf.JSFModel" scope="flow"/>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<flow xmlns="http://www.springframework.org/schema/webflow" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-1.0.xsd">
|
||||
|
||||
<start-state idref="viewState1" />
|
||||
|
||||
<view-state id="viewState1" view="view1">
|
||||
<transition on="event1" to="doSomething"/>
|
||||
<transition on="event2" to="evalSomething"/>
|
||||
</view-state>
|
||||
|
||||
<action-state id="doSomething">
|
||||
<bean-action bean="serviceBean" method="doSomething">
|
||||
<method-arguments>
|
||||
<argument expression="#{JsfBean.prop1}"/>
|
||||
</method-arguments>
|
||||
</bean-action>
|
||||
<transition to="viewState2"/>
|
||||
</action-state>
|
||||
|
||||
<action-state id="evalSomething">
|
||||
<evaluate-action expression="#{JsfBean.addValue(jsfModel.value)}"/>
|
||||
<transition to="viewState2"/>
|
||||
</action-state>
|
||||
|
||||
<view-state id="viewState2" view="view2">
|
||||
<transition on="event1" to="endState1"/>
|
||||
</view-state>
|
||||
|
||||
<end-state id="endState1" view="endView1"/>
|
||||
|
||||
</flow>
|
||||
Reference in New Issue
Block a user