use of aQute.http.testservers.HttpTestServer in project bnd by bndtools.
the class IndexedReposWithComms method testIndexedRepo.
/*
* Uses workspaces/indexed Sets up a FixedIndexedRepo to the local server.
*/
public void testIndexedRepo() throws IOException, Exception {
try (HttpTestServer ht = http()) {
createSecureSocks5();
Workspace ws = Workspace.getWorkspace(aQute.lib.io.IO.getFile("workspaces/indexed"));
assertNotNull(ws);
ws.setProperty("repo", ht.getBaseURI().toASCIIString() + "/index");
FixedIndexedRepo plugin = ws.getPlugin(FixedIndexedRepo.class);
assertTrue(ws.check());
assertNotNull(plugin);
List<String> list = plugin.list(null);
assertTrue(ws.check());
assertTrue(list.size() > 0);
}
}
use of aQute.http.testservers.HttpTestServer in project bnd by bndtools.
the class IndexedReposWithComms method https.
HttpTestServer https() throws Exception, IOException {
HttpTestServer.Config config = new HttpTestServer.Config();
config.host = "localhost";
config.https = true;
HttpTestServer ht = new HS(config);
ht.start();
return ht;
}
use of aQute.http.testservers.HttpTestServer in project bnd by bndtools.
the class IndexedReposWithComms method testIndexedRepoWithPassword.
/*
* Uses workspaces/indexed Sets up a FixedIndexedRepo to the local server.
*/
public void testIndexedRepoWithPassword() throws IOException, Exception {
try (HttpTestServer ht = https()) {
createSecureSocks5();
Workspace ws = Workspace.getWorkspace(aQute.lib.io.IO.getFile("workspaces/indexed"));
assertNotNull(ws);
ws.setProperty("-connection-settings", "${build}/settings-withpassword.xml");
ws.setProperty("repo", ht.getBaseURI().toASCIIString() + "/index-auth/user/good");
FixedIndexedRepo plugin = ws.getPlugin(FixedIndexedRepo.class);
assertTrue(ws.check());
assertNotNull(plugin);
List<String> list = plugin.list(null);
assertTrue(ws.check());
assertTrue(list.size() > 0);
}
}
use of aQute.http.testservers.HttpTestServer in project bnd by bndtools.
the class HttpTestServerTest method testPost.
public void testPost() throws IOException, Exception {
try (HttpTestServer http = getHttp()) {
URL url = new URL(http.getBaseURI() + "/put");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setDoOutput(true);
con.setRequestMethod("POST");
IO.copy("ABC".getBytes(), con.getOutputStream());
assertEquals(200, con.getResponseCode());
String s = IO.collect(con.getInputStream());
assertEquals("ABC", s);
}
}
use of aQute.http.testservers.HttpTestServer in project bnd by bndtools.
the class HttpTestServerTest method getHttps.
public HttpTestServer getHttps() throws Exception {
HttpTestServer.Config config = new Config();
config.https = true;
HttpTestServer http = new HttpTestServer(config);
http.start();
return http;
}
Aggregations