use of org.apache.http.impl.bootstrap.HttpServer in project Manga by herrlock.
the class TestUtils method testExecuteHttpGet.
@Test
public void testExecuteHttpGet() throws ClientProtocolException, IOException {
final String MAGIC_SUPER_SECRET_STRING = "somethingRandom";
HttpRequestHandler requestHandler = new SetStringHttpRequestHandler(MAGIC_SUPER_SECRET_STRING);
HttpServer server = ServerBootstrap.bootstrap().setListenerPort(1337).registerHandler("/", requestHandler).create();
URL url = new URL("http", "localhost", 1337, "/");
Properties p = new Properties();
p.setProperty(Configuration.URL, url.toExternalForm());
DownloadConfiguration conf = DownloadConfiguration.create(p);
ResponseHandler<Boolean> responseHandler = new ResponseEqualsStringResponseHandler(MAGIC_SUPER_SECRET_STRING);
server.start();
Utils.getDataAndExecuteResponseHandler(url, conf, responseHandler);
server.stop();
}
use of org.apache.http.impl.bootstrap.HttpServer in project acceptance-test-harness by jenkinsci.
the class MockUpdateCenter method close.
@Override
public void close() throws IOException {
if (original != null) {
LOGGER.log(Level.INFO, () -> "stopping MockUpdateCenter on http://" + server.getInetAddress().getHostAddress() + ":" + server.getLocalPort() + "/update-center.json");
HttpServer s = server;
// make sure this.server holds a server that is guaranteed to be up
server = null;
s.shutdown(5, TimeUnit.SECONDS);
/* TODO only if RemoteController etc.:
injector.getInstance(Jenkins.class).runScript("DownloadService.signatureCheck = true; Jenkins.instance.updateCenter.sites.replaceBy([new UpdateSite(UpdateCenter.ID_DEFAULT, '%s')])", original);
*/
original = null;
}
}
Aggregations