@Test public void supportsAllTheMethodsWithTheQueryOnlyConvenienceVersion() throws Exception { final Channel server = serve(port, new Echoer("/i-have-all-the-methods")); try { for (Method method : Method.values()) { final HttpClient testSubject = new ApacheCommons4xHttpClient(); final java.lang.reflect.Method m = RemoteObject.class.getMethod(method.name().toLowerCase(), String.class, HeaderField[].class); final RemoteObject o = testSubject.resource("http: final Response response = (Response) m.invoke(o, "?foo=bar", (Object) new HeaderField[]{new GenericHeaderField("echo-foo", "bar")}); assertEquals(ResponseCode.OK, response.code()); assertEquals(method.name().toUpperCase() + " /i-have-all-the-methods?foo=bar\necho-foo=bar\n", bodyInHeader(response)); } } 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);  }