@Test public void sendsRequests() throws Exception { final Channel server = serve(port, new Echoer("/echo")); try { final HttpClient testSubject = new ApacheCommons4xHttpClient(); final Response response = testSubject .resource("http: .post(DSL.Text("this is my content\nsee it?"), new GenericHeaderField("echo-header-A", "alpha"), new GenericHeaderField("echo-header-B", "beta")); assertEquals( "POST /echo\n" + "echo-header-A=alpha\n" + "echo-header-B=beta\n" + "this is my content\n" + "see it?", HttpObjectAssert.bodyOf(response).asString()); } finally { server.close(); } }
@Override public RemoteObject resource(final String uri) { return new RemoteObject() { @Override public Response trace(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "trace", uri); } @Override public Response put(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "put", uri); } @Override public Response post(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "post", uri); } @Override public Response patch(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "patch", uri); } @Override public Response options(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "options", uri); } @Override public Response head(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "head", uri); } @Override public Response get(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "get", uri); } @Override public Response delete(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "delete", uri); } }; }
ApacheCommons4xHttpClient implements HttpClient { @Override public RemoteObject resource(final String uri) { return new RemoteObject() { @Override public Response trace(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "trace", uri); } @Override public Response put(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "put", uri); } @Override public Response post(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "post", uri); } @Override public Response patch(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "patch", uri); } @Override public Response options(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "options", uri); } @Override public Response head(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "head", uri); } @Override public Response get(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "get", uri); } @Override public Response delete(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "delete", uri); } }; } }
ApacheCommons4xHttpClient implements HttpClient { @Override public RemoteObject resource(final String uri) { return new RemoteObject() { @Override public Response trace(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "trace", uri); } @Override public Response put(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "put", uri); } @Override public Response post(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "post", uri); } @Override public Response patch(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "patch", uri); } @Override public Response options(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "options", uri); } @Override public Response head(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "head", uri); } @Override public Response get(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "get", uri); } @Override public Response delete(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "delete", uri); } }; } ApacheCommons4xHttpClient();  ApacheCommons4xHttpClient(org.apache.http.client.HttpClient client); }
ApacheCommons4xHttpClient implements HttpClient { @Override public RemoteObject resource(final String uri) { return new RemoteObject() { @Override public Response trace(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "trace", uri); } @Override public Response put(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "put", uri); } @Override public Response post(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "post", uri); } @Override public Response patch(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "patch", uri); } @Override public Response options(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "options", uri); } @Override public Response head(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "head", uri); } @Override public Response get(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "get", uri); } @Override public Response delete(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "delete", uri); } }; } ApacheCommons4xHttpClient();  ApacheCommons4xHttpClient(org.apache.http.client.HttpClient client); @Override RemoteObject resource(final String uri); }
ApacheCommons4xHttpClient implements HttpClient { @Override public RemoteObject resource(final String uri) { return new RemoteObject() { @Override public Response trace(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "trace", uri); } @Override public Response put(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "put", uri); } @Override public Response post(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "post", uri); } @Override public Response patch(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "patch", uri); } @Override public Response options(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "options", uri); } @Override public Response head(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "head", uri); } @Override public Response get(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "get", uri); } @Override public Response delete(Representation r, String query, HeaderField ... fields) { return doit(query, r, fields, "delete", uri); } }; } ApacheCommons4xHttpClient();  ApacheCommons4xHttpClient(org.apache.http.client.HttpClient client); @Override RemoteObject resource(final String uri);  }