diff options
Diffstat (limited to 'vespa-maven-plugin/src/test/java/ai/vespa/hosted/api/MultiPartStreamerTest.java')
-rw-r--r-- | vespa-maven-plugin/src/test/java/ai/vespa/hosted/api/MultiPartStreamerTest.java | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/vespa-maven-plugin/src/test/java/ai/vespa/hosted/api/MultiPartStreamerTest.java b/vespa-maven-plugin/src/test/java/ai/vespa/hosted/api/MultiPartStreamerTest.java deleted file mode 100644 index 3abb04976c1..00000000000 --- a/vespa-maven-plugin/src/test/java/ai/vespa/hosted/api/MultiPartStreamerTest.java +++ /dev/null @@ -1,69 +0,0 @@ -package ai.vespa.hosted.api; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.TemporaryFolder; - -import java.io.IOException; -import java.net.URI; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.List; - -import static org.junit.Assert.assertEquals; - -public class MultiPartStreamerTest { - - @Rule - public TemporaryFolder tmp = new TemporaryFolder(); - - @Test - public void test() throws IOException { - Path file = tmp.newFile().toPath(); - Files.write(file, new byte[]{0x48, 0x69}); - MultiPartStreamer streamer = new MultiPartStreamer("My boundary"); - - assertEquals("--My boundary--", - new String(streamer.data().readAllBytes())); - - streamer.addData("data", "uss/enterprise", "lore") - .addJson("json", "{\"xml\":false}") - .addText("text", "Hello!") - .addFile("file", file); - - String expected = "--My boundary\r\n" + - "Content-Disposition: form-data; name=\"data\"\r\n" + - "Content-Type: uss/enterprise\r\n" + - "\r\n" + - "lore\r\n" + - "--My boundary\r\n" + - "Content-Disposition: form-data; name=\"json\"\r\n" + - "Content-Type: application/json\r\n" + - "\r\n" + - "{\"xml\":false}\r\n" + - "--My boundary\r\n" + - "Content-Disposition: form-data; name=\"text\"\r\n" + - "Content-Type: text/plain\r\n" + - "\r\n" + - "Hello!\r\n" + - "--My boundary\r\n" + - "Content-Disposition: form-data; name=\"file\"; filename=\"" + file.getFileName() + "\"\r\n" + - "Content-Type: application/octet-stream\r\n" + - "\r\n" + - "Hi\r\n" + - "--My boundary--"; - - assertEquals(expected, - new String(streamer.data().readAllBytes())); - - // Verify that all data is read again for a new builder. - assertEquals(expected, - new String(streamer.data().readAllBytes())); - - assertEquals(List.of("multipart/form-data; boundary=My boundary"), - streamer.requestBuilder(Method.POST) - .uri(URI.create("https://uri/path")) - .build().headers().allValues("Content-Type")); - } - -} |