renamed to webflow 1 url handler
This commit is contained in:
@@ -29,7 +29,7 @@ import org.springframework.webflow.core.collection.AttributeMap;
|
|||||||
*
|
*
|
||||||
* @author Keith Donald
|
* @author Keith Donald
|
||||||
*/
|
*/
|
||||||
public class ParameterBasedFlowUrlHandler implements FlowUrlHandler {
|
public class WebFlow1FlowUrlHandler implements FlowUrlHandler {
|
||||||
|
|
||||||
private static final String DEFAULT_URL_ENCODING_SCHEME = "UTF-8";
|
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) {
|
public String createFlowExecutionUrl(String flowId, String flowExecutionKey, HttpServletRequest request) {
|
||||||
StringBuffer url = new StringBuffer();
|
StringBuffer url = new StringBuffer();
|
||||||
url.append(request.getContextPath());
|
url.append(request.getRequestURI());
|
||||||
url.append(request.getServletPath());
|
|
||||||
if (request.getPathInfo() != null) {
|
|
||||||
url.append(request.getPathInfo());
|
|
||||||
}
|
|
||||||
url.append('?');
|
url.append('?');
|
||||||
appendQueryParameter(url, "_flowId", flowId);
|
appendQueryParameter(url, "_flowId", flowId);
|
||||||
url.append('&');
|
url.append('&');
|
||||||
@@ -59,11 +55,7 @@ public class ParameterBasedFlowUrlHandler implements FlowUrlHandler {
|
|||||||
|
|
||||||
public String createFlowDefinitionUrl(String flowId, AttributeMap input, HttpServletRequest request) {
|
public String createFlowDefinitionUrl(String flowId, AttributeMap input, HttpServletRequest request) {
|
||||||
StringBuffer url = new StringBuffer();
|
StringBuffer url = new StringBuffer();
|
||||||
url.append(request.getContextPath());
|
url.append(request.getRequestURI());
|
||||||
url.append(request.getServletPath());
|
|
||||||
if (request.getPathInfo() != null) {
|
|
||||||
url.append(request.getPathInfo());
|
|
||||||
}
|
|
||||||
url.append('?');
|
url.append('?');
|
||||||
appendQueryParameter(url, "_flowId", flowId);
|
appendQueryParameter(url, "_flowId", flowId);
|
||||||
if (input != null && !input.isEmpty()) {
|
if (input != null && !input.isEmpty()) {
|
||||||
@@ -5,12 +5,11 @@ import java.util.LinkedHashMap;
|
|||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.springframework.mock.web.MockHttpServletRequest;
|
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.CollectionUtils;
|
||||||
import org.springframework.webflow.core.collection.LocalAttributeMap;
|
import org.springframework.webflow.core.collection.LocalAttributeMap;
|
||||||
|
|
||||||
public class ParameterBasedFlowUrlHandlerTests extends TestCase {
|
public class WebFlow1FlowUrlHandlerTests extends TestCase {
|
||||||
private ParameterBasedFlowUrlHandler urlHandler = new ParameterBasedFlowUrlHandler();
|
private WebFlow1FlowUrlHandler urlHandler = new WebFlow1FlowUrlHandler();
|
||||||
private MockHttpServletRequest request = new MockHttpServletRequest();
|
private MockHttpServletRequest request = new MockHttpServletRequest();
|
||||||
|
|
||||||
public void testGetFlowId() {
|
public void testGetFlowId() {
|
||||||
@@ -24,25 +23,19 @@ public class ParameterBasedFlowUrlHandlerTests extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateFlowDefinitionUrl() {
|
public void testCreateFlowDefinitionUrl() {
|
||||||
request.setContextPath("/springtravel");
|
request.setRequestURI("/springtravel/app/flows");
|
||||||
request.setServletPath("/app");
|
|
||||||
request.setPathInfo("/flows");
|
|
||||||
String url = urlHandler.createFlowDefinitionUrl("bookHotel", null, request);
|
String url = urlHandler.createFlowDefinitionUrl("bookHotel", null, request);
|
||||||
assertEquals("/springtravel/app/flows?_flowId=bookHotel", url);
|
assertEquals("/springtravel/app/flows?_flowId=bookHotel", url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateFlowDefinitionUrlEmptyInput() {
|
public void testCreateFlowDefinitionUrlEmptyInput() {
|
||||||
request.setContextPath("/springtravel");
|
request.setRequestURI("/springtravel/app/flows");
|
||||||
request.setServletPath("/app");
|
|
||||||
request.setPathInfo("/flows");
|
|
||||||
String url = urlHandler.createFlowDefinitionUrl("bookHotel", CollectionUtils.EMPTY_ATTRIBUTE_MAP, request);
|
String url = urlHandler.createFlowDefinitionUrl("bookHotel", CollectionUtils.EMPTY_ATTRIBUTE_MAP, request);
|
||||||
assertEquals("/springtravel/app/flows?_flowId=bookHotel", url);
|
assertEquals("/springtravel/app/flows?_flowId=bookHotel", url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateFlowDefinitionUrlWithFlowInput() {
|
public void testCreateFlowDefinitionUrlWithFlowInput() {
|
||||||
request.setContextPath("/springtravel");
|
request.setRequestURI("/springtravel/app/flows");
|
||||||
request.setServletPath("/app");
|
|
||||||
request.setPathInfo("/flows");
|
|
||||||
LocalAttributeMap input = new LocalAttributeMap(new LinkedHashMap());
|
LocalAttributeMap input = new LocalAttributeMap(new LinkedHashMap());
|
||||||
input.put("foo", "bar");
|
input.put("foo", "bar");
|
||||||
input.put("bar", "needs encoding");
|
input.put("bar", "needs encoding");
|
||||||
@@ -53,9 +46,7 @@ public class ParameterBasedFlowUrlHandlerTests extends TestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testCreateFlowExecutionUrl() {
|
public void testCreateFlowExecutionUrl() {
|
||||||
request.setContextPath("/springtravel");
|
request.setRequestURI("/springtravel/app/flows");
|
||||||
request.setServletPath("/app");
|
|
||||||
request.setPathInfo("/flows");
|
|
||||||
String url = urlHandler.createFlowExecutionUrl("bookHotel", "12345", request);
|
String url = urlHandler.createFlowExecutionUrl("bookHotel", "12345", request);
|
||||||
assertEquals("/springtravel/app/flows?_flowId=bookHotel&_flowExecutionKey=12345", url);
|
assertEquals("/springtravel/app/flows?_flowId=bookHotel&_flowExecutionKey=12345", url);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user