OkHttpClientHttpRequestFactory allows POST request without body
Issue: SPR-15015
(cherry picked from commit 2954385)
This commit is contained in:
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.web.client;
|
||||
|
||||
import java.io.EOFException;
|
||||
@@ -15,22 +31,19 @@ import org.junit.Before;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
public class AbstractMockWebServerTestCase {
|
||||
|
||||
private static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
|
||||
private static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
|
||||
|
||||
protected static final String helloWorld = "H\u00e9llo W\u00f6rld";
|
||||
|
||||
private static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
|
||||
private static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
|
||||
|
||||
protected static final MediaType textContentType =
|
||||
new MediaType("text", "plain", Collections.singletonMap("charset", "UTF-8"));
|
||||
|
||||
@@ -40,6 +53,7 @@ public class AbstractMockWebServerTestCase {
|
||||
|
||||
protected String baseUrl;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.server = new MockWebServer();
|
||||
@@ -54,7 +68,152 @@ public class AbstractMockWebServerTestCase {
|
||||
this.server.shutdown();
|
||||
}
|
||||
|
||||
|
||||
private MockResponse getRequest(RecordedRequest request, byte[] body, String contentType) {
|
||||
if (request.getMethod().equals("OPTIONS")) {
|
||||
return new MockResponse().setResponseCode(200).setHeader("Allow", "GET, OPTIONS, HEAD, TRACE");
|
||||
}
|
||||
Buffer buf = new Buffer();
|
||||
buf.write(body);
|
||||
MockResponse response = new MockResponse()
|
||||
.setHeader("Content-Length", body.length)
|
||||
.setBody(buf)
|
||||
.setResponseCode(200);
|
||||
if (contentType != null) {
|
||||
response = response.setHeader("Content-Type", contentType);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
private MockResponse postRequest(RecordedRequest request, String expectedRequestContent,
|
||||
String location, String contentType, byte[] responseBody) {
|
||||
|
||||
assertTrue("Invalid request content-length",
|
||||
Integer.parseInt(request.getHeader("Content-Length")) > 0);
|
||||
String requestContentType = request.getHeader("Content-Type");
|
||||
assertNotNull("No content-type", requestContentType);
|
||||
Charset charset = ISO_8859_1;
|
||||
if (requestContentType.contains("charset=")) {
|
||||
String charsetName = requestContentType.split("charset=")[1];
|
||||
charset = Charset.forName(charsetName);
|
||||
}
|
||||
assertEquals("Invalid request body", expectedRequestContent, request.getBody().readString(charset));
|
||||
Buffer buf = new Buffer();
|
||||
buf.write(responseBody);
|
||||
return new MockResponse()
|
||||
.setHeader("Location", baseUrl + location)
|
||||
.setHeader("Content-Type", contentType)
|
||||
.setHeader("Content-Length", responseBody.length)
|
||||
.setBody(buf)
|
||||
.setResponseCode(201);
|
||||
}
|
||||
|
||||
private MockResponse jsonPostRequest(RecordedRequest request, String location, String contentType) {
|
||||
if (request.getBodySize() > 0) {
|
||||
assertTrue("Invalid request content-length",
|
||||
Integer.parseInt(request.getHeader("Content-Length")) > 0);
|
||||
assertNotNull("No content-type", request.getHeader("Content-Type"));
|
||||
}
|
||||
return new MockResponse()
|
||||
.setHeader("Location", baseUrl + location)
|
||||
.setHeader("Content-Type", contentType)
|
||||
.setHeader("Content-Length", request.getBody().size())
|
||||
.setBody(request.getBody())
|
||||
.setResponseCode(201);
|
||||
}
|
||||
|
||||
private MockResponse multipartRequest(RecordedRequest request) {
|
||||
String contentType = request.getHeader("Content-Type");
|
||||
assertTrue(contentType.startsWith("multipart/form-data"));
|
||||
String boundary = contentType.split("boundary=")[1];
|
||||
Buffer body = request.getBody();
|
||||
try {
|
||||
assertPart(body, "form-data", boundary, "name 1", "text/plain", "value 1");
|
||||
assertPart(body, "form-data", boundary, "name 2", "text/plain", "value 2+1");
|
||||
assertPart(body, "form-data", boundary, "name 2", "text/plain", "value 2+2");
|
||||
assertFilePart(body, "form-data", boundary, "logo", "logo.jpg", "image/jpeg");
|
||||
}
|
||||
catch (EOFException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
return new MockResponse().setResponseCode(200);
|
||||
}
|
||||
|
||||
private void assertPart(Buffer buffer, String disposition, String boundary, String name,
|
||||
String contentType, String value) throws EOFException {
|
||||
|
||||
assertTrue(buffer.readUtf8Line().contains("--" + boundary));
|
||||
String line = buffer.readUtf8Line();
|
||||
assertTrue(line.contains("Content-Disposition: "+ disposition));
|
||||
assertTrue(line.contains("name=\""+ name + "\""));
|
||||
assertTrue(buffer.readUtf8Line().startsWith("Content-Type: "+contentType));
|
||||
assertTrue(buffer.readUtf8Line().equals("Content-Length: " + value.length()));
|
||||
assertTrue(buffer.readUtf8Line().equals(""));
|
||||
assertTrue(buffer.readUtf8Line().equals(value));
|
||||
}
|
||||
|
||||
private void assertFilePart(Buffer buffer, String disposition, String boundary, String name,
|
||||
String filename, String contentType) throws EOFException {
|
||||
|
||||
assertTrue(buffer.readUtf8Line().contains("--" + boundary));
|
||||
String line = buffer.readUtf8Line();
|
||||
assertTrue(line.contains("Content-Disposition: "+ disposition));
|
||||
assertTrue(line.contains("name=\""+ name + "\""));
|
||||
assertTrue(line.contains("filename=\""+ filename + "\""));
|
||||
assertTrue(buffer.readUtf8Line().startsWith("Content-Type: "+contentType));
|
||||
assertTrue(buffer.readUtf8Line().startsWith("Content-Length: "));
|
||||
assertTrue(buffer.readUtf8Line().equals(""));
|
||||
assertNotNull(buffer.readUtf8Line());
|
||||
}
|
||||
|
||||
private MockResponse formRequest(RecordedRequest request) {
|
||||
assertEquals("application/x-www-form-urlencoded", request.getHeader("Content-Type"));
|
||||
String body = request.getBody().readUtf8();
|
||||
assertThat(body, Matchers.containsString("name+1=value+1"));
|
||||
assertThat(body, Matchers.containsString("name+2=value+2%2B1"));
|
||||
assertThat(body, Matchers.containsString("name+2=value+2%2B2"));
|
||||
return new MockResponse().setResponseCode(200);
|
||||
}
|
||||
|
||||
private MockResponse patchRequest(RecordedRequest request, String expectedRequestContent,
|
||||
String contentType, byte[] responseBody) {
|
||||
|
||||
assertEquals("PATCH", request.getMethod());
|
||||
assertTrue("Invalid request content-length",
|
||||
Integer.parseInt(request.getHeader("Content-Length")) > 0);
|
||||
String requestContentType = request.getHeader("Content-Type");
|
||||
assertNotNull("No content-type", requestContentType);
|
||||
Charset charset = ISO_8859_1;
|
||||
if (requestContentType.contains("charset=")) {
|
||||
String charsetName = requestContentType.split("charset=")[1];
|
||||
charset = Charset.forName(charsetName);
|
||||
}
|
||||
assertEquals("Invalid request body", expectedRequestContent, request.getBody().readString(charset));
|
||||
Buffer buf = new Buffer();
|
||||
buf.write(responseBody);
|
||||
return new MockResponse().setResponseCode(201)
|
||||
.setHeader("Content-Length", responseBody.length)
|
||||
.setHeader("Content-Type", contentType)
|
||||
.setBody(buf);
|
||||
}
|
||||
|
||||
private MockResponse putRequest(RecordedRequest request, String expectedRequestContent) {
|
||||
assertTrue("Invalid request content-length",
|
||||
Integer.parseInt(request.getHeader("Content-Length")) > 0);
|
||||
String requestContentType = request.getHeader("Content-Type");
|
||||
assertNotNull("No content-type", requestContentType);
|
||||
Charset charset = ISO_8859_1;
|
||||
if (requestContentType.contains("charset=")) {
|
||||
String charsetName = requestContentType.split("charset=")[1];
|
||||
charset = Charset.forName(charsetName);
|
||||
}
|
||||
assertEquals("Invalid request body", expectedRequestContent, request.getBody().readString(charset));
|
||||
return new MockResponse().setResponseCode(202);
|
||||
}
|
||||
|
||||
|
||||
protected class TestDispatcher extends Dispatcher {
|
||||
|
||||
@Override
|
||||
public MockResponse dispatch(RecordedRequest request) throws InterruptedException {
|
||||
try {
|
||||
@@ -107,151 +266,10 @@ public class AbstractMockWebServerTestCase {
|
||||
}
|
||||
return new MockResponse().setResponseCode(404);
|
||||
}
|
||||
catch (Throwable exc) {
|
||||
return new MockResponse().setResponseCode(500).setBody(exc.toString());
|
||||
catch (Throwable ex) {
|
||||
return new MockResponse().setResponseCode(500).setBody(ex.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private MockResponse getRequest(RecordedRequest request, byte[] body, String contentType) {
|
||||
if(request.getMethod().equals("OPTIONS")) {
|
||||
return new MockResponse().setResponseCode(200).setHeader("Allow", "GET, OPTIONS, HEAD, TRACE");
|
||||
}
|
||||
Buffer buf = new Buffer();
|
||||
buf.write(body);
|
||||
MockResponse response = new MockResponse()
|
||||
.setHeader("Content-Length", body.length)
|
||||
.setBody(buf)
|
||||
.setResponseCode(200);
|
||||
if (contentType != null) {
|
||||
response = response.setHeader("Content-Type", contentType);
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
private MockResponse postRequest(RecordedRequest request, String expectedRequestContent,
|
||||
String location, String contentType, byte[] responseBody) {
|
||||
|
||||
assertTrue("Invalid request content-length",
|
||||
Integer.parseInt(request.getHeader("Content-Length")) > 0);
|
||||
String requestContentType = request.getHeader("Content-Type");
|
||||
assertNotNull("No content-type", requestContentType);
|
||||
Charset charset = ISO_8859_1;
|
||||
if(requestContentType.indexOf("charset=") > -1) {
|
||||
String charsetName = requestContentType.split("charset=")[1];
|
||||
charset = Charset.forName(charsetName);
|
||||
}
|
||||
assertEquals("Invalid request body", expectedRequestContent, request.getBody().readString(charset));
|
||||
Buffer buf = new Buffer();
|
||||
buf.write(responseBody);
|
||||
return new MockResponse()
|
||||
.setHeader("Location", baseUrl + location)
|
||||
.setHeader("Content-Type", contentType)
|
||||
.setHeader("Content-Length", responseBody.length)
|
||||
.setBody(buf)
|
||||
.setResponseCode(201);
|
||||
}
|
||||
|
||||
private MockResponse jsonPostRequest(RecordedRequest request, String location, String contentType) {
|
||||
|
||||
assertTrue("Invalid request content-length",
|
||||
Integer.parseInt(request.getHeader("Content-Length")) > 0);
|
||||
assertNotNull("No content-type", request.getHeader("Content-Type"));
|
||||
return new MockResponse()
|
||||
.setHeader("Location", baseUrl + location)
|
||||
.setHeader("Content-Type", contentType)
|
||||
.setHeader("Content-Length", request.getBody().size())
|
||||
.setBody(request.getBody())
|
||||
.setResponseCode(201);
|
||||
}
|
||||
|
||||
private MockResponse multipartRequest(RecordedRequest request) {
|
||||
String contentType = request.getHeader("Content-Type");
|
||||
assertTrue(contentType.startsWith("multipart/form-data"));
|
||||
String boundary = contentType.split("boundary=")[1];
|
||||
Buffer body = request.getBody();
|
||||
try {
|
||||
assertPart(body, "form-data", boundary, "name 1", "text/plain", "value 1");
|
||||
assertPart(body, "form-data", boundary, "name 2", "text/plain", "value 2+1");
|
||||
assertPart(body, "form-data", boundary, "name 2", "text/plain", "value 2+2");
|
||||
assertFilePart(body, "form-data", boundary, "logo", "logo.jpg", "image/jpeg");
|
||||
}
|
||||
catch (EOFException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return new MockResponse().setResponseCode(200);
|
||||
}
|
||||
|
||||
private void assertPart(Buffer buffer, String disposition, String boundary, String name,
|
||||
String contentType, String value) throws EOFException {
|
||||
|
||||
assertTrue(buffer.readUtf8Line().contains("--" + boundary));
|
||||
String line = buffer.readUtf8Line();
|
||||
assertTrue(line.contains("Content-Disposition: "+ disposition));
|
||||
assertTrue(line.contains("name=\""+ name + "\""));
|
||||
assertTrue(buffer.readUtf8Line().startsWith("Content-Type: "+contentType));
|
||||
assertTrue(buffer.readUtf8Line().equals("Content-Length: " + value.length()));
|
||||
assertTrue(buffer.readUtf8Line().equals(""));
|
||||
assertTrue(buffer.readUtf8Line().equals(value));
|
||||
}
|
||||
|
||||
private void assertFilePart(Buffer buffer, String disposition, String boundary, String name,
|
||||
String filename, String contentType) throws EOFException {
|
||||
|
||||
assertTrue(buffer.readUtf8Line().contains("--" + boundary));
|
||||
String line = buffer.readUtf8Line();
|
||||
assertTrue(line.contains("Content-Disposition: "+ disposition));
|
||||
assertTrue(line.contains("name=\""+ name + "\""));
|
||||
assertTrue(line.contains("filename=\""+ filename + "\""));
|
||||
assertTrue(buffer.readUtf8Line().startsWith("Content-Type: "+contentType));
|
||||
assertTrue(buffer.readUtf8Line().startsWith("Content-Length: "));
|
||||
assertTrue(buffer.readUtf8Line().equals(""));
|
||||
assertNotNull(buffer.readUtf8Line());
|
||||
}
|
||||
|
||||
private MockResponse formRequest(RecordedRequest request) {
|
||||
assertEquals("application/x-www-form-urlencoded", request.getHeader("Content-Type"));
|
||||
String body = request.getBody().readUtf8();
|
||||
assertThat(body, Matchers.containsString("name+1=value+1"));
|
||||
assertThat(body, Matchers.containsString("name+2=value+2%2B1"));
|
||||
assertThat(body, Matchers.containsString("name+2=value+2%2B2"));
|
||||
return new MockResponse().setResponseCode(200);
|
||||
}
|
||||
|
||||
private MockResponse patchRequest(RecordedRequest request, String expectedRequestContent,
|
||||
String contentType, byte[] responseBody) {
|
||||
assertEquals("PATCH", request.getMethod());
|
||||
assertTrue("Invalid request content-length",
|
||||
Integer.parseInt(request.getHeader("Content-Length")) > 0);
|
||||
String requestContentType = request.getHeader("Content-Type");
|
||||
assertNotNull("No content-type", requestContentType);
|
||||
Charset charset = ISO_8859_1;
|
||||
if(requestContentType.indexOf("charset=") > -1) {
|
||||
String charsetName = requestContentType.split("charset=")[1];
|
||||
charset = Charset.forName(charsetName);
|
||||
}
|
||||
assertEquals("Invalid request body", expectedRequestContent, request.getBody().readString(charset));
|
||||
Buffer buf = new Buffer();
|
||||
buf.write(responseBody);
|
||||
return new MockResponse().setResponseCode(201)
|
||||
.setHeader("Content-Length", responseBody.length)
|
||||
.setHeader("Content-Type", contentType)
|
||||
.setBody(buf);
|
||||
}
|
||||
|
||||
private MockResponse putRequest(RecordedRequest request, String expectedRequestContent) {
|
||||
assertTrue("Invalid request content-length",
|
||||
Integer.parseInt(request.getHeader("Content-Length")) > 0);
|
||||
String requestContentType = request.getHeader("Content-Type");
|
||||
assertNotNull("No content-type", requestContentType);
|
||||
Charset charset = ISO_8859_1;
|
||||
if(requestContentType.indexOf("charset=") > -1) {
|
||||
String charsetName = requestContentType.split("charset=")[1];
|
||||
charset = Charset.forName(charsetName);
|
||||
}
|
||||
assertEquals("Invalid request body", expectedRequestContent, request.getBody().readString(charset));
|
||||
return new MockResponse().setResponseCode(202);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
|
||||
import org.springframework.http.client.Netty4ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.OkHttp3ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.OkHttpClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.http.converter.json.MappingJacksonValue;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
@@ -72,10 +73,11 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase
|
||||
@Parameterized.Parameters
|
||||
public static Iterable<? extends ClientHttpRequestFactory> data() {
|
||||
return Arrays.asList(
|
||||
new SimpleClientHttpRequestFactory(),
|
||||
new HttpComponentsClientHttpRequestFactory(),
|
||||
new Netty4ClientHttpRequestFactory(),
|
||||
new OkHttp3ClientHttpRequestFactory(),
|
||||
new SimpleClientHttpRequestFactory()
|
||||
new OkHttpClientHttpRequestFactory()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -141,7 +143,7 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase
|
||||
public void postForLocationEntity() throws URISyntaxException {
|
||||
HttpHeaders entityHeaders = new HttpHeaders();
|
||||
entityHeaders.setContentType(new MediaType("text", "plain", Charset.forName("ISO-8859-15")));
|
||||
HttpEntity<String> entity = new HttpEntity<String>(helloWorld, entityHeaders);
|
||||
HttpEntity<String> entity = new HttpEntity<>(helloWorld, entityHeaders);
|
||||
URI location = template.postForLocation(baseUrl + "/{method}", entity, "post");
|
||||
assertEquals("Invalid location", new URI(baseUrl + "/post/1"), location);
|
||||
}
|
||||
@@ -199,7 +201,7 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase
|
||||
|
||||
@Test
|
||||
public void multipart() throws UnsupportedEncodingException {
|
||||
MultiValueMap<String, Object> parts = new LinkedMultiValueMap<String, Object>();
|
||||
MultiValueMap<String, Object> parts = new LinkedMultiValueMap<>();
|
||||
parts.add("name 1", "value 1");
|
||||
parts.add("name 2", "value 2+1");
|
||||
parts.add("name 2", "value 2+2");
|
||||
@@ -211,7 +213,7 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase
|
||||
|
||||
@Test
|
||||
public void form() throws UnsupportedEncodingException {
|
||||
MultiValueMap<String, String> form = new LinkedMultiValueMap<String, String>();
|
||||
MultiValueMap<String, String> form = new LinkedMultiValueMap<>();
|
||||
form.add("name 1", "value 1");
|
||||
form.add("name 2", "value 2+1");
|
||||
form.add("name 2", "value 2+2");
|
||||
@@ -223,7 +225,7 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase
|
||||
public void exchangeGet() throws Exception {
|
||||
HttpHeaders requestHeaders = new HttpHeaders();
|
||||
requestHeaders.set("MyHeader", "MyValue");
|
||||
HttpEntity<String> requestEntity = new HttpEntity<String>(requestHeaders);
|
||||
HttpEntity<String> requestEntity = new HttpEntity<>(requestHeaders);
|
||||
ResponseEntity<String> response =
|
||||
template.exchange(baseUrl + "/{method}", HttpMethod.GET, requestEntity, String.class, "get");
|
||||
assertEquals("Invalid content", helloWorld, response.getBody());
|
||||
@@ -234,7 +236,7 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase
|
||||
HttpHeaders requestHeaders = new HttpHeaders();
|
||||
requestHeaders.set("MyHeader", "MyValue");
|
||||
requestHeaders.setContentType(MediaType.TEXT_PLAIN);
|
||||
HttpEntity<String> requestEntity = new HttpEntity<String>(helloWorld, requestHeaders);
|
||||
HttpEntity<String> requestEntity = new HttpEntity<>(helloWorld, requestHeaders);
|
||||
HttpEntity<Void> result = template.exchange(baseUrl + "/{method}", HttpMethod.POST, requestEntity, Void.class, "post");
|
||||
assertEquals("Invalid location", new URI(baseUrl + "/post/1"), result.getHeaders().getLocation());
|
||||
assertFalse(result.hasBody());
|
||||
@@ -248,7 +250,7 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase
|
||||
bean.setWith1("with");
|
||||
bean.setWith2("with");
|
||||
bean.setWithout("without");
|
||||
HttpEntity<MySampleBean> entity = new HttpEntity<MySampleBean>(bean, entityHeaders);
|
||||
HttpEntity<MySampleBean> entity = new HttpEntity<>(bean, entityHeaders);
|
||||
String s = template.postForObject(baseUrl + "/jsonpost", entity, String.class);
|
||||
assertTrue(s.contains("\"with1\":\"with\""));
|
||||
assertTrue(s.contains("\"with2\":\"with\""));
|
||||
@@ -262,7 +264,7 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase
|
||||
MySampleBean bean = new MySampleBean("with", "with", "without");
|
||||
MappingJacksonValue jacksonValue = new MappingJacksonValue(bean);
|
||||
jacksonValue.setSerializationView(MyJacksonView1.class);
|
||||
HttpEntity<MappingJacksonValue> entity = new HttpEntity<MappingJacksonValue>(jacksonValue, entityHeaders);
|
||||
HttpEntity<MappingJacksonValue> entity = new HttpEntity<>(jacksonValue, entityHeaders);
|
||||
String s = template.postForObject(baseUrl + "/jsonpost", entity, String.class);
|
||||
assertTrue(s.contains("\"with1\":\"with\""));
|
||||
assertFalse(s.contains("\"with2\":\"with\""));
|
||||
@@ -290,10 +292,15 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase
|
||||
assertTrue(content.contains("\"type\":\"bar\""));
|
||||
}
|
||||
|
||||
@Test // SPR-15015
|
||||
public void postWithoutBody() throws Exception {
|
||||
assertNull(template.postForObject(baseUrl + "/jsonpost", null, String.class));
|
||||
}
|
||||
|
||||
public interface MyJacksonView1 {};
|
||||
|
||||
public interface MyJacksonView2 {};
|
||||
public interface MyJacksonView1 {}
|
||||
|
||||
public interface MyJacksonView2 {}
|
||||
|
||||
|
||||
public static class MySampleBean {
|
||||
|
||||
Reference in New Issue
Block a user