renamed to webflow 1 url handler

This commit is contained in:
Keith Donald
2008-04-11 20:50:58 +00:00
parent c6c7e56e4d
commit db111b96c0
2 changed files with 10 additions and 27 deletions

View File

@@ -29,7 +29,7 @@ import org.springframework.webflow.core.collection.AttributeMap;
*
* @author Keith Donald
*/
public class ParameterBasedFlowUrlHandler implements FlowUrlHandler {
public class WebFlow1FlowUrlHandler implements FlowUrlHandler {
private static final String DEFAULT_URL_ENCODING_SCHEME = "UTF-8";
@@ -45,11 +45,7 @@ public class ParameterBasedFlowUrlHandler implements FlowUrlHandler {
public String createFlowExecutionUrl(String flowId, String flowExecutionKey, HttpServletRequest request) {
StringBuffer url = new StringBuffer();
url.append(request.getContextPath());
url.append(request.getServletPath());
if (request.getPathInfo() != null) {
url.append(request.getPathInfo());
}
url.append(request.getRequestURI());
url.append('?');
appendQueryParameter(url, "_flowId", flowId);
url.append('&');
@@ -59,11 +55,7 @@ public class ParameterBasedFlowUrlHandler implements FlowUrlHandler {
public String createFlowDefinitionUrl(String flowId, AttributeMap input, HttpServletRequest request) {
StringBuffer url = new StringBuffer();
url.append(request.getContextPath());
url.append(request.getServletPath());
if (request.getPathInfo() != null) {
url.append(request.getPathInfo());
}
url.append(request.getRequestURI());
url.append('?');
appendQueryParameter(url, "_flowId", flowId);
if (input != null && !input.isEmpty()) {

View File

@@ -5,12 +5,11 @@ import java.util.LinkedHashMap;
import junit.framework.TestCase;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.webflow.context.servlet.ParameterBasedFlowUrlHandler;
import org.springframework.webflow.core.collection.CollectionUtils;
import org.springframework.webflow.core.collection.LocalAttributeMap;
public class ParameterBasedFlowUrlHandlerTests extends TestCase {
private ParameterBasedFlowUrlHandler urlHandler = new ParameterBasedFlowUrlHandler();
public class WebFlow1FlowUrlHandlerTests extends TestCase {
private WebFlow1FlowUrlHandler urlHandler = new WebFlow1FlowUrlHandler();
private MockHttpServletRequest request = new MockHttpServletRequest();
public void testGetFlowId() {
@@ -24,38 +23,30 @@ public class ParameterBasedFlowUrlHandlerTests extends TestCase {
}
public void testCreateFlowDefinitionUrl() {
request.setContextPath("/springtravel");
request.setServletPath("/app");
request.setPathInfo("/flows");
request.setRequestURI("/springtravel/app/flows");
String url = urlHandler.createFlowDefinitionUrl("bookHotel", null, request);
assertEquals("/springtravel/app/flows?_flowId=bookHotel", url);
}
public void testCreateFlowDefinitionUrlEmptyInput() {
request.setContextPath("/springtravel");
request.setServletPath("/app");
request.setPathInfo("/flows");
request.setRequestURI("/springtravel/app/flows");
String url = urlHandler.createFlowDefinitionUrl("bookHotel", CollectionUtils.EMPTY_ATTRIBUTE_MAP, request);
assertEquals("/springtravel/app/flows?_flowId=bookHotel", url);
}
public void testCreateFlowDefinitionUrlWithFlowInput() {
request.setContextPath("/springtravel");
request.setServletPath("/app");
request.setPathInfo("/flows");
request.setRequestURI("/springtravel/app/flows");
LocalAttributeMap input = new LocalAttributeMap(new LinkedHashMap());
input.put("foo", "bar");
input.put("bar", "needs encoding");
input.put("baz", new Integer(1));
input.put("boop", null);
input.put("boop", null);
String url = urlHandler.createFlowDefinitionUrl("bookHotel", input, request);
assertEquals("/springtravel/app/flows?_flowId=bookHotel&foo=bar&bar=needs+encoding&baz=1&boop=", url);
}
public void testCreateFlowExecutionUrl() {
request.setContextPath("/springtravel");
request.setServletPath("/app");
request.setPathInfo("/flows");
request.setRequestURI("/springtravel/app/flows");
String url = urlHandler.createFlowExecutionUrl("bookHotel", "12345", request);
assertEquals("/springtravel/app/flows?_flowId=bookHotel&_flowExecutionKey=12345", url);
}