Search in sources :

Example 6 with Debug

use of org.sonatype.goodies.httpfixture.server.jetty.behaviour.Debug in project goodies by sonatype.

the class JettyProxyProviderTest method testProxyGet.

@Test
public void testProxyGet() throws Exception {
    JettyProxyProvider proxy = new JettyProxyProvider();
    proxy.addBehaviour("/*", new Debug(), new Content());
    proxy.start();
    URL url = new URL("http://speutel.invalid/foo");
    SocketAddress sa = new InetSocketAddress("localhost", proxy.getPort());
    Proxy p = new Proxy(Type.HTTP, sa);
    HttpURLConnection conn = (HttpURLConnection) url.openConnection(p);
    conn.setDoInput(true);
    conn.connect();
    assertEquals(200, conn.getResponseCode());
    assertEquals("foo", read(conn.getContent()).trim());
    conn.disconnect();
}
Also used : Proxy(java.net.Proxy) HttpURLConnection(java.net.HttpURLConnection) Content(org.sonatype.goodies.httpfixture.server.jetty.behaviour.Content) InetSocketAddress(java.net.InetSocketAddress) SocketAddress(java.net.SocketAddress) InetSocketAddress(java.net.InetSocketAddress) Debug(org.sonatype.goodies.httpfixture.server.jetty.behaviour.Debug) URL(java.net.URL) Test(org.junit.Test)

Aggregations

HttpURLConnection (java.net.HttpURLConnection)6 InetSocketAddress (java.net.InetSocketAddress)6 Proxy (java.net.Proxy)6 SocketAddress (java.net.SocketAddress)6 URL (java.net.URL)6 Test (org.junit.Test)6 Debug (org.sonatype.goodies.httpfixture.server.jetty.behaviour.Debug)6 Content (org.sonatype.goodies.httpfixture.server.jetty.behaviour.Content)5 Authenticator (java.net.Authenticator)3 PasswordAuthentication (java.net.PasswordAuthentication)3 IOException (java.io.IOException)1 Consumer (org.sonatype.goodies.httpfixture.server.jetty.behaviour.Consumer)1