mirror of https://github.com/apache/jclouds.git
removed unnecessary generic types and made RestAnnotationProcessor immutable
This commit is contained in:
parent
e4a8b84da6
commit
cddd35bc51
|
@ -43,7 +43,7 @@ import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AtmosBlobRequestSigner implements BlobRequestSigner {
|
public class AtmosBlobRequestSigner implements BlobRequestSigner {
|
||||||
private final RestAnnotationProcessor<AtmosAsyncClient> processor;
|
private final RestAnnotationProcessor processor;
|
||||||
private final BlobToObject blobToObject;
|
private final BlobToObject blobToObject;
|
||||||
private final BlobToHttpGetOptions blob2ObjectGetOptions;
|
private final BlobToHttpGetOptions blob2ObjectGetOptions;
|
||||||
|
|
||||||
|
@ -52,9 +52,9 @@ public class AtmosBlobRequestSigner implements BlobRequestSigner {
|
||||||
private final Method createMethod;
|
private final Method createMethod;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AtmosBlobRequestSigner(RestAnnotationProcessor<AtmosAsyncClient> processor, BlobToObject blobToObject,
|
public AtmosBlobRequestSigner(RestAnnotationProcessor.Factory processor, BlobToObject blobToObject,
|
||||||
BlobToHttpGetOptions blob2ObjectGetOptions) throws SecurityException, NoSuchMethodException {
|
BlobToHttpGetOptions blob2ObjectGetOptions) throws SecurityException, NoSuchMethodException {
|
||||||
this.processor = checkNotNull(processor, "processor");
|
this.processor = checkNotNull(processor, "processor").declaring(AtmosAsyncClient.class);
|
||||||
this.blobToObject = checkNotNull(blobToObject, "blobToObject");
|
this.blobToObject = checkNotNull(blobToObject, "blobToObject");
|
||||||
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
this.blob2ObjectGetOptions = checkNotNull(blob2ObjectGetOptions, "blob2ObjectGetOptions");
|
||||||
this.getMethod = AtmosAsyncClient.class.getMethod("readFile", String.class, GetOptions[].class);
|
this.getMethod = AtmosAsyncClient.class.getMethod("readFile", String.class, GetOptions[].class);
|
||||||
|
|
|
@ -50,13 +50,11 @@ import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.http.options.GetOptions;
|
import org.jclouds.http.options.GetOptions;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code AtmosAsyncClient}
|
* Tests behavior of {@code AtmosAsyncClient}
|
||||||
|
@ -301,12 +299,6 @@ public class AtmosAsyncClientTest extends BaseAsyncClientTest<AtmosAsyncClient>
|
||||||
assertEquals(request.getFilters().get(0).getClass(), SignRequest.class);
|
assertEquals(request.getFilters().get(0).getClass(), SignRequest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<AtmosAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<AtmosAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
@Override
|
@Override
|
||||||
protected void setupFactory() throws IOException {
|
protected void setupFactory() throws IOException {
|
||||||
|
|
|
@ -35,13 +35,11 @@ import org.jclouds.date.TimeStamp;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code AtmosBlobRequestSigner}
|
* Tests behavior of {@code AtmosBlobRequestSigner}
|
||||||
|
@ -123,12 +121,6 @@ public class AtmosBlobRequestSignerTest extends BaseAsyncClientTest<AtmosAsyncCl
|
||||||
assertEquals(request.getFilters().get(0).getClass(), SignRequest.class);
|
assertEquals(request.getFilters().get(0).getClass(), SignRequest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<AtmosAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<AtmosAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Module createModule() {
|
protected Module createModule() {
|
||||||
return new TestAtmosRestClientModule();
|
return new TestAtmosRestClientModule();
|
||||||
|
|
|
@ -65,13 +65,11 @@ import org.jclouds.openstack.keystone.v1_1.domain.Auth;
|
||||||
import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest;
|
import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code CloudServersAsyncClient}
|
* Tests behavior of {@code CloudServersAsyncClient}
|
||||||
|
@ -868,12 +866,6 @@ public class CloudServersAsyncClientTest extends BaseAsyncClientTest<CloudServer
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<CloudServersAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<CloudServersAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkFilters(HttpRequest request) {
|
protected void checkFilters(HttpRequest request) {
|
||||||
assertEquals(request.getFilters().size(), 2);
|
assertEquals(request.getFilters().size(), 2);
|
||||||
|
|
|
@ -48,12 +48,10 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.filters.BasicAuthentication;
|
import org.jclouds.http.filters.BasicAuthentication;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code CloudSigmaAsyncClient}
|
* Tests behavior of {@code CloudSigmaAsyncClient}
|
||||||
|
@ -641,12 +639,6 @@ public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest<CloudSigmaAsy
|
||||||
assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class);
|
assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<CloudSigmaAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<CloudSigmaAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ApiMetadata createApiMetadata() {
|
protected ApiMetadata createApiMetadata() {
|
||||||
return new CloudSigmaApiMetadata();
|
return new CloudSigmaApiMetadata();
|
||||||
|
|
|
@ -23,12 +23,9 @@ import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code CloudStackAsyncClient}
|
* Tests behavior of {@code CloudStackAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -106,12 +103,6 @@ public class CloudStackAsyncClientTest extends BaseCloudStackAsyncClientTest<Clo
|
||||||
assert globalAsyncClient.getAccountClient() != null;
|
assert globalAsyncClient.getAccountClient() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<CloudStackAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<CloudStackAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
@Override
|
@Override
|
||||||
protected void setupFactory() throws IOException {
|
protected void setupFactory() throws IOException {
|
||||||
|
|
|
@ -28,11 +28,9 @@ import org.jclouds.cloudstack.options.ListAccountsOptions;
|
||||||
import org.jclouds.functions.IdentityFunction;
|
import org.jclouds.functions.IdentityFunction;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Functions;
|
import com.google.common.base.Functions;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code AccountAsyncClient}
|
* Tests behavior of {@code AccountAsyncClient}
|
||||||
|
@ -97,9 +95,4 @@ public class AccountAsyncClientTest extends BaseCloudStackAsyncClientTest<Accoun
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<AccountAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<AccountAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,9 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Functions;
|
import com.google.common.base.Functions;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code AddressAsyncClient}
|
* Tests behavior of {@code AddressAsyncClient}
|
||||||
|
@ -136,10 +134,4 @@ public class AddressAsyncClientTest extends BaseCloudStackAsyncClientTest<Addres
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<AddressAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<AddressAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,8 @@ import org.jclouds.cloudstack.functions.ParseAsyncJobsFromHttpResponse;
|
||||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||||
import org.jclouds.cloudstack.options.ListAsyncJobsOptions;
|
import org.jclouds.cloudstack.options.ListAsyncJobsOptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code AsyncJobAsyncClient}
|
* Tests behavior of {@code AsyncJobAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -94,10 +91,4 @@ public class AsyncJobAsyncClientTest extends BaseCloudStackAsyncClientTest<Async
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<AsyncJobAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<AsyncJobAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,8 @@ import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||||
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code ConfigurationAsyncClient}
|
* Tests behavior of {@code ConfigurationAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -56,10 +53,4 @@ public class ConfigurationAsyncClientTest extends BaseCloudStackAsyncClientTest<
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<ConfigurationAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<ConfigurationAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,8 @@ import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code DomainAccountAsyncClient}
|
* Tests behavior of {@code DomainAccountAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -69,10 +66,4 @@ public class DomainAccountAsyncClientTest extends BaseCloudStackAsyncClientTest<
|
||||||
|
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<DomainAccountAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<DomainAccountAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,8 @@ import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||||
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code DomainLimitAsyncClient}
|
* Tests behavior of {@code DomainLimitAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -58,10 +55,4 @@ public class DomainLimitAsyncClientTest extends BaseCloudStackAsyncClientTest<Do
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<DomainLimitAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<DomainLimitAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,8 @@ import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||||
import org.jclouds.cloudstack.options.ListEventsOptions;
|
import org.jclouds.cloudstack.options.ListEventsOptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code EventAsyncClient}
|
* Tests behavior of {@code EventAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -91,11 +88,4 @@ public class EventAsyncClientTest extends BaseCloudStackAsyncClientTest<EventAsy
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<EventAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<EventAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,11 +31,8 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code FirewallAsyncClient}
|
* Tests behavior of {@code FirewallAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -117,10 +114,4 @@ public class FirewallAsyncClientTest extends BaseCloudStackAsyncClientTest<Firew
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<FirewallAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<FirewallAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,8 @@ import org.jclouds.cloudstack.options.UpdateAccountOptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code GlobalAccountAsyncClient}
|
* Tests behavior of {@code GlobalAccountAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -93,10 +90,4 @@ public class GlobalAccountAsyncClientTest extends BaseCloudStackAsyncClientTest<
|
||||||
|
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<GlobalAccountAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<GlobalAccountAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,11 +26,8 @@ import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||||
import org.jclouds.cloudstack.options.ListAlertsOptions;
|
import org.jclouds.cloudstack.options.ListAlertsOptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code GlobalAlertsAsyncClient}
|
* Tests behavior of {@code GlobalAlertsAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -74,11 +71,4 @@ public class GlobalAlertAsyncClientTest extends BaseCloudStackAsyncClientTest<Gl
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<GlobalAlertAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<GlobalAlertAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,8 @@ import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||||
import org.jclouds.cloudstack.options.ListCapacityOptions;
|
import org.jclouds.cloudstack.options.ListCapacityOptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code GlobalCapacityAsyncClient}
|
* Tests behavior of {@code GlobalCapacityAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -73,11 +70,4 @@ public class GlobalCapacityAsyncClientTest extends BaseCloudStackAsyncClientTest
|
||||||
|
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<GlobalCapacityAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<GlobalCapacityAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,8 @@ import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||||
import org.jclouds.cloudstack.options.ListHostsOptions;
|
import org.jclouds.cloudstack.options.ListHostsOptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code GlobalHostAsyncClient}
|
* Tests behavior of {@code GlobalHostAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -53,10 +50,4 @@ public class GlobalHostAsyncClientTest extends BaseCloudStackAsyncClientTest<Glo
|
||||||
|
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<GlobalHostAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<GlobalHostAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,11 +30,8 @@ import org.jclouds.cloudstack.options.UpdateServiceOfferingOptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code GlobalOfferingAsyncClient}
|
* Tests behavior of {@code GlobalOfferingAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -159,10 +156,4 @@ public class GlobalOfferingAsyncClientTest extends BaseCloudStackAsyncClientTest
|
||||||
|
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<GlobalOfferingAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<GlobalOfferingAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.jclouds.cloudstack.internal.BaseCloudStackClientLiveTest;
|
||||||
import org.jclouds.cloudstack.options.CreatePodOptions;
|
import org.jclouds.cloudstack.options.CreatePodOptions;
|
||||||
import org.jclouds.cloudstack.options.ListPodsOptions;
|
import org.jclouds.cloudstack.options.ListPodsOptions;
|
||||||
import org.jclouds.cloudstack.options.UpdatePodOptions;
|
import org.jclouds.cloudstack.options.UpdatePodOptions;
|
||||||
import org.testng.annotations.AfterClass;
|
|
||||||
import org.testng.annotations.AfterGroups;
|
import org.testng.annotations.AfterGroups;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,8 @@ import org.jclouds.cloudstack.options.ListStoragePoolsOptions;
|
||||||
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code GlobalStoragePoolAsyncClient}
|
* Tests behavior of {@code GlobalStoragePoolAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -69,10 +66,4 @@ public class GlobalStoragePoolAsyncClientTest extends BaseCloudStackAsyncClientT
|
||||||
|
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<GlobalStoragePoolAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<GlobalStoragePoolAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,8 @@ import org.jclouds.cloudstack.options.ListUsageRecordsOptions;
|
||||||
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code GlobalUsageAsyncClient}
|
* Tests behavior of {@code GlobalUsageAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -140,10 +137,4 @@ public class GlobalUsageAsyncClientTest extends BaseCloudStackAsyncClientTest<Gl
|
||||||
|
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<GlobalUsageAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<GlobalUsageAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,8 @@ import org.jclouds.cloudstack.options.UpdateUserOptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code GlobalUserAsyncClient}
|
* Tests behavior of {@code GlobalUserAsyncClient}
|
||||||
*/
|
*/
|
||||||
|
@ -88,10 +85,4 @@ public class GlobalUserAsyncClientTest extends BaseCloudStackAsyncClientTest<Glo
|
||||||
|
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<GlobalUserAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<GlobalUserAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,11 +30,9 @@ import org.jclouds.cloudstack.options.ListOSTypesOptions;
|
||||||
import org.jclouds.functions.IdentityFunction;
|
import org.jclouds.functions.IdentityFunction;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Functions;
|
import com.google.common.base.Functions;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code GuestOSAsyncClient}
|
* Tests behavior of {@code GuestOSAsyncClient}
|
||||||
|
@ -131,10 +129,4 @@ public class GuestOSAsyncClientTest extends BaseCloudStackAsyncClientTest<GuestO
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<GuestOSAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<GuestOSAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,8 @@ import org.jclouds.Fallbacks.EmptySetOnNotFoundOr404;
|
||||||
import org.jclouds.cloudstack.functions.ParseNamesFromHttpResponse;
|
import org.jclouds.cloudstack.functions.ParseNamesFromHttpResponse;
|
||||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code HypervisorAsyncClient}
|
* Tests behavior of {@code HypervisorAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -73,10 +70,4 @@ public class HypervisorAsyncClientTest extends BaseCloudStackAsyncClientTest<Hyp
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<HypervisorAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<HypervisorAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,9 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
/**
|
/**
|
||||||
* Tests the behaviour of ISOAsyncClient.
|
* Tests the behaviour of ISOAsyncClient.
|
||||||
*
|
*
|
||||||
|
@ -255,11 +253,4 @@ public class ISOAsyncClientTest extends BaseCloudStackAsyncClientTest<ISOAsyncCl
|
||||||
|
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<ISOAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<ISOAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,11 +26,8 @@ import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||||
import org.jclouds.cloudstack.options.ListResourceLimitsOptions;
|
import org.jclouds.cloudstack.options.ListResourceLimitsOptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code LimitAsyncClient}
|
* Tests behavior of {@code LimitAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -72,10 +69,4 @@ public class LimitAsyncClientTest extends BaseCloudStackAsyncClientTest<LimitAsy
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<LimitAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<LimitAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,11 +31,8 @@ import org.jclouds.cloudstack.options.UpdateLoadBalancerRuleOptions;
|
||||||
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code LoadBalancerAsyncClient}
|
* Tests behavior of {@code LoadBalancerAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -151,10 +148,4 @@ public class LoadBalancerAsyncClientTest extends BaseCloudStackAsyncClientTest<L
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<LoadBalancerAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<LoadBalancerAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,11 +31,8 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code NATAsyncClient}
|
* Tests behavior of {@code NATAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -187,10 +184,4 @@ public class NATAsyncClientTest extends BaseCloudStackAsyncClientTest<NATAsyncCl
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<NATAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<NATAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,11 +31,9 @@ import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
||||||
import org.jclouds.functions.IdentityFunction;
|
import org.jclouds.functions.IdentityFunction;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Functions;
|
import com.google.common.base.Functions;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code NetworkAsyncClient}
|
* Tests behavior of {@code NetworkAsyncClient}
|
||||||
|
@ -155,10 +153,4 @@ public class NetworkAsyncClientTest extends BaseCloudStackAsyncClientTest<Networ
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<NetworkAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<NetworkAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,11 +32,9 @@ import org.jclouds.cloudstack.options.ListServiceOfferingsOptions;
|
||||||
import org.jclouds.functions.IdentityFunction;
|
import org.jclouds.functions.IdentityFunction;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Functions;
|
import com.google.common.base.Functions;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code OfferingAsyncClient}
|
* Tests behavior of {@code OfferingAsyncClient}
|
||||||
|
@ -206,10 +204,4 @@ public class OfferingAsyncClientTest extends BaseCloudStackAsyncClientTest<Offer
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<OfferingAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<OfferingAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,9 @@ import org.jclouds.functions.IdentityFunction;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Functions;
|
import com.google.common.base.Functions;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code SSHKeyPairAsyncClient}
|
* Tests behavior of {@code SSHKeyPairAsyncClient}
|
||||||
|
@ -137,11 +135,4 @@ public class SSHKeyPairAsyncClientTest extends BaseCloudStackAsyncClientTest<SSH
|
||||||
|
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<SSHKeyPairAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<SSHKeyPairAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,14 +32,12 @@ import org.jclouds.functions.IdentityFunction;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Functions;
|
import com.google.common.base.Functions;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code SecurityGroupAsyncClient}
|
* Tests behavior of {@code SecurityGroupAsyncClient}
|
||||||
|
@ -237,10 +235,4 @@ public class SecurityGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<SecurityGroupAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<SecurityGroupAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,12 +36,10 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Functions;
|
import com.google.common.base.Functions;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests the behaviour of SnapshotAsyncClient.
|
* Tests the behaviour of SnapshotAsyncClient.
|
||||||
|
@ -231,10 +229,4 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
|
||||||
|
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<SnapshotAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<SnapshotAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,12 +42,10 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Functions;
|
import com.google.common.base.Functions;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code TemplateAsyncClient}
|
* Tests behavior of {@code TemplateAsyncClient}
|
||||||
|
@ -342,10 +340,4 @@ public class TemplateAsyncClientTest extends BaseCloudStackAsyncClientTest<Templ
|
||||||
|
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<TemplateAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<TemplateAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,9 @@ import org.jclouds.functions.IdentityFunction;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Functions;
|
import com.google.common.base.Functions;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code VMGroupAsyncClient}
|
* Tests behavior of {@code VMGroupAsyncClient}
|
||||||
|
@ -170,10 +168,4 @@ public class VMGroupAsyncClientTest extends BaseCloudStackAsyncClientTest<VMGrou
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<VMGroupAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<VMGroupAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,11 +32,9 @@ import org.jclouds.functions.IdentityFunction;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Functions;
|
import com.google.common.base.Functions;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code VirtualMachineAsyncClient}
|
* Tests behavior of {@code VirtualMachineAsyncClient}
|
||||||
|
@ -260,10 +258,4 @@ public class VirtualMachineAsyncClientTest extends BaseCloudStackAsyncClientTest
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<VirtualMachineAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<VirtualMachineAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,8 @@ import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
||||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
||||||
import org.jclouds.cloudstack.options.ListVolumesOptions;
|
import org.jclouds.cloudstack.options.ListVolumesOptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code EventAsyncClient}
|
* Tests behavior of {@code EventAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -149,10 +146,4 @@ public class VolumeAsyncClientTest extends BaseCloudStackAsyncClientTest<VolumeA
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<VolumeAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<VolumeAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,12 +28,10 @@ import org.jclouds.cloudstack.options.ListZonesOptions;
|
||||||
import org.jclouds.functions.IdentityFunction;
|
import org.jclouds.functions.IdentityFunction;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Functions;
|
import com.google.common.base.Functions;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code ZoneAsyncClient}
|
* Tests behavior of {@code ZoneAsyncClient}
|
||||||
|
@ -106,10 +104,4 @@ public class ZoneAsyncClientTest extends BaseCloudStackAsyncClientTest<ZoneAsync
|
||||||
checkFilters(httpRequest);
|
checkFilters(httpRequest);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<ZoneAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<ZoneAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,14 +41,12 @@ import org.jclouds.location.config.LocationModule;
|
||||||
import org.jclouds.location.suppliers.RegionIdToURISupplier;
|
import org.jclouds.location.suppliers.RegionIdToURISupplier;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
import org.jclouds.rest.internal.BaseAsyncApiTest;
|
import org.jclouds.rest.internal.BaseAsyncApiTest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.util.Suppliers2;
|
import org.jclouds.util.Suppliers2;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code CloudWatchAsyncApi}
|
* Tests behavior of {@code CloudWatchAsyncApi}
|
||||||
|
@ -82,11 +80,6 @@ public class CloudWatchAsyncApiTest extends BaseAsyncApiTest<CloudWatchAsyncApi>
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<CloudWatchAsyncApi>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<CloudWatchAsyncApi>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@ConfiguresRestClient
|
@ConfiguresRestClient
|
||||||
private static final class TestMonitoringRestClientModule extends CloudWatchRestClientModule {
|
private static final class TestMonitoringRestClientModule extends CloudWatchRestClientModule {
|
||||||
|
@ -129,4 +122,5 @@ public class CloudWatchAsyncApiTest extends BaseAsyncApiTest<CloudWatchAsyncApi>
|
||||||
assertEquals(request.getFilters().get(0).getClass(), FormSigner.class);
|
assertEquals(request.getFilters().get(0).getClass(), FormSigner.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,12 +23,9 @@ import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import org.jclouds.ec2.services.BaseEC2AsyncClientTest;
|
import org.jclouds.ec2.services.BaseEC2AsyncClientTest;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code EC2AsyncClient}
|
* Tests behavior of {@code EC2AsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -64,12 +61,6 @@ public class EC2AsyncClientTest extends BaseEC2AsyncClientTest<EC2AsyncClient> {
|
||||||
assert asyncClient.getWindowsServices() != null;
|
assert asyncClient.getWindowsServices() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<EC2AsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<EC2AsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
@Override
|
@Override
|
||||||
protected void setupFactory() throws IOException {
|
protected void setupFactory() throws IOException {
|
||||||
|
|
|
@ -25,12 +25,9 @@ import java.io.IOException;
|
||||||
import org.jclouds.ec2.services.BaseEC2AsyncClientTest;
|
import org.jclouds.ec2.services.BaseEC2AsyncClientTest;
|
||||||
import org.jclouds.ec2.services.InstanceAsyncClient;
|
import org.jclouds.ec2.services.InstanceAsyncClient;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code BindS3UploadPolicyAndSignature}
|
* Tests behavior of {@code BindS3UploadPolicyAndSignature}
|
||||||
*
|
*
|
||||||
|
@ -63,10 +60,4 @@ public class BindS3UploadPolicyAndSignatureTest extends BaseEC2AsyncClientTest<I
|
||||||
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
|
||||||
binder.bindToRequest(request, null);
|
binder.bindToRequest(request, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<InstanceAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<InstanceAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,9 @@ import org.jclouds.ec2.xml.PermissionHandler;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code AMIAsyncClient}
|
* Tests behavior of {@code AMIAsyncClient}
|
||||||
|
@ -315,11 +313,4 @@ public class AMIAsyncClientTest extends BaseEC2AsyncClientTest<AMIAsyncClient> {
|
||||||
|
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<AMIAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<AMIAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,11 +33,8 @@ import org.jclouds.ec2.xml.DescribeAvailabilityZonesResponseHandler;
|
||||||
import org.jclouds.ec2.xml.DescribeRegionsResponseHandler;
|
import org.jclouds.ec2.xml.DescribeRegionsResponseHandler;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code AvailabilityZoneAndRegionAsyncClient}
|
* Tests behavior of {@code AvailabilityZoneAndRegionAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -117,11 +114,4 @@ public class AvailabilityZoneAndRegionAsyncClientTest extends
|
||||||
|
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<AvailabilityZoneAndRegionAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<AvailabilityZoneAndRegionAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,11 +38,9 @@ import org.jclouds.ec2.xml.SnapshotHandler;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code ElasticBlockStoreAsyncClient}
|
* Tests behavior of {@code ElasticBlockStoreAsyncClient}
|
||||||
|
@ -307,11 +305,4 @@ public class ElasticBlockStoreAsyncClientTest extends BaseEC2AsyncClientTest<Ela
|
||||||
|
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<ElasticBlockStoreAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<ElasticBlockStoreAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,8 @@ import org.jclouds.ec2.xml.DescribeAddressesResponseHandler;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code ElasticIPAddressAsyncClient}
|
* Tests behavior of {@code ElasticIPAddressAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -124,11 +121,4 @@ public class ElasticIPAddressAsyncClientTest extends BaseEC2AsyncClientTest<Elas
|
||||||
|
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<ElasticIPAddressAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<ElasticIPAddressAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,11 +41,9 @@ import org.jclouds.ec2.xml.UnencodeStringValueHandler;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code InstanceAsyncClient}
|
* Tests behavior of {@code InstanceAsyncClient}
|
||||||
|
@ -505,11 +503,4 @@ public class InstanceAsyncClientTest extends BaseEC2AsyncClientTest<InstanceAsyn
|
||||||
|
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<InstanceAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<InstanceAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,8 @@ import org.jclouds.ec2.xml.DescribeKeyPairsResponseHandler;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code KeyPairAsyncClient}
|
* Tests behavior of {@code KeyPairAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -90,11 +87,4 @@ public class KeyPairAsyncClientTest extends BaseEC2AsyncClientTest<KeyPairAsyncC
|
||||||
|
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<KeyPairAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<KeyPairAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,11 +30,8 @@ import org.jclouds.ec2.xml.DescribeSecurityGroupsResponseHandler;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code SecurityGroupAsyncClient}
|
* Tests behavior of {@code SecurityGroupAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -204,11 +201,4 @@ public class SecurityGroupAsyncClientTest extends BaseEC2AsyncClientTest<Securit
|
||||||
|
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<SecurityGroupAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<SecurityGroupAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,8 @@ import org.jclouds.ec2.xml.BundleTaskHandler;
|
||||||
import org.jclouds.ec2.xml.DescribeBundleTasksResponseHandler;
|
import org.jclouds.ec2.xml.DescribeBundleTasksResponseHandler;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code WindowsAsyncClient}
|
* Tests behavior of {@code WindowsAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -119,11 +116,4 @@ public class WindowsAsyncClientTest extends BaseEC2AsyncClientTest<WindowsAsyncC
|
||||||
|
|
||||||
checkFilters(request);
|
checkFilters(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<WindowsAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<WindowsAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,12 +47,10 @@ import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.io.Payload;
|
import org.jclouds.io.Payload;
|
||||||
import org.jclouds.io.Payloads;
|
import org.jclouds.io.Payloads;
|
||||||
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code ElasticStackAsyncClient}
|
* Tests behavior of {@code ElasticStackAsyncClient}
|
||||||
|
@ -446,12 +444,6 @@ public class ElasticStackAsyncClientTest extends BaseAsyncClientTest<ElasticStac
|
||||||
assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class);
|
assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<ElasticStackAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<ElasticStackAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ApiMetadata createApiMetadata() {
|
protected ApiMetadata createApiMetadata() {
|
||||||
return new ElasticStackApiMetadata();
|
return new ElasticStackApiMetadata();
|
||||||
|
|
|
@ -221,56 +221,7 @@ public class NovaErrorHandlerTest {
|
||||||
new OverLimitParser(new GsonWrapper(new Gson())));
|
new OverLimitParser(new GsonWrapper(new Gson())));
|
||||||
|
|
||||||
private HttpCommand command() {
|
private HttpCommand command() {
|
||||||
return new HttpCommand() {
|
return new HttpCommand(HttpRequest.builder().method("POST").endpoint("https://nova/v1.1/servers").build());
|
||||||
|
|
||||||
private Exception exception;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRedirectCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int incrementRedirectCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isReplayable() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Exception getException() {
|
|
||||||
return exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getFailureCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int incrementFailureCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setException(Exception exception) {
|
|
||||||
this.exception = exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HttpRequest getCurrentRequest() {
|
|
||||||
return HttpRequest.builder().method("POST").endpoint("https://nova/v1.1/servers").build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCurrentRequest(HttpRequest request) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ import org.jclouds.s3.options.PutObjectOptions;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class S3BlobRequestSigner implements BlobRequestSigner {
|
public class S3BlobRequestSigner implements BlobRequestSigner {
|
||||||
private final RestAnnotationProcessor<S3AsyncClient> processor;
|
private final RestAnnotationProcessor processor;
|
||||||
private final BlobToObject blobToObject;
|
private final BlobToObject blobToObject;
|
||||||
private final BlobToHttpGetOptions blob2HttpGetOptions;
|
private final BlobToHttpGetOptions blob2HttpGetOptions;
|
||||||
|
|
||||||
|
@ -52,9 +52,9 @@ public class S3BlobRequestSigner implements BlobRequestSigner {
|
||||||
private final Method createMethod;
|
private final Method createMethod;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public S3BlobRequestSigner(RestAnnotationProcessor<S3AsyncClient> processor, BlobToObject blobToObject,
|
public S3BlobRequestSigner(RestAnnotationProcessor.Factory processor, BlobToObject blobToObject,
|
||||||
BlobToHttpGetOptions blob2HttpGetOptions) throws SecurityException, NoSuchMethodException {
|
BlobToHttpGetOptions blob2HttpGetOptions) throws SecurityException, NoSuchMethodException {
|
||||||
this.processor = checkNotNull(processor, "processor");
|
this.processor = checkNotNull(processor, "processor").declaring(S3AsyncClient.class);
|
||||||
this.blobToObject = checkNotNull(blobToObject, "blobToObject");
|
this.blobToObject = checkNotNull(blobToObject, "blobToObject");
|
||||||
this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions");
|
this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions");
|
||||||
this.getMethod = S3AsyncClient.class.getMethod("getObject", String.class, String.class, GetOptions[].class);
|
this.getMethod = S3AsyncClient.class.getMethod("getObject", String.class, String.class, GetOptions[].class);
|
||||||
|
|
|
@ -25,13 +25,10 @@ import java.lang.reflect.Method;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.s3.S3AsyncClient;
|
import org.jclouds.s3.S3AsyncClient;
|
||||||
import org.jclouds.s3.internal.BaseS3AsyncClientTest;
|
import org.jclouds.s3.internal.BaseS3AsyncClientTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code BindAsHostPrefixIfConfigured}
|
* Tests behavior of {@code BindAsHostPrefixIfConfigured}
|
||||||
*
|
*
|
||||||
|
@ -41,12 +38,6 @@ import com.google.inject.TypeLiteral;
|
||||||
@Test(groups = "unit", testName = "BindAsHostPrefixIfConfiguredNoPathTest")
|
@Test(groups = "unit", testName = "BindAsHostPrefixIfConfiguredNoPathTest")
|
||||||
public class BindAsHostPrefixIfConfiguredNoPathTest extends BaseS3AsyncClientTest<S3AsyncClient> {
|
public class BindAsHostPrefixIfConfiguredNoPathTest extends BaseS3AsyncClientTest<S3AsyncClient> {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<S3AsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<S3AsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testBucketWithHostnameStyle() throws IOException, SecurityException, NoSuchMethodException {
|
public void testBucketWithHostnameStyle() throws IOException, SecurityException, NoSuchMethodException {
|
||||||
|
|
||||||
Method method = S3AsyncClient.class.getMethod("deleteObject", String.class, String.class);
|
Method method = S3AsyncClient.class.getMethod("deleteObject", String.class, String.class);
|
||||||
|
|
|
@ -27,14 +27,11 @@ import java.lang.reflect.Method;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.s3.S3AsyncClient;
|
import org.jclouds.s3.S3AsyncClient;
|
||||||
import org.jclouds.s3.internal.BaseS3AsyncClientTest;
|
import org.jclouds.s3.internal.BaseS3AsyncClientTest;
|
||||||
import org.testng.annotations.DataProvider;
|
import org.testng.annotations.DataProvider;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code BindAsHostPrefixIfConfigured}
|
* Tests behavior of {@code BindAsHostPrefixIfConfigured}
|
||||||
*
|
*
|
||||||
|
@ -44,12 +41,6 @@ import com.google.inject.TypeLiteral;
|
||||||
@Test(groups = "unit", testName = "BindAsHostPrefixIfConfiguredTest")
|
@Test(groups = "unit", testName = "BindAsHostPrefixIfConfiguredTest")
|
||||||
public class BindAsHostPrefixIfConfiguredTest extends BaseS3AsyncClientTest<S3AsyncClient> {
|
public class BindAsHostPrefixIfConfiguredTest extends BaseS3AsyncClientTest<S3AsyncClient> {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<S3AsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<S3AsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testBucket() throws IOException {
|
public void testBucket() throws IOException {
|
||||||
|
|
||||||
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://euc/services/Walrus").build();
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://euc/services/Walrus").build();
|
||||||
|
|
|
@ -23,13 +23,10 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.s3.S3AsyncClient;
|
import org.jclouds.s3.S3AsyncClient;
|
||||||
import org.jclouds.s3.internal.BaseS3AsyncClientTest;
|
import org.jclouds.s3.internal.BaseS3AsyncClientTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code BindNoBucketLoggingToXmlPayload}
|
* Tests behavior of {@code BindNoBucketLoggingToXmlPayload}
|
||||||
*
|
*
|
||||||
|
@ -39,12 +36,6 @@ import com.google.inject.TypeLiteral;
|
||||||
@Test(groups = "unit", testName = "BindNoBucketLoggingToXmlPayloadTest")
|
@Test(groups = "unit", testName = "BindNoBucketLoggingToXmlPayloadTest")
|
||||||
public class BindNoBucketLoggingToXmlPayloadTest extends BaseS3AsyncClientTest<S3AsyncClient> {
|
public class BindNoBucketLoggingToXmlPayloadTest extends BaseS3AsyncClientTest<S3AsyncClient> {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<S3AsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<S3AsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testApplyInputStream() throws IOException {
|
public void testApplyInputStream() throws IOException {
|
||||||
|
|
||||||
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://test").build();
|
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://test").build();
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.jclouds.blobstore.binders.BindMapToHeadersWithPrefix;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.io.Payload;
|
import org.jclouds.io.Payload;
|
||||||
import org.jclouds.io.Payloads;
|
import org.jclouds.io.Payloads;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.s3.S3AsyncClient;
|
import org.jclouds.s3.S3AsyncClient;
|
||||||
import org.jclouds.s3.domain.S3Object;
|
import org.jclouds.s3.domain.S3Object;
|
||||||
import org.jclouds.s3.internal.BaseS3AsyncClientTest;
|
import org.jclouds.s3.internal.BaseS3AsyncClientTest;
|
||||||
|
@ -35,7 +34,6 @@ import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableMultimap;
|
import com.google.common.collect.ImmutableMultimap;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code BindS3ObjectMetadataToRequest}
|
* Tests behavior of {@code BindS3ObjectMetadataToRequest}
|
||||||
|
@ -46,12 +44,6 @@ import com.google.inject.TypeLiteral;
|
||||||
@Test(groups = "unit", testName = "BindS3ObjectMetadataToRequestTest")
|
@Test(groups = "unit", testName = "BindS3ObjectMetadataToRequestTest")
|
||||||
public class BindS3ObjectMetadataToRequestTest extends BaseS3AsyncClientTest<S3AsyncClient> {
|
public class BindS3ObjectMetadataToRequestTest extends BaseS3AsyncClientTest<S3AsyncClient> {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<S3AsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<S3AsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPassWithMinimumDetailsAndPayload5GB() {
|
public void testPassWithMinimumDetailsAndPayload5GB() {
|
||||||
S3Object object = injector.getInstance(S3Object.Factory.class).create(null);
|
S3Object object = injector.getInstance(S3Object.Factory.class).create(null);
|
||||||
|
|
|
@ -28,7 +28,6 @@ import javax.ws.rs.core.HttpHeaders;
|
||||||
import org.jclouds.blobstore.binders.BindBlobToMultipartFormTest;
|
import org.jclouds.blobstore.binders.BindBlobToMultipartFormTest;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.s3.S3AsyncClient;
|
import org.jclouds.s3.S3AsyncClient;
|
||||||
import org.jclouds.s3.domain.AccessControlList;
|
import org.jclouds.s3.domain.AccessControlList;
|
||||||
import org.jclouds.s3.domain.CannedAccessPolicy;
|
import org.jclouds.s3.domain.CannedAccessPolicy;
|
||||||
|
@ -41,7 +40,6 @@ import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.SortedSetMultimap;
|
import com.google.common.collect.SortedSetMultimap;
|
||||||
import com.google.common.collect.TreeMultimap;
|
import com.google.common.collect.TreeMultimap;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code RequestAuthorizeSignature}
|
* Tests behavior of {@code RequestAuthorizeSignature}
|
||||||
|
@ -52,12 +50,6 @@ import com.google.inject.TypeLiteral;
|
||||||
@Test(groups = "unit", testName = "RequestAuthorizeSignatureTest")
|
@Test(groups = "unit", testName = "RequestAuthorizeSignatureTest")
|
||||||
public class RequestAuthorizeSignatureTest extends BaseS3AsyncClientTest<S3AsyncClient> {
|
public class RequestAuthorizeSignatureTest extends BaseS3AsyncClientTest<S3AsyncClient> {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<S3AsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<S3AsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@DataProvider(parallel = true)
|
@DataProvider(parallel = true)
|
||||||
public Object[][] dataProvider() throws NoSuchMethodException {
|
public Object[][] dataProvider() throws NoSuchMethodException {
|
||||||
return new Object[][] { { listOwnedBuckets() }, { putObject() }, { putBucketAcl() }
|
return new Object[][] { { listOwnedBuckets() }, { putObject() }, { putBucketAcl() }
|
||||||
|
|
|
@ -83,56 +83,10 @@ public class SQSErrorRetryHandlerTest {
|
||||||
assertTrue(watch.stop().elapsedTime(TimeUnit.MILLISECONDS) < 100);
|
assertTrue(watch.stop().elapsedTime(TimeUnit.MILLISECONDS) < 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: make a builder for this
|
|
||||||
HttpCommand createHttpCommandForFailureCount(final int failureCount) {
|
HttpCommand createHttpCommandForFailureCount(final int failureCount) {
|
||||||
return new HttpCommand() {
|
HttpCommand command = new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://localhost").build());
|
||||||
int fCount = failureCount;
|
while (command.getFailureCount() != failureCount)
|
||||||
|
command.incrementFailureCount();
|
||||||
@Override
|
return command;
|
||||||
public int incrementRedirectCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRedirectCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isReplayable() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int incrementFailureCount() {
|
|
||||||
return ++fCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getFailureCount() {
|
|
||||||
return fCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HttpRequest getCurrentRequest() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCurrentRequest(HttpRequest request) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setException(Exception exception) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Exception getException() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,7 @@ import com.google.inject.Provider;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class SwiftBlobSigner<T extends CommonSwiftAsyncClient> implements BlobRequestSigner {
|
public class SwiftBlobSigner<T extends CommonSwiftAsyncClient> implements BlobRequestSigner {
|
||||||
|
|
||||||
private final RestAnnotationProcessor<T> processor;
|
private final RestAnnotationProcessor processor;
|
||||||
private final Crypto crypto;
|
private final Crypto crypto;
|
||||||
|
|
||||||
private final Provider<Long> unixEpochTimestampProvider;
|
private final Provider<Long> unixEpochTimestampProvider;
|
||||||
|
@ -77,9 +77,9 @@ public class SwiftBlobSigner<T extends CommonSwiftAsyncClient> implements BlobRe
|
||||||
protected SwiftBlobSigner(BlobToObject blobToObject, BlobToHttpGetOptions blob2HttpGetOptions, Crypto crypto,
|
protected SwiftBlobSigner(BlobToObject blobToObject, BlobToHttpGetOptions blob2HttpGetOptions, Crypto crypto,
|
||||||
@TimeStamp Provider<Long> unixEpochTimestampProvider,
|
@TimeStamp Provider<Long> unixEpochTimestampProvider,
|
||||||
@TemporaryUrlKey Supplier<String> temporaryUrlKeySupplier,
|
@TemporaryUrlKey Supplier<String> temporaryUrlKeySupplier,
|
||||||
RestAnnotationProcessor<T> processor)
|
RestAnnotationProcessor.Factory processor, Class<T> clazz)
|
||||||
throws SecurityException, NoSuchMethodException {
|
throws SecurityException, NoSuchMethodException {
|
||||||
this.processor = checkNotNull(processor, "processor");
|
this.processor = checkNotNull(processor, "processor").declaring(clazz);
|
||||||
this.crypto = checkNotNull(crypto, "crypto");
|
this.crypto = checkNotNull(crypto, "crypto");
|
||||||
|
|
||||||
this.unixEpochTimestampProvider = checkNotNull(unixEpochTimestampProvider, "unixEpochTimestampProvider");
|
this.unixEpochTimestampProvider = checkNotNull(unixEpochTimestampProvider, "unixEpochTimestampProvider");
|
||||||
|
@ -88,9 +88,9 @@ public class SwiftBlobSigner<T extends CommonSwiftAsyncClient> implements BlobRe
|
||||||
this.blobToObject = checkNotNull(blobToObject, "blobToObject");
|
this.blobToObject = checkNotNull(blobToObject, "blobToObject");
|
||||||
this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions");
|
this.blob2HttpGetOptions = checkNotNull(blob2HttpGetOptions, "blob2HttpGetOptions");
|
||||||
|
|
||||||
this.getMethod = processor.getDeclaring().getMethod("getObject", String.class, String.class, GetOptions[].class);
|
this.getMethod = clazz.getMethod("getObject", String.class, String.class, GetOptions[].class);
|
||||||
this.deleteMethod = processor.getDeclaring().getMethod("removeObject", String.class, String.class);
|
this.deleteMethod = clazz.getMethod("removeObject", String.class, String.class);
|
||||||
this.createMethod = processor.getDeclaring().getMethod("putObject", String.class, SwiftObject.class);
|
this.createMethod = clazz.getMethod("putObject", String.class, SwiftObject.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -38,7 +38,6 @@ import org.jclouds.openstack.swift.blobstore.config.SwiftBlobStoreContextModule;
|
||||||
import org.jclouds.openstack.swift.blobstore.config.TemporaryUrlExtensionModule;
|
import org.jclouds.openstack.swift.blobstore.config.TemporaryUrlExtensionModule;
|
||||||
import org.jclouds.openstack.swift.config.SwiftRestClientModule;
|
import org.jclouds.openstack.swift.config.SwiftRestClientModule;
|
||||||
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
|
@ -58,15 +57,8 @@ import com.google.inject.TypeLiteral;
|
||||||
public abstract class CommonSwiftClientTest extends BaseAsyncClientTest<SwiftAsyncClient> {
|
public abstract class CommonSwiftClientTest extends BaseAsyncClientTest<SwiftAsyncClient> {
|
||||||
|
|
||||||
public static final long UNIX_EPOCH_TIMESTAMP = 123456789L;
|
public static final long UNIX_EPOCH_TIMESTAMP = 123456789L;
|
||||||
|
|
||||||
public static final String TEMPORARY_URL_KEY = "get-or-set-X-Account-Meta-Temp-Url-Key";
|
public static final String TEMPORARY_URL_KEY = "get-or-set-X-Account-Meta-Temp-Url-Key";
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<SwiftAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<SwiftAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void checkFilters(HttpRequest request) {
|
protected void checkFilters(HttpRequest request) {
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,15 +21,12 @@ package org.jclouds.vcloud;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
|
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
|
||||||
import org.jclouds.vcloud.utils.TestUtils;
|
import org.jclouds.vcloud.utils.TestUtils;
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.DataProvider;
|
import org.testng.annotations.DataProvider;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code VCloudAsyncClient}
|
* Tests behavior of {@code VCloudAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -40,12 +37,6 @@ import com.google.inject.TypeLiteral;
|
||||||
@Test(groups = "unit", testName = "VCloudAsyncClientTest")
|
@Test(groups = "unit", testName = "VCloudAsyncClientTest")
|
||||||
public class VCloudAsyncClientTest extends BaseVCloudAsyncClientTest<VCloudAsyncClient> {
|
public class VCloudAsyncClientTest extends BaseVCloudAsyncClientTest<VCloudAsyncClient> {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<VCloudAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<VCloudAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private VCloudAsyncClient asyncClient;
|
private VCloudAsyncClient asyncClient;
|
||||||
private VCloudClient syncClient;
|
private VCloudClient syncClient;
|
||||||
|
|
||||||
|
|
|
@ -28,12 +28,9 @@ import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.providers.AnonymousProviderMetadata;
|
import org.jclouds.providers.AnonymousProviderMetadata;
|
||||||
import org.jclouds.providers.ProviderMetadata;
|
import org.jclouds.providers.ProviderMetadata;
|
||||||
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.vcloud.xml.SupportedVersionsHandler;
|
import org.jclouds.vcloud.xml.SupportedVersionsHandler;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code VCloudVersionsAsyncClient}
|
* Tests behavior of {@code VCloudVersionsAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -63,12 +60,6 @@ public class VCloudVersionsAsyncClientTest extends BaseAsyncClientTest<VCloudVer
|
||||||
assertEquals(request.getFilters().size(), 0);
|
assertEquals(request.getFilters().size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<VCloudVersionsAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<VCloudVersionsAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ProviderMetadata createProviderMetadata() {
|
protected ProviderMetadata createProviderMetadata() {
|
||||||
return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(VCloudVersionsClient.class,
|
return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(VCloudVersionsClient.class,
|
||||||
|
|
|
@ -25,15 +25,12 @@ import java.net.URI;
|
||||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
|
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
|
||||||
import org.jclouds.vcloud.options.CatalogItemOptions;
|
import org.jclouds.vcloud.options.CatalogItemOptions;
|
||||||
import org.jclouds.vcloud.xml.CatalogHandler;
|
import org.jclouds.vcloud.xml.CatalogHandler;
|
||||||
import org.jclouds.vcloud.xml.CatalogItemHandler;
|
import org.jclouds.vcloud.xml.CatalogItemHandler;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code CatalogAsyncClient}
|
* Tests behavior of {@code CatalogAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -44,12 +41,6 @@ import com.google.inject.TypeLiteral;
|
||||||
@Test(groups = "unit", testName = "CatalogAsyncClientTest")
|
@Test(groups = "unit", testName = "CatalogAsyncClientTest")
|
||||||
public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest<CatalogAsyncClient> {
|
public class CatalogAsyncClientTest extends BaseVCloudAsyncClientTest<CatalogAsyncClient> {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<CatalogAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<CatalogAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
|
public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = CatalogAsyncClient.class.getMethod("getCatalog", URI.class);
|
Method method = CatalogAsyncClient.class.getMethod("getCatalog", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method, URI
|
||||||
|
|
|
@ -25,13 +25,10 @@ import java.net.URI;
|
||||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
|
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
|
||||||
import org.jclouds.vcloud.xml.OrgNetworkHandler;
|
import org.jclouds.vcloud.xml.OrgNetworkHandler;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code NetworkAsyncClient}
|
* Tests behavior of {@code NetworkAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -42,12 +39,6 @@ import com.google.inject.TypeLiteral;
|
||||||
@Test(groups = "unit", testName = "NetworkAsyncClientTest")
|
@Test(groups = "unit", testName = "NetworkAsyncClientTest")
|
||||||
public class NetworkAsyncClientTest extends BaseVCloudAsyncClientTest<NetworkAsyncClient> {
|
public class NetworkAsyncClientTest extends BaseVCloudAsyncClientTest<NetworkAsyncClient> {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<NetworkAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<NetworkAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = NetworkAsyncClient.class.getMethod("getNetwork", URI.class);
|
Method method = NetworkAsyncClient.class.getMethod("getNetwork", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method, URI
|
||||||
|
|
|
@ -26,14 +26,11 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||||
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
|
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
|
||||||
import org.jclouds.vcloud.xml.OrgHandler;
|
import org.jclouds.vcloud.xml.OrgHandler;
|
||||||
import org.jclouds.vcloud.xml.OrgListHandler;
|
import org.jclouds.vcloud.xml.OrgListHandler;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code OrgAsyncClient}
|
* Tests behavior of {@code OrgAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -44,12 +41,6 @@ import com.google.inject.TypeLiteral;
|
||||||
@Test(groups = "unit", testName = "OrgAsyncClientTest")
|
@Test(groups = "unit", testName = "OrgAsyncClientTest")
|
||||||
public class OrgAsyncClientTest extends BaseVCloudAsyncClientTest<OrgAsyncClient> {
|
public class OrgAsyncClientTest extends BaseVCloudAsyncClientTest<OrgAsyncClient> {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<OrgAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<OrgAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testlistOrgs() throws SecurityException, NoSuchMethodException, IOException {
|
public void testlistOrgs() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = OrgAsyncClient.class.getMethod("listOrgs");
|
Method method = OrgAsyncClient.class.getMethod("listOrgs");
|
||||||
HttpRequest request = processor.createRequest(method);
|
HttpRequest request = processor.createRequest(method);
|
||||||
|
|
|
@ -26,14 +26,11 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
|
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
|
||||||
import org.jclouds.vcloud.xml.TaskHandler;
|
import org.jclouds.vcloud.xml.TaskHandler;
|
||||||
import org.jclouds.vcloud.xml.TasksListHandler;
|
import org.jclouds.vcloud.xml.TasksListHandler;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code TaskAsyncClient}
|
* Tests behavior of {@code TaskAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -44,12 +41,6 @@ import com.google.inject.TypeLiteral;
|
||||||
@Test(groups = "unit", testName = "TaskAsyncClientTest")
|
@Test(groups = "unit", testName = "TaskAsyncClientTest")
|
||||||
public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest<TaskAsyncClient> {
|
public class TaskAsyncClientTest extends BaseVCloudAsyncClientTest<TaskAsyncClient> {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<TaskAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<TaskAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = TaskAsyncClient.class.getMethod("getTasksList", URI.class);
|
Method method = TaskAsyncClient.class.getMethod("getTasksList", URI.class);
|
||||||
HttpRequest request = processor.createRequest(method, URI
|
HttpRequest request = processor.createRequest(method, URI
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
|
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
|
||||||
import org.jclouds.vcloud.options.CloneVAppOptions;
|
import org.jclouds.vcloud.options.CloneVAppOptions;
|
||||||
|
@ -35,8 +34,6 @@ import org.jclouds.vcloud.xml.TaskHandler;
|
||||||
import org.jclouds.vcloud.xml.VAppHandler;
|
import org.jclouds.vcloud.xml.VAppHandler;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code VAppAsyncClient}
|
* Tests behavior of {@code VAppAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -47,12 +44,6 @@ import com.google.inject.TypeLiteral;
|
||||||
@Test(groups = "unit", testName = "VAppAsyncClientTest")
|
@Test(groups = "unit", testName = "VAppAsyncClientTest")
|
||||||
public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClient> {
|
public class VAppAsyncClientTest extends BaseVCloudAsyncClientTest<VAppAsyncClient> {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<VAppAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<VAppAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testopyVAppToVDCAndName() throws SecurityException, NoSuchMethodException, IOException {
|
public void testopyVAppToVDCAndName() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VAppAsyncClient.class.getMethod("copyVAppToVDCAndName", URI.class, URI.class, String.class,
|
Method method = VAppAsyncClient.class.getMethod("copyVAppToVDCAndName", URI.class, URI.class, String.class,
|
||||||
CloneVAppOptions[].class);
|
CloneVAppOptions[].class);
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.ovf.xml.EnvelopeHandler;
|
import org.jclouds.ovf.xml.EnvelopeHandler;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
import org.jclouds.vcloud.domain.network.FenceMode;
|
import org.jclouds.vcloud.domain.network.FenceMode;
|
||||||
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
||||||
|
@ -41,8 +40,6 @@ import org.jclouds.vcloud.xml.VAppHandler;
|
||||||
import org.jclouds.vcloud.xml.VAppTemplateHandler;
|
import org.jclouds.vcloud.xml.VAppTemplateHandler;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code VAppTemplateAsyncClient}
|
* Tests behavior of {@code VAppTemplateAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -53,12 +50,6 @@ import com.google.inject.TypeLiteral;
|
||||||
@Test(groups = "unit", testName = "VAppTemplateAsyncClientTest")
|
@Test(groups = "unit", testName = "VAppTemplateAsyncClientTest")
|
||||||
public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppTemplateAsyncClient> {
|
public class VAppTemplateAsyncClientTest extends BaseVCloudAsyncClientTest<VAppTemplateAsyncClient> {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<VAppTemplateAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<VAppTemplateAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testCreateVAppInVDCByInstantiatingTemplate() throws SecurityException, NoSuchMethodException,
|
public void testCreateVAppInVDCByInstantiatingTemplate() throws SecurityException, NoSuchMethodException,
|
||||||
IOException {
|
IOException {
|
||||||
Method method = VAppTemplateAsyncClient.class.getMethod("createVAppInVDCByInstantiatingTemplate", String.class,
|
Method method = VAppTemplateAsyncClient.class.getMethod("createVAppInVDCByInstantiatingTemplate", String.class,
|
||||||
|
|
|
@ -26,13 +26,10 @@ import java.util.NoSuchElementException;
|
||||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
|
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
|
||||||
import org.jclouds.vcloud.xml.VDCHandler;
|
import org.jclouds.vcloud.xml.VDCHandler;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code VDCAsyncClient}
|
* Tests behavior of {@code VDCAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -43,12 +40,6 @@ import com.google.inject.TypeLiteral;
|
||||||
@Test(groups = "unit", testName = "VDCAsyncClientTest")
|
@Test(groups = "unit", testName = "VDCAsyncClientTest")
|
||||||
public class VDCAsyncClientTest extends BaseVCloudAsyncClientTest<VDCAsyncClient> {
|
public class VDCAsyncClientTest extends BaseVCloudAsyncClientTest<VDCAsyncClient> {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<VDCAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<VDCAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(expectedExceptions = NoSuchElementException.class)
|
@Test(expectedExceptions = NoSuchElementException.class)
|
||||||
public void testFindVDCInOrgNamedBadVDC() throws SecurityException, NoSuchMethodException, IOException {
|
public void testFindVDCInOrgNamedBadVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
|
Method method = VDCAsyncClient.class.getMethod("findVDCInOrgNamed", String.class, String.class);
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.functions.ParseSax;
|
import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||||
import org.jclouds.http.functions.ReturnInputStream;
|
import org.jclouds.http.functions.ReturnInputStream;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.util.Strings2;
|
import org.jclouds.util.Strings2;
|
||||||
import org.jclouds.vcloud.domain.GuestCustomizationSection;
|
import org.jclouds.vcloud.domain.GuestCustomizationSection;
|
||||||
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
|
import org.jclouds.vcloud.internal.BaseVCloudAsyncClientTest;
|
||||||
|
@ -37,8 +36,6 @@ import org.jclouds.vcloud.xml.VmHandler;
|
||||||
import org.testng.annotations.DataProvider;
|
import org.testng.annotations.DataProvider;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code VmAsyncClient}
|
* Tests behavior of {@code VmAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -49,12 +46,6 @@ import com.google.inject.TypeLiteral;
|
||||||
@Test(groups = "unit", testName = "VmAsyncClientTest")
|
@Test(groups = "unit", testName = "VmAsyncClientTest")
|
||||||
public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient> {
|
public class VmAsyncClientTest extends BaseVCloudAsyncClientTest<VmAsyncClient> {
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<VmAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<VmAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testGetThumbnailOfVm() throws SecurityException, NoSuchMethodException, IOException {
|
public void testGetThumbnailOfVm() throws SecurityException, NoSuchMethodException, IOException {
|
||||||
Method method = VmAsyncClient.class.getMethod("getScreenThumbnailForVm", URI.class);
|
Method method = VmAsyncClient.class.getMethod("getScreenThumbnailForVm", URI.class);
|
||||||
HttpRequest request = processor
|
HttpRequest request = processor
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.jclouds.location.Provider;
|
||||||
import org.jclouds.providers.AnonymousProviderMetadata;
|
import org.jclouds.providers.AnonymousProviderMetadata;
|
||||||
import org.jclouds.providers.ProviderMetadata;
|
import org.jclouds.providers.ProviderMetadata;
|
||||||
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.vcloud.endpoints.VCloudLogin;
|
import org.jclouds.vcloud.endpoints.VCloudLogin;
|
||||||
import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;
|
import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -41,7 +40,6 @@ import com.google.common.base.Supplier;
|
||||||
import com.google.inject.Binder;
|
import com.google.inject.Binder;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code VCloudLoginAsyncClient}
|
* Tests behavior of {@code VCloudLoginAsyncClient}
|
||||||
|
@ -73,12 +71,6 @@ public class VCloudLoginAsyncClientTest extends BaseAsyncClientTest<VCloudLoginA
|
||||||
assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class);
|
assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<VCloudLoginAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<VCloudLoginAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Module createModule() {
|
protected Module createModule() {
|
||||||
return new Module() {
|
return new Module() {
|
||||||
|
|
|
@ -369,47 +369,8 @@ public class LocalAsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
|
|
||||||
public static HttpResponseException returnResponseException(int code) {
|
public static HttpResponseException returnResponseException(int code) {
|
||||||
HttpResponse response = HttpResponse.builder().statusCode(code).build();
|
HttpResponse response = HttpResponse.builder().statusCode(code).build();
|
||||||
return new HttpResponseException(new HttpCommand() {
|
return new HttpResponseException(new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://stub")
|
||||||
|
.build()), response);
|
||||||
public int getRedirectCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int incrementRedirectCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isReplayable() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Exception getException() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFailureCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int incrementFailureCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setException(Exception exception) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HttpRequest getCurrentRequest() {
|
|
||||||
return HttpRequest.builder().method("GET").endpoint("http://stub").build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCurrentRequest(HttpRequest request) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}, response);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -29,12 +29,9 @@ import org.jclouds.blobstore.domain.Blob;
|
||||||
import org.jclouds.blobstore.domain.BlobBuilder;
|
import org.jclouds.blobstore.domain.BlobBuilder;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code LocalBlobRequestSigner}
|
* Tests behavior of {@code LocalBlobRequestSigner}
|
||||||
*
|
*
|
||||||
|
@ -120,12 +117,6 @@ public class TransientBlobRequestSignerTest extends BaseAsyncClientTest<LocalAsy
|
||||||
protected void checkFilters(HttpRequest request) {
|
protected void checkFilters(HttpRequest request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<LocalAsyncBlobStore>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<LocalAsyncBlobStore>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiMetadata createApiMetadata() {
|
public ApiMetadata createApiMetadata() {
|
||||||
return new TransientApiMetadata();
|
return new TransientApiMetadata();
|
||||||
|
|
|
@ -29,11 +29,8 @@ import org.jclouds.http.IntegrationTestClient;
|
||||||
import org.jclouds.openstack.functions.ParseAuthenticationResponseFromHeaders;
|
import org.jclouds.openstack.functions.ParseAuthenticationResponseFromHeaders;
|
||||||
import org.jclouds.rest.AnonymousRestApiMetadata;
|
import org.jclouds.rest.AnonymousRestApiMetadata;
|
||||||
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code OpenStackAuthAsyncClient}
|
* Tests behavior of {@code OpenStackAuthAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -80,11 +77,4 @@ public class OpenStackAuthAsyncClientTest extends BaseAsyncClientTest<OpenStackA
|
||||||
@Override
|
@Override
|
||||||
protected void checkFilters(HttpRequest request) {
|
protected void checkFilters(HttpRequest request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<OpenStackAuthAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<OpenStackAuthAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ package org.jclouds.trmk.vcloud_0_8.binders;
|
||||||
import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NS;
|
import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NS;
|
||||||
import static org.testng.Assert.assertEquals;
|
import static org.testng.Assert.assertEquals;
|
||||||
import static org.testng.Assert.assertNotEquals;
|
import static org.testng.Assert.assertNotEquals;
|
||||||
import static org.testng.Assert.assertTrue;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
|
@ -32,7 +32,6 @@ import org.jclouds.location.Provider;
|
||||||
import org.jclouds.providers.AnonymousProviderMetadata;
|
import org.jclouds.providers.AnonymousProviderMetadata;
|
||||||
import org.jclouds.providers.ProviderMetadata;
|
import org.jclouds.providers.ProviderMetadata;
|
||||||
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.trmk.vcloud_0_8.endpoints.VCloudLogin;
|
import org.jclouds.trmk.vcloud_0_8.endpoints.VCloudLogin;
|
||||||
import org.jclouds.trmk.vcloud_0_8.functions.ParseLoginResponseFromHeaders;
|
import org.jclouds.trmk.vcloud_0_8.functions.ParseLoginResponseFromHeaders;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -41,7 +40,6 @@ import com.google.common.base.Supplier;
|
||||||
import com.google.inject.Binder;
|
import com.google.inject.Binder;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code VCloudLoginAsyncClient}
|
* Tests behavior of {@code VCloudLoginAsyncClient}
|
||||||
|
@ -74,12 +72,6 @@ public class TerremarkVCloudLoginAsyncClientTest extends BaseAsyncClientTest<Ter
|
||||||
assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class);
|
assertEquals(request.getFilters().get(0).getClass(), BasicAuthentication.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<TerremarkVCloudLoginAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<TerremarkVCloudLoginAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Module createModule() {
|
protected Module createModule() {
|
||||||
return new Module() {
|
return new Module() {
|
||||||
|
|
|
@ -28,12 +28,9 @@ import org.jclouds.http.functions.ParseSax;
|
||||||
import org.jclouds.providers.AnonymousProviderMetadata;
|
import org.jclouds.providers.AnonymousProviderMetadata;
|
||||||
import org.jclouds.providers.ProviderMetadata;
|
import org.jclouds.providers.ProviderMetadata;
|
||||||
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.jclouds.trmk.vcloud_0_8.xml.SupportedVersionsHandler;
|
import org.jclouds.trmk.vcloud_0_8.xml.SupportedVersionsHandler;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests behavior of {@code VCloudVersionsAsyncClient}
|
* Tests behavior of {@code VCloudVersionsAsyncClient}
|
||||||
*
|
*
|
||||||
|
@ -63,12 +60,6 @@ public class TerremarkVCloudVersionsAsyncClientTest extends BaseAsyncClientTest<
|
||||||
assertEquals(request.getFilters().size(), 0);
|
assertEquals(request.getFilters().size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected TypeLiteral<RestAnnotationProcessor<TerremarkVCloudVersionsAsyncClient>> createTypeLiteral() {
|
|
||||||
return new TypeLiteral<RestAnnotationProcessor<TerremarkVCloudVersionsAsyncClient>>() {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ProviderMetadata createProviderMetadata() {
|
protected ProviderMetadata createProviderMetadata() {
|
||||||
return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(TerremarkVCloudVersionsClient.class,
|
return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(TerremarkVCloudVersionsClient.class,
|
||||||
|
|
|
@ -18,65 +18,125 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.http;
|
package org.jclouds.http;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||||
|
|
||||||
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command whose endpoint is an http service.
|
* Command whose endpoint is an http service.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public interface HttpCommand {
|
//TODO: get rid of all the mock tests so that this can be made final
|
||||||
|
public class HttpCommand {
|
||||||
|
|
||||||
/**
|
private volatile HttpRequest request;
|
||||||
* increments the current number of redirect attempts for this command.
|
private volatile int failureCount;
|
||||||
*
|
private volatile int redirectCount;
|
||||||
* @see #getRedirectCount
|
private volatile Exception exception;
|
||||||
*/
|
|
||||||
int incrementRedirectCount();
|
|
||||||
|
|
||||||
/**
|
public HttpCommand(HttpRequest request) {
|
||||||
* This displays the current number of redirect attempts for this command.
|
this.request = checkNotNull(request, "request");
|
||||||
*
|
this.failureCount = 0;
|
||||||
* @see org.jclouds.Constants.PROPERTY_MAX_REDIRECTS
|
this.redirectCount = 0;
|
||||||
*/
|
}
|
||||||
int getRedirectCount();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Commands need to be replayed, if redirected or on a retryable error. Typically, this implies
|
|
||||||
* the payload carried is not a streaming type.
|
|
||||||
*/
|
|
||||||
boolean isReplayable();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* increment the current failure count.
|
|
||||||
*
|
|
||||||
* @see #getFailureCount
|
|
||||||
*/
|
|
||||||
int incrementFailureCount();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This displays the current number of error retries for this command.
|
* This displays the current number of error retries for this command.
|
||||||
*
|
*
|
||||||
* @see org.jclouds.Constants.PROPERTY_MAX_RETRIES
|
* @see org.jclouds.Constants.PROPERTY_MAX_RETRIES
|
||||||
*/
|
*/
|
||||||
int getFailureCount();
|
public int getFailureCount() {
|
||||||
|
return failureCount;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The request associated with this command.
|
* increment the current failure count.
|
||||||
|
*
|
||||||
|
* @see #getFailureCount
|
||||||
*/
|
*/
|
||||||
HttpRequest getCurrentRequest();
|
public int incrementFailureCount() {
|
||||||
|
return ++failureCount;
|
||||||
/**
|
}
|
||||||
* The request associated with this command.
|
|
||||||
*/
|
|
||||||
void setCurrentRequest(HttpRequest request);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to prevent a command from being re-executed, or having its response parsed.
|
* Used to prevent a command from being re-executed, or having its response parsed.
|
||||||
*/
|
*/
|
||||||
void setException(Exception exception);
|
public void setException(Exception exception) {
|
||||||
|
this.exception = exception;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #setException
|
* @see #setException
|
||||||
*/
|
*/
|
||||||
Exception getException();
|
public Exception getException() {
|
||||||
|
return exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* increments the current number of redirect attempts for this command.
|
||||||
|
*
|
||||||
|
* @see #getRedirectCount
|
||||||
|
*/
|
||||||
|
public int incrementRedirectCount() {
|
||||||
|
return ++redirectCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This displays the current number of redirect attempts for this command.
|
||||||
|
*
|
||||||
|
* @see org.jclouds.Constants.PROPERTY_MAX_REDIRECTS
|
||||||
|
*/
|
||||||
|
public int getRedirectCount() {
|
||||||
|
return redirectCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commands need to be replayed, if redirected or on a retryable error. Typically, this implies
|
||||||
|
* the payload carried is not a streaming type.
|
||||||
|
*/
|
||||||
|
public boolean isReplayable() {
|
||||||
|
return (request.getPayload() == null) ? true : request.getPayload().isRepeatable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The request associated with this command.
|
||||||
|
*/
|
||||||
|
public HttpRequest getCurrentRequest() {
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The request associated with this command.
|
||||||
|
*/
|
||||||
|
public void setCurrentRequest(HttpRequest request) {
|
||||||
|
this.request = request;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hashCode(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object that) {
|
||||||
|
if (that == null)
|
||||||
|
return false;
|
||||||
|
if (!(that instanceof HttpCommand))
|
||||||
|
return false;
|
||||||
|
return Objects.equal(this.request, HttpCommand.class.cast(that).getCurrentRequest());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
if (request instanceof GeneratedHttpRequest)
|
||||||
|
return String.format("[method=%s.%s, request=%s]", GeneratedHttpRequest.class.cast(request).getDeclaring()
|
||||||
|
.getSimpleName(), GeneratedHttpRequest.class.cast(request).getJavaMethod().getName(), request
|
||||||
|
.getRequestLine());
|
||||||
|
else
|
||||||
|
return "[request=" + request.getRequestLine() + "]";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,65 +0,0 @@
|
||||||
/**
|
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package org.jclouds.http;
|
|
||||||
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
import java.util.concurrent.SynchronousQueue;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used for passing objects for response processing
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
public class HttpCommandRendezvous<T, R extends HttpRequest> {
|
|
||||||
|
|
||||||
private final HttpCommand command;
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
private final SynchronousQueue rendezvous;
|
|
||||||
private final Future<T> future;
|
|
||||||
|
|
||||||
public HttpCommandRendezvous(HttpCommand command, @SuppressWarnings("rawtypes") SynchronousQueue rendezvous,
|
|
||||||
Future<T> future) {
|
|
||||||
this.command = command;
|
|
||||||
this.rendezvous = rendezvous;
|
|
||||||
this.future = future;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void setResponse(HttpResponse response) throws InterruptedException {
|
|
||||||
this.rendezvous.put(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public void setException(Exception exception) throws InterruptedException {
|
|
||||||
this.rendezvous.put(exception);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void cancel() {
|
|
||||||
getFuture().cancel(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HttpCommand getCommand() {
|
|
||||||
return command;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Future<T> getFuture() {
|
|
||||||
return future;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
/**
|
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package org.jclouds.http;
|
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Command that utilizes RESTFul apis and extracts <code>T</code> from the HttpResponse.
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
public interface TransformingHttpCommand<T> extends HttpCommand {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* invoke and transform the response {@code <R>} into value type {@code <T>}
|
|
||||||
*
|
|
||||||
* @return future containing the expected value
|
|
||||||
*
|
|
||||||
* @throws ExecutionException
|
|
||||||
* if there is a fatal error preventing the command from invoking
|
|
||||||
*/
|
|
||||||
ListenableFuture<T> execute() throws ExecutionException;
|
|
||||||
}
|
|
|
@ -1,48 +0,0 @@
|
||||||
/**
|
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package org.jclouds.http;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
|
||||||
import com.google.inject.ImplementedBy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Executor which will invoke and transform the response of an {@code EndpointCommand} into generic
|
|
||||||
* type <T>.
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
@ImplementedBy(TransformingHttpCommandExecutorServiceImpl.class)
|
|
||||||
public interface TransformingHttpCommandExecutorService {
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Submits the command and transforms the result before requested via {@link Future#get()}.
|
|
||||||
*
|
|
||||||
* @param <T>
|
|
||||||
* type that is required from the value.
|
|
||||||
* @param command
|
|
||||||
* holds the state of the request, including metadata such as redirect counts
|
|
||||||
* @param responseTransformer
|
|
||||||
* how to transform the response from the above command
|
|
||||||
* @return value of the intended response.
|
|
||||||
*/
|
|
||||||
public <T, R extends HttpRequest> ListenableFuture<T> submit(HttpCommand command,
|
|
||||||
Function<HttpResponse, T> responseTransformer);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
/**
|
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package org.jclouds.http;
|
|
||||||
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Named;
|
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
|
||||||
import org.jclouds.concurrent.Futures;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Executor which will invoke and transform the response of an {@code EndpointCommand} into generic
|
|
||||||
* type <T>. TODO
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
public class TransformingHttpCommandExecutorServiceImpl implements TransformingHttpCommandExecutorService {
|
|
||||||
private final HttpCommandExecutorService client;
|
|
||||||
private final ExecutorService userThreads;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public TransformingHttpCommandExecutorServiceImpl(HttpCommandExecutorService client,
|
|
||||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads) {
|
|
||||||
this.client = client;
|
|
||||||
this.userThreads = userThreads;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
public <T, R extends HttpRequest> ListenableFuture<T> submit(HttpCommand command,
|
|
||||||
Function<HttpResponse, T> responseTransformer) {
|
|
||||||
return Futures.compose(client.submit(command), responseTransformer, userThreads);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,172 +0,0 @@
|
||||||
/**
|
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package org.jclouds.http;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
|
|
||||||
import org.jclouds.logging.Logger;
|
|
||||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.base.Objects;
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Executor which will invoke and transform the response of an {@code EndpointCommand} into generic
|
|
||||||
* type <T>.
|
|
||||||
*
|
|
||||||
* @see TransformingHttpCommand
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
public class TransformingHttpCommandImpl<T> implements TransformingHttpCommand<T> {
|
|
||||||
|
|
||||||
protected final TransformingHttpCommandExecutorService executorService;
|
|
||||||
protected final Function<HttpResponse, T> transformer;
|
|
||||||
|
|
||||||
protected volatile HttpRequest request;
|
|
||||||
protected volatile int failureCount;
|
|
||||||
protected volatile int redirectCount;
|
|
||||||
protected volatile Exception exception;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
protected Logger logger = Logger.NULL;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public TransformingHttpCommandImpl(TransformingHttpCommandExecutorService executorService, HttpRequest request,
|
|
||||||
Function<HttpResponse, T> transformer) {
|
|
||||||
this.request = checkNotNull(request, "request");
|
|
||||||
this.executorService = checkNotNull(executorService, "executorService");
|
|
||||||
this.transformer = checkNotNull(transformer, "transformer");
|
|
||||||
this.failureCount = 0;
|
|
||||||
this.redirectCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public ListenableFuture<T> execute() throws ExecutionException {
|
|
||||||
if (exception != null)
|
|
||||||
throw new ExecutionException(exception);
|
|
||||||
return executorService.submit(this, transformer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int getFailureCount() {
|
|
||||||
return failureCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int incrementFailureCount() {
|
|
||||||
return ++failureCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setException(Exception exception) {
|
|
||||||
this.exception = exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Exception getException() {
|
|
||||||
return exception;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int incrementRedirectCount() {
|
|
||||||
return ++redirectCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int getRedirectCount() {
|
|
||||||
return redirectCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean isReplayable() {
|
|
||||||
return (request.getPayload() == null) ? true : request.getPayload().isRepeatable();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public HttpRequest getCurrentRequest() {
|
|
||||||
return request;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setCurrentRequest(HttpRequest request) {
|
|
||||||
this.request = request;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode() {
|
|
||||||
return Objects.hashCode(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object that) {
|
|
||||||
if (that == null)
|
|
||||||
return false;
|
|
||||||
if (!(that instanceof HttpCommand))
|
|
||||||
return false;
|
|
||||||
return Objects.equal(this.request, HttpCommand.class.cast(that).getCurrentRequest());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
if (request instanceof GeneratedHttpRequest)
|
|
||||||
return String.format("[method=%s.%s, request=%s]", GeneratedHttpRequest.class.cast(request).getDeclaring()
|
|
||||||
.getSimpleName(), GeneratedHttpRequest.class.cast(request).getJavaMethod().getName(), request
|
|
||||||
.getRequestLine());
|
|
||||||
else
|
|
||||||
return "[request=" + request.getRequestLine() + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -19,8 +19,6 @@
|
||||||
package org.jclouds.http.config;
|
package org.jclouds.http.config;
|
||||||
|
|
||||||
import org.jclouds.http.HttpCommandExecutorService;
|
import org.jclouds.http.HttpCommandExecutorService;
|
||||||
import org.jclouds.http.TransformingHttpCommandExecutorService;
|
|
||||||
import org.jclouds.http.TransformingHttpCommandExecutorServiceImpl;
|
|
||||||
import org.jclouds.http.internal.JavaUrlHttpCommandExecutorService;
|
import org.jclouds.http.internal.JavaUrlHttpCommandExecutorService;
|
||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
|
@ -40,8 +38,6 @@ public class JavaUrlHttpCommandExecutorServiceModule extends AbstractModule {
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
install(new SSLModule());
|
install(new SSLModule());
|
||||||
bind(HttpCommandExecutorService.class).to(JavaUrlHttpCommandExecutorService.class).in(Scopes.SINGLETON);
|
bind(HttpCommandExecutorService.class).to(JavaUrlHttpCommandExecutorService.class).in(Scopes.SINGLETON);
|
||||||
bind(TransformingHttpCommandExecutorService.class).to(TransformingHttpCommandExecutorServiceImpl.class).in(
|
|
||||||
Scopes.SINGLETON);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,26 +29,26 @@ import com.google.common.base.Objects.ToStringHelper;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class ClassMethodArgsAndReturnVal extends ClassMethodArgs {
|
public final class ClassMethodArgsAndReturnVal extends ClassMethodArgs {
|
||||||
|
|
||||||
public static Builder<?> builder() {
|
public static Builder builder() {
|
||||||
return new ConcreteBuilder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder<?> toBuilder() {
|
public Builder toBuilder() {
|
||||||
return builder().fromClassMethodArgsAndReturnVal(this);
|
return builder().fromClassMethodArgsAndReturnVal(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder<B extends Builder<B>> extends ClassMethodArgs.Builder<B> {
|
public final static class Builder extends ClassMethodArgs.Builder<Builder> {
|
||||||
|
|
||||||
private Object returnVal;
|
private Object returnVal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ClassMethodArgsAndReturnVal#getReturnVal()
|
* @see ClassMethodArgsAndReturnVal#getReturnVal()
|
||||||
*/
|
*/
|
||||||
public B returnVal(Object returnVal) {
|
public Builder returnVal(Object returnVal) {
|
||||||
this.returnVal = returnVal;
|
this.returnVal = returnVal;
|
||||||
return self();
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,22 +56,19 @@ public class ClassMethodArgsAndReturnVal extends ClassMethodArgs {
|
||||||
return new ClassMethodArgsAndReturnVal(this);
|
return new ClassMethodArgsAndReturnVal(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public B fromClassMethodArgsAndReturnVal(ClassMethodArgsAndReturnVal in) {
|
public Builder fromClassMethodArgsAndReturnVal(ClassMethodArgsAndReturnVal in) {
|
||||||
return fromClassMethodArgs(in).returnVal(in.getReturnVal());
|
return fromClassMethodArgs(in).returnVal(in.getReturnVal());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ConcreteBuilder extends Builder<ConcreteBuilder> {
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Object returnVal;
|
private final Object returnVal;
|
||||||
|
|
||||||
public ClassMethodArgsAndReturnVal(Class<?> clazz, Method method, Object[] args, Object returnVal) {
|
private ClassMethodArgsAndReturnVal(Class<?> clazz, Method method, Object[] args, Object returnVal) {
|
||||||
super(clazz, method, args);
|
super(clazz, method, args);
|
||||||
this.returnVal = returnVal;
|
this.returnVal = returnVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClassMethodArgsAndReturnVal(Builder<?> builder) {
|
private ClassMethodArgsAndReturnVal(Builder builder) {
|
||||||
super(builder);
|
super(builder);
|
||||||
this.returnVal = builder.returnVal;
|
this.returnVal = builder.returnVal;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
/**
|
|
||||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. jclouds licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package org.jclouds.rest;
|
|
||||||
|
|
||||||
import static com.google.common.reflect.Reflection.newProxy;
|
|
||||||
import static com.google.inject.util.Types.newParameterizedType;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import org.jclouds.rest.internal.AsyncRestClientProxy;
|
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.google.inject.Key;
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
@Singleton
|
|
||||||
public class AsyncClientFactory {
|
|
||||||
private final Injector injector;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private AsyncClientFactory(Injector injector) {
|
|
||||||
this.injector = injector;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public <T> T create(Class<T> clazz) {
|
|
||||||
Key<AsyncRestClientProxy<T>> key = (Key<AsyncRestClientProxy<T>>) Key.get(TypeLiteral.get(newParameterizedType(
|
|
||||||
AsyncRestClientProxy.class, clazz)));
|
|
||||||
return newProxy(clazz, injector.getInstance(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -18,12 +18,16 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rest.config;
|
package org.jclouds.rest.config;
|
||||||
|
|
||||||
|
import static com.google.common.reflect.Reflection.newProxy;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.rest.AsyncClientFactory;
|
import org.jclouds.rest.internal.AsyncRestClientProxy;
|
||||||
|
import org.jclouds.rest.internal.AsyncRestClientProxy.Factory;
|
||||||
|
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -31,19 +35,20 @@ import com.google.inject.Provider;
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AsyncClientProvider<A> implements Provider<A> {
|
public class AsyncClientProvider<A> implements Provider<A> {
|
||||||
private final Class<A> asyncClientType;
|
private final Class<? super A> asyncClientType;
|
||||||
private final AsyncClientFactory factory;
|
private final Factory factory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private AsyncClientProvider(AsyncClientFactory factory, Class<A> asyncClientType) {
|
private AsyncClientProvider(AsyncRestClientProxy.Factory factory, TypeLiteral<A> asyncClientType) {
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
this.asyncClientType = asyncClientType;
|
this.asyncClientType = asyncClientType.getRawType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
@Singleton
|
@Singleton
|
||||||
public A get() {
|
public A get() {
|
||||||
return factory.create(asyncClientType);
|
return (A) newProxy(asyncClientType, factory.declaring(asyncClientType));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rest.config;
|
package org.jclouds.rest.config;
|
||||||
|
|
||||||
import static com.google.common.reflect.Reflection.newProxy;
|
|
||||||
import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX;
|
import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX;
|
||||||
import static org.jclouds.rest.config.BinderUtils.bindClientAndAsyncClient;
|
import static org.jclouds.rest.config.BinderUtils.bindClientAndAsyncClient;
|
||||||
|
|
||||||
|
@ -32,11 +31,6 @@ import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.concurrent.internal.SyncProxy;
|
import org.jclouds.concurrent.internal.SyncProxy;
|
||||||
import org.jclouds.functions.IdentityFunction;
|
import org.jclouds.functions.IdentityFunction;
|
||||||
import org.jclouds.http.HttpRequest;
|
|
||||||
import org.jclouds.http.HttpResponse;
|
|
||||||
import org.jclouds.http.TransformingHttpCommand;
|
|
||||||
import org.jclouds.http.TransformingHttpCommandExecutorService;
|
|
||||||
import org.jclouds.http.TransformingHttpCommandImpl;
|
|
||||||
import org.jclouds.http.functions.config.SaxParserModule;
|
import org.jclouds.http.functions.config.SaxParserModule;
|
||||||
import org.jclouds.internal.ClassMethodArgs;
|
import org.jclouds.internal.ClassMethodArgs;
|
||||||
import org.jclouds.internal.FilterStringsBoundToInjectorByName;
|
import org.jclouds.internal.FilterStringsBoundToInjectorByName;
|
||||||
|
@ -47,6 +41,8 @@ import org.jclouds.rest.HttpAsyncClient;
|
||||||
import org.jclouds.rest.HttpClient;
|
import org.jclouds.rest.HttpClient;
|
||||||
import org.jclouds.rest.binders.BindToJsonPayloadWrappedWith;
|
import org.jclouds.rest.binders.BindToJsonPayloadWrappedWith;
|
||||||
import org.jclouds.rest.internal.AsyncRestClientProxy;
|
import org.jclouds.rest.internal.AsyncRestClientProxy;
|
||||||
|
import org.jclouds.rest.internal.CreateAsyncClientForCaller;
|
||||||
|
import org.jclouds.rest.internal.CreateClientForCaller;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor.MethodKey;
|
import org.jclouds.rest.internal.RestAnnotationProcessor.MethodKey;
|
||||||
import org.jclouds.rest.internal.SeedAnnotationCache;
|
import org.jclouds.rest.internal.SeedAnnotationCache;
|
||||||
|
@ -58,21 +54,14 @@ import com.google.common.base.Predicate;
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
|
||||||
import com.google.common.cache.LoadingCache;
|
import com.google.common.cache.LoadingCache;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.util.concurrent.Atomics;
|
import com.google.common.util.concurrent.Atomics;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Inject;
|
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.google.inject.Key;
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.Scopes;
|
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||||
import com.google.inject.name.Names;
|
|
||||||
import com.google.inject.util.Types;
|
|
||||||
|
|
||||||
public class RestModule extends AbstractModule {
|
public class RestModule extends AbstractModule {
|
||||||
|
|
||||||
|
@ -99,8 +88,9 @@ public class RestModule extends AbstractModule {
|
||||||
install(new SaxParserModule());
|
install(new SaxParserModule());
|
||||||
install(new GsonModule());
|
install(new GsonModule());
|
||||||
install(new FactoryModuleBuilder().build(BindToJsonPayloadWrappedWith.Factory.class));
|
install(new FactoryModuleBuilder().build(BindToJsonPayloadWrappedWith.Factory.class));
|
||||||
|
install(new FactoryModuleBuilder().build(RestAnnotationProcessor.Factory.class));
|
||||||
|
install(new FactoryModuleBuilder().build(AsyncRestClientProxy.Factory.class));
|
||||||
bind(IdentityFunction.class).toInstance(IdentityFunction.INSTANCE);
|
bind(IdentityFunction.class).toInstance(IdentityFunction.INSTANCE);
|
||||||
bind(AsyncRestClientProxy.Factory.class).to(Factory.class).in(Scopes.SINGLETON);
|
|
||||||
install(new FactoryModuleBuilder().build(SyncProxy.Factory.class));
|
install(new FactoryModuleBuilder().build(SyncProxy.Factory.class));
|
||||||
bindClientAndAsyncClient(binder(), HttpClient.class, HttpAsyncClient.class);
|
bindClientAndAsyncClient(binder(), HttpClient.class, HttpAsyncClient.class);
|
||||||
// this will help short circuit scenarios that can otherwise lock out users
|
// this will help short circuit scenarios that can otherwise lock out users
|
||||||
|
@ -111,18 +101,6 @@ public class RestModule extends AbstractModule {
|
||||||
installLocations();
|
installLocations();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Shared for all types of rest clients. this is read-only in this class, and
|
|
||||||
* currently populated only by {@link SeedAnnotationCache}
|
|
||||||
*
|
|
||||||
* @see SeedAnnotationCache
|
|
||||||
*/
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
protected Cache<MethodKey, Method> delegationMap(){
|
|
||||||
return CacheBuilder.newBuilder().build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@Named("TIMEOUTS")
|
@Named("TIMEOUTS")
|
||||||
|
@ -149,7 +127,7 @@ public class RestModule extends AbstractModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
protected LoadingCache<Class<?>, Boolean> seedAnnotationCache(SeedAnnotationCache seedAnnotationCache) {
|
private LoadingCache<Class<?>, Cache<MethodKey, Method>> seedAnnotationCache(SeedAnnotationCache seedAnnotationCache) {
|
||||||
return CacheBuilder.newBuilder().build(seedAnnotationCache);
|
return CacheBuilder.newBuilder().build(seedAnnotationCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,45 +138,6 @@ public class RestModule extends AbstractModule {
|
||||||
return CacheBuilder.newBuilder().build(createAsyncClientForCaller);
|
return CacheBuilder.newBuilder().build(createAsyncClientForCaller);
|
||||||
}
|
}
|
||||||
|
|
||||||
static class CreateAsyncClientForCaller extends CacheLoader<ClassMethodArgs, Object> {
|
|
||||||
private final Injector injector;
|
|
||||||
private final AsyncRestClientProxy.Factory factory;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
CreateAsyncClientForCaller(Injector injector, AsyncRestClientProxy.Factory factory) {
|
|
||||||
this.injector = injector;
|
|
||||||
this.factory = factory;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings( { "unchecked", "rawtypes" })
|
|
||||||
@Override
|
|
||||||
public Object load(final ClassMethodArgs from) {
|
|
||||||
Class clazz = from.getClazz();
|
|
||||||
TypeLiteral typeLiteral = TypeLiteral.get(clazz);
|
|
||||||
RestAnnotationProcessor util = (RestAnnotationProcessor) injector.getInstance(Key.get(TypeLiteral.get(Types
|
|
||||||
.newParameterizedType(RestAnnotationProcessor.class, clazz))));
|
|
||||||
// cannot use child injectors due to the super coarse guice lock on Singleton
|
|
||||||
util.setCaller(from);
|
|
||||||
LoadingCache<ClassMethodArgs, Object> delegateMap = injector.getInstance(Key.get(
|
|
||||||
new TypeLiteral<LoadingCache<ClassMethodArgs, Object>>() {
|
|
||||||
}, Names.named("async")));
|
|
||||||
AsyncRestClientProxy proxy = new AsyncRestClientProxy(injector, factory, util, typeLiteral, delegateMap);
|
|
||||||
injector.injectMembers(proxy);
|
|
||||||
return newProxy(clazz, proxy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class Factory implements AsyncRestClientProxy.Factory {
|
|
||||||
@Inject
|
|
||||||
private TransformingHttpCommandExecutorService executorService;
|
|
||||||
|
|
||||||
@SuppressWarnings( { "unchecked", "rawtypes" })
|
|
||||||
@Override
|
|
||||||
public TransformingHttpCommand<?> create(HttpRequest request, Function<HttpResponse, ?> transformer) {
|
|
||||||
return new TransformingHttpCommandImpl(executorService, request, transformer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
@Named("sync")
|
@Named("sync")
|
||||||
|
|
|
@ -19,23 +19,28 @@
|
||||||
package org.jclouds.rest.internal;
|
package org.jclouds.rest.internal;
|
||||||
|
|
||||||
import static com.google.common.util.concurrent.Futures.immediateFailedFuture;
|
import static com.google.common.util.concurrent.Futures.immediateFailedFuture;
|
||||||
|
import static com.google.common.util.concurrent.Futures.transform;
|
||||||
import static com.google.common.util.concurrent.Futures.withFallback;
|
import static com.google.common.util.concurrent.Futures.withFallback;
|
||||||
|
import static org.jclouds.concurrent.Futures.makeListenable;
|
||||||
|
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.ExecutorService;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Qualifier;
|
import javax.inject.Qualifier;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
|
||||||
|
import org.jclouds.http.HttpCommand;
|
||||||
|
import org.jclouds.http.HttpCommandExecutorService;
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.TransformingHttpCommand;
|
|
||||||
import org.jclouds.internal.ClassMethodArgs;
|
import org.jclouds.internal.ClassMethodArgs;
|
||||||
import org.jclouds.internal.ClassMethodArgsAndReturnVal;
|
import org.jclouds.internal.ClassMethodArgsAndReturnVal;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
@ -61,12 +66,11 @@ import com.google.common.util.concurrent.FutureFallback;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
import com.google.inject.Binding;
|
import com.google.inject.Binding;
|
||||||
import com.google.inject.ConfigurationException;
|
import com.google.inject.ConfigurationException;
|
||||||
import com.google.inject.Inject;
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Key;
|
import com.google.inject.Key;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import com.google.inject.ProvisionException;
|
import com.google.inject.ProvisionException;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.assistedinject.Assisted;
|
||||||
import com.google.inject.util.Types;
|
import com.google.inject.util.Types;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,40 +98,55 @@ import com.google.inject.util.Types;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AsyncRestClientProxy<T> extends AbstractInvocationHandler {
|
public abstract class AsyncRestClientProxy extends AbstractInvocationHandler {
|
||||||
public Class<T> getDeclaring() {
|
public static interface Factory {
|
||||||
return declaring;
|
Declaring declaring(Class<?> declaring);
|
||||||
|
|
||||||
|
Caller caller(ClassMethodArgs caller);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Injector injector;
|
public final static class Declaring extends AsyncRestClientProxy {
|
||||||
private final RestAnnotationProcessor<T> annotationProcessor;
|
@Inject
|
||||||
private final Class<T> declaring;
|
private Declaring(Injector injector, Function<ClassMethodArgsAndReturnVal, Optional<Object>> optionalConverter,
|
||||||
private final Factory commandFactory;
|
HttpCommandExecutorService http, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads,
|
||||||
|
@Named("async") LoadingCache<ClassMethodArgs, Object> delegateMap, RestAnnotationProcessor.Factory rap,
|
||||||
|
@Assisted Class<?> declaring) {
|
||||||
|
super(injector, optionalConverter, http, userThreads, delegateMap, rap.declaring(declaring), declaring);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
public final static class Caller extends AsyncRestClientProxy {
|
||||||
* maximum duration of an unbackend http Request
|
@Inject
|
||||||
*/
|
private Caller(Injector injector, Function<ClassMethodArgsAndReturnVal, Optional<Object>> optionalConverter,
|
||||||
@Inject(optional = true)
|
HttpCommandExecutorService http, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads,
|
||||||
@Named(Constants.PROPERTY_REQUEST_TIMEOUT)
|
@Named("async") LoadingCache<ClassMethodArgs, Object> delegateMap, RestAnnotationProcessor.Factory rap,
|
||||||
protected long requestTimeoutMilliseconds = 30000;
|
@Assisted ClassMethodArgs caller) {
|
||||||
|
super(injector, optionalConverter, http, userThreads, delegateMap, rap.caller(caller), caller.getClazz());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
private Logger logger = Logger.NULL;
|
||||||
|
|
||||||
|
private final Injector injector;
|
||||||
|
private final HttpCommandExecutorService http;
|
||||||
|
private final ExecutorService userThreads;
|
||||||
private final Function<ClassMethodArgsAndReturnVal, Optional<Object>> optionalConverter;
|
private final Function<ClassMethodArgsAndReturnVal, Optional<Object>> optionalConverter;
|
||||||
private final LoadingCache<ClassMethodArgs, Object> delegateMap;
|
private final LoadingCache<ClassMethodArgs, Object> delegateMap;
|
||||||
|
private final RestAnnotationProcessor annotationProcessor;
|
||||||
|
private final Class<?> declaring;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
private AsyncRestClientProxy(Injector injector,
|
||||||
@Inject
|
Function<ClassMethodArgsAndReturnVal, Optional<Object>> optionalConverter, HttpCommandExecutorService http,
|
||||||
public AsyncRestClientProxy(Injector injector, Factory factory, RestAnnotationProcessor<T> util,
|
ExecutorService userThreads, LoadingCache<ClassMethodArgs, Object> delegateMap,
|
||||||
TypeLiteral<T> typeLiteral, @Named("async") LoadingCache<ClassMethodArgs, Object> delegateMap) {
|
RestAnnotationProcessor annotationProcessor, Class<?> declaring) {
|
||||||
this.injector = injector;
|
this.injector = injector;
|
||||||
this.optionalConverter = injector.getInstance(Key
|
this.optionalConverter = optionalConverter;
|
||||||
.get(new TypeLiteral<Function<ClassMethodArgsAndReturnVal, Optional<Object>>>() {
|
this.http = http;
|
||||||
}));
|
this.userThreads = userThreads;
|
||||||
this.annotationProcessor = util;
|
|
||||||
this.declaring = (Class<T>) typeLiteral.getRawType();
|
|
||||||
this.commandFactory = factory;
|
|
||||||
this.delegateMap = delegateMap;
|
this.delegateMap = delegateMap;
|
||||||
|
this.declaring = declaring;
|
||||||
|
this.annotationProcessor = annotationProcessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Predicate<Annotation> isQualifierPresent = new Predicate<Annotation>() {
|
private static final Predicate<Annotation> isQualifierPresent = new Predicate<Annotation>() {
|
||||||
|
@ -249,7 +268,7 @@ public class AsyncRestClientProxy<T> extends AbstractInvocationHandler {
|
||||||
logger.trace("<< response from %s is parsed by %s", name, transformer.getClass().getSimpleName());
|
logger.trace("<< response from %s is parsed by %s", name, transformer.getClass().getSimpleName());
|
||||||
|
|
||||||
logger.debug(">> invoking %s", name);
|
logger.debug(">> invoking %s", name);
|
||||||
result = commandFactory.create(request, transformer).execute();
|
result = transform(makeListenable(http.submit(new HttpCommand(request)), userThreads), transformer);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
AuthorizationException aex = Throwables2.getFirstThrowableOfType(e, AuthorizationException.class);
|
AuthorizationException aex = Throwables2.getFirstThrowableOfType(e, AuthorizationException.class);
|
||||||
if (aex != null)
|
if (aex != null)
|
||||||
|
@ -264,10 +283,6 @@ public class AsyncRestClientProxy<T> extends AbstractInvocationHandler {
|
||||||
return withFallback(result, fallback);
|
return withFallback(result, fallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static interface Factory {
|
|
||||||
public TransformingHttpCommand<?> create(HttpRequest request, Function<HttpResponse, ?> transformer);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Client Proxy for :" + declaring.getName();
|
return "Client Proxy for :" + declaring.getName();
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ public class BaseRestApiMetadata extends BaseApiMetadata implements RestApiMetad
|
||||||
|
|
||||||
public static <S, A> TypeToken<RestContext<S, A>> contextToken(TypeToken<S> apiToken, TypeToken<A> asyncApiToken) {
|
public static <S, A> TypeToken<RestContext<S, A>> contextToken(TypeToken<S> apiToken, TypeToken<A> asyncApiToken) {
|
||||||
return new TypeToken<RestContext<S, A>>() {
|
return new TypeToken<RestContext<S, A>>() {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
}.where(new TypeParameter<S>() {
|
}.where(new TypeParameter<S>() {
|
||||||
}, apiToken).where(new TypeParameter<A>() {
|
}, apiToken).where(new TypeParameter<A>() {
|
||||||
}, asyncApiToken);
|
}, asyncApiToken);
|
||||||
|
|
|
@ -16,25 +16,26 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudstack.features;
|
package org.jclouds.rest.internal;
|
||||||
|
|
||||||
import org.jclouds.cloudstack.internal.BaseCloudStackAsyncClientTest;
|
import static com.google.common.reflect.Reflection.newProxy;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import com.google.inject.TypeLiteral;
|
import org.jclouds.internal.ClassMethodArgs;
|
||||||
|
import org.jclouds.rest.internal.AsyncRestClientProxy.Factory;
|
||||||
|
|
||||||
/**
|
import com.google.common.cache.CacheLoader;
|
||||||
* Tests behavior of {@code DomainUserAsyncClient}
|
import com.google.inject.Inject;
|
||||||
*
|
|
||||||
* @author Andrei Savu
|
public final class CreateAsyncClientForCaller extends CacheLoader<ClassMethodArgs, Object> {
|
||||||
*/
|
private final Factory factory;
|
||||||
@Test(groups = "unit", testName = "DomainUserAsyncClientTest")
|
|
||||||
public class DomainUserAsyncClientTest extends BaseCloudStackAsyncClientTest<DomainUserAsyncClient> {
|
@Inject
|
||||||
|
private CreateAsyncClientForCaller(AsyncRestClientProxy.Factory factory) {
|
||||||
|
this.factory = factory;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeLiteral<RestAnnotationProcessor<DomainUserAsyncClient>> createTypeLiteral() {
|
public Object load(ClassMethodArgs from) {
|
||||||
return new TypeLiteral<RestAnnotationProcessor<DomainUserAsyncClient>>() {
|
return newProxy(from.getClazz(), factory.caller(from));
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -16,7 +16,7 @@
|
||||||
* specific language governing permissions and limitations
|
* specific language governing permissions and limitations
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rest.config;
|
package org.jclouds.rest.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.common.reflect.Reflection.newProxy;
|
import static com.google.common.reflect.Reflection.newProxy;
|
|
@ -17,12 +17,12 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rest.internal;
|
package org.jclouds.rest.internal;
|
||||||
|
|
||||||
import static com.google.common.base.Functions.compose;
|
import static com.google.common.base.Functions.compose;
|
||||||
import static com.google.common.base.Functions.toStringFunction;
|
import static com.google.common.base.Functions.toStringFunction;
|
||||||
import static com.google.common.base.Objects.equal;
|
import static com.google.common.base.Objects.equal;
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
import static com.google.common.base.Predicates.and;
|
import static com.google.common.base.Predicates.and;
|
||||||
import static com.google.common.base.Predicates.in;
|
import static com.google.common.base.Predicates.in;
|
||||||
import static com.google.common.base.Predicates.not;
|
import static com.google.common.base.Predicates.not;
|
||||||
|
@ -42,6 +42,7 @@ import static com.google.common.collect.Sets.newTreeSet;
|
||||||
import static com.google.common.net.HttpHeaders.ACCEPT;
|
import static com.google.common.net.HttpHeaders.ACCEPT;
|
||||||
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
import static com.google.common.net.HttpHeaders.CONTENT_TYPE;
|
||||||
import static com.google.common.net.HttpHeaders.HOST;
|
import static com.google.common.net.HttpHeaders.HOST;
|
||||||
|
import static java.lang.String.format;
|
||||||
import static java.util.Arrays.asList;
|
import static java.util.Arrays.asList;
|
||||||
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
|
||||||
import static javax.ws.rs.core.MediaType.APPLICATION_XML;
|
import static javax.ws.rs.core.MediaType.APPLICATION_XML;
|
||||||
|
@ -161,6 +162,7 @@ import com.google.inject.Inject;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Key;
|
import com.google.inject.Key;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
import com.google.inject.assistedinject.Assisted;
|
||||||
import com.google.inject.util.Types;
|
import com.google.inject.util.Types;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,13 +170,72 @@ import com.google.inject.util.Types;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class RestAnnotationProcessor<T> {
|
public abstract class RestAnnotationProcessor {
|
||||||
|
|
||||||
|
public static interface Factory {
|
||||||
|
Declaring declaring(Class<?> declaring);
|
||||||
|
Caller caller(ClassMethodArgs caller);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Declaring extends RestAnnotationProcessor {
|
||||||
|
@Inject
|
||||||
|
private Declaring(Injector injector, LoadingCache<Class<?>, Cache<MethodKey, Method>> delegationMapCache,
|
||||||
|
@ApiVersion String apiVersion, @BuildVersion String buildVersion, ParseSax.Factory parserFactory,
|
||||||
|
HttpUtils utils, ContentMetadataCodec contentMetadataCodec, InputParamValidator inputParamValidator,
|
||||||
|
@Assisted Class<?> declaring) {
|
||||||
|
super(injector, delegationMapCache, apiVersion, buildVersion, parserFactory, utils, contentMetadataCodec,
|
||||||
|
inputParamValidator, declaring);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Caller extends RestAnnotationProcessor {
|
||||||
|
private final ClassMethodArgs caller;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Caller(Injector injector, LoadingCache<Class<?>, Cache<MethodKey, Method>> delegationMapCache,
|
||||||
|
@ApiVersion String apiVersion, @BuildVersion String buildVersion, ParseSax.Factory parserFactory,
|
||||||
|
HttpUtils utils, ContentMetadataCodec contentMetadataCodec, InputParamValidator inputParamValidator,
|
||||||
|
@Assisted ClassMethodArgs caller) {
|
||||||
|
super(injector, delegationMapCache, apiVersion, buildVersion, parserFactory, utils, contentMetadataCodec,
|
||||||
|
inputParamValidator, caller.getClazz());
|
||||||
|
// declaring class of method is the callee, this will lazily warm annotation cache
|
||||||
|
// until we have a better annotation cache warming approach
|
||||||
|
delegationMapCache.getUnchecked(caller.getMethod().getDeclaringClass());
|
||||||
|
this.caller = caller;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected GeneratedHttpRequest.Builder requestBuilder() {
|
||||||
|
return super.requestBuilder().caller(caller);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Optional<URI> findEndpoint(Method method, Object... args) {
|
||||||
|
Optional<URI> endpoint = getEndpointFor(caller.getMethod(), caller.getArgs());
|
||||||
|
if (endpoint.isPresent())
|
||||||
|
logger.trace("using endpoint %s from caller %s for %s", endpoint, caller, cma(method, args));
|
||||||
|
else
|
||||||
|
endpoint = super.findEndpoint(method, args);
|
||||||
|
return endpoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Multimap<String, Object> addPathAndGetTokens(Class<?> clazz, Method method, Object[] args,
|
||||||
|
UriBuilder uriBuilder) {
|
||||||
|
Class<?> callerClass = caller.getMethod().getDeclaringClass();
|
||||||
|
return ImmutableMultimap.<String, Object> builder()
|
||||||
|
.putAll(super.addPathAndGetTokens(callerClass, caller.getMethod(), caller.getArgs(), uriBuilder))
|
||||||
|
.putAll(super.addPathAndGetTokens(clazz, method, args, uriBuilder)).build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ClassMethodArgs cma(Method method, Object... args) {
|
||||||
|
return logger.isTraceEnabled() ? new ClassMethodArgs(method.getDeclaringClass(), method, args) : null;
|
||||||
|
}
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
protected Logger logger = Logger.NULL;
|
||||||
|
|
||||||
private final Class<T> declaring;
|
|
||||||
|
|
||||||
// TODO replace with Table object
|
// TODO replace with Table object
|
||||||
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToBinderParamAnnotation = createMethodToIndexOfParamToAnnotation(BinderParam.class);
|
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToBinderParamAnnotation = createMethodToIndexOfParamToAnnotation(BinderParam.class);
|
||||||
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToWrapWithAnnotation = createMethodToIndexOfParamToAnnotation(WrapWith.class);
|
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToWrapWithAnnotation = createMethodToIndexOfParamToAnnotation(WrapWith.class);
|
||||||
|
@ -187,8 +248,19 @@ public class RestAnnotationProcessor<T> {
|
||||||
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToPostParamAnnotations = createMethodToIndexOfParamToAnnotation(PayloadParam.class);
|
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToPostParamAnnotations = createMethodToIndexOfParamToAnnotation(PayloadParam.class);
|
||||||
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToPartParamAnnotations = createMethodToIndexOfParamToAnnotation(PartParam.class);
|
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToPartParamAnnotations = createMethodToIndexOfParamToAnnotation(PartParam.class);
|
||||||
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToParamParserAnnotations = createMethodToIndexOfParamToAnnotation(ParamParser.class);
|
static final LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> methodToIndexOfParamToParamParserAnnotations = createMethodToIndexOfParamToAnnotation(ParamParser.class);
|
||||||
|
static final LoadingCache<Method, Set<Integer>> methodToIndexesOfOptions = CacheBuilder.newBuilder().build(
|
||||||
final Cache<MethodKey, Method> delegationMap;
|
new CacheLoader<Method, Set<Integer>>() {
|
||||||
|
@Override
|
||||||
|
public Set<Integer> load(Method method) {
|
||||||
|
Builder<Integer> toReturn = ImmutableSet.builder();
|
||||||
|
for (int index = 0; index < method.getParameterTypes().length; index++) {
|
||||||
|
Class<?> type = method.getParameterTypes()[index];
|
||||||
|
if (HttpRequestOptions.class.isAssignableFrom(type) || HttpRequestOptions[].class.isAssignableFrom(type))
|
||||||
|
toReturn.add(index);
|
||||||
|
}
|
||||||
|
return toReturn.build();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
static LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> createMethodToIndexOfParamToAnnotation(
|
static LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> createMethodToIndexOfParamToAnnotation(
|
||||||
final Class<? extends Annotation> annotation) {
|
final Class<? extends Annotation> annotation) {
|
||||||
|
@ -216,42 +288,15 @@ public class RestAnnotationProcessor<T> {
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Function<? super Entry<String, Object>, ? extends Part> ENTRY_TO_PART = new Function<Entry<String, Object>, Part>() {
|
private static final Function<? super Entry<String, Object>, ? extends Part> ENTRY_TO_PART = new Function<Entry<String, Object>, Part>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Part apply(Entry<String, Object> from) {
|
public Part apply(Entry<String, Object> from) {
|
||||||
return Part.create(from.getKey(), from.getValue().toString());
|
return Part.create(from.getKey(), from.getValue().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static final LoadingCache<Method, Set<Integer>> methodToIndexesOfOptions = CacheBuilder.newBuilder().build(
|
|
||||||
new CacheLoader<Method, Set<Integer>>() {
|
|
||||||
@Override
|
|
||||||
public Set<Integer> load(Method method) {
|
|
||||||
Builder<Integer> toReturn = ImmutableSet.builder();
|
|
||||||
for (int index = 0; index < method.getParameterTypes().length; index++) {
|
|
||||||
Class<?> type = method.getParameterTypes()[index];
|
|
||||||
if (HttpRequestOptions.class.isAssignableFrom(type) || HttpRequestOptions[].class.isAssignableFrom(type))
|
|
||||||
toReturn.add(index);
|
|
||||||
}
|
|
||||||
return toReturn.build();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
private final ParseSax.Factory parserFactory;
|
|
||||||
private final HttpUtils utils;
|
|
||||||
private final ContentMetadataCodec contentMetadataCodec;
|
|
||||||
private final LoadingCache<Class<?>, Boolean> seedAnnotationCache;
|
|
||||||
private final String apiVersion;
|
|
||||||
private final String buildVersion;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private InputParamValidator inputParamValidator;
|
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
Function<HttpResponse, ?> createResponseParser(Method method, HttpRequest request) {
|
Function<HttpResponse, ?> createResponseParser(Method method, HttpRequest request) {
|
||||||
return createResponseParser(parserFactory, injector, method, request);
|
return createResponseParser(parserFactory, injector, method, request);
|
||||||
|
@ -298,29 +343,48 @@ public class RestAnnotationProcessor<T> {
|
||||||
return transformer;
|
return transformer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
private final Class<?> declaring;
|
||||||
@Inject
|
private final Injector injector;
|
||||||
public RestAnnotationProcessor(Injector injector, LoadingCache<Class<?>, Boolean> seedAnnotationCache, Cache<MethodKey, Method> delegationMap,
|
private final ParseSax.Factory parserFactory;
|
||||||
@ApiVersion String apiVersion, @BuildVersion String buildVersion, ParseSax.Factory parserFactory,
|
private final HttpUtils utils;
|
||||||
HttpUtils utils, ContentMetadataCodec contentMetadataCodec, TypeLiteral<T> typeLiteral) {
|
private final ContentMetadataCodec contentMetadataCodec;
|
||||||
this.declaring = (Class<T>) typeLiteral.getRawType();
|
private final Cache<MethodKey, Method> delegationMap;
|
||||||
|
private final String apiVersion;
|
||||||
|
private final String buildVersion;
|
||||||
|
private final InputParamValidator inputParamValidator;
|
||||||
|
|
||||||
|
private RestAnnotationProcessor(Injector injector,
|
||||||
|
LoadingCache<Class<?>, Cache<MethodKey, Method>> delegationMapCache, String apiVersion, String buildVersion,
|
||||||
|
ParseSax.Factory parserFactory, HttpUtils utils, ContentMetadataCodec contentMetadataCodec,
|
||||||
|
InputParamValidator inputParamValidator, Class<?> declaring) {
|
||||||
this.injector = injector;
|
this.injector = injector;
|
||||||
this.parserFactory = parserFactory;
|
this.parserFactory = parserFactory;
|
||||||
this.utils = utils;
|
this.utils = utils;
|
||||||
this.contentMetadataCodec = contentMetadataCodec;
|
this.contentMetadataCodec = contentMetadataCodec;
|
||||||
this.seedAnnotationCache = seedAnnotationCache;
|
this.delegationMap = delegationMapCache.getUnchecked(declaring);
|
||||||
seedAnnotationCache.getUnchecked(declaring);
|
|
||||||
this.delegationMap = delegationMap;
|
|
||||||
this.apiVersion = apiVersion;
|
this.apiVersion = apiVersion;
|
||||||
this.buildVersion = buildVersion;
|
this.buildVersion = buildVersion;
|
||||||
|
this.inputParamValidator = inputParamValidator;
|
||||||
|
this.declaring = declaring;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Method getDelegateOrNull(Method in) {
|
public Method getDelegateOrNull(Method in) {
|
||||||
return delegationMap.getIfPresent(new MethodKey(in));
|
return delegationMap.getIfPresent(new MethodKey(in));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class MethodKey {
|
public static class MethodKey {
|
||||||
|
private final String name;
|
||||||
|
private final int parametersTypeHashCode;
|
||||||
|
private final Class<?> declaringClass;
|
||||||
|
|
||||||
|
public MethodKey(Method method) {
|
||||||
|
this.name = method.getName();
|
||||||
|
this.declaringClass = method.getDeclaringClass();
|
||||||
|
int parametersTypeHashCode = 0;
|
||||||
|
for (Class<?> param : method.getParameterTypes())
|
||||||
|
parametersTypeHashCode += param.hashCode();
|
||||||
|
this.parametersTypeHashCode = parametersTypeHashCode;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
|
@ -336,59 +400,34 @@ public class RestAnnotationProcessor<T> {
|
||||||
&& equal(this.name, that.name)
|
&& equal(this.name, that.name)
|
||||||
&& equal(this.parametersTypeHashCode, that.parametersTypeHashCode);
|
&& equal(this.parametersTypeHashCode, that.parametersTypeHashCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String name;
|
|
||||||
private final int parametersTypeHashCode;
|
|
||||||
private final Class<?> declaringClass;
|
|
||||||
|
|
||||||
public MethodKey(Method method) {
|
|
||||||
this.name = method.getName();
|
|
||||||
this.declaringClass = method.getDeclaringClass();
|
|
||||||
int parametersTypeHashCode = 0;
|
|
||||||
for (Class<?> param : method.getParameterTypes())
|
|
||||||
parametersTypeHashCode += param.hashCode();
|
|
||||||
this.parametersTypeHashCode = parametersTypeHashCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
final Injector injector;
|
|
||||||
|
|
||||||
private ClassMethodArgs caller;
|
|
||||||
|
|
||||||
public void setCaller(ClassMethodArgs caller) {
|
|
||||||
seedAnnotationCache.getUnchecked(caller.getMethod().getDeclaringClass());
|
|
||||||
this.caller = caller;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeneratedHttpRequest createRequest(Method method, Object... args) {
|
public GeneratedHttpRequest createRequest(Method method, Object... args) {
|
||||||
inputParamValidator.validateMethodParametersOrThrow(method, args);
|
inputParamValidator.validateMethodParametersOrThrow(method, args);
|
||||||
|
|
||||||
|
Optional<URI> endpoint = Optional.absent();
|
||||||
Optional<URI> endpoint = findEndpoint(method, args);
|
HttpRequest r = findHttpRequestInArgs(args);
|
||||||
|
if (r != null) {
|
||||||
if (!endpoint.isPresent()) {
|
endpoint = Optional.fromNullable(r.getEndpoint());
|
||||||
throw new NoSuchElementException(String.format("no endpoint found for %s",
|
if (endpoint.isPresent())
|
||||||
new ClassMethodArgs(method.getDeclaringClass(), method, args)));
|
logger.trace("using endpoint %s from args for %s", endpoint, cma(method, args));
|
||||||
|
} else {
|
||||||
|
endpoint = findEndpoint(method, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
GeneratedHttpRequest.Builder requestBuilder = GeneratedHttpRequest.builder();
|
if (!endpoint.isPresent())
|
||||||
HttpRequest r = RestAnnotationProcessor.findHttpRequestInArgs(args);
|
throw new NoSuchElementException(format("no endpoint found for %s", cma(method, args)));
|
||||||
|
|
||||||
|
GeneratedHttpRequest.Builder requestBuilder = requestBuilder();
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
requestBuilder.fromHttpRequest(r);
|
requestBuilder.fromHttpRequest(r);
|
||||||
} else {
|
} else {
|
||||||
requestBuilder.method(getHttpMethodOrConstantOrThrowException(method));
|
requestBuilder.method(getHttpMethodOrConstantOrThrowException(method));
|
||||||
}
|
}
|
||||||
|
|
||||||
// URI template in rfc6570 form
|
|
||||||
UriBuilder uriBuilder = uriBuilder(endpoint.get().toString());
|
|
||||||
|
|
||||||
overridePathEncoding(uriBuilder, method);
|
|
||||||
|
|
||||||
requestBuilder.declaring(declaring)
|
requestBuilder.declaring(declaring)
|
||||||
.javaMethod(method)
|
.javaMethod(method)
|
||||||
.args(args)
|
.args(args)
|
||||||
.caller(caller)
|
|
||||||
.filters(getFiltersIfAnnotated(method));
|
.filters(getFiltersIfAnnotated(method));
|
||||||
|
|
||||||
Multimap<String, Object> tokenValues = LinkedHashMultimap.create();
|
Multimap<String, Object> tokenValues = LinkedHashMultimap.create();
|
||||||
|
@ -396,11 +435,9 @@ public class RestAnnotationProcessor<T> {
|
||||||
tokenValues.put(Constants.PROPERTY_API_VERSION, apiVersion);
|
tokenValues.put(Constants.PROPERTY_API_VERSION, apiVersion);
|
||||||
tokenValues.put(Constants.PROPERTY_BUILD_VERSION, buildVersion);
|
tokenValues.put(Constants.PROPERTY_BUILD_VERSION, buildVersion);
|
||||||
|
|
||||||
// make sure any path from the caller is a prefix
|
UriBuilder uriBuilder = uriBuilder(endpoint.get().toString()); // URI template in rfc6570 form
|
||||||
if (caller != null) {
|
|
||||||
tokenValues.putAll(addPathAndGetTokens(caller.getMethod().getDeclaringClass(), caller.getMethod(),
|
overridePathEncoding(uriBuilder, method);
|
||||||
caller.getArgs(), uriBuilder));
|
|
||||||
}
|
|
||||||
|
|
||||||
tokenValues.putAll(addPathAndGetTokens(declaring, method, args, uriBuilder));
|
tokenValues.putAll(addPathAndGetTokens(declaring, method, args, uriBuilder));
|
||||||
|
|
||||||
|
@ -491,6 +528,10 @@ public class RestAnnotationProcessor<T> {
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected org.jclouds.rest.internal.GeneratedHttpRequest.Builder requestBuilder() {
|
||||||
|
return GeneratedHttpRequest.builder();
|
||||||
|
}
|
||||||
|
|
||||||
// TODO cache
|
// TODO cache
|
||||||
private void overridePathEncoding(UriBuilder uriBuilder, Method method) {
|
private void overridePathEncoding(UriBuilder uriBuilder, Method method) {
|
||||||
if (declaring.isAnnotationPresent(SkipEncoding.class)) {
|
if (declaring.isAnnotationPresent(SkipEncoding.class)) {
|
||||||
|
@ -504,43 +545,19 @@ public class RestAnnotationProcessor<T> {
|
||||||
// different than guava as accepts null
|
// different than guava as accepts null
|
||||||
private static enum NullableToStringFunction implements Function<Object, String> {
|
private static enum NullableToStringFunction implements Function<Object, String> {
|
||||||
INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String apply(Object o) {
|
public String apply(Object o) {
|
||||||
if (o == null)
|
if (o == null)
|
||||||
return null;
|
return null;
|
||||||
return o.toString();
|
return o.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "toString";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<URI> findEndpoint(Method method, Object... args) {
|
protected Optional<URI> findEndpoint(Method method, Object... args) {
|
||||||
ClassMethodArgs cma = logger.isTraceEnabled() ? new ClassMethodArgs(method.getDeclaringClass(), method, args)
|
ClassMethodArgs cma = cma(method, args);
|
||||||
: null;
|
Optional<URI> endpoint = getEndpointFor(method, args);
|
||||||
Optional<URI> endpoint = Optional.absent();
|
if (endpoint.isPresent())
|
||||||
|
logger.trace("using endpoint %s for %s", endpoint, cma);
|
||||||
HttpRequest r = RestAnnotationProcessor.findHttpRequestInArgs(args);
|
|
||||||
|
|
||||||
if (r != null) {
|
|
||||||
endpoint = Optional.fromNullable(r.getEndpoint());
|
|
||||||
if (endpoint.isPresent())
|
|
||||||
logger.trace("using endpoint %s from args for %s", endpoint, cma);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!endpoint.isPresent() && caller != null) {
|
|
||||||
endpoint = getEndpointFor(caller.getMethod(), caller.getArgs());
|
|
||||||
if (endpoint.isPresent())
|
|
||||||
logger.trace("using endpoint %s from caller %s for %s", endpoint, caller, cma);
|
|
||||||
}
|
|
||||||
if (!endpoint.isPresent()) {
|
|
||||||
endpoint = getEndpointFor(method, args);
|
|
||||||
if (endpoint.isPresent())
|
|
||||||
logger.trace("using endpoint %s for %s", endpoint, cma);
|
|
||||||
}
|
|
||||||
if (!endpoint.isPresent()) {
|
if (!endpoint.isPresent()) {
|
||||||
logger.trace("looking up default endpoint for %s", cma);
|
logger.trace("looking up default endpoint for %s", cma);
|
||||||
endpoint = Optional.fromNullable(injector.getInstance(
|
endpoint = Optional.fromNullable(injector.getInstance(
|
||||||
|
@ -558,7 +575,7 @@ public class RestAnnotationProcessor<T> {
|
||||||
|
|
||||||
public static final String BOUNDARY = "--JCLOUDS--";
|
public static final String BOUNDARY = "--JCLOUDS--";
|
||||||
|
|
||||||
private Multimap<String, Object> addPathAndGetTokens(Class<?> clazz, Method method, Object[] args, UriBuilder uriBuilder) {
|
protected Multimap<String, Object> addPathAndGetTokens(Class<?> clazz, Method method, Object[] args, UriBuilder uriBuilder) {
|
||||||
if (clazz.isAnnotationPresent(Path.class))
|
if (clazz.isAnnotationPresent(Path.class))
|
||||||
uriBuilder.appendPath(clazz.getAnnotation(Path.class).value());
|
uriBuilder.appendPath(clazz.getAnnotation(Path.class).value());
|
||||||
if (method.isAnnotationPresent(Path.class))
|
if (method.isAnnotationPresent(Path.class))
|
||||||
|
@ -661,8 +678,7 @@ public class RestAnnotationProcessor<T> {
|
||||||
|
|
||||||
//TODO: change to LoadingCache<ClassMethodArgs, Optional<URI>> and move this logic to the CacheLoader.
|
//TODO: change to LoadingCache<ClassMethodArgs, Optional<URI>> and move this logic to the CacheLoader.
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static URI getEndpointInParametersOrNull(Method method, final Object[] args, Injector injector)
|
public static URI getEndpointInParametersOrNull(Method method, final Object[] args, Injector injector) {
|
||||||
{
|
|
||||||
Map<Integer, Set<Annotation>> map = indexWithAtLeastOneAnnotation(method,
|
Map<Integer, Set<Annotation>> map = indexWithAtLeastOneAnnotation(method,
|
||||||
methodToIndexOfParamToEndpointParamAnnotations);
|
methodToIndexOfParamToEndpointParamAnnotations);
|
||||||
if (map.size() >= 1 && args.length > 0) {
|
if (map.size() >= 1 && args.length > 0) {
|
||||||
|
@ -674,29 +690,27 @@ public class RestAnnotationProcessor<T> {
|
||||||
try {
|
try {
|
||||||
URI returnVal = parser.apply(args[index]);
|
URI returnVal = parser.apply(args[index]);
|
||||||
checkArgument(returnVal != null,
|
checkArgument(returnVal != null,
|
||||||
String.format("endpoint for [%s] not configured for %s", args[index], method));
|
format("endpoint for [%s] not configured for %s", args[index], method));
|
||||||
return returnVal;
|
return returnVal;
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
throw new IllegalArgumentException(String.format("argument at index %d on method %s was null", index, method), e);
|
throw new IllegalArgumentException(format("argument at index %d on method %s was null", index, method),
|
||||||
|
e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SortedSet<Integer> keys = newTreeSet(map.keySet());
|
SortedSet<Integer> keys = newTreeSet(map.keySet());
|
||||||
Iterable<Object> argsToParse = transform(keys, new Function<Integer, Object>() {
|
Iterable<Object> argsToParse = transform(keys, new Function<Integer, Object>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object apply(Integer from) {
|
public Object apply(Integer from) {
|
||||||
return args[from];
|
return args[from];
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
URI returnVal = parser.apply(argsToParse);
|
URI returnVal = parser.apply(argsToParse);
|
||||||
checkArgument(returnVal != null,
|
checkArgument(returnVal != null, format("endpoint for [%s] not configured for %s", argsToParse, method));
|
||||||
String.format("endpoint for [%s] not configured for %s", argsToParse, method));
|
|
||||||
return returnVal;
|
return returnVal;
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
throw new IllegalArgumentException(String.format("illegal argument in [%s] for method %s", argsToParse,
|
throw new IllegalArgumentException(
|
||||||
method), e);
|
format("illegal argument in [%s] for method %s", argsToParse, method), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -707,7 +721,7 @@ public class RestAnnotationProcessor<T> {
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: change to LoadingCache<ClassMethodArgs, URI> and move this logic to the CacheLoader.
|
// TODO: change to LoadingCache<ClassMethodArgs, URI> and move this logic to the CacheLoader.
|
||||||
private Optional<URI> getEndpointFor(Method method, Object[] args) {
|
protected Optional<URI> getEndpointFor(Method method, Object[] args) {
|
||||||
URI endpoint = getEndpointInParametersOrNull(method, args, injector);
|
URI endpoint = getEndpointInParametersOrNull(method, args, injector);
|
||||||
if (endpoint == null) {
|
if (endpoint == null) {
|
||||||
Endpoint annotation;
|
Endpoint annotation;
|
||||||
|
@ -721,16 +735,14 @@ public class RestAnnotationProcessor<T> {
|
||||||
}
|
}
|
||||||
endpoint = injector.getInstance(Key.get(uriSupplierLiteral, annotation.value())).get();
|
endpoint = injector.getInstance(Key.get(uriSupplierLiteral, annotation.value())).get();
|
||||||
}
|
}
|
||||||
URI providerEndpoint = injector.getInstance(Key.get(uriSupplierLiteral, org.jclouds.location.Provider.class))
|
URI provider = injector.getInstance(Key.get(uriSupplierLiteral, org.jclouds.location.Provider.class)).get();
|
||||||
.get();
|
return Optional.fromNullable(addHostIfMissing(endpoint, provider));
|
||||||
return Optional.fromNullable(addHostIfMissing(endpoint, providerEndpoint));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static URI addHostIfMissing(URI original, URI withHost) {
|
static URI addHostIfMissing(URI original, URI withHost) {
|
||||||
checkNotNull(withHost, "URI withHost cannot be null");
|
checkNotNull(withHost, "URI withHost cannot be null");
|
||||||
checkArgument(withHost.getHost() != null, "URI withHost must have host:" + withHost);
|
checkArgument(withHost.getHost() != null, "URI withHost must have host:" + withHost);
|
||||||
|
|
||||||
if (original == null)
|
if (original == null)
|
||||||
return null;
|
return null;
|
||||||
if (original.getHost() != null)
|
if (original.getHost() != null)
|
||||||
|
@ -876,25 +888,18 @@ public class RestAnnotationProcessor<T> {
|
||||||
if (http != null)
|
if (http != null)
|
||||||
methodsBuilder.add(http.value());
|
methodsBuilder.add(http.value());
|
||||||
}
|
}
|
||||||
Set<String> methods = methodsBuilder.build();
|
return methodsBuilder.build();
|
||||||
return (methods.size() == 0) ? null : methods;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHttpMethodOrConstantOrThrowException(Method method) {
|
public String getHttpMethodOrConstantOrThrowException(Method method) {
|
||||||
Set<String> requests = getHttpMethods(method);
|
Set<String> requests = getHttpMethods(method);
|
||||||
if (requests == null || requests.size() != 1) {
|
checkState(requests.size() == 1,
|
||||||
throw new IllegalStateException(
|
"You must use at least one, but no more than one http method or pathparam annotation on: %s", method);
|
||||||
"You must use at least one, but no more than one http method or pathparam annotation on: "
|
return get(requests, 0);
|
||||||
+ method.toString());
|
|
||||||
}
|
|
||||||
return requests.iterator().next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shouldAddHostHeader(Method method) {
|
public boolean shouldAddHostHeader(Method method) {
|
||||||
if (declaring.isAnnotationPresent(VirtualHost.class) || method.isAnnotationPresent(VirtualHost.class)) {
|
return (declaring.isAnnotationPresent(VirtualHost.class) || method.isAnnotationPresent(VirtualHost.class));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Predicate<Set<?>> notEmpty = new Predicate<Set<?>>() {
|
private static final Predicate<Set<?>> notEmpty = new Predicate<Set<?>>() {
|
||||||
|
@ -949,14 +954,13 @@ public class RestAnnotationProcessor<T> {
|
||||||
// (first, however, let's make sure we have enough args on the actual method)
|
// (first, however, let's make sure we have enough args on the actual method)
|
||||||
if (entry.getKey() >= request.getJavaMethod().getParameterAnnotations().length) {
|
if (entry.getKey() >= request.getJavaMethod().getParameterAnnotations().length) {
|
||||||
// not known whether this happens
|
// not known whether this happens
|
||||||
throw new IllegalArgumentException("Argument index " + (entry.getKey() + 1)
|
throw new IllegalArgumentException(format("Argument index %s is out of bounds for method %s",
|
||||||
+ " is out of bounds for method " + request.getJavaMethod());
|
entry.getKey() + 1, request.getJavaMethod()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.getJavaMethod().isVarArgs()
|
if (request.getJavaMethod().isVarArgs()
|
||||||
&& entry.getKey() + 1 == request.getJavaMethod().getParameterTypes().length)
|
&& entry.getKey() + 1 == request.getJavaMethod().getParameterTypes().length)
|
||||||
// allow null/missing for var args
|
continue OUTER; // allow null/missing for var args
|
||||||
continue OUTER;
|
|
||||||
|
|
||||||
Annotation[] annotations = request.getJavaMethod().getParameterAnnotations()[entry.getKey()];
|
Annotation[] annotations = request.getJavaMethod().getParameterAnnotations()[entry.getKey()];
|
||||||
for (Annotation a : annotations) {
|
for (Annotation a : annotations) {
|
||||||
|
@ -966,7 +970,6 @@ public class RestAnnotationProcessor<T> {
|
||||||
checkNotNull(null, request.getJavaMethod().getName() + " parameter " + (entry.getKey() + 1));
|
checkNotNull(null, request.getJavaMethod().getName() + " parameter " + (entry.getKey() + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -974,7 +977,7 @@ public class RestAnnotationProcessor<T> {
|
||||||
LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> toRefine) {
|
LoadingCache<Method, LoadingCache<Integer, Set<Annotation>>> toRefine) {
|
||||||
Map<Integer, Set<Annotation>> indexToPayloadAnnotation = indexWithAtLeastOneAnnotation(method, toRefine);
|
Map<Integer, Set<Annotation>> indexToPayloadAnnotation = indexWithAtLeastOneAnnotation(method, toRefine);
|
||||||
if (indexToPayloadAnnotation.size() > 1) {
|
if (indexToPayloadAnnotation.size() > 1) {
|
||||||
throw new IllegalStateException(String.format(
|
throw new IllegalStateException(format(
|
||||||
"You must not specify more than one %s annotation on: %s; found %s", description, method.toString(),
|
"You must not specify more than one %s annotation on: %s; found %s", description, method.toString(),
|
||||||
indexToPayloadAnnotation));
|
indexToPayloadAnnotation));
|
||||||
}
|
}
|
||||||
|
@ -1080,7 +1083,6 @@ public class RestAnnotationProcessor<T> {
|
||||||
value = replaceTokens(value, tokenValues);
|
value = replaceTokens(value, tokenValues);
|
||||||
headers.put(header.keys()[i], value);
|
headers.put(header.keys()[i], value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Part> getParts(Method method, Object[] args, Multimap<String, ?> tokenValues) {
|
private List<Part> getParts(Method method, Object[] args, Multimap<String, ?> tokenValues) {
|
||||||
|
@ -1143,7 +1145,6 @@ public class RestAnnotationProcessor<T> {
|
||||||
String paramKey = method.getAnnotation(PathParam.class).value();
|
String paramKey = method.getAnnotation(PathParam.class).value();
|
||||||
String paramValue = injector.getInstance(method.getAnnotation(ParamParser.class).value()).apply(args);
|
String paramValue = injector.getInstance(method.getAnnotation(ParamParser.class).value()).apply(args);
|
||||||
pathParamValues.put(paramKey, paramValue);
|
pathParamValues.put(paramKey, paramValue);
|
||||||
|
|
||||||
}
|
}
|
||||||
return pathParamValues;
|
return pathParamValues;
|
||||||
}
|
}
|
||||||
|
@ -1154,8 +1155,7 @@ public class RestAnnotationProcessor<T> {
|
||||||
Object arg = args[argIndex];
|
Object arg = args[argIndex];
|
||||||
if (extractors != null && extractors.size() > 0 && checkPresentOrNullable(method, paramKey, argIndex, arg)) {
|
if (extractors != null && extractors.size() > 0 && checkPresentOrNullable(method, paramKey, argIndex, arg)) {
|
||||||
ParamParser extractor = (ParamParser) extractors.iterator().next();
|
ParamParser extractor = (ParamParser) extractors.iterator().next();
|
||||||
// ParamParsers can deal with nullable parameters
|
arg = injector.getInstance(extractor.value()).apply(arg); // ParamParsers can deal with nullable parameters
|
||||||
arg = injector.getInstance(extractor.value()).apply(arg);
|
|
||||||
}
|
}
|
||||||
checkPresentOrNullable(method, paramKey, argIndex, arg);
|
checkPresentOrNullable(method, paramKey, argIndex, arg);
|
||||||
return Optional.fromNullable(arg);
|
return Optional.fromNullable(arg);
|
||||||
|
@ -1163,7 +1163,7 @@ public class RestAnnotationProcessor<T> {
|
||||||
|
|
||||||
private static boolean checkPresentOrNullable(Method method, String paramKey, Integer argIndex, Object arg) {
|
private static boolean checkPresentOrNullable(Method method, String paramKey, Integer argIndex, Object arg) {
|
||||||
if (arg == null && !argNullable(method, argIndex))
|
if (arg == null && !argNullable(method, argIndex))
|
||||||
throw new NullPointerException(String.format("param{%s} for method %s.%s", paramKey, method
|
throw new NullPointerException(format("param{%s} for method %s.%s", paramKey, method
|
||||||
.getDeclaringClass().getSimpleName(), method.getName()));
|
.getDeclaringClass().getSimpleName(), method.getName()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1173,7 +1173,6 @@ public class RestAnnotationProcessor<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Predicate<Annotation> NULLABLE = new Predicate<Annotation>() {
|
private static final Predicate<Annotation> NULLABLE = new Predicate<Annotation>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Annotation in) {
|
public boolean apply(Annotation in) {
|
||||||
return Nullable.class.isAssignableFrom(in.annotationType());
|
return Nullable.class.isAssignableFrom(in.annotationType());
|
||||||
|
@ -1184,7 +1183,6 @@ public class RestAnnotationProcessor<T> {
|
||||||
return any(ImmutableSet.copyOf(annotations), NULLABLE);
|
return any(ImmutableSet.copyOf(annotations), NULLABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO: change to LoadingCache<ClassMethodArgs, Multimap<String,String> and move this logic to the CacheLoader.
|
//TODO: change to LoadingCache<ClassMethodArgs, Multimap<String,String> and move this logic to the CacheLoader.
|
||||||
//take care to manage size of this cache
|
//take care to manage size of this cache
|
||||||
private Multimap<String, Object> getFormParamKeyValues(Method method, Object... args) {
|
private Multimap<String, Object> getFormParamKeyValues(Method method, Object... args) {
|
||||||
|
@ -1208,7 +1206,6 @@ public class RestAnnotationProcessor<T> {
|
||||||
String paramKey = method.getAnnotation(FormParam.class).value();
|
String paramKey = method.getAnnotation(FormParam.class).value();
|
||||||
String paramValue = injector.getInstance(method.getAnnotation(ParamParser.class).value()).apply(args);
|
String paramValue = injector.getInstance(method.getAnnotation(ParamParser.class).value()).apply(args);
|
||||||
formParamValues.put(paramKey, paramValue);
|
formParamValues.put(paramKey, paramValue);
|
||||||
|
|
||||||
}
|
}
|
||||||
return formParamValues;
|
return formParamValues;
|
||||||
}
|
}
|
||||||
|
@ -1230,8 +1227,7 @@ public class RestAnnotationProcessor<T> {
|
||||||
if (paramValue.get() instanceof Iterable) {
|
if (paramValue.get() instanceof Iterable) {
|
||||||
Iterable<String> iterableStrings = transform(Iterable.class.cast(paramValue.get()), toStringFunction());
|
Iterable<String> iterableStrings = transform(Iterable.class.cast(paramValue.get()), toStringFunction());
|
||||||
queryParamValues.putAll(paramKey, iterableStrings);
|
queryParamValues.putAll(paramKey, iterableStrings);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
queryParamValues.put(paramKey, paramValue.get().toString());
|
queryParamValues.put(paramKey, paramValue.get().toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1242,7 +1238,6 @@ public class RestAnnotationProcessor<T> {
|
||||||
String paramKey = method.getAnnotation(QueryParam.class).value();
|
String paramKey = method.getAnnotation(QueryParam.class).value();
|
||||||
String paramValue = injector.getInstance(method.getAnnotation(ParamParser.class).value()).apply(args);
|
String paramValue = injector.getInstance(method.getAnnotation(ParamParser.class).value()).apply(args);
|
||||||
queryParamValues.put(paramKey, paramValue);
|
queryParamValues.put(paramKey, paramValue);
|
||||||
|
|
||||||
}
|
}
|
||||||
return queryParamValues;
|
return queryParamValues;
|
||||||
}
|
}
|
||||||
|
@ -1264,11 +1259,4 @@ public class RestAnnotationProcessor<T> {
|
||||||
}
|
}
|
||||||
return postParams;
|
return postParams;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* the class that is being processed
|
|
||||||
*/
|
|
||||||
public Class<T> getDeclaring(){
|
|
||||||
return declaring;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,14 +42,15 @@ import javax.ws.rs.Path;
|
||||||
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.logging.Logger;
|
import org.jclouds.logging.Logger;
|
||||||
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.annotations.Delegate;
|
import org.jclouds.rest.annotations.Delegate;
|
||||||
import org.jclouds.rest.internal.RestAnnotationProcessor.MethodKey;
|
import org.jclouds.rest.internal.RestAnnotationProcessor.MethodKey;
|
||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Inject;
|
import com.google.common.util.concurrent.Callables;
|
||||||
import com.google.inject.Injector;
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,21 +62,13 @@ import com.google.inject.Provides;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class SeedAnnotationCache extends CacheLoader<Class<?>, Boolean> {
|
public final class SeedAnnotationCache extends CacheLoader<Class<?>, Cache<MethodKey, Method>> {
|
||||||
@Resource
|
@Resource
|
||||||
protected Logger logger = Logger.NULL;
|
private Logger logger = Logger.NULL;
|
||||||
|
|
||||||
protected final Injector injector;
|
|
||||||
protected final Cache<MethodKey, Method> delegationMap;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
public SeedAnnotationCache(Injector injector, Cache<MethodKey, Method> delegationMap) {
|
|
||||||
this.injector = injector;
|
|
||||||
this.delegationMap = delegationMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean load(Class<?> declaring) throws ExecutionException {
|
public Cache<MethodKey, Method> load(Class<?> declaring) throws ExecutionException {
|
||||||
|
Cache<MethodKey, Method> delegationMap = CacheBuilder.newBuilder().<MethodKey, Method>build();
|
||||||
for (Method method : difference(ImmutableSet.copyOf(declaring.getMethods()), ImmutableSet.copyOf(Object.class
|
for (Method method : difference(ImmutableSet.copyOf(declaring.getMethods()), ImmutableSet.copyOf(Object.class
|
||||||
.getMethods()))) {
|
.getMethods()))) {
|
||||||
if (isHttpMethod(method) || method.isAnnotationPresent(Delegate.class)) {
|
if (isHttpMethod(method) || method.isAnnotationPresent(Delegate.class)) {
|
||||||
|
@ -93,7 +86,7 @@ public class SeedAnnotationCache extends CacheLoader<Class<?>, Boolean> {
|
||||||
methodToIndexOfParamToPartParamAnnotations.get(method).get(index);
|
methodToIndexOfParamToPartParamAnnotations.get(method).get(index);
|
||||||
methodToIndexesOfOptions.get(method);
|
methodToIndexesOfOptions.get(method);
|
||||||
}
|
}
|
||||||
delegationMap.put(new MethodKey(method), method);
|
delegationMap.get(new MethodKey(method), Callables.returning(method));
|
||||||
} else if (!method.getDeclaringClass().equals(declaring)) {
|
} else if (!method.getDeclaringClass().equals(declaring)) {
|
||||||
logger.trace("skipping potentially overridden method %s", method);
|
logger.trace("skipping potentially overridden method %s", method);
|
||||||
} else if (method.isAnnotationPresent(Provides.class)) {
|
} else if (method.isAnnotationPresent(Provides.class)) {
|
||||||
|
@ -102,11 +95,11 @@ public class SeedAnnotationCache extends CacheLoader<Class<?>, Boolean> {
|
||||||
logger.trace("Method is not annotated as either http or provider method: %s", method);
|
logger.trace("Method is not annotated as either http or provider method: %s", method);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return delegationMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isHttpMethod(Method method) {
|
public static boolean isHttpMethod(Method method) {
|
||||||
return method.isAnnotationPresent(Path.class) || getHttpMethods(method) != null
|
return method.isAnnotationPresent(Path.class) || !getHttpMethods(method).isEmpty()
|
||||||
|| ImmutableSet.copyOf(method.getParameterTypes()).contains(HttpRequest.class);
|
|| ImmutableSet.copyOf(method.getParameterTypes()).contains(HttpRequest.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,54 +65,7 @@ public class HeaderToRetryAfterExceptionTest {
|
||||||
.addHeader(HttpHeaders.RETRY_AFTER, "Sun, 2 Jan 2000 00:00:00 GMT").build()));
|
.addHeader(HttpHeaders.RETRY_AFTER, "Sun, 2 Jan 2000 00:00:00 GMT").build()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HttpCommand command = new HttpCommand() {
|
public static HttpCommand command = new HttpCommand(HttpRequest.builder().method("GET").endpoint("http://stub").build());
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getRedirectCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int incrementRedirectCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isReplayable() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Exception getException() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getFailureCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int incrementFailureCount() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setException(Exception exception) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HttpRequest getCurrentRequest() {
|
|
||||||
return HttpRequest.builder().method("GET").endpoint("http://stub").build();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCurrentRequest(HttpRequest request) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
static DateCodec rfc822 = new DateServiceRfc822Codec(new SimpleDateFormatDateService());
|
static DateCodec rfc822 = new DateServiceRfc822Codec(new SimpleDateFormatDateService());
|
||||||
|
|
||||||
|
|
|
@ -36,12 +36,10 @@ import org.jclouds.date.internal.DateServiceDateCodecFactory;
|
||||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||||
import org.jclouds.http.BaseJettyTest;
|
import org.jclouds.http.BaseJettyTest;
|
||||||
import org.jclouds.http.HttpCommand;
|
import org.jclouds.http.HttpCommand;
|
||||||
|
import org.jclouds.http.HttpCommandExecutorService;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.HttpUtils;
|
import org.jclouds.http.HttpUtils;
|
||||||
import org.jclouds.http.IntegrationTestAsyncClient;
|
import org.jclouds.http.IntegrationTestAsyncClient;
|
||||||
import org.jclouds.http.TransformingHttpCommandExecutorServiceImpl;
|
|
||||||
import org.jclouds.http.TransformingHttpCommandImpl;
|
|
||||||
import org.jclouds.http.functions.ReturnStringIf2xx;
|
|
||||||
import org.jclouds.http.internal.HttpWire;
|
import org.jclouds.http.internal.HttpWire;
|
||||||
import org.jclouds.http.internal.JavaUrlHttpCommandExecutorService;
|
import org.jclouds.http.internal.JavaUrlHttpCommandExecutorService;
|
||||||
import org.jclouds.io.ContentMetadataCodec;
|
import org.jclouds.io.ContentMetadataCodec;
|
||||||
|
@ -52,8 +50,6 @@ import org.testng.annotations.BeforeTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.base.Supplier;
|
import com.google.common.base.Supplier;
|
||||||
import com.google.inject.Key;
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
@Test(groups = "unit", testName = "BackoffLimitedRetryHandlerTest")
|
@Test(groups = "unit", testName = "BackoffLimitedRetryHandlerTest")
|
||||||
public class BackoffLimitedRetryHandlerTest {
|
public class BackoffLimitedRetryHandlerTest {
|
||||||
|
@ -97,7 +93,7 @@ public class BackoffLimitedRetryHandlerTest {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TransformingHttpCommandExecutorServiceImpl executorService;
|
HttpCommandExecutorService http;
|
||||||
|
|
||||||
@BeforeTest
|
@BeforeTest
|
||||||
void setupExecutorService() throws Exception {
|
void setupExecutorService() throws Exception {
|
||||||
|
@ -107,7 +103,7 @@ public class BackoffLimitedRetryHandlerTest {
|
||||||
ContentMetadataCodec contentMetadataCodec = new DefaultContentMetadataCodec(new DateServiceDateCodecFactory(
|
ContentMetadataCodec contentMetadataCodec = new DefaultContentMetadataCodec(new DateServiceDateCodecFactory(
|
||||||
new SimpleDateFormatDateService()));
|
new SimpleDateFormatDateService()));
|
||||||
RedirectionRetryHandler retry = new RedirectionRetryHandler(backoff);
|
RedirectionRetryHandler retry = new RedirectionRetryHandler(backoff);
|
||||||
JavaUrlHttpCommandExecutorService httpService = new JavaUrlHttpCommandExecutorService(utils,
|
http = new JavaUrlHttpCommandExecutorService(utils,
|
||||||
contentMetadataCodec, execService,
|
contentMetadataCodec, execService,
|
||||||
new DelegatingRetryHandler(backoff, retry), new BackoffLimitedRetryHandler(),
|
new DelegatingRetryHandler(backoff, retry), new BackoffLimitedRetryHandler(),
|
||||||
new DelegatingErrorHandler(), new HttpWire(), new HostnameVerifier() {
|
new DelegatingErrorHandler(), new HttpWire(), new HostnameVerifier() {
|
||||||
|
@ -124,7 +120,6 @@ public class BackoffLimitedRetryHandlerTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
executorService = new TransformingHttpCommandExecutorServiceImpl(httpService, execService);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -170,16 +165,13 @@ public class BackoffLimitedRetryHandlerTest {
|
||||||
assertEquals(response.getPayload().getInput().read(), -1);
|
assertEquals(response.getPayload().getInput().read(), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final RestAnnotationProcessor<IntegrationTestAsyncClient> processor = BaseJettyTest.newBuilder(8100,
|
private final RestAnnotationProcessor processor = BaseJettyTest.newBuilder(8100, new Properties()).buildInjector()
|
||||||
new Properties()).buildInjector().getInstance(
|
.getInstance(RestAnnotationProcessor.Factory.class).declaring(IntegrationTestAsyncClient.class);
|
||||||
Key.get(new TypeLiteral<RestAnnotationProcessor<IntegrationTestAsyncClient>>() {
|
|
||||||
}));
|
|
||||||
|
|
||||||
private HttpCommand createCommand() throws SecurityException, NoSuchMethodException {
|
private HttpCommand createCommand() throws SecurityException, NoSuchMethodException {
|
||||||
Method method = IntegrationTestAsyncClient.class.getMethod("download", String.class);
|
Method method = IntegrationTestAsyncClient.class.getMethod("download", String.class);
|
||||||
|
|
||||||
return new TransformingHttpCommandImpl<String>(executorService, processor.createRequest(method, "1"),
|
return new HttpCommand(processor.createRequest(method, "1"));
|
||||||
new ReturnStringIf2xx());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -35,9 +35,6 @@ import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Key;
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
import com.google.inject.util.Types;
|
|
||||||
|
|
||||||
@Test(groups = "unit")
|
@Test(groups = "unit")
|
||||||
public class InputParamValidatorTest {
|
public class InputParamValidatorTest {
|
||||||
|
@ -65,7 +62,7 @@ public class InputParamValidatorTest {
|
||||||
String.class);
|
String.class);
|
||||||
Method oneParamValidatedMethod = InputParamValidatorForm.class.getMethod("oneParamValidated", String.class,
|
Method oneParamValidatedMethod = InputParamValidatorForm.class.getMethod("oneParamValidated", String.class,
|
||||||
String.class);
|
String.class);
|
||||||
RestAnnotationProcessor<InputParamValidatorForm> restAnnotationProcessor = factory(InputParamValidatorForm.class);
|
RestAnnotationProcessor restAnnotationProcessor = factory(InputParamValidatorForm.class);
|
||||||
restAnnotationProcessor.createRequest(allParamsValidatedMethod, "blah", "blah");
|
restAnnotationProcessor.createRequest(allParamsValidatedMethod, "blah", "blah");
|
||||||
restAnnotationProcessor.createRequest(oneParamValidatedMethod, "blah", "blah");
|
restAnnotationProcessor.createRequest(oneParamValidatedMethod, "blah", "blah");
|
||||||
|
|
||||||
|
@ -105,10 +102,8 @@ public class InputParamValidatorTest {
|
||||||
new InputParamValidator(injector).validateMethodParametersOrThrow(method, 55);
|
new InputParamValidator(injector).validateMethodParametersOrThrow(method, 55);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
private RestAnnotationProcessor factory(Class<?> clazz) {
|
||||||
private <T> RestAnnotationProcessor<T> factory(Class<T> clazz) {
|
return injector.getInstance(RestAnnotationProcessor.Factory.class).declaring(clazz);
|
||||||
return ((RestAnnotationProcessor<T>) injector.getInstance(Key.get(TypeLiteral.get(Types.newParameterizedType(
|
|
||||||
RestAnnotationProcessor.class, clazz)))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Injector injector;
|
Injector injector;
|
||||||
|
|
|
@ -33,11 +33,10 @@ import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.google.inject.Binder;
|
import com.google.inject.Binder;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Key;
|
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -46,9 +45,7 @@ import com.google.inject.TypeLiteral;
|
||||||
@Test(groups = "unit")
|
@Test(groups = "unit")
|
||||||
public abstract class BaseAsyncApiTest<T> extends BaseRestApiTest {
|
public abstract class BaseAsyncApiTest<T> extends BaseRestApiTest {
|
||||||
|
|
||||||
protected RestAnnotationProcessor<T> processor;
|
protected RestAnnotationProcessor processor;
|
||||||
|
|
||||||
protected abstract TypeLiteral<RestAnnotationProcessor<T>> createTypeLiteral();
|
|
||||||
|
|
||||||
protected abstract void checkFilters(HttpRequest request);
|
protected abstract void checkFilters(HttpRequest request);
|
||||||
|
|
||||||
|
@ -67,7 +64,9 @@ public abstract class BaseAsyncApiTest<T> extends BaseRestApiTest {
|
||||||
protected void setupFactory() throws IOException {
|
protected void setupFactory() throws IOException {
|
||||||
injector = createInjector();
|
injector = createInjector();
|
||||||
parserFactory = injector.getInstance(ParseSax.Factory.class);
|
parserFactory = injector.getInstance(ParseSax.Factory.class);
|
||||||
processor = injector.getInstance(Key.get(createTypeLiteral()));
|
processor = injector.getInstance(RestAnnotationProcessor.Factory.class).declaring(new TypeToken<T>(getClass()) {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
}.getRawType());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String identity = "identity";
|
protected String identity = "identity";
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.rest.internal;
|
package org.jclouds.rest.internal;
|
||||||
import static com.google.common.base.Throwables.propagate;
|
import static com.google.common.base.Throwables.propagate;
|
||||||
import static com.google.inject.util.Types.newParameterizedType;
|
|
||||||
import static org.easymock.EasyMock.createMock;
|
import static org.easymock.EasyMock.createMock;
|
||||||
import static org.eclipse.jetty.http.HttpHeaders.TRANSFER_ENCODING;
|
import static org.eclipse.jetty.http.HttpHeaders.TRANSFER_ENCODING;
|
||||||
import static org.jclouds.rest.internal.RestAnnotationProcessor.createResponseParser;
|
import static org.jclouds.rest.internal.RestAnnotationProcessor.createResponseParser;
|
||||||
|
@ -53,7 +52,6 @@ import com.google.common.collect.SortedSetMultimap;
|
||||||
import com.google.common.collect.TreeMultimap;
|
import com.google.common.collect.TreeMultimap;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Key;
|
|
||||||
import com.google.inject.name.Names;
|
import com.google.inject.name.Names;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -181,10 +179,8 @@ public abstract class BaseRestApiTest {
|
||||||
assertEquals(createResponseParser(parserFactory, injector, method, request).getClass(), parserClass);
|
assertEquals(createResponseParser(parserFactory, injector, method, request).getClass(), parserClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
protected RestAnnotationProcessor factory(Class<?> clazz) {
|
||||||
protected <T> RestAnnotationProcessor<T> factory(Class<T> clazz) {
|
return injector.getInstance(RestAnnotationProcessor.Factory.class).declaring(clazz);
|
||||||
return ((RestAnnotationProcessor<T>) injector.getInstance(Key.get(newParameterizedType(
|
|
||||||
RestAnnotationProcessor.class, clazz))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue