Search in sources :

Example 1 with FilePart

use of org.asynchttpclient.request.body.multipart.FilePart in project async-http-client by AsyncHttpClient.

the class FastUnauthorizedUploadTest method testUnauthorizedWhileUploading.

@Test(groups = "standalone")
public void testUnauthorizedWhileUploading() throws Exception {
    File file = createTempFile(1024 * 1024);
    try (AsyncHttpClient client = asyncHttpClient()) {
        Response response = client.preparePut(getTargetUrl()).addBodyPart(new FilePart("test", file, "application/octet-stream", UTF_8)).execute().get();
        assertEquals(response.getStatusCode(), 401);
    }
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(org.asynchttpclient.Response) File(java.io.File) TestUtils.createTempFile(org.asynchttpclient.test.TestUtils.createTempFile) FilePart(org.asynchttpclient.request.body.multipart.FilePart) AsyncHttpClient(org.asynchttpclient.AsyncHttpClient) Test(org.testng.annotations.Test) AbstractBasicTest(org.asynchttpclient.AbstractBasicTest)

Example 2 with FilePart

use of org.asynchttpclient.request.body.multipart.FilePart in project async-http-client by AsyncHttpClient.

the class FilePartLargeFileTest method testPutLargeTextFile.

@Test(groups = "standalone")
public void testPutLargeTextFile() throws Exception {
    File file = createTempFile(1024 * 1024);
    try (AsyncHttpClient client = asyncHttpClient(config().setRequestTimeout(100 * 6000))) {
        Response response = client.preparePut(getTargetUrl()).addBodyPart(new FilePart("test", file, "application/octet-stream", UTF_8)).execute().get();
        assertEquals(response.getStatusCode(), 200);
    }
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(org.asynchttpclient.Response) File(java.io.File) FilePart(org.asynchttpclient.request.body.multipart.FilePart) AsyncHttpClient(org.asynchttpclient.AsyncHttpClient) Test(org.testng.annotations.Test) AbstractBasicTest(org.asynchttpclient.AbstractBasicTest)

Example 3 with FilePart

use of org.asynchttpclient.request.body.multipart.FilePart in project async-http-client by AsyncHttpClient.

the class FilePartLargeFileTest method testPutImageFile.

@Test(groups = "standalone")
public void testPutImageFile() throws Exception {
    try (AsyncHttpClient client = asyncHttpClient(config().setRequestTimeout(100 * 6000))) {
        Response response = client.preparePut(getTargetUrl()).addBodyPart(new FilePart("test", LARGE_IMAGE_FILE, "application/octet-stream", UTF_8)).execute().get();
        assertEquals(response.getStatusCode(), 200);
    }
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(org.asynchttpclient.Response) FilePart(org.asynchttpclient.request.body.multipart.FilePart) AsyncHttpClient(org.asynchttpclient.AsyncHttpClient) Test(org.testng.annotations.Test) AbstractBasicTest(org.asynchttpclient.AbstractBasicTest)

Aggregations

HttpServletResponse (javax.servlet.http.HttpServletResponse)3 AbstractBasicTest (org.asynchttpclient.AbstractBasicTest)3 AsyncHttpClient (org.asynchttpclient.AsyncHttpClient)3 Response (org.asynchttpclient.Response)3 FilePart (org.asynchttpclient.request.body.multipart.FilePart)3 Test (org.testng.annotations.Test)3 File (java.io.File)2 TestUtils.createTempFile (org.asynchttpclient.test.TestUtils.createTempFile)1