Examples of preparePut()


Examples of com.ning.http.client.AsyncHttpClient.preparePut()

                                String newUrlWithParams = String.format("%s?description=%s&releaseDate=%s",
                                        newVersionUrl, versionDescription, versionReleaseDate);

                                // If not - create it
                                Future<Response> newVersion = client
                                        .preparePut(newUrlWithParams)
                                        .addHeader(AUTHORIZATION, BASIC + " " + encodedLogon)
                                        .execute();

                                return newVersion.get();
View Full Code Here

Examples of org.asynchttpclient.AsyncHttpClient.preparePut()

    public void testUnauthorizedWhileUploading() throws Exception {
        File file = createTempFile(1024 * 1024);

        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Response response = client.preparePut(getTargetUrl()).addBodyPart(new FilePart("test", file, "application/octet-stream", UTF_8)).execute()
                    .get();
            assertEquals(response.getStatusCode(), 401);
        } finally {
            client.close();
        }
View Full Code Here

Examples of org.asynchttpclient.AsyncHttpClient.preparePut()

    @Test(groups = { "standalone", "default_provider" }, enabled = true)
    public void testPutImageFile() throws Exception {
        AsyncHttpClient client = getAsyncHttpClient(new AsyncHttpClientConfig.Builder().setRequestTimeout(100 * 6000).build());
        try {
            Response response = client.preparePut(getTargetUrl()).addBodyPart(new FilePart("test", LARGE_IMAGE_FILE, "application/octet-stream", UTF_8)).execute().get();
            assertEquals(response.getStatusCode(), 200);
        } finally {
            client.close();
        }
    }
View Full Code Here

Examples of org.asynchttpclient.AsyncHttpClient.preparePut()

    public void testPutLargeTextFile() throws Exception {
        File file = createTempFile(1024 * 1024);

        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Response response = client.preparePut(getTargetUrl()).addBodyPart(new FilePart("test", file, "application/octet-stream", UTF_8)).execute().get();
            assertEquals(response.getStatusCode(), 200);
        } finally {
            client.close();
        }
    }
View Full Code Here

Examples of org.asynchttpclient.AsyncHttpClient.preparePut()

    @Test(groups = { "standalone", "default_provider" })
    public void zeroCopyPutTest() throws IOException, ExecutionException, TimeoutException, InterruptedException, URISyntaxException {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Future<Response> f = client.preparePut("http://127.0.0.1:" + port1 + "/").setBody(SIMPLE_TEXT_FILE).execute();
            Response resp = f.get();
            assertNotNull(resp);
            assertEquals(resp.getStatusCode(), HttpServletResponse.SC_OK);
            assertEquals(resp.getResponseBody(), SIMPLE_TEXT_FILE_STRING);
        } finally {
View Full Code Here

Examples of org.asynchttpclient.AsyncHttpClient.preparePut()

                sb.append("param_").append(i).append("=value_").append(i).append("&");
            }
            sb.setLength(sb.length() - 1);
            ByteArrayInputStream is = new ByteArrayInputStream(sb.toString().getBytes());

            client.preparePut(getTargetUrl()).setHeaders(h).setBody(is).execute(new AsyncCompletionHandlerAdapter() {

                @Override
                public Response onCompleted(Response response) throws Exception {
                    try {
                        assertEquals(response.getStatusCode(), 200);
View Full Code Here

Examples of org.asynchttpclient.AsyncHttpClient.preparePut()

            for (int i = 0; i < 5; i++) {
                sb.append("param_").append(i).append("=value_").append(i).append("&");
            }
            sb.setLength(sb.length() - 1);

            Response response = client.preparePut(getTargetUrl()).setHeaders(h).setBody(sb.toString()).execute(new AsyncCompletionHandlerAdapter()).get();

            assertEquals(response.getStatusCode(), 200);
        } finally {
            client.close();
        }
View Full Code Here

Examples of org.asynchttpclient.AsyncHttpClient.preparePut()

        int timeout = (int) file.length() / 1000;

        AsyncHttpClient client = getAsyncHttpClient(new AsyncHttpClientConfig.Builder().setConnectTimeout(timeout).build());
        try {
            Response response = client.preparePut(getTargetUrl()).setBody(file).execute().get();
            assertEquals(response.getStatusCode(), 200);
        } finally {
            client.close();
        }
    }
View Full Code Here

Examples of org.asynchttpclient.AsyncHttpClient.preparePut()

        File file = createTempFile(1024);

        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Response response = client.preparePut(getTargetUrl()).setBody(file).execute().get();
            assertEquals(response.getStatusCode(), 200);
        } finally {
            client.close();
        }
    }
View Full Code Here

Examples of org.asynchttpclient.AsyncHttpClient.preparePut()

    @Test(groups = { "standalone", "default_provider" })
    public void Expect100Continue() throws Exception {
        AsyncHttpClient client = getAsyncHttpClient(null);
        try {
            Future<Response> f = client.preparePut("http://127.0.0.1:" + port1 + "/").setHeader("Expect", "100-continue").setBody(SIMPLE_TEXT_FILE).execute();
            Response resp = f.get();
            assertNotNull(resp);
            assertEquals(resp.getStatusCode(), HttpServletResponse.SC_OK);
            assertEquals(resp.getResponseBody(), SIMPLE_TEXT_FILE_STRING);
        } finally {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.