fixed regression on http headers

This commit is contained in:
Adrian Cole 2010-07-06 22:41:44 -07:00
parent 276e3a76b7
commit 47a843dd24
4 changed files with 57 additions and 59 deletions

View File

@ -10,6 +10,7 @@ import javax.ws.rs.POST;
import javax.ws.rs.PUT; import javax.ws.rs.PUT;
import org.jclouds.http.Payload; import org.jclouds.http.Payload;
import org.jclouds.http.options.HttpRequestOptions;
import org.jclouds.rest.annotations.EndpointParam; import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.ExceptionParser; import org.jclouds.rest.annotations.ExceptionParser;
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404; import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
@ -29,12 +30,20 @@ public interface HttpAsyncClient {
@PUT @PUT
ListenableFuture<Void> put(@EndpointParam URI location, Payload payload); ListenableFuture<Void> put(@EndpointParam URI location, Payload payload);
@PUT
ListenableFuture<Void> put(@EndpointParam URI location, Payload payload,
HttpRequestOptions options);
/** /**
* @see HttpClient#post * @see HttpClient#post
*/ */
@POST @POST
ListenableFuture<Void> post(@EndpointParam URI location, Payload payload); ListenableFuture<Void> post(@EndpointParam URI location, Payload payload);
@POST
ListenableFuture<Void> post(@EndpointParam URI location, Payload payload,
HttpRequestOptions options);
/** /**
* @see HttpClient#exists * @see HttpClient#exists
*/ */
@ -49,6 +58,10 @@ public interface HttpAsyncClient {
@ExceptionParser(ReturnNullOnNotFoundOr404.class) @ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<InputStream> get(@EndpointParam URI location); ListenableFuture<InputStream> get(@EndpointParam URI location);
@GET
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
ListenableFuture<InputStream> get(@EndpointParam URI location, HttpRequestOptions options);
/** /**
* @see HttpClient#delete * @see HttpClient#delete
*/ */

View File

@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout; import org.jclouds.concurrent.Timeout;
import org.jclouds.http.Payload; import org.jclouds.http.Payload;
import org.jclouds.http.options.HttpRequestOptions;
/** /**
* Simple client * Simple client
@ -35,8 +36,12 @@ public interface HttpClient {
void put(URI location, Payload payload); void put(URI location, Payload payload);
void put(URI location, Payload payload, HttpRequestOptions options);
void post(URI location, Payload payload); void post(URI location, Payload payload);
void post(URI location, Payload payload, HttpRequestOptions options);
boolean exists(URI location); boolean exists(URI location);
/** /**
@ -44,6 +49,8 @@ public interface HttpClient {
*/ */
InputStream get(URI location); InputStream get(URI location);
InputStream get(URI location, HttpRequestOptions options);
/** /**
* @return false if the resource didn't exist. * @return false if the resource didn't exist.
*/ */

View File

@ -442,14 +442,14 @@ public class RestAnnotationProcessor<T> {
request.getHeaders().put(HttpHeaders.CONTENT_LENGTH, form.calculateSize() + ""); request.getHeaders().put(HttpHeaders.CONTENT_LENGTH, form.calculateSize() + "");
} else if (formParams.size() > 0) { } else if (formParams.size() > 0) {
if (headers.get(HttpHeaders.CONTENT_TYPE) != null) if (headers.get(HttpHeaders.CONTENT_TYPE).size() == 0)
headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED); headers.put(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_FORM_URLENCODED);
request.setPayload(makeQueryLine(formParams, null, skips)); request.setPayload(makeQueryLine(formParams, null, skips));
} else if (payload != null) { } else if (payload != null) {
request.setPayload(payload); request.setPayload(payload);
if (headers.get(HttpHeaders.CONTENT_LENGTH) != null) if (headers.get(HttpHeaders.CONTENT_LENGTH).size() == 0)
headers.put(HttpHeaders.CONTENT_LENGTH, payload.calculateSize() + ""); headers.put(HttpHeaders.CONTENT_LENGTH, payload.calculateSize() + "");
if (headers.get(HttpHeaders.CONTENT_TYPE) != null) if (headers.get(HttpHeaders.CONTENT_TYPE).size() == 0)
headers.put(HttpHeaders.CONTENT_TYPE, "application/unknown"); headers.put(HttpHeaders.CONTENT_TYPE, "application/unknown");
} }
request.getHeaders().putAll(headers); request.getHeaders().putAll(headers);

