use of org.sonatype.goodies.httpfixture.server.jetty.behaviour.Consumer in project goodies by sonatype.
the class JettyProxyProviderTest method testProxyPut.
@Test
public void testProxyPut() throws Exception {
JettyProxyProvider proxy = new JettyProxyProvider();
Consumer consumer = new Consumer();
proxy.addBehaviour("/*", new Debug(), consumer);
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.setDoOutput(true);
conn.setRequestMethod("PUT");
conn.connect();
byte[] bytes = "TestPut".getBytes("US-ASCII");
conn.getOutputStream().write(bytes);
conn.getOutputStream().close();
assertEquals(200, conn.getResponseCode());
assertEquals(bytes.length, consumer.getTotal());
conn.disconnect();
}
Aggregations