use of aQute.http.testservers.HttpTestServer in project bnd by bndtools.
the class HttpTestServerTest method getHttp.
public HttpTestServer getHttp() throws Exception {
HttpTestServer.Config config = new Config();
config.https = false;
HttpTestServer http = new Httpbin(config);
http.start();
return http;
}
use of aQute.http.testservers.HttpTestServer in project bnd by bndtools.
the class HttpTestServerTest method testGet.
public void testGet() throws Exception {
try (HttpTestServer http = getHttp()) {
Map<String, ?> map = get(http, MAP_REF, "/get");
assertNotNull(map.get("headers"));
}
}
use of aQute.http.testservers.HttpTestServer in project bnd by bndtools.
the class HttpTestServerTest method testCorrectCommonName.
public void testCorrectCommonName() throws Exception {
HttpTestServer http = getHttps();
X509Certificate cert = http.getCertificateChain()[0];
String name = cert.getSubjectDN().getName();
Matcher m = DN_P.matcher(name);
assertTrue(m.find());
assertEquals(m.group("cn"), http.getAddress().getHostName());
}
use of aQute.http.testservers.HttpTestServer in project bnd by bndtools.
the class HttpTestServerTest method testStatus.
public void testStatus() throws Exception {
try (HttpTestServer http = getHttp()) {
URL uri = new URI(http.getBaseURI() + "/status/500").toURL();
HttpURLConnection connection = (HttpURLConnection) uri.openConnection();
assertEquals(500, connection.getResponseCode());
}
}
use of aQute.http.testservers.HttpTestServer in project bnd by bndtools.
the class HttpTestServerTest method testURI.
public void testURI() throws Exception {
try (HttpTestServer http = getHttps()) {
URI uri = http.getBaseURI();
assertEquals(http.getAddress().getPort(), uri.getPort());
assertEquals(http.getAddress().getHostName(), uri.getHost());
assertEquals("https", uri.getScheme());
}
}
Aggregations