Skip to content
This repository has been archived by the owner on Jul 13, 2020. It is now read-only.

Commit

Permalink
use infrautils' TestHttpClient
Browse files Browse the repository at this point in the history
  • Loading branch information
vorburger committed Jan 23, 2019
1 parent e1e70f1 commit 32ba701
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
package org.opendaylight.infrautils.testutils;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.aaa.web.WebServer;
import org.opendaylight.infrautils.testutils.web.TestWebClient;
import org.opendaylight.infrautils.testutils.web.TestWebClient.Method;

/**
* HTTP Client.
Expand All @@ -22,21 +22,14 @@
@Singleton
public class TestHttpClient {

public enum Method {
GET, POST, HEAD, OPTIONS, PUT, DELETE, TRACE
}

private final WebServer webServer;
private final TestWebClient webClient;

@Inject
public TestHttpClient(WebServer webServer) {
this.webServer = webServer;
this.webClient = new TestWebClient(webServer.getBaseURL());
}

public int responseCode(Method httpMethod, String path) throws IOException {
URL url = new URL(webServer.getBaseURL() + path);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod(httpMethod.name());
return conn.getResponseCode();
return webClient.request(httpMethod, path).getStatus();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package org.opendaylight.neutron.simple.test;

import static com.google.common.truth.Truth.assertThat;
import static org.opendaylight.infrautils.testutils.TestHttpClient.Method.GET;
import static org.opendaylight.infrautils.testutils.web.TestWebClient.Method.GET;

import java.io.IOException;
import javax.inject.Inject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
package org.opendaylight.restconf.simple.test;

import static com.google.common.truth.Truth.assertThat;
import static org.opendaylight.infrautils.testutils.TestHttpClient.Method.GET;
import static org.opendaylight.infrautils.testutils.web.TestWebClient.Method.GET;

import java.io.IOException;
import javax.inject.Inject;
Expand Down

0 comments on commit 32ba701

Please sign in to comment.