View File

@ -397,8 +397,7 @@ public class RestAnnotationProcessorTest {
public void testQuery() throws SecurityException, NoSuchMethodException { public void testQuery() throws SecurityException, NoSuchMethodException {
Method method = TestQuery.class.getMethod("foo"); Method method = TestQuery.class.getMethod("foo");
HttpRequest request = factory(TestQuery.class).createRequest(method, HttpRequest request = factory(TestQuery.class).createRequest(method, new Object[] {});
new Object[] {});
assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getHost(), "localhost");
assertEquals(request.getEndpoint().getPath(), ""); assertEquals(request.getEndpoint().getPath(), "");
assertEquals(request.getEndpoint().getQuery(), "x-ms-version=2009-07-17&x-ms-rubbish=bin"); assertEquals(request.getEndpoint().getQuery(), "x-ms-version=2009-07-17&x-ms-rubbish=bin");
@ -407,12 +406,10 @@ public class RestAnnotationProcessorTest {
public void testQuery2() throws SecurityException, NoSuchMethodException { public void testQuery2() throws SecurityException, NoSuchMethodException {
Method method = TestQuery.class.getMethod("foo2"); Method method = TestQuery.class.getMethod("foo2");
HttpRequest request = factory(TestQuery.class).createRequest(method, HttpRequest request = factory(TestQuery.class).createRequest(method, new Object[] {});
new Object[] {});
assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getHost(), "localhost");
assertEquals(request.getEndpoint().getPath(), ""); assertEquals(request.getEndpoint().getPath(), "");
assertEquals(request.getEndpoint().getQuery(), assertEquals(request.getEndpoint().getQuery(), "x-ms-version=2009-07-17&foo=bar&fooble=baz");
"x-ms-version=2009-07-17&foo=bar&fooble=baz");
assertEquals(request.getMethod(), "FOO"); assertEquals(request.getMethod(), "FOO");
} }
@ -448,8 +445,8 @@ public class RestAnnotationProcessorTest {
} }
private void verifyTestPostOptions(Method method) { private void verifyTestPostOptions(Method method) {
HttpRequest request = factory(TestPayloadParamVarargs.class).createRequest( HttpRequest request = factory(TestPayloadParamVarargs.class).createRequest(method,
method, new Object[] { new HttpRequestOptions() { new Object[] { new HttpRequestOptions() {
public Multimap<String, String> buildMatrixParameters() { public Multimap<String, String> buildMatrixParameters() {
return LinkedHashMultimap.create(); return LinkedHashMultimap.create();
@ -495,8 +492,7 @@ public class RestAnnotationProcessorTest {
public void testCustomMethod() throws SecurityException, NoSuchMethodException { public void testCustomMethod() throws SecurityException, NoSuchMethodException {
Method method = TestCustomMethod.class.getMethod("foo"); Method method = TestCustomMethod.class.getMethod("foo");
HttpRequest request = factory(TestCustomMethod.class).createRequest(method, HttpRequest request = factory(TestCustomMethod.class).createRequest(method, new Object[] {});
new Object[] {});
assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getHost(), "localhost");
assertEquals(request.getEndpoint().getPath(), ""); assertEquals(request.getEndpoint().getPath(), "");
assertEquals(request.getMethod(), "FOO"); assertEquals(request.getMethod(), "FOO");
@ -514,8 +510,7 @@ public class RestAnnotationProcessorTest {
public void testOverriddenMethod() throws SecurityException, NoSuchMethodException { public void testOverriddenMethod() throws SecurityException, NoSuchMethodException {
Method method = TestOverridden.class.getMethod("foo"); Method method = TestOverridden.class.getMethod("foo");
HttpRequest request = factory(TestOverridden.class).createRequest(method, HttpRequest request = factory(TestOverridden.class).createRequest(method, new Object[] {});
new Object[] {});
assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getHost(), "localhost");
assertEquals(request.getEndpoint().getPath(), ""); assertEquals(request.getEndpoint().getPath(), "");
assertEquals(request.getMethod(), "POST"); assertEquals(request.getMethod(), "POST");
@ -535,8 +530,8 @@ public class RestAnnotationProcessorTest {
public void testOverriddenEndpointMethod() throws SecurityException, NoSuchMethodException { public void testOverriddenEndpointMethod() throws SecurityException, NoSuchMethodException {
Method method = TestOverriddenEndpoint.class.getMethod("foo"); Method method = TestOverriddenEndpoint.class.getMethod("foo");
HttpRequest request = factory(TestOverriddenEndpoint.class).createRequest( HttpRequest request = factory(TestOverriddenEndpoint.class).createRequest(method,
method, new Object[] {}); new Object[] {});
assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getHost(), "localhost");
assertEquals(request.getEndpoint().getPort(), 1111); assertEquals(request.getEndpoint().getPort(), 1111);
assertEquals(request.getEndpoint().getPath(), ""); assertEquals(request.getEndpoint().getPath(), "");
@ -545,8 +540,8 @@ public class RestAnnotationProcessorTest {
public void testOverriddenEndpointParameter() throws SecurityException, NoSuchMethodException { public void testOverriddenEndpointParameter() throws SecurityException, NoSuchMethodException {
Method method = TestOverriddenEndpoint.class.getMethod("foo", URI.class); Method method = TestOverriddenEndpoint.class.getMethod("foo", URI.class);
HttpRequest request = factory(TestOverriddenEndpoint.class).createRequest( HttpRequest request = factory(TestOverriddenEndpoint.class).createRequest(method,
method, new Object[] { URI.create("http://wowsa:8001") }); new Object[] { URI.create("http://wowsa:8001") });
assertEquals(request.getEndpoint().getHost(), "wowsa"); assertEquals(request.getEndpoint().getHost(), "wowsa");
assertEquals(request.getEndpoint().getPort(), 8001); assertEquals(request.getEndpoint().getPort(), 8001);
assertEquals(request.getEndpoint().getPath(), ""); assertEquals(request.getEndpoint().getPath(), "");
@ -591,8 +586,7 @@ public class RestAnnotationProcessorTest {
public void testCreatePostRequestNullOk() throws SecurityException, NoSuchMethodException { public void testCreatePostRequestNullOk() throws SecurityException, NoSuchMethodException {
Method method = TestPost.class.getMethod("post", String.class); Method method = TestPost.class.getMethod("post", String.class);
HttpRequest request = factory(TestPost.class).createRequest(method, HttpRequest request = factory(TestPost.class).createRequest(method, new Object[] { null });
new Object[] { null });
assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getHost(), "localhost");
assertEquals(request.getEndpoint().getPath(), ""); assertEquals(request.getEndpoint().getPath(), "");
assertEquals(request.getMethod(), HttpMethod.POST); assertEquals(request.getMethod(), HttpMethod.POST);
@ -604,8 +598,7 @@ public class RestAnnotationProcessorTest {
public void testCreatePostJsonRequest() throws SecurityException, NoSuchMethodException { public void testCreatePostJsonRequest() throws SecurityException, NoSuchMethodException {
Method method = TestPost.class.getMethod("postAsJson", String.class); Method method = TestPost.class.getMethod("postAsJson", String.class);
HttpRequest request = factory(TestPost.class).createRequest(method, HttpRequest request = factory(TestPost.class).createRequest(method, new Object[] { "data" });
new Object[] { "data" });
assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getHost(), "localhost");
assertEquals(request.getEndpoint().getPath(), ""); assertEquals(request.getEndpoint().getPath(), "");
assertEquals(request.getMethod(), HttpMethod.POST); assertEquals(request.getMethod(), HttpMethod.POST);
@ -638,8 +631,7 @@ public class RestAnnotationProcessorTest {
public void testCreatePostWithMethodBinder() throws SecurityException, NoSuchMethodException { public void testCreatePostWithMethodBinder() throws SecurityException, NoSuchMethodException {
Method method = TestPost.class.getMethod("postWithMethodBinder", String.class); Method method = TestPost.class.getMethod("postWithMethodBinder", String.class);
HttpRequest request = factory(TestPost.class).createRequest(method, HttpRequest request = factory(TestPost.class).createRequest(method, new Object[] { "data", });
new Object[] { "data", });
assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getHost(), "localhost");
assertEquals(request.getEndpoint().getPath(), "/data"); assertEquals(request.getEndpoint().getPath(), "/data");
assertEquals(request.getMethod(), HttpMethod.POST); assertEquals(request.getMethod(), HttpMethod.POST);
@ -825,8 +817,7 @@ public class RestAnnotationProcessorTest {
public void testCreatePutWithMethodBinder() throws SecurityException, NoSuchMethodException { public void testCreatePutWithMethodBinder() throws SecurityException, NoSuchMethodException {
Method method = TestPut.class.getMethod("putWithMethodBinder", String.class); Method method = TestPut.class.getMethod("putWithMethodBinder", String.class);
HttpRequest request = factory(TestPut.class).createRequest(method, HttpRequest request = factory(TestPut.class).createRequest(method, new Object[] { "data", });
new Object[] { "data", });
assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getHost(), "localhost");
assertEquals(request.getEndpoint().getPath(), "/data"); assertEquals(request.getEndpoint().getPath(), "/data");
assertEquals(request.getMethod(), HttpMethod.PUT); assertEquals(request.getMethod(), HttpMethod.PUT);
@ -841,8 +832,7 @@ public class RestAnnotationProcessorTest {
public void testCreatePutWithMethodProduces() throws SecurityException, NoSuchMethodException { public void testCreatePutWithMethodProduces() throws SecurityException, NoSuchMethodException {
Method method = TestPut.class.getMethod("putWithMethodBinderProduces", String.class); Method method = TestPut.class.getMethod("putWithMethodBinderProduces", String.class);
HttpRequest request = factory(TestPut.class).createRequest(method, HttpRequest request = factory(TestPut.class).createRequest(method, new Object[] { "data", });
new Object[] { "data", });
assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getHost(), "localhost");
assertEquals(request.getEndpoint().getPath(), "/data"); assertEquals(request.getEndpoint().getPath(), "/data");
assertEquals(request.getMethod(), HttpMethod.PUT); assertEquals(request.getMethod(), HttpMethod.PUT);
@ -856,8 +846,7 @@ public class RestAnnotationProcessorTest {
public void testCreatePutWithMethodConsumes() throws SecurityException, NoSuchMethodException { public void testCreatePutWithMethodConsumes() throws SecurityException, NoSuchMethodException {
Method method = TestPut.class.getMethod("putWithMethodBinderConsumes", String.class); Method method = TestPut.class.getMethod("putWithMethodBinderConsumes", String.class);
HttpRequest request = factory(TestPut.class).createRequest(method, HttpRequest request = factory(TestPut.class).createRequest(method, new Object[] { "data", });
new Object[] { "data", });
assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getHost(), "localhost");
assertEquals(request.getEndpoint().getPath(), "/data"); assertEquals(request.getEndpoint().getPath(), "/data");
assertEquals(request.getMethod(), HttpMethod.PUT); assertEquals(request.getMethod(), HttpMethod.PUT);
@ -899,8 +888,7 @@ public class RestAnnotationProcessorTest {
@Test @Test
public void testRequestFilter() throws SecurityException, NoSuchMethodException { public void testRequestFilter() throws SecurityException, NoSuchMethodException {
Method method = TestRequestFilter.class.getMethod("get"); Method method = TestRequestFilter.class.getMethod("get");
HttpRequest request = factory(TestRequestFilter.class).createRequest(method, HttpRequest request = factory(TestRequestFilter.class).createRequest(method, new Object[] {});
new Object[] {});
assertEquals(request.getFilters().size(), 2); assertEquals(request.getFilters().size(), 2);
assertEquals(request.getFilters().get(0).getClass(), TestRequestFilter1.class); assertEquals(request.getFilters().get(0).getClass(), TestRequestFilter1.class);
assertEquals(request.getFilters().get(1).getClass(), TestRequestFilter2.class); assertEquals(request.getFilters().get(1).getClass(), TestRequestFilter2.class);
@ -908,8 +896,7 @@ public class RestAnnotationProcessorTest {
public void testRequestFilterOverride() throws SecurityException, NoSuchMethodException { public void testRequestFilterOverride() throws SecurityException, NoSuchMethodException {
Method method = TestRequestFilter.class.getMethod("getOverride"); Method method = TestRequestFilter.class.getMethod("getOverride");
HttpRequest request = factory(TestRequestFilter.class).createRequest(method, HttpRequest request = factory(TestRequestFilter.class).createRequest(method, new Object[] {});
new Object[] {});
assertEquals(request.getFilters().size(), 1); assertEquals(request.getFilters().size(), 1);
assertEquals(request.getFilters().get(0).getClass(), TestRequestFilter2.class); assertEquals(request.getFilters().get(0).getClass(), TestRequestFilter2.class);
} }
@ -957,10 +944,9 @@ public class RestAnnotationProcessorTest {
@Test(enabled = false) @Test(enabled = false)
public void testConstantPathParam() throws SecurityException, NoSuchMethodException, IOException { public void testConstantPathParam() throws SecurityException, NoSuchMethodException, IOException {
Method method = TestConstantPathParam.class.getMethod("twoPaths", String.class, String.class); Method method = TestConstantPathParam.class.getMethod("twoPaths", String.class, String.class);
HttpRequest request = factory(TestConstantPathParam.class).createRequest( HttpRequest request = factory(TestConstantPathParam.class).createRequest(method,
method, new Object[] { "1", "localhost" }); new Object[] { "1", "localhost" });
assertRequestLineEquals(request, assertRequestLineEquals(request, "GET http://localhost:9999/v1/ralphie/1/localhost HTTP/1.1");
"GET http://localhost:9999/v1/ralphie/1/localhost HTTP/1.1");
assertHeadersEqual(request, ""); assertHeadersEqual(request, "");
assertPayloadEquals(request, null); assertPayloadEquals(request, null);
} }
@ -1029,8 +1015,7 @@ public class RestAnnotationProcessorTest {
public void testQueryParamExtractor() throws SecurityException, NoSuchMethodException, public void testQueryParamExtractor() throws SecurityException, NoSuchMethodException,
IOException { IOException {
Method method = TestPath.class.getMethod("oneQueryParamExtractor", String.class); Method method = TestPath.class.getMethod("oneQueryParamExtractor", String.class);
HttpRequest request = factory(TestPath.class).createRequest(method, HttpRequest request = factory(TestPath.class).createRequest(method, "localhost");
"localhost");
assertRequestLineEquals(request, "GET http://localhost:9999/?one=l HTTP/1.1"); assertRequestLineEquals(request, "GET http://localhost:9999/?one=l HTTP/1.1");
assertHeadersEqual(request, ""); assertHeadersEqual(request, "");
assertPayloadEquals(request, null); assertPayloadEquals(request, null);
@ -1191,9 +1176,8 @@ public class RestAnnotationProcessorTest {
UnsupportedEncodingException { UnsupportedEncodingException {
Method method = TestMapMatrixParams.class.getMethod("action", String.class, String.class, Method method = TestMapMatrixParams.class.getMethod("action", String.class, String.class,
Map.class); Map.class);
HttpRequest request = factory(TestMapMatrixParams.class) HttpRequest request = factory(TestMapMatrixParams.class).createRequest(method,
.createRequest(method, new Object[] { "robot", "kill", ImmutableMap.of("death", "slow") });
new Object[] { "robot", "kill", ImmutableMap.of("death", "slow") });
assertEquals(request.getRequestLine(), assertEquals(request.getRequestLine(),
"POST http://localhost:9999/objects/robot/action/kill;death=slow HTTP/1.1"); "POST http://localhost:9999/objects/robot/action/kill;death=slow HTTP/1.1");
assertEquals(request.getHeaders().size(), 0); assertEquals(request.getHeaders().size(), 0);
@ -1587,8 +1571,7 @@ public class RestAnnotationProcessorTest {
public void testCreateGetQuery() throws SecurityException, NoSuchMethodException { public void testCreateGetQuery() throws SecurityException, NoSuchMethodException {
Method method = TestRequest.class.getMethod("getQuery", String.class); Method method = TestRequest.class.getMethod("getQuery", String.class);
HttpRequest request = factory(TestRequest.class).createRequest(method, HttpRequest request = factory(TestRequest.class).createRequest(method, new Object[] { "1" });
new Object[] { "1" });
assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getHost(), "localhost");
assertEquals(request.getEndpoint().getPath(), "/1"); assertEquals(request.getEndpoint().getPath(), "/1");
assertEquals(request.getEndpoint().getQuery(), "max-keys=0"); assertEquals(request.getEndpoint().getQuery(), "max-keys=0");
@ -1598,8 +1581,7 @@ public class RestAnnotationProcessorTest {
public void testCreateGetQueryNull() throws SecurityException, NoSuchMethodException { public void testCreateGetQueryNull() throws SecurityException, NoSuchMethodException {
Method method = TestRequest.class.getMethod("getQueryNull", String.class); Method method = TestRequest.class.getMethod("getQueryNull", String.class);
HttpRequest request = factory(TestRequest.class).createRequest(method, HttpRequest request = factory(TestRequest.class).createRequest(method, new Object[] { "1" });
new Object[] { "1" });
assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getHost(), "localhost");
assertEquals(request.getEndpoint().getPath(), "/1"); assertEquals(request.getEndpoint().getPath(), "/1");
assertEquals(request.getEndpoint().getQuery(), "acl"); assertEquals(request.getEndpoint().getQuery(), "acl");
@ -1624,14 +1606,11 @@ public class RestAnnotationProcessorTest {
assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getHost(), "localhost");
assertEquals(request.getEndpoint().getPath(), "/1"); assertEquals(request.getEndpoint().getPath(), "/1");
assertEquals(request.getMethod(), HttpMethod.PUT); assertEquals(request.getMethod(), HttpMethod.PUT);
assertEquals(request.getHeaders().size(), 3);
assertEquals(request.getHeaders().get(HttpHeaders.HOST), Collections assertEquals(HttpUtils.sortAndConcatHeadersIntoString(request.getHeaders()),
.singletonList("localhost")); "Content-Length: 3\nContent-Type: application/unknown\nHost: localhost\n");
assertEquals(request.getPayload().toString(), "foo"); assertEquals(request.getPayload().toString(), "foo");
assertEquals(request.getHeaders().get(HttpHeaders.CONTENT_TYPE), Collections
.singletonList("application/unknown"));
assertEquals(request.getHeaders().get(HttpHeaders.CONTENT_LENGTH), Collections
.singletonList("foo".getBytes().length + ""));
} }
@DataProvider(name = "strings") @DataProvider(name = "strings")
@ -1698,8 +1677,8 @@ public class RestAnnotationProcessorTest {
@Test @Test
public void testVirtualHostMethod() throws SecurityException, NoSuchMethodException { public void testVirtualHostMethod() throws SecurityException, NoSuchMethodException {
Method method = TestVirtualHostMethod.class.getMethod("get", String.class, String.class); Method method = TestVirtualHostMethod.class.getMethod("get", String.class, String.class);
HttpRequest request = factory(TestVirtualHostMethod.class).createRequest( HttpRequest request = factory(TestVirtualHostMethod.class).createRequest(method,
method, new Object[] { "1", "localhost" }); new Object[] { "1", "localhost" });
assertEquals(request.getEndpoint().getHost(), "localhost"); assertEquals(request.getEndpoint().getHost(), "localhost");
assertEquals(request.getEndpoint().getPath(), "/1"); assertEquals(request.getEndpoint().getPath(), "/1");
assertEquals(request.getMethod(), HttpMethod.GET); assertEquals(request.getMethod(), HttpMethod.GET);
@ -2001,8 +1980,7 @@ public class RestAnnotationProcessorTest {
} }
protected void assertPayloadEquals(HttpRequest request, String toMatch) protected void assertPayloadEquals(HttpRequest request, String toMatch) throws IOException {
throws IOException {
if (request.getPayload() == null) { if (request.getPayload() == null) {
assertNull(toMatch); assertNull(toMatch);
} else { } else {