Package org.apache.http.localserver

Examples of org.apache.http.localserver.LocalTestServer


        TrustManager[] trustmanagers = tmfactory.getTrustManagers();
       
        SSLContext sslcontext = SSLContext.getInstance("TLSv1");
        sslcontext.init(keymanagers, trustmanagers, null);
       
        LocalTestServer server = new LocalTestServer(null, null, null, sslcontext);
        server.registerDefaultHandlers();
        server.start();
        try {
           
            TestX509HostnameVerifier hostnameVerifier = new TestX509HostnameVerifier();
           
            SSLSocketFactory socketFactory = new SSLSocketFactory(sslcontext);
            socketFactory.setHostnameVerifier(hostnameVerifier);
           
            Scheme https = new Scheme("https", socketFactory, 443);
            DefaultHttpClient httpclient = new DefaultHttpClient();
            httpclient.getConnectionManager().getSchemeRegistry().register(https);
           
            HttpHost target = new HttpHost(
                    LocalTestServer.TEST_SERVER_ADDR.getHostName(),
                    server.getServicePort(),
                    "https");
            HttpGet httpget = new HttpGet("/random/100");
            HttpResponse response = httpclient.execute(target, httpget);
            assertEquals(200, response.getStatusLine().getStatusCode());
            assertTrue(hostnameVerifier.isFired());
        } finally {
            server.stop();
        }
    }
View Full Code Here


        httpproc.addInterceptor(new ResponseDate());
        httpproc.addInterceptor(new ResponseServer());
        httpproc.addInterceptor(new ResponseContent());
        httpproc.addInterceptor(new ResponseConnControl());
       
        this.localServer = new LocalTestServer(httpproc, null);
        this.localServer.register("/random/*", new RandomHandler());
        this.localServer.start();

        InetSocketAddress saddress = (InetSocketAddress) this.localServer.getServiceAddress();
       
View Full Code Here

        httpproc.addInterceptor(new ResponseDate());
        httpproc.addInterceptor(new ResponseServer());
        httpproc.addInterceptor(new ResponseContent());
        httpproc.addInterceptor(new AlwaysCloseConn());
       
        this.localServer = new LocalTestServer(httpproc, null);
        this.localServer.register("/random/*", new RandomHandler());
        this.localServer.start();

        InetSocketAddress saddress = (InetSocketAddress) this.localServer.getServiceAddress();
       
View Full Code Here

        httpproc.addInterceptor(new ResponseDate());
        httpproc.addInterceptor(new ResponseServer());
        httpproc.addInterceptor(new ResponseContent());
        httpproc.addInterceptor(new ResponseConnControl());
       
        this.localServer = new LocalTestServer(httpproc, null);
        this.localServer.register("/random/*", new RandomHandler());
        this.localServer.start();

        InetSocketAddress saddress = (InetSocketAddress) this.localServer.getServiceAddress();
       
View Full Code Here

        httpproc.addInterceptor(new ResponseServer());
        httpproc.addInterceptor(new ResponseContent());
        httpproc.addInterceptor(new ResponseConnControl());
        httpproc.addInterceptor(new ResponseKeepAlive());
       
        this.localServer = new LocalTestServer(httpproc, null);
        this.localServer.register("/random/*", new RandomHandler());
        this.localServer.start();

        InetSocketAddress saddress = (InetSocketAddress) this.localServer.getServiceAddress();
       
View Full Code Here

    }

  }

  protected String startAuthorizationCallbackServer(String clientId, String secret) throws Exception {
    this.oauthClientServer = new LocalTestServer(null, null);
    oauthClientServer.start();
    // report how to access the server
    String oauthClientBaseUri = String.format("http://%s:%d", oauthClientServer.getServiceAddress().getHostName(),
            oauthClientServer.getServiceAddress().getPort());
View Full Code Here

        proc.addInterceptor(new ResponseServer());
        proc.addInterceptor(new ResponseContent());
        proc.addInterceptor(new ResponseConnControl());
        proc.addInterceptor(new RequestBasicAuth());
        proc.addInterceptor(new ResponseBasicUnauthorized());
        server = new LocalTestServer(proc, null);
        server.start();
        InetSocketAddress address = server.getServiceAddress();
        baseUrl = new URL("http", address.getHostName(), address.getPort(), "/").toExternalForm();
    }
View Full Code Here

*/
public class TestDefaultClientRequestDirector extends BasicServerTestBase {

    @Before
    public void setUp() throws Exception {
        localServer = new LocalTestServer(null, null);
        localServer.registerDefaultHandlers();
        localServer.start();
    }
View Full Code Here

*/
public class TestRedirects extends BasicServerTestBase {

    @Before
    public void setUp() throws Exception {
        localServer = new LocalTestServer(null, null);
        localServer.registerDefaultHandlers();
        localServer.start();
    }
View Full Code Here

  protected String servletName = ProxyServlet.class.getName();
  protected String servletPath = "/proxyMe";

  @Before
  public void setUp() throws Exception {
    localTestServer = new LocalTestServer(null, null);
    localTestServer.start();
    localTestServer.register("/targetPath*", new RequestInfoHandler());//matches /targetPath and /targetPath/blahblah

    servletRunner = new ServletRunner();

View Full Code Here

TOP

Related Classes of org.apache.http.localserver.LocalTestServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.