mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-09-24 15:49:26 +00:00
SPR-7314 - RestTemplate does not handle null uri template parameters
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@3457 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
+34
@@ -20,6 +20,7 @@ import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -82,6 +83,21 @@ public class RestTemplateTests {
|
||||
|
||||
verifyMocks();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void varArgsNullTemplateVariable() throws Exception {
|
||||
expect(requestFactory.createRequest(new URI("http://example.com/-foo"), HttpMethod.GET))
|
||||
.andReturn(request);
|
||||
expect(request.execute()).andReturn(response);
|
||||
expect(errorHandler.hasError(response)).andReturn(false);
|
||||
response.close();
|
||||
|
||||
replayMocks();
|
||||
|
||||
template.execute("http://example.com/{first}-{last}", HttpMethod.GET, null, null, null, "foo");
|
||||
|
||||
verifyMocks();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mapTemplateVariables() throws Exception {
|
||||
@@ -99,6 +115,24 @@ public class RestTemplateTests {
|
||||
verifyMocks();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mapNullTemplateVariable() throws Exception {
|
||||
expect(requestFactory.createRequest(new URI("http://example.com/-foo"), HttpMethod.GET))
|
||||
.andReturn(request);
|
||||
expect(request.execute()).andReturn(response);
|
||||
expect(errorHandler.hasError(response)).andReturn(false);
|
||||
response.close();
|
||||
|
||||
replayMocks();
|
||||
|
||||
Map<String, String> vars = new HashMap<String, String>(2);
|
||||
vars.put("first", null);
|
||||
vars.put("last", "foo");
|
||||
template.execute("http://example.com/{first}-{last}", HttpMethod.GET, null, null, vars);
|
||||
|
||||
verifyMocks();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void errorHandling() throws Exception {
|
||||
expect(requestFactory.createRequest(new URI("http://example.com"), HttpMethod.GET)).andReturn(request);
|
||||
|
||||
Reference in New Issue
Block a user