mirror of https://github.com/apache/jclouds.git
commit
6a1f9e3fbe
|
@ -423,7 +423,15 @@ public class RestAnnotationProcessor<T> {
|
||||||
requestBuilder = GeneratedHttpRequest.Builder.<T> from(r);
|
requestBuilder = GeneratedHttpRequest.Builder.<T> from(r);
|
||||||
endpoint = r.getEndpoint();
|
endpoint = r.getEndpoint();
|
||||||
} else {
|
} else {
|
||||||
requestBuilder = GeneratedHttpRequest.<T> builder();
|
/*
|
||||||
|
* Can't use GeneratedHttpRequest.<T>builder() because the T is too
|
||||||
|
* general for the compiler to be able to distinguish between
|
||||||
|
* GeneratedHttpRequest.builder() and HttpMessage.builder() - the
|
||||||
|
* latter is available because GHR inherits from HM.
|
||||||
|
*
|
||||||
|
* See http://code.google.com/p/jclouds/issues/detail?id=461
|
||||||
|
*/
|
||||||
|
requestBuilder = new GeneratedHttpRequest.Builder<T>();
|
||||||
requestBuilder.method(getHttpMethodOrConstantOrThrowException(method));
|
requestBuilder.method(getHttpMethodOrConstantOrThrowException(method));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,8 @@ public class BindMapToStringPayloadTest {
|
||||||
@Test
|
@Test
|
||||||
public void testCorrect() throws SecurityException, NoSuchMethodException {
|
public void testCorrect() throws SecurityException, NoSuchMethodException {
|
||||||
Method testPayload = TestPayload.class.getMethod("testPayload", String.class);
|
Method testPayload = TestPayload.class.getMethod("testPayload", String.class);
|
||||||
GeneratedHttpRequest<TestPayload> request = GeneratedHttpRequest.<TestPayload> builder()
|
// can't use GHR.builder() - see http://code.google.com/p/jclouds/issues/detail?id=461
|
||||||
|
GeneratedHttpRequest<TestPayload> request = new GeneratedHttpRequest.Builder<TestPayload>()
|
||||||
.declaring(TestPayload.class).javaMethod(testPayload).args(ImmutableList.<Object> of("robot"))
|
.declaring(TestPayload.class).javaMethod(testPayload).args(ImmutableList.<Object> of("robot"))
|
||||||
.method(HttpMethod.POST).endpoint(URI.create("http://localhost")).build();
|
.method(HttpMethod.POST).endpoint(URI.create("http://localhost")).build();
|
||||||
|
|
||||||
|
@ -68,7 +69,8 @@ public class BindMapToStringPayloadTest {
|
||||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||||
public void testMustHavePayloadAnnotation() throws SecurityException, NoSuchMethodException {
|
public void testMustHavePayloadAnnotation() throws SecurityException, NoSuchMethodException {
|
||||||
Method noPayload = TestPayload.class.getMethod("noPayload", String.class);
|
Method noPayload = TestPayload.class.getMethod("noPayload", String.class);
|
||||||
GeneratedHttpRequest<TestPayload> request = GeneratedHttpRequest.<TestPayload> builder()
|
// can't use GHR.builder() - see http://code.google.com/p/jclouds/issues/detail?id=461
|
||||||
|
GeneratedHttpRequest<TestPayload> request = new GeneratedHttpRequest.Builder<TestPayload>()
|
||||||
.declaring(TestPayload.class).javaMethod(noPayload).args(ImmutableList.<Object> of("robot"))
|
.declaring(TestPayload.class).javaMethod(noPayload).args(ImmutableList.<Object> of("robot"))
|
||||||
.method(HttpMethod.POST).endpoint(URI.create("http://localhost")).build();
|
.method(HttpMethod.POST).endpoint(URI.create("http://localhost")).build();
|
||||||
binder().bindToRequest(request, ImmutableMap.of("fooble", "robot"));
|
binder().bindToRequest(request, ImmutableMap.of("fooble", "robot"));
|
||||||
|
|
|
@ -1816,7 +1816,8 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
|
||||||
public void oneTransformerWithContext() throws SecurityException, NoSuchMethodException {
|
public void oneTransformerWithContext() throws SecurityException, NoSuchMethodException {
|
||||||
RestAnnotationProcessor<TestTransformers> processor = factory(TestTransformers.class);
|
RestAnnotationProcessor<TestTransformers> processor = factory(TestTransformers.class);
|
||||||
Method method = TestTransformers.class.getMethod("oneTransformerWithContext");
|
Method method = TestTransformers.class.getMethod("oneTransformerWithContext");
|
||||||
GeneratedHttpRequest<TestTransformers> request = GeneratedHttpRequest.<TestTransformers> builder().method("GET")
|
// can't use GHR.builder() - see http://code.google.com/p/jclouds/issues/detail?id=461
|
||||||
|
GeneratedHttpRequest<TestTransformers> request = new GeneratedHttpRequest.Builder<TestTransformers>().method("GET")
|
||||||
.endpoint(URI.create("http://localhost")).declaring(TestTransformers.class).javaMethod(method)
|
.endpoint(URI.create("http://localhost")).declaring(TestTransformers.class).javaMethod(method)
|
||||||
.args(new Object[] {}).build();
|
.args(new Object[] {}).build();
|
||||||
Function<HttpResponse, ?> transformer = processor.createResponseParser(method, request);
|
Function<HttpResponse, ?> transformer = processor.createResponseParser(method, request);
|
||||||
|
@ -2348,7 +2349,8 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
|
||||||
public void testCreateJAXBResponseParserWithAnnotation() throws SecurityException, NoSuchMethodException {
|
public void testCreateJAXBResponseParserWithAnnotation() throws SecurityException, NoSuchMethodException {
|
||||||
RestAnnotationProcessor<TestJAXBResponseParser> processor = factory(TestJAXBResponseParser.class);
|
RestAnnotationProcessor<TestJAXBResponseParser> processor = factory(TestJAXBResponseParser.class);
|
||||||
Method method = TestJAXBResponseParser.class.getMethod("jaxbGetWithAnnotation");
|
Method method = TestJAXBResponseParser.class.getMethod("jaxbGetWithAnnotation");
|
||||||
GeneratedHttpRequest<TestJAXBResponseParser> request = GeneratedHttpRequest.<TestJAXBResponseParser> builder()
|
// can't use GHR.builder() - see http://code.google.com/p/jclouds/issues/detail?id=461
|
||||||
|
GeneratedHttpRequest<TestJAXBResponseParser> request = new GeneratedHttpRequest.Builder<TestJAXBResponseParser>()
|
||||||
.method("GET").endpoint(URI.create("http://localhost")).declaring(TestJAXBResponseParser.class)
|
.method("GET").endpoint(URI.create("http://localhost")).declaring(TestJAXBResponseParser.class)
|
||||||
.javaMethod(method).args(new Object[] {}).build();
|
.javaMethod(method).args(new Object[] {}).build();
|
||||||
Function<HttpResponse, ?> transformer = processor.createResponseParser(method, request);
|
Function<HttpResponse, ?> transformer = processor.createResponseParser(method, request);
|
||||||
|
@ -2359,7 +2361,8 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
|
||||||
public void testCreateJAXBResponseParserWithAcceptHeader() throws SecurityException, NoSuchMethodException {
|
public void testCreateJAXBResponseParserWithAcceptHeader() throws SecurityException, NoSuchMethodException {
|
||||||
RestAnnotationProcessor<TestJAXBResponseParser> processor = factory(TestJAXBResponseParser.class);
|
RestAnnotationProcessor<TestJAXBResponseParser> processor = factory(TestJAXBResponseParser.class);
|
||||||
Method method = TestJAXBResponseParser.class.getMethod("jaxbGetWithAcceptHeader");
|
Method method = TestJAXBResponseParser.class.getMethod("jaxbGetWithAcceptHeader");
|
||||||
GeneratedHttpRequest<TestJAXBResponseParser> request = GeneratedHttpRequest.<TestJAXBResponseParser> builder()
|
// can't use GHR.builder() - see http://code.google.com/p/jclouds/issues/detail?id=461
|
||||||
|
GeneratedHttpRequest<TestJAXBResponseParser> request = new GeneratedHttpRequest.Builder<TestJAXBResponseParser>()
|
||||||
.method("GET").endpoint(URI.create("http://localhost")).declaring(TestJAXBResponseParser.class)
|
.method("GET").endpoint(URI.create("http://localhost")).declaring(TestJAXBResponseParser.class)
|
||||||
.javaMethod(method).args(new Object[] {}).build();
|
.javaMethod(method).args(new Object[] {}).build();
|
||||||
Function<HttpResponse, ?> transformer = processor.createResponseParser(method, request);
|
Function<HttpResponse, ?> transformer = processor.createResponseParser(method, request);
|
||||||
|
|
Loading…
Reference in New Issue