|
1 | 1 | /*
|
2 |
| - * Copyright 2014-2023 the original author or authors. |
| 2 | + * Copyright 2014-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -165,6 +165,36 @@ public void multipartPost() throws IOException {
|
165 | 165 | .content(expectedContent));
|
166 | 166 | }
|
167 | 167 |
|
| 168 | + @Test |
| 169 | + public void multipartPut() throws IOException { |
| 170 | + new HttpRequestSnippet().document(this.operationBuilder.request("http://localhost/upload") |
| 171 | + .method("PUT") |
| 172 | + .header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE) |
| 173 | + .part("image", "<< data >>".getBytes()) |
| 174 | + .build()); |
| 175 | + String expectedContent = createPart( |
| 176 | + String.format("Content-Disposition: " + "form-data; " + "name=image%n%n<< data >>")); |
| 177 | + assertThat(this.generatedSnippets.httpRequest()).is(httpRequest(RequestMethod.PUT, "/upload") |
| 178 | + .header("Content-Type", "multipart/form-data; boundary=" + BOUNDARY) |
| 179 | + .header(HttpHeaders.HOST, "localhost") |
| 180 | + .content(expectedContent)); |
| 181 | + } |
| 182 | + |
| 183 | + @Test |
| 184 | + public void multipartPatch() throws IOException { |
| 185 | + new HttpRequestSnippet().document(this.operationBuilder.request("http://localhost/upload") |
| 186 | + .method("PATCH") |
| 187 | + .header(HttpHeaders.CONTENT_TYPE, MediaType.MULTIPART_FORM_DATA_VALUE) |
| 188 | + .part("image", "<< data >>".getBytes()) |
| 189 | + .build()); |
| 190 | + String expectedContent = createPart( |
| 191 | + String.format("Content-Disposition: " + "form-data; " + "name=image%n%n<< data >>")); |
| 192 | + assertThat(this.generatedSnippets.httpRequest()).is(httpRequest(RequestMethod.PATCH, "/upload") |
| 193 | + .header("Content-Type", "multipart/form-data; boundary=" + BOUNDARY) |
| 194 | + .header(HttpHeaders.HOST, "localhost") |
| 195 | + .content(expectedContent)); |
| 196 | + } |
| 197 | + |
168 | 198 | @Test
|
169 | 199 | public void multipartPostWithFilename() throws IOException {
|
170 | 200 | new HttpRequestSnippet().document(this.operationBuilder.request("http://localhost/upload")
|
|
0 commit comments