Search in sources :

Example 16 with HttpClientWrapper

use of org.opennms.core.web.HttpClientWrapper in project opennms by OpenNMS.

the class GraphMLTopologyIT method deleteGraph.

private void deleteGraph() throws IOException, InterruptedException {
    try (HttpClientWrapper client = createClientWrapper()) {
        HttpDelete httpDelete = new HttpDelete(URL);
        CloseableHttpResponse response = client.execute(httpDelete);
        assertEquals(200, response.getStatusLine().getStatusCode());
    }
    // We wait to give the GraphMLMetaTopologyFactory the chance to clean up afterwards
    Thread.sleep(20000);
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) HttpClientWrapper(org.opennms.core.web.HttpClientWrapper) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse)

Example 17 with HttpClientWrapper

use of org.opennms.core.web.HttpClientWrapper in project opennms by OpenNMS.

the class GraphMLTopologyIT method createClientWrapper.

private static HttpClientWrapper createClientWrapper() {
    HttpClientWrapper wrapper = HttpClientWrapper.create();
    wrapper.addBasicCredentials(BASIC_AUTH_USERNAME, BASIC_AUTH_PASSWORD);
    return wrapper;
}
Also used : HttpClientWrapper(org.opennms.core.web.HttpClientWrapper)

Example 18 with HttpClientWrapper

use of org.opennms.core.web.HttpClientWrapper in project opennms by OpenNMS.

the class GraphMLTopologyIT method importGraph.

private void importGraph() throws IOException, InterruptedException {
    try (HttpClientWrapper client = createClientWrapper()) {
        HttpPost httpPost = new HttpPost(URL);
        httpPost.setHeader("Accept", "application/xml");
        httpPost.setHeader("Content-Type", "application/xml");
        httpPost.setEntity(new StringEntity(IOUtils.toString(GraphMLTopologyIT.class.getResourceAsStream("/topology/graphml/test-topology.xml"), Charsets.UTF_8)));
        CloseableHttpResponse response = client.execute(httpPost);
        assertEquals(201, response.getStatusLine().getStatusCode());
    }
    // We wait to give the GraphMLMetaTopologyFactory the chance to initialize the new Topology
    Thread.sleep(20000);
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) StringEntity(org.apache.http.entity.StringEntity) HttpClientWrapper(org.opennms.core.web.HttpClientWrapper) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse)

Aggregations

HttpClientWrapper (org.opennms.core.web.HttpClientWrapper)18 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)14 HttpGet (org.apache.http.client.methods.HttpGet)7 HttpPost (org.apache.http.client.methods.HttpPost)7 IOException (java.io.IOException)6 StringEntity (org.apache.http.entity.StringEntity)6 URI (java.net.URI)4 URISyntaxException (java.net.URISyntaxException)4 GeneralSecurityException (java.security.GeneralSecurityException)3 HttpEntity (org.apache.http.HttpEntity)3 HttpVersion (org.apache.http.HttpVersion)3 NameValuePair (org.apache.http.NameValuePair)3 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)3 Test (org.junit.Test)3 PollStatus (org.opennms.netmgt.poller.PollStatus)3 ArrayList (java.util.ArrayList)2 ClientProtocolException (org.apache.http.client.ClientProtocolException)2 UrlEncodedFormEntity (org.apache.http.client.entity.UrlEncodedFormEntity)2 URIBuilder (org.apache.http.client.utils.URIBuilder)2 BasicNameValuePair (org.apache.http.message.BasicNameValuePair)2