SWF-1144 - NPE in FlowHandlerAdapter.sendFlowDefinitionRedirect when flowRedirect does not have parameters appended to it

This commit is contained in:
Jeremy Grelle
2009-08-04 21:29:24 +00:00
parent 0346a9132b
commit fbd83eb05b
4 changed files with 28 additions and 2 deletions

View File

@@ -245,7 +245,7 @@ public class PortletExternalContext implements ExternalContext {
public void requestFlowDefinitionRedirect(String flowId, MutableAttributeMap input) throws IllegalStateException {
assertRedirectResponseAllowed();
flowDefinitionRedirectFlowId = flowId;
flowDefinitionRedirectFlowInput = input;
flowDefinitionRedirectFlowInput = input != null ? input : new LocalAttributeMap();
recordResponseComplete();
}

View File

@@ -241,7 +241,7 @@ public class ServletExternalContext implements ExternalContext {
public void requestFlowDefinitionRedirect(String flowId, MutableAttributeMap input) throws IllegalStateException {
assertResponseAllowed();
flowDefinitionRedirectFlowId = flowId;
flowDefinitionRedirectFlowInput = input;
flowDefinitionRedirectFlowInput = input != null ? input : new LocalAttributeMap();
recordResponseComplete();
}

View File

@@ -26,6 +26,7 @@ import org.springframework.mock.web.portlet.MockPortletContext;
import org.springframework.mock.web.portlet.MockRenderRequest;
import org.springframework.mock.web.portlet.MockRenderResponse;
import org.springframework.webflow.context.servlet.ServletExternalContext;
import org.springframework.webflow.core.collection.LocalAttributeMap;
/**
* Unit tests for {@link ServletExternalContext}.
@@ -109,6 +110,19 @@ public class PortletExternalContextTests extends TestCase {
assertTrue(context.isResponseComplete());
assertFalse(context.isResponseCompleteFlowExecutionRedirect());
assertFalse(context.isResponseAllowed());
assertNotNull(context.getFlowRedirectFlowInput());
}
public void testCommitFlowRedirectWithInput() {
assertFalse(context.isResponseAllowed());
LocalAttributeMap input = new LocalAttributeMap();
context.requestFlowDefinitionRedirect("foo", input);
assertTrue(context.getFlowDefinitionRedirectRequested());
assertEquals("foo", context.getFlowRedirectFlowId());
assertTrue(context.isResponseComplete());
assertFalse(context.isResponseCompleteFlowExecutionRedirect());
assertFalse(context.isResponseAllowed());
assertSame(input, context.getFlowRedirectFlowInput());
}
public void testCommitFlowRedirectRenderRequest() {

View File

@@ -23,6 +23,7 @@ import junit.framework.TestCase;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext;
import org.springframework.webflow.core.collection.LocalAttributeMap;
/**
* Unit tests for {@link ServletExternalContext}.
@@ -106,6 +107,17 @@ public class ServletExternalContextTests extends TestCase {
assertEquals("foo", context.getFlowRedirectFlowId());
assertTrue(context.isResponseComplete());
assertFalse(context.isResponseCompleteFlowExecutionRedirect());
assertNotNull(context.getFlowRedirectFlowInput());
}
public void testCommitFlowRedirectWithInput() {
LocalAttributeMap input = new LocalAttributeMap();
context.requestFlowDefinitionRedirect("foo", input);
assertTrue(context.getFlowDefinitionRedirectRequested());
assertEquals("foo", context.getFlowRedirectFlowId());
assertTrue(context.isResponseComplete());
assertFalse(context.isResponseCompleteFlowExecutionRedirect());
assertSame(input, context.getFlowRedirectFlowInput());
}
public void testCommitExternalRedirect() {