Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ public void setUp() {

@Test
public void testPostFormNoParams() {
when(request.getParameter(HttpContentServiceImpl.IS_FORM_PARAM)).thenReturn("true");
when(request.getParameter(HttpContentServiceImpl.FORM_METHOD_PARAM)).thenReturn("POST");
when(processor.process(any(String.class), any(PortletRequest.class))).thenReturn("http://somewhere.com/path/page.html");
setupSpringELProcessorProcessAndGetParameterStubs2("POST");
HttpContentRequestImpl proxyRequest = new HttpContentRequestImpl(request, processor);

final HttpUriRequest httpRequest = service.getHttpRequest(proxyRequest, request);
Expand All @@ -75,9 +73,7 @@ public void testGetForm() {
params.put("param1", new String[]{"value1"});
params.put("param2", new String[]{"value3", "value4"});

when(request.getParameter(HttpContentServiceImpl.IS_FORM_PARAM)).thenReturn("true");
when(request.getParameter(HttpContentServiceImpl.FORM_METHOD_PARAM)).thenReturn("GET");
when(processor.process(any(String.class), any(PortletRequest.class))).thenReturn("http://somewhere.com/path/page.html");
setupSpringELProcessorProcessAndGetParameterStubs2("GET");
HttpContentRequestImpl proxyRequest = new HttpContentRequestImpl(request, processor);

final HttpUriRequest httpRequest = service.getHttpRequest(proxyRequest, request);
Expand All @@ -88,9 +84,7 @@ public void testGetForm() {

@Test
public void testGetFormNoParams() {
when(request.getParameter(HttpContentServiceImpl.IS_FORM_PARAM)).thenReturn("true");
when(request.getParameter(HttpContentServiceImpl.FORM_METHOD_PARAM)).thenReturn("GET");
when(processor.process(any(String.class), any(PortletRequest.class))).thenReturn("http://somewhere.com/path/page.html");
setupSpringELProcessorProcessAndGetParameterStubs2("GET");
HttpContentRequestImpl proxyRequest = new HttpContentRequestImpl(request, processor);

final HttpUriRequest httpRequest = service.getHttpRequest(proxyRequest, request);
Expand All @@ -103,8 +97,7 @@ public void testGetFormNoParams() {
@Test
public void testNonForm() {

when(request.getParameter(HttpContentServiceImpl.IS_FORM_PARAM)).thenReturn("false");
when(processor.process(any(String.class), any(PortletRequest.class))).thenReturn("http://somewhere.com/path/page.html");
setupSpringELProcessorProcessAndGetParameterStubs("false");
HttpContentRequestImpl proxyRequest = new HttpContentRequestImpl(request, processor);

final HttpUriRequest httpRequest = service.getHttpRequest(proxyRequest, request);
Expand All @@ -113,5 +106,13 @@ public void testNonForm() {

}

private void setupSpringELProcessorProcessAndGetParameterStubs(String getParameterReturnValue) {
when(request.getParameter(HttpContentServiceImpl.IS_FORM_PARAM)).thenReturn(getParameterReturnValue);
when(processor.process(any(String.class), any(PortletRequest.class))).thenReturn("http://somewhere.com/path/page.html");
}

private void setupSpringELProcessorProcessAndGetParameterStubs2(String getParameterReturnValue) {
setupSpringELProcessorProcessAndGetParameterStubs("true");
when(request.getParameter(HttpContentServiceImpl.FORM_METHOD_PARAM)).thenReturn(getParameterReturnValue);
}
}