Search in sources :

Example 1 with HttpTestServer

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);
    }
}
Also used : HttpTestServer(aQute.http.testservers.HttpTestServer) FixedIndexedRepo(aQute.bnd.deployer.repository.FixedIndexedRepo) Workspace(aQute.bnd.build.Workspace)

Example 2 with HttpTestServer

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;
}
Also used : HttpTestServer(aQute.http.testservers.HttpTestServer)

Example 3 with HttpTestServer

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);
    }
}
Also used : HttpTestServer(aQute.http.testservers.HttpTestServer) FixedIndexedRepo(aQute.bnd.deployer.repository.FixedIndexedRepo) Workspace(aQute.bnd.build.Workspace)

Example 4 with HttpTestServer

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);
    }
}
Also used : HttpURLConnection(java.net.HttpURLConnection) HttpTestServer(aQute.http.testservers.HttpTestServer) URL(java.net.URL)

Example 5 with HttpTestServer

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;
}
Also used : Config(aQute.http.testservers.HttpTestServer.Config) Config(aQute.http.testservers.HttpTestServer.Config) HttpTestServer(aQute.http.testservers.HttpTestServer)

Aggregations

HttpTestServer (aQute.http.testservers.HttpTestServer)22 URL (java.net.URL)10 HttpURLConnection (java.net.HttpURLConnection)7 Workspace (aQute.bnd.build.Workspace)5 FixedIndexedRepo (aQute.bnd.deployer.repository.FixedIndexedRepo)2 Repository (aQute.bnd.jpm.Repository)2 ResourceDescriptor (aQute.bnd.service.repository.SearchableRepository.ResourceDescriptor)2 Config (aQute.http.testservers.HttpTestServer.Config)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 URI (java.net.URI)2 HttpClient (aQute.bnd.http.HttpClient)1 URLConnector (aQute.bnd.service.url.URLConnector)1 Version (aQute.bnd.version.Version)1 Httpbin (aQute.http.testservers.Httpbin)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 X509Certificate (java.security.cert.X509Certificate)1 Matcher (java.util.regex.Matcher)1 GZIPInputStream (java.util.zip.GZIPInputStream)1