Package org.apache.http.client

Examples of org.apache.http.client.HttpClient.execute()


            // check that the connector is live
            String cURL = "https://" + url.getHost() + ":8181";
            HttpClient httpClient = HttpClientUtils.wrapHttpsClient(new DefaultHttpClient());
            HttpGet get = new HttpGet(cURL);

            HttpResponse hr = httpClient.execute(get);
            String response = EntityUtils.toString(hr.getEntity());
            assertTrue("Invalid response: " + response, response.indexOf("JBoss") >= 0);
            removeConnector(Connector.HTTPSNATIVE);

            if (keyPEMFile.exists())
View Full Code Here


                new UsernamePasswordCredentials(user, pass));

        HttpGet get = new HttpGet(url);
        HttpResponse hr;
        try {
            hr = httpClient.execute(get);
        } catch (Exception e) {
            if (responseSubstring == null)
                return false;
            else // in case substring is defined, rethrow exception so, we can easier analyze the cause
                throw new Exception(e);
View Full Code Here

        final String xml = "dummy.xml";

        final String requestURL = withoutJsf.toExternalForm() + XercesUsageServlet.URL_PATTERN
                + "?" + XercesUsageServlet.XML_RESOURCE_NAME_PARAMETER + "=" + xml;
        final HttpGet request = new HttpGet(requestURL);
        final HttpResponse response = httpClient.execute(request);
        int statusCode = response.getStatusLine().getStatusCode();
        Assert.assertEquals("Unexpected status code", 200, statusCode);
        final HttpEntity entity = response.getEntity();
        Assert.assertNotNull("Response message from servlet was null", entity);
        final String responseMessage = EntityUtils.toString(entity);
View Full Code Here

        final String xml = "dummy.xml";

        final String requestURL = withJsf.toExternalForm()+ XercesUsageServlet.URL_PATTERN
                + "?" + XercesUsageServlet.XML_RESOURCE_NAME_PARAMETER + "=" + xml;
        final HttpGet request = new HttpGet(requestURL);
        final HttpResponse response = httpClient.execute(request);
        int statusCode = response.getStatusLine().getStatusCode();
        Assert.assertEquals("Unexpected status code", 200, statusCode);
        final HttpEntity entity = response.getEntity();
        Assert.assertNotNull("Response message from servlet was null", entity);
        final String responseMessage = EntityUtils.toString(entity);
View Full Code Here

            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }

            response = client.execute(targetHost, getMethod, localcontext);

            maxit--;
        } while ((response == null || response.getStatusLine().getStatusCode() != 200) && maxit > 0);

        assertEquals(200, response.getStatusLine().getStatusCode());
View Full Code Here

        assertNotNull(export);
        assertFalse(export.isEmpty());

        // 2. HTML
        getMethod = new HttpGet(BASE_URL + "report/execution/export/" + postExecIds.iterator().next() + "?fmt=HTML");
        response = client.execute(targetHost, getMethod, localcontext);
        assertEquals(200, response.getStatusLine().getStatusCode());

        export = EntityUtils.toString(response.getEntity()).trim();
        assertNotNull(export);
        assertFalse(export.isEmpty());
View Full Code Here

        assertNotNull(export);
        assertFalse(export.isEmpty());

        // 3. PDF
        getMethod = new HttpGet(BASE_URL + "report/execution/export/" + postExecIds.iterator().next() + "?fmt=PDF");
        response = client.execute(targetHost, getMethod, localcontext);
        assertEquals(200, response.getStatusLine().getStatusCode());

        export = EntityUtils.toString(response.getEntity()).trim();
        assertNotNull(export);
        assertFalse(export.isEmpty());
View Full Code Here

        assertNotNull(export);
        assertFalse(export.isEmpty());

        // 4. RTF
        getMethod = new HttpGet(BASE_URL + "report/execution/export/" + postExecIds.iterator().next() + "?fmt=RTF");
        response = client.execute(targetHost, getMethod, localcontext);
        assertEquals(200, response.getStatusLine().getStatusCode());

        export = EntityUtils.toString(response.getEntity()).trim();
        assertNotNull(export);
        assertFalse(export.isEmpty());
View Full Code Here

            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }

            response = client.execute(targetHost, getMethod, localcontext);

            maxit--;
        } while ((response == null || response.getStatusLine().getStatusCode() != 200) && maxit > 0);

        assertEquals(200, response.getStatusLine().getStatusCode());
View Full Code Here

                ob.append(requestOrigin);
                ob.append(" "); // extra trailing space won't hurt.
            }
            httpget.addHeader("Origin", ob.toString());
        }
        HttpResponse response = httpclient.execute(httpget);
        assertEquals(200, response.getStatusLine().getStatusCode());
        HttpEntity entity = response.getEntity();
        String e = IOUtils.toString(entity.getContent(), "utf-8");

        assertEquals("HelloThere", e); // ensure that we didn't bust the operation itself.
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.