JAVA-22043 Fixed formatting (#14386)
This commit is contained in:
parent
82532d661d
commit
dcb08e1495
@ -44,29 +44,29 @@ public class GetRequestMockServer {
|
|||||||
MockServerClient client = new MockServerClient(SERVER_ADDRESS, serverPort);
|
MockServerClient client = new MockServerClient(SERVER_ADDRESS, serverPort);
|
||||||
|
|
||||||
client.when(
|
client.when(
|
||||||
request()
|
request()
|
||||||
.withPath(SECURITY_PATH)
|
.withPath(SECURITY_PATH)
|
||||||
.withMethod("GET"),
|
.withMethod("GET"),
|
||||||
exactly(1)
|
exactly(1)
|
||||||
)
|
)
|
||||||
.respond(
|
.respond(
|
||||||
response()
|
response()
|
||||||
.withStatusCode(HttpStatus.SC_OK)
|
.withStatusCode(HttpStatus.SC_OK)
|
||||||
.withBody("{\"status\":\"ok\"}")
|
.withBody("{\"status\":\"ok\"}")
|
||||||
);
|
);
|
||||||
|
|
||||||
client.when(
|
client.when(
|
||||||
request()
|
request()
|
||||||
.withPath(UPLOAD_PATH)
|
.withPath(UPLOAD_PATH)
|
||||||
.withMethod("POST"),
|
.withMethod("POST"),
|
||||||
exactly(4)
|
exactly(4)
|
||||||
)
|
)
|
||||||
.respond(
|
.respond(
|
||||||
response()
|
response()
|
||||||
.withStatusCode(HttpStatus.SC_OK)
|
.withStatusCode(HttpStatus.SC_OK)
|
||||||
.withBody("{\"status\":\"ok\"}")
|
.withBody("{\"status\":\"ok\"}")
|
||||||
.withHeader("Content-Type", "multipart/form-data")
|
.withHeader("Content-Type", "multipart/form-data")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getFreePort() throws IOException {
|
private static int getFreePort() throws IOException {
|
||||||
|
@ -28,7 +28,6 @@ import java.io.InputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
|
|
||||||
class HttpClientMultipartLiveTest extends GetRequestMockServer {
|
class HttpClientMultipartLiveTest extends GetRequestMockServer {
|
||||||
|
|
||||||
// No longer available
|
// No longer available
|
||||||
@ -44,15 +43,15 @@ class HttpClientMultipartLiveTest extends GetRequestMockServer {
|
|||||||
@BeforeEach
|
@BeforeEach
|
||||||
public void before() {
|
public void before() {
|
||||||
post = new HttpPost(SERVER);
|
post = new HttpPost(SERVER);
|
||||||
String URL = "http://localhost:"+serverPort+"/spring-mvc-java/stub/multipart";
|
String URL = "http://localhost:" + serverPort + "/spring-mvc-java/stub/multipart";
|
||||||
post = new HttpPost(URL);
|
post = new HttpPost(URL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void givenFileandMultipleTextParts_whenUploadwithAddPart_thenNoExceptions() throws IOException {
|
void givenFileandMultipleTextParts_whenUploadwithAddPart_thenNoExceptions() throws IOException {
|
||||||
final URL url = Thread.currentThread()
|
final URL url = Thread.currentThread()
|
||||||
.getContextClassLoader()
|
.getContextClassLoader()
|
||||||
.getResource("uploads/" + TEXTFILENAME);
|
.getResource("uploads/" + TEXTFILENAME);
|
||||||
|
|
||||||
final File file = new File(url.getPath());
|
final File file = new File(url.getPath());
|
||||||
final FileBody fileBody = new FileBody(file, ContentType.DEFAULT_BINARY);
|
final FileBody fileBody = new FileBody(file, ContentType.DEFAULT_BINARY);
|
||||||
@ -68,7 +67,7 @@ class HttpClientMultipartLiveTest extends GetRequestMockServer {
|
|||||||
|
|
||||||
post.setEntity(entity);
|
post.setEntity(entity);
|
||||||
try (CloseableHttpClient client = HttpClientBuilder.create()
|
try (CloseableHttpClient client = HttpClientBuilder.create()
|
||||||
.build()) {
|
.build()) {
|
||||||
|
|
||||||
client.execute(post, response -> {
|
client.execute(post, response -> {
|
||||||
final int statusCode = response.getCode();
|
final int statusCode = response.getCode();
|
||||||
@ -87,8 +86,8 @@ class HttpClientMultipartLiveTest extends GetRequestMockServer {
|
|||||||
@Test
|
@Test
|
||||||
void givenFileandTextPart_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoExeption() throws IOException {
|
void givenFileandTextPart_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoExeption() throws IOException {
|
||||||
final URL url = Thread.currentThread()
|
final URL url = Thread.currentThread()
|
||||||
.getContextClassLoader()
|
.getContextClassLoader()
|
||||||
.getResource("uploads/" + TEXTFILENAME);
|
.getResource("uploads/" + TEXTFILENAME);
|
||||||
final File file = new File(url.getPath());
|
final File file = new File(url.getPath());
|
||||||
final String message = "This is a multipart post";
|
final String message = "This is a multipart post";
|
||||||
final MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
final MultipartEntityBuilder builder = MultipartEntityBuilder.create();
|
||||||
@ -99,7 +98,7 @@ class HttpClientMultipartLiveTest extends GetRequestMockServer {
|
|||||||
post.setEntity(entity);
|
post.setEntity(entity);
|
||||||
|
|
||||||
try (CloseableHttpClient client = HttpClientBuilder.create()
|
try (CloseableHttpClient client = HttpClientBuilder.create()
|
||||||
.build()) {
|
.build()) {
|
||||||
|
|
||||||
client.execute(post, response -> {
|
client.execute(post, response -> {
|
||||||
|
|
||||||
@ -118,11 +117,11 @@ class HttpClientMultipartLiveTest extends GetRequestMockServer {
|
|||||||
@Test
|
@Test
|
||||||
void givenFileAndInputStreamandText_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoException() throws IOException {
|
void givenFileAndInputStreamandText_whenUploadwithAddBinaryBodyandAddTextBody_ThenNoException() throws IOException {
|
||||||
final URL url = Thread.currentThread()
|
final URL url = Thread.currentThread()
|
||||||
.getContextClassLoader()
|
.getContextClassLoader()
|
||||||
.getResource("uploads/" + ZIPFILENAME);
|
.getResource("uploads/" + ZIPFILENAME);
|
||||||
final URL url2 = Thread.currentThread()
|
final URL url2 = Thread.currentThread()
|
||||||
.getContextClassLoader()
|
.getContextClassLoader()
|
||||||
.getResource("uploads/" + IMAGEFILENAME);
|
.getResource("uploads/" + IMAGEFILENAME);
|
||||||
final InputStream inputStream = new FileInputStream(url.getPath());
|
final InputStream inputStream = new FileInputStream(url.getPath());
|
||||||
final File file = new File(url2.getPath());
|
final File file = new File(url2.getPath());
|
||||||
final String message = "This is a multipart post";
|
final String message = "This is a multipart post";
|
||||||
@ -135,7 +134,7 @@ class HttpClientMultipartLiveTest extends GetRequestMockServer {
|
|||||||
post.setEntity(entity);
|
post.setEntity(entity);
|
||||||
|
|
||||||
try (CloseableHttpClient client = HttpClientBuilder.create()
|
try (CloseableHttpClient client = HttpClientBuilder.create()
|
||||||
.build()) {
|
.build()) {
|
||||||
|
|
||||||
client.execute(post, response -> {
|
client.execute(post, response -> {
|
||||||
final int statusCode = response.getCode();
|
final int statusCode = response.getCode();
|
||||||
@ -163,7 +162,7 @@ class HttpClientMultipartLiveTest extends GetRequestMockServer {
|
|||||||
post.setEntity(entity);
|
post.setEntity(entity);
|
||||||
|
|
||||||
try (CloseableHttpClient httpClient = HttpClientBuilder.create()
|
try (CloseableHttpClient httpClient = HttpClientBuilder.create()
|
||||||
.build()) {
|
.build()) {
|
||||||
|
|
||||||
httpClient.execute(post, response -> {
|
httpClient.execute(post, response -> {
|
||||||
final int statusCode = response.getCode();
|
final int statusCode = response.getCode();
|
||||||
@ -186,15 +185,15 @@ class HttpClientMultipartLiveTest extends GetRequestMockServer {
|
|||||||
StringBuilder content = new StringBuilder();
|
StringBuilder content = new StringBuilder();
|
||||||
while ((body = rd.readLine()) != null) {
|
while ((body = rd.readLine()) != null) {
|
||||||
content.append(body)
|
content.append(body)
|
||||||
.append("\n");
|
.append("\n");
|
||||||
}
|
}
|
||||||
return content.toString()
|
return content.toString()
|
||||||
.trim();
|
.trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getContentTypeHeader() {
|
private String getContentTypeHeader() {
|
||||||
return post.getEntity()
|
return post.getEntity()
|
||||||
.getContentType();
|
.getContentType();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user