From 886d2cafb961b707d0ea88ed54047b34a2d15928 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 23 Apr 2012 15:06:58 -0700 Subject: [PATCH] created base Context class with ProviderMetadata and Identity --- .../taskdefs/compute/ComputeTaskUtils.java | 12 +- .../org/jclouds/atmos/filters/ShareUrl.java | 6 +- .../jclouds/atmos/filters/SignRequest.java | 8 +- .../jclouds/atmos/AtmosClientLiveTest.java | 2 +- .../blobstore/integration/AtmosLiveTest.java | 2 +- .../cloudfiles/CloudFilesClientLiveTest.java | 2 +- ...BaseCloudLoadBalancersAsyncClientTest.java | 1 + .../BaseCloudLoadBalancersClientLiveTest.java | 8 +- .../CloudServersClientLiveTest.java | 2 +- .../cloudsigma/CloudSigmaClientLiveTest.java | 4 +- .../cloudstack/filters/QuerySigner.java | 7 +- .../internal/CloudStackContextImpl.java | 11 +- ...oudStackComputeServiceAdapterLiveTest.java | 2 +- .../compute/CloudStackExperimentLiveTest.java | 14 +- .../BaseCloudStackClientLiveTest.java | 20 +- .../features/GlobalUserClientLiveTest.java | 5 +- .../features/OfferingClientLiveTest.java | 3 +- .../features/SessionClientLiveTest.java | 4 +- .../ReadOnlyDeltacloudClientLiveTest.java | 2 +- .../DeltacloudTemplateBuilderLiveTest.java | 2 +- .../EC2ComputeServiceContextImpl.java | 11 +- .../BundleInstanceS3StorageOptions.java | 6 +- ...icationArchitecturesEC2ClientLiveTest.java | 2 +- .../jclouds/ec2/EBSBootEC2ClientLiveTest.java | 2 +- .../compute/EC2ComputeServiceLiveTest.java | 16 +- .../compute/EC2TemplateBuilderLiveTest.java | 4 +- .../compute/TestCanRecreateGroupLiveTest.java | 12 +- ...ailabilityZoneAndRegionClientLiveTest.java | 2 +- .../ElasticBlockStoreClientLiveTest.java | 4 +- .../ElasticIPAddressClientLiveTest.java | 2 +- .../ec2/services/InstanceClientLiveTest.java | 2 +- .../ec2/services/KeyPairClientLiveTest.java | 2 +- .../services/SecurityGroupClientLiveTest.java | 4 +- .../ec2/services/WindowsClientLiveTest.java | 6 +- .../ElasticStackClientLiveTest.java | 4 +- .../FilesystemAsyncBlobStoreTest.java | 4 +- ...ystemContainerIntegrationTestDisabled.java | 4 +- .../openstack/nova/NovaClientLiveTest.java | 2 +- .../SimpleTenantUsageClientExpectTest.java | 14 +- .../SimpleTenantUsageClientLiveTest.java | 2 - ...EqualsAnyNamespaceInExtensionsSetTest.java | 28 +- .../v1_1/internal/BaseNovaClientLiveTest.java | 2 +- .../nova/v1_1/parse/ParseKeyPairListTest.java | 4 +- .../internal/S3BlobStoreContextImpl.java | 5 +- .../s3/filters/RequestAuthorizeSignature.java | 8 +- .../java/org/jclouds/s3/S3ClientLiveTest.java | 2 +- .../jclouds/s3/services/BucketsLiveTest.java | 2 +- .../openstack/swift/CommonSwiftClient.java | 1 - .../swift/blobstore/SwiftAsyncBlobStore.java | 1 - .../ParallelMultipartUploadStrategy.java | 7 +- .../SequentialMultipartUploadStrategy.java | 16 +- .../openstack/swift/SwiftClientLiveTest.java | 2 +- .../SwiftBlobIntegrationLiveTest.java | 4 +- .../integration/SwiftContainerLiveTest.java | 5 +- .../swift/internal/StubSwiftAsyncClient.java | 1 - ...IntoNameThenCustomizeDeployAndPowerOn.java | 6 +- .../config/DefaultVCloudReferencesModule.java | 6 +- .../vcloud/config/VCloudRestClientModule.java | 10 +- .../features/CatalogClientLiveTest.java | 2 +- .../internal/BaseVCloudClientLiveTest.java | 4 +- .../internal/BlobStoreContextImpl.java | 15 +- .../TransientContainerIntegrationTest.java | 6 +- .../internal/BaseBlobIntegrationTest.java | 70 ++-- .../internal/BaseBlobLiveTest.java | 8 +- .../internal/BaseBlobMapIntegrationTest.java | 26 +- .../internal/BaseBlobSignerLiveTest.java | 32 +- .../BaseBlobStoreIntegrationTest.java | 42 +- .../BaseContainerIntegrationTest.java | 94 ++--- .../internal/BaseContainerLiveTest.java | 10 +- .../BaseInputStreamMapIntegrationTest.java | 32 +- .../internal/BaseMapIntegrationTest.java | 30 +- .../internal/BaseServiceIntegrationTest.java | 14 +- .../blobstore/internal/BaseBlobMapTest.java | 3 +- .../filters/SharedKeyLiteAuthentication.java | 6 +- .../config/DefaultVCloudReferencesModule.java | 6 +- .../TerremarkVCloudRestClientModule.java | 4 +- .../vcloud_0_8/TerremarkClientLiveTest.java | 16 +- .../VAppTemplatesInOrgsLiveTest.java | 2 +- .../internal/BaseTerremarkClientLiveTest.java | 4 +- .../compute/ComputeServiceContext.java | 25 +- .../main/java/org/jclouds/compute/Utils.java | 2 +- .../internal/ComputeServiceContextImpl.java | 56 +-- .../jclouds/compute/internal/UtilsImpl.java | 11 +- .../BaseComputeServiceContextLiveTest.java | 56 +-- .../internal/BaseComputeServiceLiveTest.java | 22 +- ...eGenericComputeServiceContextLiveTest.java | 81 ++++ .../internal/BaseImageExtensionLiveTest.java | 14 +- .../internal/BaseTemplateBuilderLiveTest.java | 40 +- core/src/main/java/org/jclouds/Context.java | 119 ++++++ .../main/java/org/jclouds/ContextBuilder.java | 365 +++++++++--------- core/src/main/java/org/jclouds/Wrapper.java | 8 +- .../java/org/jclouds/apis/ApiMetadata.java | 6 +- .../apis/internal/BaseApiMetadata.java | 15 +- .../BindPropertiesToExpandedValues.java | 67 ++++ ...WithWildcardExtendsExplicitAndRawType.java | 69 ++++ .../http/filters/BasicAuthentication.java | 14 +- .../org/jclouds/internal/BaseWrapper.java | 32 +- .../org/jclouds/internal/ContextImpl.java | 220 +++++++++++ .../suppliers/ProviderURISupplier.java | 4 +- ...a => ProviderURIFromProviderMetadata.java} | 11 +- .../jclouds/providers/ProviderPredicates.java | 9 +- .../java/org/jclouds/providers/Providers.java | 6 +- ...ProviderMetadataContextAndCredentials.java | 97 +++++ .../UpdateProviderMetadataFromProperties.java | 102 +++++ .../main/java/org/jclouds/rest/Providers.java | 5 +- .../java/org/jclouds/rest/RestContext.java | 51 +-- .../src/main/java/org/jclouds/rest/Utils.java | 27 ++ .../config/BindPropertiesToAnnotations.java | 159 -------- .../org/jclouds/rest/config/RestModule.java | 40 ++ .../rest/internal/RestContextImpl.java | 164 +------- .../org/jclouds/rest/internal/UtilsImpl.java | 18 +- .../java/org/jclouds/ContextBuilderTest.java | 61 ++- .../test/java/org/jclouds/apis/Balancer.java | 5 +- .../org/jclouds/apis/BaseContextLiveTest.java | 6 +- .../org/jclouds/apis/BaseWrapperLiveTest.java | 56 +++ .../test/java/org/jclouds/apis/Compute.java | 5 +- .../test/java/org/jclouds/apis/Storage.java | 5 +- .../BindPropertiesToExpandedValuesTest.java | 49 +++ ...WildcardExtendsExplicitAndRawTypeTest.java | 127 ++++++ .../events/config/EventBusModuleTest.java | 5 +- .../org/jclouds/internal/BaseWrapperTest.java | 29 +- ...iderMetadataContextAndCredentialsTest.java | 163 ++++++++ ...ateProviderMetadataFromPropertiesTest.java | 73 ++++ .../java/org/jclouds/util/ProvidersTest.java | 1 + .../GleSYSTemplateBuilderLiveTest.java | 2 +- .../internal/BaseGleSYSClientLiveTest.java | 2 +- .../internal/BasePooledComputeService.java | 9 +- .../java/org/jclouds/nodepool/AppTest.java | 9 +- .../vpdc/config/VPDCRestClientModule.java | 4 +- .../compute/VPDCTemplateBuilderLiveTest.java | 2 +- .../vpdc/features/VMClientLiveTest.java | 2 +- .../internal/VCloudDirectorContextImpl.java | 23 +- ...CloudDirectorClientExperimentLiveTest.java | 2 +- ...sionAndRetryOn401AndLogoutOnCloseTest.java | 1 + .../v1_5/login/SessionClientLiveTest.java | 1 + ...VirtualBoxComputeServiceContextModule.java | 5 +- .../BaseVirtualBoxClientLiveTest.java | 12 +- ...rtualBoxComputeServiceAdapterLiveTest.java | 4 +- ...romIMachineIfNotAlreadyExistsLiveTest.java | 4 +- .../functions/CreateAndInstallVmLiveTest.java | 4 +- ...hineFromIsoIfNotAlreadyExistsLiveTest.java | 4 +- .../GuestAdditionsInstallerLiveTest.java | 4 +- .../IMachinePredicatesLiveTest.java | 4 +- .../util/MachineControllerLiveTest.java | 4 +- .../virtualbox/util/MachineUtilsLiveTest.java | 4 +- .../LoadBalancerServiceContextImpl.java | 17 +- .../BaseLoadBalancerServiceLiveTest.java | 6 +- .../aws/ec2/AWSEC2ProviderMetadata.java | 3 + .../AWSEC2ComputeServiceContextImpl.java | 14 +- .../compute/AWSEC2ComputeServiceLiveTest.java | 12 +- .../AWSEC2TemplateBuilderLiveTest.java | 32 +- .../aws/ec2/services/AMIClientLiveTest.java | 12 +- .../ec2/services/AWSAMIClientLiveTest.java | 4 +- .../services/AWSInstanceClientLiveTest.java | 4 +- .../services/AWSKeyPairClientLiveTest.java | 14 +- .../services/MonitoringClientLiveTest.java | 2 +- .../PlacementGroupClientLiveTest.java | 10 +- .../services/SpotInstanceClientLiveTest.java | 2 +- .../aws/ec2/services/TagClientLiveTest.java | 8 +- .../internal/AWSS3BlobStoreContextImpl.java | 5 +- .../jclouds/aws/s3/AWSS3ClientLiveTest.java | 8 +- .../azureblob/AzureBlobClientLiveTest.java | 6 +- ...ckVCloudZone01TemplateBuilderLiveTest.java | 2 +- .../CloudFilesUKClientLiveTest.java | 2 +- .../CloudLoadBalancersUKProviderMetadata.java | 3 + .../CloudLoadBalancersUSProviderMetadata.java | 3 + .../CloudOneStorageProviderMetadata.java | 3 + ...CloudServersUKTemplateBuilderLiveTest.java | 2 +- ...CloudServersUSTemplateBuilderLiveTest.java | 2 +- .../CloudSigmaLasVegasProviderMetadata.java | 7 +- ...dSigmaLasVegasTemplateBuilderLiveTest.java | 9 +- .../CloudSigmaZurichProviderMetadata.java | 7 +- ...loudSigmaZurichComputeServiceLiveTest.java | 5 +- ...oudSigmaZurichTemplateBuilderLiveTest.java | 9 +- ...cHostsPeer1LosAngelesProviderMetadata.java | 7 +- ...eer1LosAngelesTemplateBuilderLiveTest.java | 9 +- ...HostsBlueSquareLondonProviderMetadata.java | 8 +- ...ueSquareLondonTemplateBuilderLiveTest.java | 9 +- ...asticHostsPeer1LondonProviderMetadata.java | 7 +- ...stsPeer1LondonTemplateBuilderLiveTest.java | 9 +- ...eer1SanAntonioTemplateBuilderLiveTest.java | 2 +- ...tsPeer1TorontoTemplateBuilderLiveTest.java | 2 +- ...loudEucalyptusTemplateBuilderLiveTest.java | 2 +- ...dJohannesburg1TemplateBuilderLiveTest.java | 2 +- .../filters/SharedKeyLiteAuthentication.java | 8 +- .../gogrid/GoGridLiveTestDisabled.java | 2 +- .../compute/GoGridComputeServiceLiveTest.java | 2 +- .../GoGridTemplateBuilderLiveTest.java | 2 +- .../services/BaseGoGridClientLiveTest.java | 2 +- ...aElementVCloudTemplateBuilderLiveTest.java | 2 +- ...HPCloudComputeTemplateBuilderLiveTest.java | 2 +- .../HPCloudObjectStorageClientLiveTest.java | 2 +- ...inefoldComputeTemplateBuilderLiveTest.java | 4 +- ...enHostingEast1TemplateBuilderLiveTest.java | 2 +- .../filters/RimuHostingAuthentication.java | 5 +- .../miro/RimuHostingClientLiveTest.java | 2 +- .../RimuHostingTemplateBuilderLiveTest.java | 2 +- ...loveManchesterTemplateBuilderLiveTest.java | 2 +- ...iCloudMalaysiaTemplateBuilderLiveTest.java | 2 +- .../slicehost/filters/SlicehostBasic.java | 5 +- .../slicehost/SlicehostClientLiveTest.java | 2 +- .../SlicehostTemplateBuilderLiveTest.java | 2 +- ...oftLayerComputeServiceAdapterLiveTest.java | 6 +- .../SoftLayerTemplateBuilderLiveTest.java | 16 +- .../features/BaseSoftLayerClientLiveTest.java | 2 +- .../features/VirtualGuestClientLiveTest.java | 2 +- ...nVCloudMyCloudTemplateBuilderLiveTest.java | 2 +- ...TerremarkECloudComputeServiceLiveTest.java | 2 +- ...erremarkECloudTemplateBuilderLiveTest.java | 2 +- .../InternetServiceLiveTest.java | 2 +- ...rkVCloudExpressComputeServiceLiveTest.java | 2 +- ...kVCloudExpressTemplateBuilderLiveTest.java | 2 +- .../TryStackNovaTemplateBuilderLiveTest.java | 2 +- .../jclouds/scriptbuilder/InitBuilder.java | 2 + .../scriptbuilder/InitBuilderTest.java | 1 + ...nagerComputeServiceContextBuilderTest.java | 4 +- 216 files changed, 2311 insertions(+), 1420 deletions(-) create mode 100644 compute/src/test/java/org/jclouds/compute/internal/BaseGenericComputeServiceContextLiveTest.java create mode 100644 core/src/main/java/org/jclouds/Context.java create mode 100644 core/src/main/java/org/jclouds/config/BindPropertiesToExpandedValues.java create mode 100644 core/src/main/java/org/jclouds/config/BindRestContextWithWildcardExtendsExplicitAndRawType.java create mode 100644 core/src/main/java/org/jclouds/internal/ContextImpl.java rename core/src/main/java/org/jclouds/location/suppliers/fromconfig/{ProviderURIFromConfiguration.java => ProviderURIFromProviderMetadata.java} (74%) create mode 100644 core/src/main/java/org/jclouds/providers/config/BindProviderMetadataContextAndCredentials.java create mode 100644 core/src/main/java/org/jclouds/providers/internal/UpdateProviderMetadataFromProperties.java delete mode 100644 core/src/main/java/org/jclouds/rest/config/BindPropertiesToAnnotations.java create mode 100644 core/src/test/java/org/jclouds/apis/BaseWrapperLiveTest.java create mode 100644 core/src/test/java/org/jclouds/config/BindPropertiesToExpandedValuesTest.java create mode 100644 core/src/test/java/org/jclouds/config/BindRestContextWithWildcardExtendsExplicitAndRawTypeTest.java create mode 100644 core/src/test/java/org/jclouds/providers/config/BindProviderMetadataContextAndCredentialsTest.java create mode 100644 core/src/test/java/org/jclouds/providers/internal/UpdateProviderMetadataFromPropertiesTest.java diff --git a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java b/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java index 0c4b3c2a3b..f08db34618 100644 --- a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java +++ b/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java @@ -26,9 +26,9 @@ import java.util.Set; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; +import org.jclouds.ContextBuilder; import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilder; @@ -73,14 +73,16 @@ public class ComputeTaskUtils { public ComputeServiceContext load(URI from) { Properties props = new Properties(); props.putAll(projectProvider.get().getProperties()); + Set modules = ImmutableSet. of(new AntLoggingModule(projectProvider.get(), + ComputeServiceConstants.COMPUTE_LOGGER), new JschSshClientModule()); // adding the properties to the factory will allow us to pass // alternate endpoints String provider = from.getHost(); Credentials creds = Credentials.parse(from); - return new ComputeServiceContextFactory().createContext(provider, creds.identity, creds.credential, - ImmutableSet.of((Module) new AntLoggingModule(projectProvider.get(), - ComputeServiceConstants.COMPUTE_LOGGER), new JschSshClientModule()), props); - + return ContextBuilder.newBuilder(provider) + .credentials(creds.identity, creds.credential) + .modules(modules) + .overrides(props).buildAndWrapWith(ComputeServiceContext.class); } }); diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/filters/ShareUrl.java b/apis/atmos/src/main/java/org/jclouds/atmos/filters/ShareUrl.java index 4fdf7a7cee..596235295d 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/filters/ShareUrl.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/filters/ShareUrl.java @@ -19,8 +19,6 @@ package org.jclouds.atmos.filters; import static org.jclouds.Constants.LOGGER_SIGNATURE; -import static org.jclouds.Constants.PROPERTY_CREDENTIAL; -import static org.jclouds.Constants.PROPERTY_IDENTITY; import java.net.URI; @@ -37,6 +35,8 @@ import org.jclouds.http.HttpException; import org.jclouds.io.InputSuppliers; import org.jclouds.location.Provider; import org.jclouds.logging.Logger; +import org.jclouds.rest.annotations.Credential; +import org.jclouds.rest.annotations.Identity; import com.google.common.base.Function; import com.google.common.base.Supplier; @@ -66,7 +66,7 @@ public class ShareUrl implements Function { Logger signatureLog = Logger.NULL; @Inject - public ShareUrl(@Named(PROPERTY_IDENTITY) String uid, @Named(PROPERTY_CREDENTIAL) String encodedKey, + public ShareUrl(@Identity String uid, @Credential String encodedKey, @Provider Supplier provider, @TimeStamp javax.inject.Provider timeStampProvider, javax.inject.Provider uriBuilders, Crypto crypto) { this.uid = uid; diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/filters/SignRequest.java b/apis/atmos/src/main/java/org/jclouds/atmos/filters/SignRequest.java index 94be6d2c57..65d49031b7 100644 --- a/apis/atmos/src/main/java/org/jclouds/atmos/filters/SignRequest.java +++ b/apis/atmos/src/main/java/org/jclouds/atmos/filters/SignRequest.java @@ -19,8 +19,6 @@ package org.jclouds.atmos.filters; import static org.jclouds.Constants.LOGGER_SIGNATURE; -import static org.jclouds.Constants.PROPERTY_CREDENTIAL; -import static org.jclouds.Constants.PROPERTY_IDENTITY; import static org.jclouds.util.Patterns.NEWLINE_PATTERN; import static org.jclouds.util.Patterns.TWO_SPACE_PATTERN; @@ -46,6 +44,8 @@ import org.jclouds.http.internal.SignatureWire; import org.jclouds.http.utils.ModifyRequest; import org.jclouds.io.InputSuppliers; import org.jclouds.logging.Logger; +import org.jclouds.rest.annotations.Credential; +import org.jclouds.rest.annotations.Identity; import org.jclouds.util.Strings2; import com.google.common.annotations.VisibleForTesting; @@ -79,8 +79,8 @@ public class SignRequest implements HttpRequestFilter { Logger signatureLog = Logger.NULL; @Inject - public SignRequest(SignatureWire signatureWire, @Named(PROPERTY_IDENTITY) String uid, - @Named(PROPERTY_CREDENTIAL) String encodedKey, @TimeStamp Provider timeStampProvider, Crypto crypto, + public SignRequest(SignatureWire signatureWire, @Identity String uid, + @Credential String encodedKey, @TimeStamp Provider timeStampProvider, Crypto crypto, HttpUtils utils) { this.signatureWire = signatureWire; this.uid = uid; diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java index fc9adafdb9..7c380006a7 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosClientLiveTest.java @@ -57,7 +57,7 @@ import com.google.common.collect.Sets; public class AtmosClientLiveTest extends BaseBlobStoreIntegrationTest { public AtmosClient getApi() { - return context.unwrap(AtmosApiMetadata.CONTEXT_TOKEN).getApi(); + return wrapper.unwrap(AtmosApiMetadata.CONTEXT_TOKEN).getApi(); } private static final class HeadMatches implements Runnable { diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosLiveTest.java index 4c17e48f31..c6e989b24c 100644 --- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosLiveTest.java +++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosLiveTest.java @@ -34,6 +34,6 @@ public class AtmosLiveTest extends BaseBlobLiveTest { } protected void checkMD5(String container, String name, byte[] md5) { // atmos does not support content-md5 yet - assertEquals(context.getBlobStore().blobMetadata(container, name).getContentMetadata().getContentMD5(), null); + assertEquals(wrapper.getBlobStore().blobMetadata(container, name).getContentMetadata().getContentMD5(), null); } } diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java index e7b382059f..38fa4b8d3b 100644 --- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java +++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java @@ -47,7 +47,7 @@ public class CloudFilesClientLiveTest extends CommonSwiftClientLiveTest extends BaseAsync protected void configure() { } + @SuppressWarnings("unused") @Provides @Singleton GetAuth provideGetAuth() { diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java index 201a5b363a..684aecb26f 100644 --- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java +++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java @@ -20,7 +20,7 @@ package org.jclouds.cloudloadbalancers.internal; import java.util.concurrent.TimeUnit; -import org.jclouds.apis.BaseContextLiveTest; +import org.jclouds.apis.BaseWrapperLiveTest; import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient; import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient; import org.jclouds.cloudloadbalancers.domain.LoadBalancer; @@ -42,7 +42,7 @@ import com.google.inject.Injector; * * @author Adrian Cole */ -public class BaseCloudLoadBalancersClientLiveTest extends BaseContextLiveTest { +public class BaseCloudLoadBalancersClientLiveTest extends BaseWrapperLiveTest { public BaseCloudLoadBalancersClientLiveTest() { provider = "cloudloadbalancers"; @@ -61,7 +61,7 @@ public class BaseCloudLoadBalancersClientLiveTest extends BaseContextLiveTest contextType() { + protected TypeToken wrapperType() { return TypeToken.of(LoadBalancerServiceContext.class); } diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java index d1f0cc47e9..45e6e2ad26 100644 --- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java +++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java @@ -85,7 +85,7 @@ public class CloudServersClientLiveTest extends BaseComputeServiceContextLiveTes @Override public void setupContext() { super.setupContext(); - Injector injector = context.utils().injector(); + Injector injector = wrapper.utils().injector(); client = injector.getInstance(CloudServersClient.class); sshFactory = injector.getInstance(SshClient.Factory.class); SocketOpen socketOpen = injector.getInstance(SocketOpen.class); diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java index 48f8c98bb7..ef1a4438c9 100644 --- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java +++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java @@ -89,7 +89,7 @@ public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest @Override public void setupContext() { super.setupContext(); - cloudSigmaContext = context.unwrap(); + cloudSigmaContext = wrapper.unwrap(); client = cloudSigmaContext.getApi(); driveNotClaimed = new RetryablePredicate(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, @@ -98,7 +98,7 @@ public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest TimeUnit.SECONDS); if (Strings.emptyToNull(imageId) == null) { - imageId = context.getComputeService().templateBuilder().build().getImage().getId(); + imageId = wrapper.getComputeService().templateBuilder().build().getImage().getId(); } } diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/filters/QuerySigner.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/filters/QuerySigner.java index bf5a18fc0b..01d53ffe18 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/filters/QuerySigner.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/filters/QuerySigner.java @@ -40,6 +40,8 @@ import org.jclouds.http.utils.ModifyRequest; import org.jclouds.io.InputSuppliers; import org.jclouds.logging.Logger; import org.jclouds.rest.RequestSigner; +import org.jclouds.rest.annotations.Credential; +import org.jclouds.rest.annotations.Identity; import org.jclouds.util.Strings2; import com.google.common.annotations.VisibleForTesting; @@ -71,9 +73,8 @@ public class QuerySigner implements AuthenticationFilter, RequestSigner { private Logger signatureLog = Logger.NULL; @Inject - public QuerySigner(SignatureWire signatureWire, @Named(Constants.PROPERTY_IDENTITY) String accessKey, - @Named(Constants.PROPERTY_CREDENTIAL) String secretKey, Crypto crypto, HttpUtils utils, - Provider builder) { + public QuerySigner(SignatureWire signatureWire, @Identity String accessKey, @Credential String secretKey, + Crypto crypto, HttpUtils utils, Provider builder) { this.signatureWire = signatureWire; this.accessKey = accessKey; this.secretKey = secretKey; diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java index 3267f9d56b..9cc4e615cc 100644 --- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java +++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java @@ -18,12 +18,10 @@ */ package org.jclouds.cloudstack.internal; -import java.io.Closeable; -import java.util.Map; - import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.Context; import org.jclouds.cloudstack.CloudStackAsyncClient; import org.jclouds.cloudstack.CloudStackClient; import org.jclouds.cloudstack.CloudStackContext; @@ -34,7 +32,6 @@ import org.jclouds.cloudstack.CloudStackGlobalClient; import org.jclouds.compute.ComputeService; import org.jclouds.compute.Utils; import org.jclouds.compute.internal.ComputeServiceContextImpl; -import org.jclouds.domain.Credentials; import org.jclouds.location.Provider; import org.jclouds.rest.RestContext; @@ -49,11 +46,11 @@ public class CloudStackContextImpl extends ComputeServiceContextImpl implements private final RestContext globalContext; @Inject - public CloudStackContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, - ComputeService computeService, Map credentialStore, Utils utils, + public CloudStackContextImpl(@Provider Context wrapped, @Provider TypeToken wrappedType, + ComputeService computeService, Utils utils, RestContext domainContext, RestContext globalContext) { - super(wrapped, wrappedType, computeService, credentialStore, utils); + super(wrapped, wrappedType, computeService, utils); this.domainContext = domainContext; this.globalContext = globalContext; } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java index 0da85d8081..240f0a6509 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java @@ -157,7 +157,7 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien public void testCreateNodeWithGroupEncodedIntoName() throws InterruptedException { String group = prefix + "-foo"; String name = group + "-node-" + new Random().nextInt(); - Template template = context.getComputeService().templateBuilder().build(); + Template template = wrapper.getComputeService().templateBuilder().build(); if (!client .getTemplateClient() diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackExperimentLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackExperimentLiveTest.java index c8c8445bb7..63ff72926a 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackExperimentLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackExperimentLiveTest.java @@ -90,9 +90,9 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest { Network network = null; Set nodes = null; try { - assert context.getComputeService().listAssignableLocations().size() > 0; + assert wrapper.getComputeService().listAssignableLocations().size() > 0; - Template template = context.getComputeService().templateBuilder().build(); + Template template = wrapper.getComputeService().templateBuilder().build(); // get the zone we are launching into long zoneId = Long.parseLong(template.getLocation().getId()); @@ -115,7 +115,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest { template.getOptions().as(CloudStackTemplateOptions.class).networkId(network.getId()); // launch the VM - nodes = context.getComputeService().createNodesInGroup(group, 1, template); + nodes = wrapper.getComputeService().createNodesInGroup(group, 1, template); assert nodes.size() > 0; @@ -124,7 +124,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest { nodes = newTreeSet(concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet())); } finally { if (nodes != null) - context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group)); + wrapper.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group)); if (network != null) domainAdminContext.getApi().getNetworkClient().deleteNetwork(network.getId()); } @@ -143,14 +143,14 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest { SshKeyPair keyPair = client.getSSHKeyPairClient().createSSHKeyPair(keyPairName); String group = prefix + "-windows-test"; - Template template = context.getComputeService().templateBuilder() + Template template = wrapper.getComputeService().templateBuilder() .imageId("290").locationId("1") .options(new CloudStackTemplateOptions().setupStaticNat(false).keyPair(keyPairName)) .build(); NodeMetadata node = null; try { - node = getOnlyElement(context.getComputeService() + node = getOnlyElement(wrapper.getComputeService() .createNodesInGroup(group, 1, template)); String encryptedPassword = client.getVirtualMachineClient() @@ -165,7 +165,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest { } finally { if (node != null) { - context.getComputeService().destroyNode(node.getId()); + wrapper.getComputeService().destroyNode(node.getId()); } } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java index d202c58841..23992bd69c 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/BaseCloudStackClientLiveTest.java @@ -51,7 +51,7 @@ import org.jclouds.cloudstack.predicates.VirtualMachineRunning; import org.jclouds.cloudstack.strategy.BlockUntilJobCompletesAndReturnResult; import org.jclouds.compute.ComputeService; import org.jclouds.compute.domain.ExecResponse; -import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; +import org.jclouds.compute.internal.BaseGenericComputeServiceContextLiveTest; import org.jclouds.net.IPSocket; import org.jclouds.predicates.InetSocketAddressConnect; import org.jclouds.predicates.RetryablePredicate; @@ -65,6 +65,7 @@ import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; +import com.google.common.reflect.TypeToken; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Module; @@ -73,7 +74,7 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public class BaseCloudStackClientLiveTest extends BaseComputeServiceContextLiveTest { +public class BaseCloudStackClientLiveTest extends BaseGenericComputeServiceContextLiveTest { protected String domainAdminIdentity; protected String domainAdminCredential; protected String globalAdminIdentity; @@ -82,7 +83,12 @@ public class BaseCloudStackClientLiveTest extends BaseComputeServiceContextLiveT public BaseCloudStackClientLiveTest() { provider = "cloudstack"; } - + + @Override + protected TypeToken wrapperType() { + return TypeToken.of(CloudStackContext.class); + } + @Override protected Properties setupProperties() { Properties overrides = super.setupProperties(); @@ -193,14 +199,14 @@ public class BaseCloudStackClientLiveTest extends BaseComputeServiceContextLiveT @Override public void setupContext() { super.setupContext(); - computeClient = context.getComputeService(); - cloudStackContext = context.unwrap(); + computeClient = wrapper.getComputeService(); + cloudStackContext = wrapper.unwrap(); client = cloudStackContext.getApi(); user = verifyCurrentUserIsOfType(cloudStackContext, Account.Type.USER); domainAdminEnabled = setupDomainAdminProperties() != null; if (domainAdminEnabled) { - domainAdminComputeContext = createContext(setupDomainAdminProperties(), setupModules()).unwrap(); + domainAdminComputeContext = createWrapper(setupDomainAdminProperties(), setupModules()); domainAdminContext = domainAdminComputeContext.getDomainContext(); domainAdminClient = domainAdminContext.getApi(); domainAdminUser = verifyCurrentUserIsOfType(domainAdminContext, Account.Type.DOMAIN_ADMIN); @@ -209,7 +215,7 @@ public class BaseCloudStackClientLiveTest extends BaseComputeServiceContextLiveT globalAdminEnabled = setupGlobalAdminProperties() != null; if (globalAdminEnabled) { - globalAdminComputeContext = createContext(setupGlobalAdminProperties(), setupModules()).unwrap(); + globalAdminComputeContext = createWrapper(setupGlobalAdminProperties(), setupModules()); globalAdminContext = globalAdminComputeContext.getGlobalContext(); globalAdminClient = globalAdminContext.getApi(); globalAdminUser = verifyCurrentUserIsOfType(globalAdminContext, Account.Type.ADMIN); diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserClientLiveTest.java index fbc3166f7d..988e831024 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/GlobalUserClientLiveTest.java @@ -27,6 +27,7 @@ import static org.testng.Assert.assertNotNull; import java.util.Properties; import java.util.Set; +import org.jclouds.cloudstack.CloudStackApiMetadata; import org.jclouds.cloudstack.CloudStackClient; import org.jclouds.cloudstack.CloudStackGlobalClient; import org.jclouds.cloudstack.domain.Account; @@ -83,9 +84,9 @@ public class GlobalUserClientLiveTest extends BaseCloudStackClientLiveTest { } private void checkAuthAsUser(ApiKeyPair keyPair) { - ComputeServiceContext context = createContext(credentialsAsProperties(keyPair), setupModules()); + ComputeServiceContext context = createWrapper(credentialsAsProperties(keyPair), setupModules()); - CloudStackClient client = CloudStackClient.class.cast(context.getProviderSpecificContext().getApi()); + CloudStackClient client = context.unwrap(CloudStackApiMetadata.CONTEXT_TOKEN).getApi(); Set accounts = client.getAccountClient().listAccounts(); assert accounts.size() > 0; diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/OfferingClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/OfferingClientLiveTest.java index fd187ab6c4..b5e2a8c0c5 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/OfferingClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/OfferingClientLiveTest.java @@ -66,7 +66,8 @@ public class OfferingClientLiveTest extends BaseCloudStackClientLiveTest { } catch (NoSuchElementException e) { // This bug is present both in 2.2.8 and 2.2.12 - assertTrue(Predicates.in(ImmutableSet.of("2.2.8", "2.2.12")).apply(cloudStackContext.getApiVersion())); + assertTrue(Predicates.in(ImmutableSet.of("2.2.8", "2.2.12")).apply( + cloudStackContext.getProviderMetadata().getApiMetadata().getVersion())); } } } diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SessionClientLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SessionClientLiveTest.java index 938be58289..aa703839b8 100644 --- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SessionClientLiveTest.java +++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/SessionClientLiveTest.java @@ -44,7 +44,7 @@ public class SessionClientLiveTest extends BaseCloudStackClientLiveTest { @Test public void testCreateContextUsingUserAndPasswordAuthentication() { - String endpoint = cloudStackContext.getEndpoint().toASCIIString(); + String endpoint = cloudStackContext.getProviderMetadata().getEndpoint(); assert globalAdminEnabled; Account testAccount = null; @@ -75,7 +75,7 @@ public class SessionClientLiveTest extends BaseCloudStackClientLiveTest { @Test(expectedExceptions = AuthorizationException.class) public void testTryToGetApiKeypairWithWrongCredentials() { - String endpoint = cloudStackContext.getEndpoint().toASCIIString(); + String endpoint = cloudStackContext.getProviderMetadata().getEndpoint(); ApiKeyPairs.loginToEndpointAsUsernameInDomainWithPasswordAndReturnApiKeyPair( URI.create(endpoint), "dummy-missing-user", "with-a-wrong-password", ""); } diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java index c63cbd8b47..785997633f 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/ReadOnlyDeltacloudClientLiveTest.java @@ -71,7 +71,7 @@ public class ReadOnlyDeltacloudClientLiveTest extends BaseComputeServiceContextL @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.unwrap(DeltacloudApiMetadata.CONTEXT_TOKEN).getApi(); + client = wrapper.unwrap(DeltacloudApiMetadata.CONTEXT_TOKEN).getApi(); socketTester = new RetryablePredicate(new InetSocketAddressConnect(), 180, 1, TimeUnit.SECONDS); stateChanges = ImmutableMap.> of(// Instance.State.RUNNING, new RetryablePredicate(new InstanceRunning(client), 600, 1, diff --git a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java index 4af99e42f0..9788ba9a75 100644 --- a/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java +++ b/apis/deltacloud/src/test/java/org/jclouds/deltacloud/compute/DeltacloudTemplateBuilderLiveTest.java @@ -70,7 +70,7 @@ public class DeltacloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTe @Test public void testTemplateBuilder() { - Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); + Template defaultTemplate = this.wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java b/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java index b63728b8b1..0b05f90d71 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/compute/internal/EC2ComputeServiceContextImpl.java @@ -18,15 +18,12 @@ */ package org.jclouds.ec2.compute.internal; -import java.io.Closeable; -import java.util.Map; - import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.Context; import org.jclouds.compute.Utils; import org.jclouds.compute.internal.ComputeServiceContextImpl; -import org.jclouds.domain.Credentials; import org.jclouds.ec2.compute.EC2ComputeService; import org.jclouds.ec2.compute.EC2ComputeServiceContext; import org.jclouds.location.Provider; @@ -39,9 +36,9 @@ import com.google.common.reflect.TypeToken; @Singleton public class EC2ComputeServiceContextImpl extends ComputeServiceContextImpl implements EC2ComputeServiceContext { @Inject - public EC2ComputeServiceContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, - EC2ComputeService computeService, Map credentialStore, Utils utils){ - super(wrapped, wrappedType, computeService, credentialStore, utils); + public EC2ComputeServiceContextImpl(@Provider Context wrapped, @Provider TypeToken wrappedType, + EC2ComputeService computeService, Utils utils) { + super(wrapped, wrappedType, computeService, utils); } @Override diff --git a/apis/ec2/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java b/apis/ec2/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java index 8c0ea7d5f9..71524c24ff 100644 --- a/apis/ec2/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java +++ b/apis/ec2/src/main/java/org/jclouds/ec2/options/BundleInstanceS3StorageOptions.java @@ -20,11 +20,9 @@ package org.jclouds.ec2.options; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import static org.jclouds.Constants.PROPERTY_IDENTITY; - -import javax.inject.Named; import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; +import org.jclouds.rest.annotations.Identity; import com.google.common.collect.Multimap; import com.google.inject.Inject; @@ -52,7 +50,7 @@ import com.google.inject.Inject; public class BundleInstanceS3StorageOptions extends BaseEC2RequestOptions { @Inject(optional = true) - @Named(PROPERTY_IDENTITY) + @Identity String currentAwsAccessKeyId; @Override diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java index 1993e42c3a..cb2bc8dd5a 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/CloudApplicationArchitecturesEC2ClientLiveTest.java @@ -95,7 +95,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - Injector injector = context.utils().injector(); + Injector injector = wrapper.utils().injector(); client = injector.getInstance(EC2Client.class); sshFactory = injector.getInstance(SshClient.Factory.class); runningTester = new RetryablePredicate(new InstanceStateRunning(client), 180, 5, diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java index 87c75162a6..2eb3b27cce 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/EBSBootEC2ClientLiveTest.java @@ -126,7 +126,7 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - Injector injector = context.utils().injector(); + Injector injector = wrapper.utils().injector(); client = injector.getInstance(EC2Client.class); sshFactory = injector.getInstance(SshClient.Factory.class); SocketOpen socketOpen = injector.getInstance(SocketOpen.class); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java index 500a0b0786..795c549110 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2ComputeServiceLiveTest.java @@ -102,13 +102,13 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { @Test(enabled = true, dependsOnMethods = "testCompareSizes") public void testExtendedOptionsAndLogin() throws Exception { - SecurityGroupClient securityGroupClient = EC2Client.class.cast(context.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi()) + SecurityGroupClient securityGroupClient = EC2Client.class.cast(wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi()) .getSecurityGroupServices(); - KeyPairClient keyPairClient = EC2Client.class.cast(context.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi()) + KeyPairClient keyPairClient = EC2Client.class.cast(wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi()) .getKeyPairServices(); - InstanceClient instanceClient = EC2Client.class.cast(context.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi()) + InstanceClient instanceClient = EC2Client.class.cast(wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi()) .getInstanceServices(); String group = this.group + "o"; @@ -181,7 +181,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { Properties overrides = setupProperties(); overrides.setProperty(EC2Constants.PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS, "true"); - context = createContext(overrides, setupModules()); + context = createWrapper(overrides, setupModules()); // create a node Set nodes = @@ -233,19 +233,19 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest { @Test(enabled = true) public void testMapEBS() throws Exception { - InstanceClient instanceClient = EC2Client.class.cast(context.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi()) + InstanceClient instanceClient = EC2Client.class.cast(wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi()) .getInstanceServices(); - ElasticBlockStoreClient ebsClient = EC2Client.class.cast(context.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi()) + ElasticBlockStoreClient ebsClient = EC2Client.class.cast(wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi()) .getElasticBlockStoreServices(); String group = this.group + "e"; int volumeSize = 8; - final Template template = context.getComputeService().templateBuilder().hardwareId(InstanceType.M1_SMALL) + final Template template = wrapper.getComputeService().templateBuilder().hardwareId(InstanceType.M1_SMALL) .osFamily(OsFamily.UBUNTU).osVersionMatches("10.04").imageDescriptionMatches(".*ebs.*").build(); - Location zone = Iterables.find(context.getComputeService().listAssignableLocations(), new Predicate() { + Location zone = Iterables.find(wrapper.getComputeService().listAssignableLocations(), new Predicate() { @Override public boolean apply(Location arg0) { diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java index dafe81fc4b..3bbcf0c66d 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/EC2TemplateBuilderLiveTest.java @@ -50,7 +50,7 @@ public abstract class EC2TemplateBuilderLiveTest extends BaseTemplateBuilderLive @Test public void testTemplateBuilderCanUseImageIdWithoutFetchingAllImages() throws Exception { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); String defaultImageId = defaultTemplate.getImage().getId(); String defaultImageProviderId = defaultTemplate.getImage().getProviderId(); @@ -58,7 +58,7 @@ public abstract class EC2TemplateBuilderLiveTest extends BaseTemplateBuilderLive try { // Track http commands final List commandsInvoked = Lists.newArrayList(); - context = createContext( + context = createWrapper( setupProperties(), ImmutableSet. of(new Log4JLoggingModule(), TrackingJavaUrlHttpCommandExecutorService.newTrackingModule(commandsInvoked))); diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java index fc7ca34a97..967b808d82 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/compute/TestCanRecreateGroupLiveTest.java @@ -39,18 +39,18 @@ public class TestCanRecreateGroupLiveTest extends BaseComputeServiceContextLiveT public void testCanRecreateGroup() throws Exception { String tag = PREFIX + "recreate"; - context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(tag)); + wrapper.getComputeService().destroyNodesMatching(NodePredicates.inGroup(tag)); try { - Template template = context.getComputeService().templateBuilder().build(); - context.getComputeService().createNodesInGroup(tag, 1, template); - context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(tag)); - context.getComputeService().createNodesInGroup(tag, 1, template); + Template template = wrapper.getComputeService().templateBuilder().build(); + wrapper.getComputeService().createNodesInGroup(tag, 1, template); + wrapper.getComputeService().destroyNodesMatching(NodePredicates.inGroup(tag)); + wrapper.getComputeService().createNodesInGroup(tag, 1, template); } catch (RunNodesException e) { System.err.println(e.getNodeErrors().keySet()); Throwables.propagate(e); } finally { - context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(tag)); + wrapper.getComputeService().destroyNodesMatching(NodePredicates.inGroup(tag)); } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java index 80dbaf4d1c..b68cc8c5e2 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/AvailabilityZoneAndRegionClientLiveTest.java @@ -56,7 +56,7 @@ public class AvailabilityZoneAndRegionClientLiveTest extends BaseComputeServiceC @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices(); + client = wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices(); } public void testDescribeAvailabilityZones() { diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java index 4fd9676cec..4945931110 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticBlockStoreClientLiveTest.java @@ -61,12 +61,12 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticBlockStoreServices(); + client = wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticBlockStoreServices(); } @Test void testDescribeVolumes() { - for (String region : context.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { + for (String region : wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { SortedSet allResults = Sets.newTreeSet(client.describeVolumesInRegion(region)); assertNotNull(allResults); if (allResults.size() >= 1) { diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java index 83bb5c4503..c623bb7968 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/ElasticIPAddressClientLiveTest.java @@ -50,7 +50,7 @@ public class ElasticIPAddressClientLiveTest extends BaseComputeServiceContextLiv @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticIPAddressServices(); + client = wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticIPAddressServices(); } @Test diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceClientLiveTest.java index d44b224082..5927c60077 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/InstanceClientLiveTest.java @@ -49,7 +49,7 @@ public class InstanceClientLiveTest extends BaseComputeServiceContextLiveTest { @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getInstanceServices(); + client = wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getInstanceServices(); } @Test diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairClientLiveTest.java index cd5287b7af..13e5811157 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/KeyPairClientLiveTest.java @@ -51,7 +51,7 @@ public class KeyPairClientLiveTest extends BaseComputeServiceContextLiveTest { @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getKeyPairServices(); + client = wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getKeyPairServices(); } @Test diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java index d4b623c7e5..8b4fc8db8f 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/SecurityGroupClientLiveTest.java @@ -60,7 +60,7 @@ public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTe @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getSecurityGroupServices(); + client = wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getSecurityGroupServices(); } @Test @@ -281,6 +281,6 @@ public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTe @AfterTest public void shutdown() { - context.close(); + wrapper.close(); } } diff --git a/apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsClientLiveTest.java b/apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsClientLiveTest.java index c877fbae7c..9cf1fc1383 100644 --- a/apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsClientLiveTest.java +++ b/apis/ec2/src/test/java/org/jclouds/ec2/services/WindowsClientLiveTest.java @@ -76,8 +76,8 @@ public class WindowsClientLiveTest extends BaseComputeServiceContextLiveTest { @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getWindowsServices(); - computeService = context.getComputeService(); + client = wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getWindowsServices(); + computeService = wrapper.getComputeService(); } @@ -141,7 +141,7 @@ public class WindowsClientLiveTest extends BaseComputeServiceContextLiveTest { node.getCredentials().getPrivateKey()); // And apply it to the decryption function - WindowsLoginCredentialsFromEncryptedData f = context.getUtils().getInjector().getInstance(WindowsLoginCredentialsFromEncryptedData.class); + WindowsLoginCredentialsFromEncryptedData f = wrapper.getUtils().getInjector().getInstance(WindowsLoginCredentialsFromEncryptedData.class); LoginCredentials credentials = f.apply(dataAndKey); assertEquals(credentials.getUser(), "Administrator"); diff --git a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java index 0eb8854bf1..a454360888 100644 --- a/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java +++ b/apis/elasticstack/src/test/java/org/jclouds/elasticstack/ElasticStackClientLiveTest.java @@ -88,7 +88,7 @@ public class ElasticStackClientLiveTest @Override public void setupContext() { super.setupContext(); - cloudStackContext = context.unwrap(); + cloudStackContext = wrapper.unwrap(); client = cloudStackContext.getApi(); driveNotClaimed = new RetryablePredicate(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, @@ -97,7 +97,7 @@ public class ElasticStackClientLiveTest TimeUnit.SECONDS); if (Strings.emptyToNull(imageId) == null) { - imageId = context.getComputeService().templateBuilder().build().getImage().getId(); + imageId = wrapper.getComputeService().templateBuilder().build().getImage().getId(); } } diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java index e9f6b3cbb5..0045df0be7 100644 --- a/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java +++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java @@ -131,7 +131,7 @@ public class FilesystemAsyncBlobStoreTest { // no base directory declared in properties try { Properties props = new Properties(); - context = ContextBuilder.newBuilder(PROVIDER).overrides(props).build(); + context = ContextBuilder.newBuilder(PROVIDER).overrides(props).build(BlobStoreContext.class); fail("No error if base directory is not specified"); } catch (CreationException e) { } @@ -140,7 +140,7 @@ public class FilesystemAsyncBlobStoreTest { try { Properties props = new Properties(); props.setProperty(FilesystemConstants.PROPERTY_BASEDIR, null); - context = ContextBuilder.newBuilder(PROVIDER).overrides(props).build(); + context = ContextBuilder.newBuilder(PROVIDER).overrides(props).build(BlobStoreContext.class); fail("No error if base directory is null in the option"); } catch (NullPointerException e) { } diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemContainerIntegrationTestDisabled.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemContainerIntegrationTestDisabled.java index 4950969167..b78f1704b1 100644 --- a/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemContainerIntegrationTestDisabled.java +++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/integration/FilesystemContainerIntegrationTestDisabled.java @@ -62,14 +62,14 @@ public class FilesystemContainerIntegrationTestDisabled extends BaseContainerInt // NOTE all metadata in jclouds comes out as lowercase, in an effort to normalize the // providers. - Blob object = context.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("Adrian", "powderpuff")) + Blob object = wrapper.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("Adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).build(); String containerName = getContainerName(); try { addBlobToContainer(containerName, object); validateContent(containerName, key); - PageSet container = context.getBlobStore().list(containerName, maxResults(1)); + PageSet container = wrapper.getBlobStore().list(containerName, maxResults(1)); BlobMetadata metadata = (BlobMetadata) Iterables.getOnlyElement(container); // transient container should be lenient and not return metadata on undetailed listing. diff --git a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java index 117e97c726..de9a7d15de 100644 --- a/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java +++ b/apis/nova/src/test/java/org/jclouds/openstack/nova/NovaClientLiveTest.java @@ -78,7 +78,7 @@ public class NovaClientLiveTest extends BaseComputeServiceContextLiveTest { @Override public void setupContext() { super.setupContext(); - Injector injector = context.utils().injector(); + Injector injector = wrapper.utils().injector(); client = injector.getInstance(NovaClient.class); sshFactory = injector.getInstance(SshClient.Factory.class); SocketOpen socketOpen = injector.getInstance(SocketOpen.class); diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/SimpleTenantUsageClientExpectTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/SimpleTenantUsageClientExpectTest.java index 9f9a01e508..3a85a3c7c5 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/SimpleTenantUsageClientExpectTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/SimpleTenantUsageClientExpectTest.java @@ -18,32 +18,22 @@ */ package org.jclouds.openstack.nova.v1_1.extensions; -import static org.testng.Assert.*; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; import java.net.URI; import java.util.Set; import javax.ws.rs.core.MediaType; -import org.jclouds.ContextBuilder; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.date.DateService; import org.jclouds.date.internal.SimpleDateFormatDateService; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpResponse; -import org.jclouds.openstack.nova.v1_1.NovaClient; -import org.jclouds.openstack.nova.v1_1.domain.Ingress; -import org.jclouds.openstack.nova.v1_1.domain.IpProtocol; -import org.jclouds.openstack.nova.v1_1.domain.SecurityGroup; -import org.jclouds.openstack.nova.v1_1.domain.SecurityGroupRule; -import org.jclouds.openstack.nova.v1_1.domain.Server; import org.jclouds.openstack.nova.v1_1.domain.SimpleServerUsage; import org.jclouds.openstack.nova.v1_1.domain.SimpleTenantUsage; import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientExpectTest; -import org.jclouds.openstack.nova.v1_1.parse.ParseSecurityGroupListTest; -import org.jclouds.openstack.nova.v1_1.parse.ParseSecurityGroupTest; -import org.jclouds.rest.internal.RestContextImpl; import org.testng.annotations.Test; import com.google.common.collect.ImmutableMultimap; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/SimpleTenantUsageClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/SimpleTenantUsageClientLiveTest.java index c3d7de7b14..89307955d1 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/SimpleTenantUsageClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/extensions/SimpleTenantUsageClientLiveTest.java @@ -22,9 +22,7 @@ import static org.testng.Assert.assertNotNull; import java.util.Set; -import org.jclouds.openstack.nova.v1_1.domain.SecurityGroup; import org.jclouds.openstack.nova.v1_1.domain.SimpleTenantUsage; -import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientExpectTest; import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientLiveTest; import org.testng.annotations.Test; diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java index 73f1db16d0..07cb2df6c3 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/functions/PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSetTest.java @@ -123,17 +123,25 @@ public class PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensio CacheLoader.from(Functions.forMap(ImmutableMap.of("expectedzone", extensions, "differentzone", ImmutableSet. of())))); - PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet fn = Guice.createInjector(new AbstractModule() { - @Override - protected void configure() {} - - @Provides - LoadingCache> getExtensions() { return extensionsForZone;} + PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet fn = Guice.createInjector( + new AbstractModule() { + @Override + protected void configure() { + } - @Provides - @Named("openstack.nova.extensions") - Multimap getAliases() { return aliases;} - }).getInstance(PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.class); + @SuppressWarnings("unused") + @Provides + LoadingCache> getExtensions() { + return extensionsForZone; + } + + @SuppressWarnings("unused") + @Provides + @Named("openstack.nova.extensions") + Multimap getAliases() { + return aliases; + } + }).getInstance(PresentWhenExtensionAnnotationNamespaceEqualsAnyNamespaceInExtensionsSet.class); return fn; } diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java index f4cc9157e4..44ce91a594 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/internal/BaseNovaClientLiveTest.java @@ -48,7 +48,7 @@ public class BaseNovaClientLiveTest extends BaseComputeServiceContextLiveTest { @Override public void setupContext() { super.setupContext(); - novaContext = context.unwrap(); + novaContext = wrapper.unwrap(); } @Override diff --git a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseKeyPairListTest.java b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseKeyPairListTest.java index 8622e08a97..fe8a72b801 100644 --- a/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseKeyPairListTest.java +++ b/apis/openstack-nova/src/test/java/org/jclouds/openstack/nova/v1_1/parse/ParseKeyPairListTest.java @@ -25,7 +25,7 @@ import java.util.Set; import javax.ws.rs.Consumes; import javax.ws.rs.core.MediaType; -import org.jclouds.json.BaseParserTest; +import org.jclouds.json.BaseItemParserTest; import org.jclouds.json.config.GsonModule; import org.jclouds.openstack.nova.v1_1.config.NovaParserModule; import org.jclouds.openstack.nova.v1_1.domain.KeyPair; @@ -41,7 +41,7 @@ import com.google.inject.Injector; * @author Michael Arnold */ @Test(groups = "unit", testName = "ParseKeyPairListTest") -public class ParseKeyPairListTest extends BaseParserTest { +public class ParseKeyPairListTest extends BaseItemParserTest>> { @Override public String resource() { diff --git a/apis/s3/src/main/java/org/jclouds/s3/blobstore/internal/S3BlobStoreContextImpl.java b/apis/s3/src/main/java/org/jclouds/s3/blobstore/internal/S3BlobStoreContextImpl.java index 16146c35c8..5bd193b88f 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/blobstore/internal/S3BlobStoreContextImpl.java +++ b/apis/s3/src/main/java/org/jclouds/s3/blobstore/internal/S3BlobStoreContextImpl.java @@ -18,11 +18,10 @@ */ package org.jclouds.s3.blobstore.internal; -import java.io.Closeable; - import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.Context; import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobRequestSigner; @@ -45,7 +44,7 @@ import com.google.common.reflect.TypeToken; public class S3BlobStoreContextImpl extends BlobStoreContextImpl implements S3BlobStoreContext { @Inject - public S3BlobStoreContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, + public S3BlobStoreContextImpl(@Provider Context wrapped, @Provider TypeToken wrappedType, BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel, InputStreamMap.Factory inputStreamMapFactory, AsyncBlobStore ablobStore, BlobStore blobStore, BlobRequestSigner blobRequestSigner) { diff --git a/apis/s3/src/main/java/org/jclouds/s3/filters/RequestAuthorizeSignature.java b/apis/s3/src/main/java/org/jclouds/s3/filters/RequestAuthorizeSignature.java index db8d97f4dc..74876d10e6 100644 --- a/apis/s3/src/main/java/org/jclouds/s3/filters/RequestAuthorizeSignature.java +++ b/apis/s3/src/main/java/org/jclouds/s3/filters/RequestAuthorizeSignature.java @@ -21,8 +21,6 @@ package org.jclouds.s3.filters; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.collect.Iterables.any; import static com.google.common.collect.Iterables.get; -import static org.jclouds.Constants.PROPERTY_CREDENTIAL; -import static org.jclouds.Constants.PROPERTY_IDENTITY; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG; import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG; import static org.jclouds.http.utils.ModifyRequest.parseQueryToMap; @@ -35,8 +33,8 @@ import java.lang.annotation.Annotation; import java.util.Arrays; import java.util.Collection; import java.util.Locale; -import java.util.Map.Entry; import java.util.Set; +import java.util.Map.Entry; import javax.annotation.Resource; import javax.inject.Inject; @@ -57,6 +55,8 @@ import org.jclouds.http.internal.SignatureWire; import org.jclouds.io.InputSuppliers; import org.jclouds.logging.Logger; import org.jclouds.rest.RequestSigner; +import org.jclouds.rest.annotations.Credential; +import org.jclouds.rest.annotations.Identity; import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.s3.Bucket; @@ -114,7 +114,7 @@ public class RequestAuthorizeSignature implements HttpRequestFilter, RequestSign public RequestAuthorizeSignature(SignatureWire signatureWire, @Named(PROPERTY_AUTH_TAG) String authTag, @Named(PROPERTY_S3_VIRTUAL_HOST_BUCKETS) boolean isVhostStyle, @Named(PROPERTY_S3_SERVICE_PATH) String servicePath, @Named(PROPERTY_HEADER_TAG) String headerTag, - @Named(PROPERTY_IDENTITY) String accessKey, @Named(PROPERTY_CREDENTIAL) String secretKey, + @Identity String accessKey, @Credential String secretKey, @TimeStamp Provider timeStampProvider, Crypto crypto, HttpUtils utils) { this.isVhostStyle = isVhostStyle; this.servicePath = servicePath; diff --git a/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java b/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java index 74c0b0989a..f143f75059 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java @@ -68,7 +68,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest { } public S3Client getApi() { - return context.unwrap(S3ApiMetadata.CONTEXT_TOKEN).getApi(); + return wrapper.unwrap(S3ApiMetadata.CONTEXT_TOKEN).getApi(); } /** diff --git a/apis/s3/src/test/java/org/jclouds/s3/services/BucketsLiveTest.java b/apis/s3/src/test/java/org/jclouds/s3/services/BucketsLiveTest.java index 90de74bb69..566bcc338a 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/services/BucketsLiveTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/services/BucketsLiveTest.java @@ -71,7 +71,7 @@ public class BucketsLiveTest extends BaseBlobStoreIntegrationTest { } public S3Client getApi() { - return (S3Client) context.unwrap(S3ApiMetadata.CONTEXT_TOKEN).getApi(); + return (S3Client) wrapper.unwrap(S3ApiMetadata.CONTEXT_TOKEN).getApi(); } /** diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/CommonSwiftClient.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/CommonSwiftClient.java index 5ad663bacf..e325aef6de 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/CommonSwiftClient.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/CommonSwiftClient.java @@ -26,7 +26,6 @@ import org.jclouds.blobstore.ContainerNotFoundException; import org.jclouds.blobstore.domain.PageSet; import org.jclouds.concurrent.Timeout; import org.jclouds.http.options.GetOptions; -import org.jclouds.io.Payload; import org.jclouds.openstack.swift.domain.AccountMetadata; import org.jclouds.openstack.swift.domain.ContainerMetadata; import org.jclouds.openstack.swift.domain.MutableObjectInfoWithMetadata; diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java index 1ffd600bf0..5ae25a4989 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/SwiftAsyncBlobStore.java @@ -56,7 +56,6 @@ import org.jclouds.openstack.swift.blobstore.functions.ContainerToResourceMetada import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlob; import org.jclouds.openstack.swift.blobstore.functions.ObjectToBlobMetadata; import org.jclouds.openstack.swift.blobstore.strategy.internal.AsyncMultipartUploadStrategy; -import org.jclouds.openstack.swift.blobstore.strategy.internal.MultipartUploadStrategy; import org.jclouds.openstack.swift.domain.ContainerMetadata; import org.jclouds.openstack.swift.domain.MutableObjectInfoWithMetadata; import org.jclouds.openstack.swift.domain.ObjectInfo; diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java index d4331caaa5..a5b02c5728 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/strategy/internal/ParallelMultipartUploadStrategy.java @@ -15,6 +15,7 @@ import org.jclouds.io.PayloadSlicer; import org.jclouds.logging.Logger; import org.jclouds.openstack.swift.CommonSwiftAsyncClient; import org.jclouds.openstack.swift.CommonSwiftClient; +import org.jclouds.openstack.swift.SwiftApiMetadata; import org.jclouds.openstack.swift.blobstore.SwiftAsyncBlobStore; import org.jclouds.openstack.swift.blobstore.functions.BlobToObject; import org.jclouds.util.Throwables2; @@ -91,8 +92,7 @@ public class ParallelMultipartUploadStrategy implements AsyncMultipartUploadStra latch.countDown(); return; } - final CommonSwiftAsyncClient client = (CommonSwiftAsyncClient) ablobstore.getContext() - .getProviderSpecificContext().getAsyncApi(); + final CommonSwiftAsyncClient client = ablobstore.getContext().unwrap(SwiftApiMetadata.CONTEXT_TOKEN).getAsyncApi(); Payload chunkedPart = slicer.slice(payload, offset, size); logger.debug(String.format("async uploading part %s of %s to container %s", part, key, container)); final long start = System.currentTimeMillis(); @@ -146,8 +146,7 @@ public class ParallelMultipartUploadStrategy implements AsyncMultipartUploadStra long chunkSize = algorithm.getChunkSize(); long remaining = algorithm.getRemaining(); if (parts > 0) { - CommonSwiftClient client = (CommonSwiftClient) ablobstore - .getContext().getProviderSpecificContext().getApi(); + CommonSwiftClient client = ablobstore.getContext().unwrap(SwiftApiMetadata.CONTEXT_TOKEN).getApi(); final Map> futureParts = new ConcurrentHashMap>(); final Map errorMap = Maps.newHashMap(); diff --git a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java index c723a51742..9618e25aa3 100644 --- a/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java +++ b/apis/swift/src/main/java/org/jclouds/openstack/swift/blobstore/strategy/internal/SequentialMultipartUploadStrategy.java @@ -1,11 +1,10 @@ package org.jclouds.openstack.swift.blobstore.strategy.internal; +import static com.google.common.base.Preconditions.checkNotNull; + import javax.annotation.Resource; import javax.inject.Named; -import com.google.common.collect.Maps; -import com.google.inject.Inject; -import org.jclouds.blobstore.KeyNotFoundException; import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.options.PutOptions; import org.jclouds.blobstore.reference.BlobStoreConstants; @@ -13,15 +12,12 @@ import org.jclouds.io.Payload; import org.jclouds.io.PayloadSlicer; import org.jclouds.logging.Logger; import org.jclouds.openstack.swift.CommonSwiftClient; -import org.jclouds.openstack.swift.SwiftClient; +import org.jclouds.openstack.swift.SwiftApiMetadata; import org.jclouds.openstack.swift.blobstore.SwiftBlobStore; import org.jclouds.openstack.swift.blobstore.functions.BlobToObject; -import org.jclouds.openstack.swift.domain.SwiftObject; import org.jclouds.util.Throwables2; -import java.util.SortedMap; - -import static com.google.common.base.Preconditions.checkNotNull; +import com.google.inject.Inject; public class SequentialMultipartUploadStrategy implements MultipartUploadStrategy { @@ -52,9 +48,7 @@ public class SequentialMultipartUploadStrategy implements MultipartUploadStrateg int parts = algorithm.getParts(); long chunkSize = algorithm.getChunkSize(); if (parts > 0) { - CommonSwiftClient client = (CommonSwiftClient) ablobstore.getContext() - .getProviderSpecificContext().getApi(); - + CommonSwiftClient client = ablobstore.getContext().unwrap(SwiftApiMetadata.CONTEXT_TOKEN).getApi(); try { int part; while ((part = algorithm.getNextPart()) <= parts) { diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java index 06a26a5ca3..6b53f0af03 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/SwiftClientLiveTest.java @@ -33,7 +33,7 @@ public class SwiftClientLiveTest extends CommonSwiftClientLiveTest @Override public SwiftClient getApi() { - return context.unwrap(SwiftApiMetadata.CONTEXT_TOKEN).getApi(); + return wrapper.unwrap(SwiftApiMetadata.CONTEXT_TOKEN).getApi(); } } diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobIntegrationLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobIntegrationLiveTest.java index dc6a9555d8..3bfac51d6d 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobIntegrationLiveTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftBlobIntegrationLiveTest.java @@ -89,10 +89,10 @@ public class SwiftBlobIntegrationLiveTest extends BaseBlobIntegrationTest { String containerName = getContainerName(); try { - BlobStore blobStore = context.getBlobStore(); + BlobStore blobStore = wrapper.getBlobStore(); blobStore.createContainerInLocation(null, containerName); Blob blob = blobStore.blobBuilder("const.txt") - .payload(new File("target/const.txt")).build(); + .payload(new File("target/const.txt")).contentMD5(oneHundredOneConstitutionsMD5).build(); blobStore.putBlob(containerName, blob, PutOptions.Builder.multipart()); } finally { returnContainer(containerName); diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerLiveTest.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerLiveTest.java index 7901ac4fa8..cbd39b5c15 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerLiveTest.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/blobstore/integration/SwiftContainerLiveTest.java @@ -27,12 +27,13 @@ import org.testng.annotations.Test; /** * @author Adrian Cole */ -@Test(groups = { "live" }) +@Test(groups = "live", testName = "SwiftContainerLiveTest" ) public class SwiftContainerLiveTest extends BaseContainerLiveTest { public SwiftContainerLiveTest() { provider = "swift"; } - @Test(expectedExceptions=UnsupportedOperationException.class) + + @Test(expectedExceptions = UnsupportedOperationException.class) public void testPublicAccess() throws MalformedURLException, InterruptedException, IOException { super.testPublicAccess(); } diff --git a/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/StubSwiftAsyncClient.java b/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/StubSwiftAsyncClient.java index 7178760509..308a62a2cf 100644 --- a/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/StubSwiftAsyncClient.java +++ b/apis/swift/src/test/java/org/jclouds/openstack/swift/internal/StubSwiftAsyncClient.java @@ -31,7 +31,6 @@ import java.util.concurrent.ExecutorService; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; -import javax.ws.rs.PathParam; import org.jclouds.Constants; import org.jclouds.blobstore.TransientAsyncBlobStore; diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java index b307b877a4..83300a54aa 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/compute/strategy/InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn.java @@ -22,7 +22,6 @@ import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Predicates.not; import static com.google.common.collect.Iterables.find; import static com.google.common.collect.Iterables.get; -import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; import static org.jclouds.compute.util.ComputeServiceUtils.getCores; import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getCredentialsFrom; import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig; @@ -41,17 +40,18 @@ import org.jclouds.javax.annotation.Nullable; import org.jclouds.logging.Logger; import org.jclouds.ovf.Network; import org.jclouds.predicates.validators.DnsNameValidator; +import org.jclouds.rest.annotations.BuildVersion; import org.jclouds.vcloud.TaskStillRunningException; import org.jclouds.vcloud.VCloudClient; import org.jclouds.vcloud.compute.options.VCloudTemplateOptions; import org.jclouds.vcloud.domain.GuestCustomizationSection; import org.jclouds.vcloud.domain.NetworkConnection; import org.jclouds.vcloud.domain.NetworkConnectionSection; -import org.jclouds.vcloud.domain.NetworkConnectionSection.Builder; import org.jclouds.vcloud.domain.Task; import org.jclouds.vcloud.domain.VApp; import org.jclouds.vcloud.domain.VAppTemplate; import org.jclouds.vcloud.domain.Vm; +import org.jclouds.vcloud.domain.NetworkConnectionSection.Builder; import org.jclouds.vcloud.domain.network.IpAddressAllocationMode; import org.jclouds.vcloud.domain.network.NetworkConfig; import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions; @@ -79,7 +79,7 @@ public class InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployA @Inject protected InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn(VCloudClient client, Predicate successTester, LoadingCache vAppTemplates, - Supplier defaultNetworkConfig, @Named(PROPERTY_BUILD_VERSION) String buildVersion) { + Supplier defaultNetworkConfig, @BuildVersion String buildVersion) { this.client = client; this.successTester = successTester; this.vAppTemplates = vAppTemplates; diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java index 314825fc36..fe8c4088a9 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/DefaultVCloudReferencesModule.java @@ -18,17 +18,15 @@ */ package org.jclouds.vcloud.config; -import static org.jclouds.Constants.PROPERTY_IDENTITY; - import java.net.URI; import java.util.Map; import javax.annotation.Resource; import javax.inject.Inject; -import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.logging.Logger; +import org.jclouds.rest.annotations.Identity; import org.jclouds.vcloud.domain.Catalog; import org.jclouds.vcloud.domain.ReferenceType; @@ -58,7 +56,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule { @org.jclouds.vcloud.endpoints.Org @Singleton protected Supplier provideDefaultOrg(DefaultOrgForUser defaultOrgURIForUser, - @Named(PROPERTY_IDENTITY) String user) { + @Identity String user) { return defaultOrgURIForUser.apply(user); } diff --git a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java index 96d82e0201..c84b1a37d6 100644 --- a/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java +++ b/apis/vcloud/src/main/java/org/jclouds/vcloud/config/VCloudRestClientModule.java @@ -27,17 +27,16 @@ import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.getLast; import static com.google.common.collect.Iterables.transform; import static com.google.common.collect.Maps.transformValues; -import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.rest.config.BinderUtils.bindClientAndAsyncClient; +import static org.jclouds.util.Maps2.uniqueIndex; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE; import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED; -import static org.jclouds.util.Maps2.uniqueIndex; import java.net.URI; import java.util.Map; -import java.util.Map.Entry; import java.util.SortedMap; +import java.util.Map.Entry; import java.util.concurrent.atomic.AtomicReference; import javax.inject.Inject; @@ -56,6 +55,7 @@ import org.jclouds.ovf.Envelope; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.AuthorizationException; import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.annotations.ApiVersion; import org.jclouds.rest.config.RestClientModule; import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; import org.jclouds.vcloud.VCloudAsyncClient; @@ -117,8 +117,8 @@ import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableMap.Builder; import com.google.common.collect.Lists; +import com.google.common.collect.ImmutableMap.Builder; import com.google.inject.Injector; import com.google.inject.Provides; import com.google.inject.Scopes; @@ -390,7 +390,7 @@ public class VCloudRestClientModule extends RestClientModule provideAuthenticationURI(final VCloudVersionsClient versionService, - @Named(PROPERTY_API_VERSION) final String version) { + @ApiVersion final String version) { return new Supplier() { @Override diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java index 36ee0a4b00..d35eba8a73 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/CatalogClientLiveTest.java @@ -49,7 +49,7 @@ public class CatalogClientLiveTest extends BaseVCloudClientLiveTest { public void testFindCatalogIsWriteableIfNotVersion1_5() throws Exception { // when we are in vCloud 1.0.0 public catalogs don't work, so our default // catalog is private - if (!context.utils().injector().getInstance(Key.get(String.class, ApiVersion.class)).startsWith("1.5")) + if (!wrapper.utils().injector().getInstance(Key.get(String.class, ApiVersion.class)).startsWith("1.5")) assertTrue(getVCloudApi().getCatalogClient().findCatalogInOrgNamed(null, null).isReadOnly()); } } \ No newline at end of file diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java index e806763fe3..7b103ab142 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java @@ -45,14 +45,14 @@ public abstract class BaseVCloudClientLiveTest extends BaseComputeServiceContext } protected VCloudClient getVCloudApi() { - return VCloudClient.class.cast(context.unwrap(VCloudApiMetadata.CONTEXT_TOKEN).getApi()); + return VCloudClient.class.cast(wrapper.unwrap(VCloudApiMetadata.CONTEXT_TOKEN).getApi()); } @Override @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.getComputeService(); + client = wrapper.getComputeService(); } @Override diff --git a/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java b/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java index 3a08168b26..ff949ff39d 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/internal/BlobStoreContextImpl.java @@ -20,11 +20,10 @@ package org.jclouds.blobstore.internal; import static com.google.common.base.Preconditions.checkNotNull; -import java.io.Closeable; - import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.Context; import org.jclouds.blobstore.AsyncBlobStore; import org.jclouds.blobstore.BlobMap; import org.jclouds.blobstore.BlobRequestSigner; @@ -55,7 +54,7 @@ public class BlobStoreContextImpl extends BaseWrapper implements BlobStoreContex private final BlobRequestSigner blobRequestSigner; @Inject - public BlobStoreContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, + public BlobStoreContextImpl(@Provider Context wrapped, @Provider TypeToken wrappedType, BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel, InputStreamMap.Factory inputStreamMapFactory, AsyncBlobStore ablobStore, BlobStore blobStore, BlobRequestSigner blobRequestSigner) { @@ -122,26 +121,26 @@ public class BlobStoreContextImpl extends BaseWrapper implements BlobStoreContex @SuppressWarnings("unchecked") @Override public RestContext getProviderSpecificContext() { - return (RestContext) getWrapped(); + return (RestContext) delegate(); } @Override public void close() { - Closeables.closeQuietly(getWrapped()); + Closeables.closeQuietly(delegate()); } public int hashCode() { - return getWrapped().hashCode(); + return delegate().hashCode(); } @Override public String toString() { - return getWrapped().toString(); + return delegate().toString(); } @Override public boolean equals(Object obj) { - return getWrapped().equals(obj); + return delegate().equals(obj); } } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientContainerIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientContainerIntegrationTest.java index 5ab15a7137..991cc4a365 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientContainerIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/TransientContainerIntegrationTest.java @@ -53,7 +53,7 @@ public class TransientContainerIntegrationTest extends BaseContainerIntegrationT String key = "hello"; // NOTE all metadata in jclouds comes out as lowercase, in an effort to normalize the // providers. - Blob blob = context.getBlobStore().blobBuilder("hello").userMetadata(ImmutableMap.of("Adrian", "powderpuff")) + Blob blob = wrapper.getBlobStore().blobBuilder("hello").userMetadata(ImmutableMap.of("Adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).build(); String containerName = getContainerName(); @@ -61,7 +61,7 @@ public class TransientContainerIntegrationTest extends BaseContainerIntegrationT addBlobToContainer(containerName, blob); validateContent(containerName, key); - PageSet container = context.getBlobStore().list(containerName, maxResults(1)); + PageSet container = wrapper.getBlobStore().list(containerName, maxResults(1)); BlobMetadata metadata = (BlobMetadata) getOnlyElement(container); // transient container should be lenient and not return metadata on undetailed listing. @@ -75,7 +75,7 @@ public class TransientContainerIntegrationTest extends BaseContainerIntegrationT @Test(groups = { "integration", "live" }) public void testDuplicateCreateContainer() { - BlobStore blobStore = context.getBlobStore(); + BlobStore blobStore = wrapper.getBlobStore(); Location location = null; String container = "container"; boolean created; diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java index e9aac1bc3a..e5ce9ae03a 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobIntegrationTest.java @@ -141,15 +141,15 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { @Override public Void call() throws Exception { String name = blobCount.incrementAndGet() + ""; - Blob blob = context.getBlobStore().blobBuilder(name).payload(testPayload).build(); - context.getBlobStore().putBlob(container, blob); + Blob blob = wrapper.getBlobStore().blobBuilder(name).payload(testPayload).build(); + wrapper.getBlobStore().putBlob(container, blob); assertConsistencyAwareBlobExists(container, name); - blob = context.getBlobStore().getBlob(container, name); + blob = wrapper.getBlobStore().getBlob(container, name); assert Arrays.equals(CryptoStreams.md5(blob.getPayload()), md5) : String.format( "md5 didn't match on %s/%s", container, name); - context.getBlobStore().removeBlob(container, name); + wrapper.getBlobStore().removeBlob(container, name); assertConsistencyAwareBlobDoesntExist(container, name); return null; } @@ -176,7 +176,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { Map> responses = Maps.newHashMap(); for (int i = 0; i < 10; i++) { - responses.put(i, Futures.compose(context.getAsyncBlobStore().getBlob(container, name), + responses.put(i, Futures.compose(wrapper.getAsyncBlobStore().getBlob(container, name), new Function() { @Override @@ -204,9 +204,9 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { } private void uploadConstitution(String container, String name, String contentDisposition) throws IOException { - context.getBlobStore().putBlob( + wrapper.getBlobStore().putBlob( container, - context.getBlobStore().blobBuilder(name).payload(oneHundredOneConstitutions.getInput()).contentType( + wrapper.getBlobStore().blobBuilder(name).payload(oneHundredOneConstitutions.getInput()).contentType( "text/plain").contentMD5(oneHundredOneConstitutionsMD5).contentLength( oneHundredOneConstitutionsLength).contentDisposition(contentDisposition).build()); } @@ -224,11 +224,11 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { addObjectAndValidateContent(container, name); Date after = new Date(System.currentTimeMillis() + 1000); - context.getBlobStore().getBlob(container, name, ifModifiedSince(before)); + wrapper.getBlobStore().getBlob(container, name, ifModifiedSince(before)); validateContent(container, name); try { - context.getBlobStore().getBlob(container, name, ifModifiedSince(after)); + wrapper.getBlobStore().getBlob(container, name, ifModifiedSince(after)); validateContent(container, name); } catch (HttpResponseException ex) { assertEquals(ex.getResponse().getStatusCode(), 304); @@ -250,11 +250,11 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { addObjectAndValidateContent(container, name); Date after = new Date(System.currentTimeMillis() + 1000); - context.getBlobStore().getBlob(container, name, ifUnmodifiedSince(after)); + wrapper.getBlobStore().getBlob(container, name, ifUnmodifiedSince(after)); validateContent(container, name); try { - context.getBlobStore().getBlob(container, name, ifUnmodifiedSince(before)); + wrapper.getBlobStore().getBlob(container, name, ifUnmodifiedSince(before)); validateContent(container, name); } catch (HttpResponseException ex) { assertEquals(ex.getResponse().getStatusCode(), 412); @@ -273,11 +273,11 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { String goodETag = addObjectAndValidateContent(container, name); - context.getBlobStore().getBlob(container, name, ifETagMatches(goodETag)); + wrapper.getBlobStore().getBlob(container, name, ifETagMatches(goodETag)); validateContent(container, name); try { - context.getBlobStore().getBlob(container, name, ifETagMatches("powerfrisbee")); + wrapper.getBlobStore().getBlob(container, name, ifETagMatches("powerfrisbee")); validateContent(container, name); } catch (HttpResponseException ex) { assertEquals(ex.getResponse().getStatusCode(), 412); @@ -296,11 +296,11 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { String goodETag = addObjectAndValidateContent(container, name); - context.getBlobStore().getBlob(container, name, ifETagDoesntMatch("powerfrisbee")); + wrapper.getBlobStore().getBlob(container, name, ifETagDoesntMatch("powerfrisbee")); validateContent(container, name); try { - context.getBlobStore().getBlob(container, name, ifETagDoesntMatch(goodETag)); + wrapper.getBlobStore().getBlob(container, name, ifETagDoesntMatch(goodETag)); } catch (HttpResponseException ex) { assertEquals(ex.getResponse().getStatusCode(), 304); } @@ -317,11 +317,11 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { String name = "apples"; addObjectAndValidateContent(container, name); - Blob blob1 = context.getBlobStore().getBlob(container, name, range(0, 5)); + Blob blob1 = wrapper.getBlobStore().getBlob(container, name, range(0, 5)); validateMetadata(blob1.getMetadata(), container, name); assertEquals(getContentAsStringOrNullAndClose(blob1), TEST_STRING.substring(0, 6)); - Blob blob2 = context.getBlobStore().getBlob(container, name, range(6, TEST_STRING.length())); + Blob blob2 = wrapper.getBlobStore().getBlob(container, name, range(6, TEST_STRING.length())); validateMetadata(blob2.getMetadata(), container, name); assertEquals(getContentAsStringOrNullAndClose(blob2), TEST_STRING.substring(6, TEST_STRING.length())); } finally { @@ -337,7 +337,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { String name = "apples"; addObjectAndValidateContent(container, name); - Blob blob = context.getBlobStore().getBlob(container, name, range(0, 5).range(6, TEST_STRING.length())); + Blob blob = wrapper.getBlobStore().getBlob(container, name, range(0, 5).range(6, TEST_STRING.length())); validateMetadata(blob.getMetadata(), container, name); assertEquals(getContentAsStringOrNullAndClose(blob), TEST_STRING); } finally { @@ -401,7 +401,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { String container = getContainerName(); String name = "test"; try { - context.getBlobStore().removeBlob(container, name); + wrapper.getBlobStore().removeBlob(container, name); } finally { returnContainer(container); } @@ -412,7 +412,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { String container = getContainerName(); String name = "test"; try { - assert !context.getBlobStore().blobExists(container, name); + assert !wrapper.getBlobStore().blobExists(container, name); } finally { returnContainer(container); } @@ -429,7 +429,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { String container = getContainerName(); try { addBlobToContainer(container, name, name, MediaType.TEXT_PLAIN); - context.getBlobStore().removeBlob(container, name); + wrapper.getBlobStore().removeBlob(container, name); assertContainerEmptyDeleting(container, name); } finally { returnContainer(container); @@ -437,7 +437,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { } private void assertContainerEmptyDeleting(String container, String name) { - Iterable listing = Iterables.filter(context.getBlobStore().list(container), + Iterable listing = Iterables.filter(wrapper.getBlobStore().list(container), new Predicate() { @Override @@ -454,7 +454,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { @Test(groups = { "integration", "live" }) public void deleteObjectNoContainer() { try { - context.getBlobStore().removeBlob("donb", "test"); + wrapper.getBlobStore().removeBlob("donb", "test"); } catch (HttpResponseException e) { assertEquals(e.getResponse().getStatusCode(), 404); } catch (ContainerNotFoundException e) { @@ -475,7 +475,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { @Test(groups = { "integration", "live" }, dataProvider = "putTests") public void testPutObject(String name, String type, Object content, Object realObject) throws InterruptedException, IOException { - PayloadBlobBuilder blobBuilder = context.getBlobStore().blobBuilder(name).payload(Payloads.newPayload(content)) + PayloadBlobBuilder blobBuilder = wrapper.getBlobStore().blobBuilder(name).payload(Payloads.newPayload(content)) .contentType(type); addContentMetadata(blobBuilder); if (content instanceof InputStream) { @@ -484,14 +484,14 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { Blob blob = blobBuilder.build(); String container = getContainerName(); try { - assertNotNull(context.getBlobStore().putBlob(container, blob)); - blob = context.getBlobStore().getBlob(container, blob.getMetadata().getName()); + assertNotNull(wrapper.getBlobStore().putBlob(container, blob)); + blob = wrapper.getBlobStore().getBlob(container, blob.getMetadata().getName()); validateMetadata(blob.getMetadata(), container, name); checkContentMetadata(blob); String returnedString = getContentAsStringOrNullAndClose(blob); assertEquals(returnedString, realObject); - PageSet set = context.getBlobStore().list(container); + PageSet set = wrapper.getBlobStore().list(container); assert set.size() == 1 : set; } finally { returnContainer(container); @@ -500,7 +500,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { @Test(groups = { "integration", "live" }) public void testPutObjectStream() throws InterruptedException, IOException, ExecutionException { - PayloadBlobBuilder blobBuilder = context.getBlobStore().blobBuilder("streaming").payload( + PayloadBlobBuilder blobBuilder = wrapper.getBlobStore().blobBuilder("streaming").payload( new StreamingPayload(new WriteTo() { @Override public void writeTo(OutputStream outstream) throws IOException { @@ -514,14 +514,14 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { String container = getContainerName(); try { - assertNotNull(context.getBlobStore().putBlob(container, blob)); + assertNotNull(wrapper.getBlobStore().putBlob(container, blob)); - blob = context.getBlobStore().getBlob(container, blob.getMetadata().getName()); + blob = wrapper.getBlobStore().getBlob(container, blob.getMetadata().getName()); String returnedString = getContentAsStringOrNullAndClose(blob); assertEquals(returnedString, "foo"); validateMetadata(blob.getMetadata(), container, blob.getMetadata().getName()); checkContentMetadata(blob); - PageSet set = context.getBlobStore().list(container); + PageSet set = wrapper.getBlobStore().list(container); assert set.size() == 1 : set; } finally { returnContainer(container); @@ -588,11 +588,11 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { // NOTE all metadata in jclouds comes out as lowercase, in an effort to // normalize the // providers. - Blob blob = context.getBlobStore().blobBuilder(name).userMetadata(ImmutableMap.of("Adrian", "powderpuff")) + Blob blob = wrapper.getBlobStore().blobBuilder(name).userMetadata(ImmutableMap.of("Adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).calculateMD5().build(); String container = getContainerName(); try { - assertNull(context.getBlobStore().blobMetadata(container, "powderpuff")); + assertNull(wrapper.getBlobStore().blobMetadata(container, "powderpuff")); addBlobToContainer(container, blob); Blob newObject = validateContent(container, name); @@ -601,7 +601,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { validateMetadata(metadata); validateMetadata(metadata, container, name); - validateMetadata(context.getBlobStore().blobMetadata(container, name)); + validateMetadata(wrapper.getBlobStore().blobMetadata(container, name)); // write 2 items with the same name to ensure that provider doesn't // accept dupes @@ -609,7 +609,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest { blob.getMetadata().getUserMetadata().put("Adrian", "powderpuff"); addBlobToContainer(container, blob); - validateMetadata(context.getBlobStore().blobMetadata(container, name)); + validateMetadata(wrapper.getBlobStore().blobMetadata(container, name)); } finally { returnContainer(container); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobLiveTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobLiveTest.java index 7bd700ae84..0f96bcca11 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobLiveTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobLiveTest.java @@ -51,18 +51,18 @@ public class BaseBlobLiveTest extends BaseBlobStoreIntegrationTest { httpStreamMD5 = checkNotNull(httpStreamMD5 != null ? httpStreamMD5 : sysHttpStreamMD5, "httpStreamMd5"); - HttpResponse response = context.utils().http().invoke( + HttpResponse response = wrapper.utils().http().invoke( HttpRequest.builder().method("GET").endpoint(URI.create(httpStreamUrl)).build()); long length = response.getPayload().getContentMetadata().getContentLength(); String name = "hello"; byte[] md5 = CryptoStreams.hex(httpStreamMD5); - Blob blob = context.getBlobStore().blobBuilder(name).payload(response.getPayload()).contentLength(length) + Blob blob = wrapper.getBlobStore().blobBuilder(name).payload(response.getPayload()).contentLength(length) .contentMD5(md5).build(); String container = getContainerName(); try { - context.getBlobStore().putBlob(container, blob); + wrapper.getBlobStore().putBlob(container, blob); checkMD5(container, name, md5); } finally { returnContainer(container); @@ -70,7 +70,7 @@ public class BaseBlobLiveTest extends BaseBlobStoreIntegrationTest { } protected void checkMD5(String container, String name, byte[] md5) { - assertEquals(context.getBlobStore().blobMetadata(container, name).getContentMetadata().getContentMD5(), md5); + assertEquals(wrapper.getBlobStore().blobMetadata(container, name).getContentMetadata().getContentMD5(), md5); } } \ No newline at end of file diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java index 384c9121f5..149c6f53b5 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobMapIntegrationTest.java @@ -73,7 +73,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest< public void testValues() throws IOException, InterruptedException { String bucketName = getContainerName(); try { - BlobMap map = createMap(context, bucketName); + BlobMap map = createMap(wrapper, bucketName); putFiveStrings(map); putFiveStringsUnderPath(map); @@ -95,7 +95,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest< public void testRemove() throws InterruptedException, ExecutionException, TimeoutException, IOException { String bucketName = getContainerName(); try { - Map map = createMap(context, bucketName); + Map map = createMap(wrapper, bucketName); putStringWithMD5(map, "one", "two"); assertConsistencyAwareContentEquals(map, "one", "two"); // TODO track how often this occurs and potentially update map implementation @@ -126,7 +126,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest< public void testEntrySet() throws IOException, InterruptedException { String bucketName = getContainerName(); try { - final BlobMap map = createMap(context, bucketName); + final BlobMap map = createMap(wrapper, bucketName); putFiveStrings(map); assertConsistencyAwareMapSize(map, 5); Set> entries = map.entrySet(); @@ -159,9 +159,9 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest< public void testContains() throws InterruptedException, ExecutionException, TimeoutException, IOException { String bucketName = getContainerName(); try { - Map map = createMap(context, bucketName); + Map map = createMap(wrapper, bucketName); putStringWithMD5(map, "one", "apple"); - Blob blob = context.getBlobStore().blobBuilder("one").payload("apple").calculateMD5().build(); + Blob blob = wrapper.getBlobStore().blobBuilder("one").payload("apple").calculateMD5().build(); assertConsistencyAwareContainsValue(map, blob); } finally { returnContainer(bucketName); @@ -185,8 +185,8 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest< public void testPut() throws IOException, InterruptedException { String bucketName = getContainerName(); try { - Map map = createMap(context, bucketName); - Blob blob = context.getBlobStore().blobBuilder("one").payload(Strings2.toInputStream("apple")).calculateMD5() + Map map = createMap(wrapper, bucketName); + Blob blob = wrapper.getBlobStore().blobBuilder("one").payload(Strings2.toInputStream("apple")).calculateMD5() .build(); Blob old = map.put(blob.getMetadata().getName(), blob); getOneReturnsAppleAndOldValueIsNull(map, old); @@ -203,12 +203,12 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest< public void testPutAll() throws InterruptedException, ExecutionException, TimeoutException { String bucketName = getContainerName(); try { - Map map = createMap(context, bucketName); + Map map = createMap(wrapper, bucketName); ImmutableMap.Builder newMap = ImmutableMap.builder(); for (String key : fiveInputs.keySet()) { newMap.put( key, - context.getBlobStore().blobBuilder(key).payload(fiveInputs.get(key)) + wrapper.getBlobStore().blobBuilder(key).payload(fiveInputs.get(key)) .contentLength((long) fiveBytes.get(key).length).build()); } map.putAll(newMap.build()); @@ -226,7 +226,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest< return; String bucketName = getContainerName(); try { - BlobMap map = createMap(context, bucketName); + BlobMap map = createMap(wrapper, bucketName); Builder keySet = ImmutableSet.builder(); for (int i = 0; i < maxResultsForTestListings() + 1; i++) { keySet.add(i + ""); @@ -250,7 +250,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest< @Override protected void putStringWithMD5(Map map, String key, String text) throws IOException { - map.put(key, context.getBlobStore().blobBuilder(key).payload(text).calculateMD5().build()); + map.put(key, wrapper.getBlobStore().blobBuilder(key).payload(text).calculateMD5().build()); } protected void putFiveStrings(BlobMap map) { @@ -277,7 +277,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest< @Override protected void addTenObjectsUnderPrefix(String containerName, String prefix) throws InterruptedException { - BlobMap blobMap = createMap(context, containerName, inDirectory(prefix)); + BlobMap blobMap = createMap(wrapper, containerName, inDirectory(prefix)); for (int i = 0; i < 10; i++) { blobMap.put(i + "", blobMap.blobBuilder().payload(i + "content").build()); } @@ -285,7 +285,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest< @Override protected void addTenObjectsUnderRoot(String containerName) throws InterruptedException { - BlobMap blobMap = createMap(context, containerName, ListContainerOptions.NONE); + BlobMap blobMap = createMap(wrapper, containerName, ListContainerOptions.NONE); for (int i = 0; i < 10; i++) { blobMap.put(i + "", blobMap.blobBuilder().payload(i + "content").build()); } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobSignerLiveTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobSignerLiveTest.java index 5eba4cfc37..b67571a98a 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobSignerLiveTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobSignerLiveTest.java @@ -41,15 +41,15 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest { String name = "hello"; String text = "fooooooooooooooooooooooo"; - Blob blob = context.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build(); + Blob blob = wrapper.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build(); String container = getContainerName(); try { - context.getBlobStore().putBlob(container, blob); + wrapper.getBlobStore().putBlob(container, blob); assertConsistencyAwareContainerSize(container, 1); - HttpRequest request = context.getSigner().signRemoveBlob(container, name); + HttpRequest request = wrapper.getSigner().signRemoveBlob(container, name); assertEquals(request.getFilters().size(), 0); - context.utils().http().invoke(request); - assert !context.getBlobStore().blobExists(container, name); + wrapper.utils().http().invoke(request); + assert !wrapper.getBlobStore().blobExists(container, name); } finally { returnContainer(container); } @@ -60,14 +60,14 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest { String name = "hello"; String text = "fooooooooooooooooooooooo"; - Blob blob = context.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build(); + Blob blob = wrapper.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build(); String container = getContainerName(); try { - context.getBlobStore().putBlob(container, blob); + wrapper.getBlobStore().putBlob(container, blob); assertConsistencyAwareContainerSize(container, 1); - HttpRequest request = context.getSigner().signGetBlob(container, name); + HttpRequest request = wrapper.getSigner().signGetBlob(container, name); assertEquals(request.getFilters().size(), 0); - assertEquals(Strings2.toStringAndClose(context.utils().http().invoke(request).getPayload().getInput()), text); + assertEquals(Strings2.toStringAndClose(wrapper.utils().http().invoke(request).getPayload().getInput()), text); } finally { returnContainer(container); } @@ -78,14 +78,14 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest { String name = "hello"; String text = "fooooooooooooooooooooooo"; - Blob blob = context.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build(); + Blob blob = wrapper.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build(); String container = getContainerName(); try { - context.getBlobStore().putBlob(container, blob); + wrapper.getBlobStore().putBlob(container, blob); assertConsistencyAwareContainerSize(container, 1); - HttpRequest request = context.getSigner().signGetBlob(container, name, range(0, 1)); + HttpRequest request = wrapper.getSigner().signGetBlob(container, name, range(0, 1)); assertEquals(request.getFilters().size(), 0); - assertEquals(Strings2.toStringAndClose(context.utils().http().invoke(request).getPayload().getInput()), "fo"); + assertEquals(Strings2.toStringAndClose(wrapper.utils().http().invoke(request).getPayload().getInput()), "fo"); } finally { returnContainer(container); } @@ -96,12 +96,12 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest { String name = "hello"; String text = "fooooooooooooooooooooooo"; - Blob blob = context.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build(); + Blob blob = wrapper.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build(); String container = getContainerName(); try { - HttpRequest request = context.getSigner().signPutBlob(container, blob); + HttpRequest request = wrapper.getSigner().signPutBlob(container, blob); assertEquals(request.getFilters().size(), 0); - Strings2.toStringAndClose(context.utils().http().invoke(request).getPayload().getInput()); + Strings2.toStringAndClose(wrapper.utils().http().invoke(request).getPayload().getInput()); assertConsistencyAwareContainerSize(container, 1); } finally { returnContainer(container); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java index 2872c1db01..486eee452c 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseBlobStoreIntegrationTest.java @@ -36,7 +36,7 @@ import java.util.concurrent.atomic.AtomicInteger; import javax.ws.rs.core.MediaType; -import org.jclouds.apis.BaseContextLiveTest; +import org.jclouds.apis.BaseWrapperLiveTest; import org.jclouds.blobstore.BlobStoreContext; import org.jclouds.blobstore.attr.ConsistencyModel; import org.jclouds.blobstore.domain.Blob; @@ -59,7 +59,7 @@ import com.google.common.collect.Sets; import com.google.common.reflect.TypeToken; import com.google.inject.Module; -public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest { +public class BaseBlobStoreIntegrationTest extends BaseWrapperLiveTest { protected static final String LOCAL_ENCODING = System.getProperty("file.encoding"); protected static final String XML_STRING_FORMAT = " "; protected static final String TEST_STRING = String.format(XML_STRING_FORMAT, "apple"); @@ -90,9 +90,9 @@ public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest setupModules() { @@ -119,7 +119,7 @@ public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest entry : Iterables.concat(fiveStrings.entrySet(), fiveStringsUnderPath.entrySet())) { - Blob sourceObject = context.getBlobStore().blobBuilder(entry.getKey()).payload(entry.getValue()) + Blob sourceObject = wrapper.getBlobStore().blobBuilder(entry.getKey()).payload(entry.getValue()) .contentType("text/xml").build(); addBlobToContainer(sourceContainer, sourceObject); } } protected String addBlobToContainer(String sourceContainer, Blob object) { - return context.getBlobStore().putBlob(sourceContainer, object); + return wrapper.getBlobStore().putBlob(sourceContainer, object); } protected T validateMetadata(T md, String container, String name) { @@ -269,7 +269,7 @@ public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest() { public String apply(StorageMetadata from) { @@ -307,9 +307,9 @@ public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest() { + wrapper.getBlobStore().list(containerName), new Function() { public String apply(StorageMetadata from) { return from.getName(); @@ -328,7 +328,7 @@ public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest() { + if (!Iterables.any(wrapper.getBlobStore().list(), new Predicate() { public boolean apply(StorageMetadata md) { return containerName.equals(md.getName()); } @@ -382,7 +382,7 @@ public class BaseBlobStoreIntegrationTest extends BaseContextLiveTest contextType() { + protected TypeToken wrapperType() { return TypeToken.of(BlobStoreContext.class); } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java index ed2bcc34d5..589f8f18f5 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java @@ -49,21 +49,21 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { @Test(groups = { "integration", "live" }) public void containerDoesntExist() { - assert !context.getBlobStore().containerExists("forgetaboutit"); - assert !context.getBlobStore().containerExists("cloudcachestorefunctionalintegrationtest-first"); + assert !wrapper.getBlobStore().containerExists("forgetaboutit"); + assert !wrapper.getBlobStore().containerExists("cloudcachestorefunctionalintegrationtest-first"); } @Test(groups = { "integration", "live" }) public void testPutTwiceIsOkAndDoesntOverwrite() throws InterruptedException { String containerName = getContainerName(); try { - context.getBlobStore().createContainerInLocation(null, containerName); + wrapper.getBlobStore().createContainerInLocation(null, containerName); - Blob blob = context.getBlobStore().blobBuilder("hello").payload(TEST_STRING).build(); - context.getBlobStore().putBlob(containerName, blob); + Blob blob = wrapper.getBlobStore().blobBuilder("hello").payload(TEST_STRING).build(); + wrapper.getBlobStore().putBlob(containerName, blob); - context.getBlobStore().createContainerInLocation(null, containerName); - assertEquals(context.getBlobStore().countBlobs(containerName), 1); + wrapper.getBlobStore().createContainerInLocation(null, containerName); + assertEquals(wrapper.getBlobStore().countBlobs(containerName), 1); } finally { returnContainer(containerName); } @@ -77,11 +77,11 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { addBlobToContainer(containerName, // NOTE all metadata in jclouds comes out as lowercase, in an effort to // normalize the providers. - context.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("Adrian", "powderpuff")) + wrapper.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("Adrian", "powderpuff")) .payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).calculateMD5().build()); validateContent(containerName, key); - PageSet container = context.getBlobStore().list(containerName, + PageSet container = wrapper.getBlobStore().list(containerName, maxResults(1).withDetails()); BlobMetadata metadata = BlobMetadata.class.cast(get(container, 0)); @@ -105,7 +105,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { String containerName = getContainerName(); try { add5BlobsUnderPathAnd5UnderRootToContainer(containerName); - context.getBlobStore().clearContainer(containerName); + wrapper.getBlobStore().clearContainer(containerName); assertConsistencyAwareContainerSize(containerName, 0); } finally { returnContainer(containerName); @@ -118,13 +118,13 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { try { addAlphabetUnderRoot(containerName); - PageSet container = context.getBlobStore().list(containerName, maxResults(1)); + PageSet container = wrapper.getBlobStore().list(containerName, maxResults(1)); assert container.getNextMarker() != null; assertEquals(container.size(), 1); String marker = container.getNextMarker(); - container = context.getBlobStore().list(containerName, afterMarker(marker)); + container = wrapper.getBlobStore().list(containerName, afterMarker(marker)); assertEquals(container.getNextMarker(), null); assert container.size() == 25 : String.format("size should have been 25, but was %d: %s", container.size(), container); @@ -142,7 +142,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { String prefix = "rootdelimeter"; addTenObjectsUnderPrefix(containerName, prefix); add15UnderRoot(containerName); - PageSet container = context.getBlobStore().list(containerName); + PageSet container = wrapper.getBlobStore().list(containerName); assert container.getNextMarker() == null; assertEquals(container.size(), 16); } finally { @@ -157,17 +157,17 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { try { String directory = "directory"; - assert !context.getBlobStore().directoryExists(containerName, directory); + assert !wrapper.getBlobStore().directoryExists(containerName, directory); - context.getBlobStore().createDirectory(containerName, directory); + wrapper.getBlobStore().createDirectory(containerName, directory); - assert context.getBlobStore().directoryExists(containerName, directory); - PageSet container = context.getBlobStore().list(containerName); + assert wrapper.getBlobStore().directoryExists(containerName, directory); + PageSet container = wrapper.getBlobStore().list(containerName); // we should have only the directory under root assert container.getNextMarker() == null; assert container.size() == 1 : container; - container = context.getBlobStore().list(containerName, inDirectory(directory)); + container = wrapper.getBlobStore().list(containerName, inDirectory(directory)); // we should have nothing in the directory assert container.getNextMarker() == null; @@ -175,50 +175,50 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { addTenObjectsUnderPrefix(containerName, directory); - container = context.getBlobStore().list(containerName); + container = wrapper.getBlobStore().list(containerName); // we should still have only the directory under root assert container.getNextMarker() == null; assert container.size() == 1 : container; - container = context.getBlobStore().list(containerName, inDirectory(directory)); + container = wrapper.getBlobStore().list(containerName, inDirectory(directory)); // we should have only the 10 items under the directory assert container.getNextMarker() == null; assert container.size() == 10 : container; // try 2 level deep directory - assert !context.getBlobStore().directoryExists(containerName, directory + "/" + directory); - context.getBlobStore().createDirectory(containerName, directory + "/" + directory); - assert context.getBlobStore().directoryExists(containerName, directory + "/" + directory); + assert !wrapper.getBlobStore().directoryExists(containerName, directory + "/" + directory); + wrapper.getBlobStore().createDirectory(containerName, directory + "/" + directory); + assert wrapper.getBlobStore().directoryExists(containerName, directory + "/" + directory); - context.getBlobStore().clearContainer(containerName, inDirectory(directory)); - assert context.getBlobStore().directoryExists(containerName, directory); - assert context.getBlobStore().directoryExists(containerName, directory + "/" + directory); + wrapper.getBlobStore().clearContainer(containerName, inDirectory(directory)); + assert wrapper.getBlobStore().directoryExists(containerName, directory); + assert wrapper.getBlobStore().directoryExists(containerName, directory + "/" + directory); // should have only the 2 level-deep directory above - container = context.getBlobStore().list(containerName, inDirectory(directory)); + container = wrapper.getBlobStore().list(containerName, inDirectory(directory)); assert container.getNextMarker() == null; assert container.size() == 1 : container; - context.getBlobStore().createDirectory(containerName, directory + "/" + directory); + wrapper.getBlobStore().createDirectory(containerName, directory + "/" + directory); - container = context.getBlobStore().list(containerName, inDirectory(directory).recursive()); + container = wrapper.getBlobStore().list(containerName, inDirectory(directory).recursive()); assert container.getNextMarker() == null; assert container.size() == 1 : container; - context.getBlobStore().clearContainer(containerName, inDirectory(directory).recursive()); + wrapper.getBlobStore().clearContainer(containerName, inDirectory(directory).recursive()); // should no longer have the 2 level-deep directory above - container = context.getBlobStore().list(containerName, inDirectory(directory)); + container = wrapper.getBlobStore().list(containerName, inDirectory(directory)); assert container.getNextMarker() == null; assert container.size() == 0 : container; - container = context.getBlobStore().list(containerName); + container = wrapper.getBlobStore().list(containerName); // should only have the directory assert container.getNextMarker() == null; assert container.size() == 1 : container; - context.getBlobStore().deleteDirectory(containerName, directory); + wrapper.getBlobStore().deleteDirectory(containerName, directory); - container = context.getBlobStore().list(containerName); + container = wrapper.getBlobStore().list(containerName); // now should be completely empty assert container.getNextMarker() == null; assert container.size() == 0 : container; @@ -236,7 +236,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { addTenObjectsUnderPrefix(containerName, prefix); add15UnderRoot(containerName); - PageSet container = context.getBlobStore().list(containerName, inDirectory(prefix)); + PageSet container = wrapper.getBlobStore().list(containerName, inDirectory(prefix)); assert container.getNextMarker() == null; assertEquals(container.size(), 10); } finally { @@ -251,7 +251,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { try { addAlphabetUnderRoot(containerName); - PageSet container = context.getBlobStore().list(containerName, maxResults(5)); + PageSet container = wrapper.getBlobStore().list(containerName, maxResults(5)); assertEquals(container.size(), 5); assert container.getNextMarker() != null; } finally { @@ -263,7 +263,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { public void containerExists() throws InterruptedException { String containerName = getContainerName(); try { - assert context.getBlobStore().containerExists(containerName); + assert wrapper.getBlobStore().containerExists(containerName); } finally { returnContainer(containerName); } @@ -274,7 +274,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { String containerName = getContainerName(); try { addBlobToContainer(containerName, "test"); - context.getBlobStore().deleteContainer(containerName); + wrapper.getBlobStore().deleteContainer(containerName); assertNotExists(containerName); } finally { recycleContainer(containerName); @@ -285,7 +285,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { public void deleteContainerIfEmpty() throws InterruptedException { final String containerName = getContainerName(); try { - context.getBlobStore().deleteContainer(containerName); + wrapper.getBlobStore().deleteContainer(containerName); assertNotExists(containerName); } finally { // this container is now deleted, so we can't reuse it directly @@ -298,7 +298,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { String containerName = getContainerName(); try { add15UnderRoot(containerName); - Set container = context.getBlobStore().list(containerName); + Set container = wrapper.getBlobStore().list(containerName); assertEquals(container.size(), 15); } finally { returnContainer(containerName); @@ -308,8 +308,8 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { protected void addAlphabetUnderRoot(String containerName) throws InterruptedException { for (char letter = 'a'; letter <= 'z'; letter++) { - context.getBlobStore().putBlob(containerName, - context.getBlobStore().blobBuilder(letter + "").payload(letter + "content").build()); + wrapper.getBlobStore().putBlob(containerName, + wrapper.getBlobStore().blobBuilder(letter + "").payload(letter + "content").build()); } assertContainerSize(containerName, 26); @@ -319,7 +319,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { assertConsistencyAware(new Runnable() { public void run() { try { - assertEquals(context.getBlobStore().countBlobs(containerName), size); + assertEquals(wrapper.getBlobStore().countBlobs(containerName), size); } catch (Exception e) { propagateIfPossible(e); } @@ -329,15 +329,15 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest { protected void add15UnderRoot(String containerName) throws InterruptedException { for (int i = 0; i < 15; i++) { - context.getBlobStore().putBlob(containerName, - context.getBlobStore().blobBuilder(i + "").payload(i + "content").build()); + wrapper.getBlobStore().putBlob(containerName, + wrapper.getBlobStore().blobBuilder(i + "").payload(i + "content").build()); } } protected void addTenObjectsUnderPrefix(String containerName, String prefix) throws InterruptedException { for (int i = 0; i < 10; i++) { - context.getBlobStore().putBlob(containerName, - context.getBlobStore().blobBuilder(prefix + "/" + i).payload(i + "content").build()); + wrapper.getBlobStore().putBlob(containerName, + wrapper.getBlobStore().blobBuilder(prefix + "/" + i).payload(i + "content").build()); } } } \ No newline at end of file diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerLiveTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerLiveTest.java index 40e094528b..e717403e45 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerLiveTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerLiveTest.java @@ -38,18 +38,18 @@ public class BaseContainerLiveTest extends BaseBlobStoreIntegrationTest { public void testPublicAccess() throws InterruptedException, MalformedURLException, IOException { final String containerName = getScratchContainerName(); try { - context.getBlobStore().createContainerInLocation(null, containerName, publicRead()); + wrapper.getBlobStore().createContainerInLocation(null, containerName, publicRead()); assertConsistencyAwareContainerSize(containerName, 0); - context.getBlobStore().putBlob(containerName, - context.getBlobStore().blobBuilder("hello").payload(TEST_STRING).build()); + wrapper.getBlobStore().putBlob(containerName, + wrapper.getBlobStore().blobBuilder("hello").payload(TEST_STRING).build()); assertConsistencyAwareContainerSize(containerName, 1); - BlobMetadata metadata = context.getBlobStore().blobMetadata(containerName, "hello"); + BlobMetadata metadata = wrapper.getBlobStore().blobMetadata(containerName, "hello"); assert metadata.getPublicUri() != null : metadata; - assertEquals(Strings2.toStringAndClose(context.utils().http().get(metadata.getPublicUri())), TEST_STRING); + assertEquals(Strings2.toStringAndClose(wrapper.utils().http().get(metadata.getPublicUri())), TEST_STRING); } finally { // this container is now public, so we can't reuse it directly diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseInputStreamMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseInputStreamMapIntegrationTest.java index 085b0d7fc9..1372ecf383 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseInputStreamMapIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseInputStreamMapIntegrationTest.java @@ -53,7 +53,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati public void testValues() throws InterruptedException, IOException { String containerName = getContainerName(); try { - Map map = createMap(context, containerName); + Map map = createMap(wrapper, containerName); map.putAll(this.fiveInputs); // this will cause us to block until the bucket updates. assertConsistencyAwareMapSize(map, 5); @@ -74,7 +74,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati public void testPutMoreThanSingleListing() throws InterruptedException, ExecutionException, TimeoutException { String containerName = getContainerName(); try { - InputStreamMap map = createMap(context, containerName); + InputStreamMap map = createMap(wrapper, containerName); Set keySet = Sets.newLinkedHashSet(); for (int i = 0; i < maxResultsForTestListings() + 1; i++) { keySet.add(i + ""); @@ -100,7 +100,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati public void testRemove() throws InterruptedException, IOException { String containerName = getContainerName(); try { - Map map = createMap(context, containerName); + Map map = createMap(wrapper, containerName); putStringWithMD5(map, "one", "two"); InputStream old = map.remove("one"); assertEquals(Strings2.toStringAndClose(old), "two"); @@ -120,7 +120,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati public void testEntrySet() throws InterruptedException, IOException { String containerName = getContainerName(); try { - Map map = createMap(context, containerName); + Map map = createMap(wrapper, containerName); ((InputStreamMap) map).putAllStrings(this.fiveStrings); // this will cause us to block until the bucket updates. assertConsistencyAwareKeySize(map, 5); @@ -143,7 +143,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati public void testContainsStringValue() throws InterruptedException, ExecutionException, TimeoutException { String containerName = getContainerName(); try { - Map map = createMap(context, containerName); + Map map = createMap(wrapper, containerName); ((InputStreamMap) map).putString("one", String.format(XML_STRING_FORMAT, "apple")); assertConsistencyAwareContainsValue(map, fiveStrings.get("one")); } finally { @@ -155,7 +155,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati public void testContainsFileValue() throws InterruptedException, ExecutionException, TimeoutException { String containerName = getContainerName(); try { - Map map = createMap(context, containerName); + Map map = createMap(wrapper, containerName); ((InputStreamMap) map).putString("one", String.format(XML_STRING_FORMAT, "apple")); assertConsistencyAwareContainsValue(map, fiveFiles.get("one")); } finally { @@ -167,7 +167,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati public void testContainsInputStreamValue() throws InterruptedException, ExecutionException, TimeoutException { String containerName = getContainerName(); try { - Map map = createMap(context, containerName); + Map map = createMap(wrapper, containerName); ((InputStreamMap) map).putString("one", String.format(XML_STRING_FORMAT, "apple")); assertConsistencyAwareContainsValue(map, this.fiveInputs.get("one")); } finally { @@ -179,7 +179,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati public void testContainsBytesValue() throws InterruptedException, ExecutionException, TimeoutException { String containerName = getContainerName(); try { - Map map = createMap(context, containerName); + Map map = createMap(wrapper, containerName); ((InputStreamMap) map).putString("one", String.format(XML_STRING_FORMAT, "apple")); assertConsistencyAwareContainsValue(map, this.fiveBytes.get("one")); } finally { @@ -192,7 +192,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati public void testPutAll() throws InterruptedException { String containerName = getContainerName(); try { - Map map = createMap(context, containerName); + Map map = createMap(wrapper, containerName); map.putAll(this.fiveInputs); assertConsistencyAwareMapSize(map, 5); assertConsistencyAwareKeySetEquals(map, new TreeSet(fiveInputs.keySet())); @@ -206,7 +206,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati public void testPutAllBytes() throws InterruptedException { String containerName = getContainerName(); try { - Map map = createMap(context, containerName); + Map map = createMap(wrapper, containerName); ((InputStreamMap) map).putAllBytes(this.fiveBytes); assertConsistencyAwareMapSize(map, 5); @@ -221,7 +221,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati public void testPutAllFiles() throws InterruptedException { String containerName = getContainerName(); try { - Map map = createMap(context, containerName); + Map map = createMap(wrapper, containerName); ((InputStreamMap) map).putAllFiles(this.fiveFiles); assertConsistencyAwareMapSize(map, 5); @@ -236,7 +236,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati public void testPutAllStrings() throws InterruptedException { String containerName = getContainerName(); try { - Map map = createMap(context, containerName); + Map map = createMap(wrapper, containerName); ((InputStreamMap) map).putAllStrings(this.fiveStrings); assertConsistencyAwareMapSize(map, 5); @@ -251,7 +251,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati public void testPutString() throws InterruptedException, IOException { String containerName = getContainerName(); try { - Map map = createMap(context, containerName); + Map map = createMap(wrapper, containerName); InputStream old = ((InputStreamMap) map).putString("one", fiveStrings.get("one")); getOneReturnsAppleAndOldValueIsNull(map, old); @@ -280,7 +280,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati public void testPutFile() throws IOException, InterruptedException { String containerName = getContainerName(); try { - Map map = createMap(context, containerName); + Map map = createMap(wrapper, containerName); InputStream old = ((InputStreamMap) map).putFile("one", fiveFiles.get("one")); getOneReturnsAppleAndOldValueIsNull(map, old); @@ -295,7 +295,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati public void testPutBytes() throws InterruptedException, IOException { String containerName = getContainerName(); try { - Map map = createMap(context, containerName); + Map map = createMap(wrapper, containerName); InputStream old = ((InputStreamMap) map).putBytes("one", fiveBytes.get("one")); getOneReturnsAppleAndOldValueIsNull(map, old); @@ -310,7 +310,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati public void testPut() throws InterruptedException, IOException { String containerName = getContainerName(); try { - Map map = createMap(context, containerName); + Map map = createMap(wrapper, containerName); InputStream old = map.put("one", fiveInputs.get("one")); getOneReturnsAppleAndOldValueIsNull(map, old); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseMapIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseMapIntegrationTest.java index 6e59bd2a58..d71391393f 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseMapIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseMapIntegrationTest.java @@ -106,7 +106,7 @@ public abstract class BaseMapIntegrationTest extends BaseBlobStoreIntegration public void testClear() throws InterruptedException, ExecutionException, TimeoutException, IOException { String containerNameName = getContainerName(); try { - Map map = createMap(context, containerNameName); + Map map = createMap(wrapper, containerNameName); assertConsistencyAwareMapSize(map, 0); putStringWithMD5(map, "one", "apple"); assertConsistencyAwareMapSize(map, 1); @@ -124,7 +124,7 @@ public abstract class BaseMapIntegrationTest extends BaseBlobStoreIntegration public void testKeySet() throws InterruptedException, ExecutionException, TimeoutException, IOException { String containerNameName = getContainerName(); try { - Map map = createMap(context, containerNameName); + Map map = createMap(wrapper, containerNameName); assertConsistencyAwareKeySize(map, 0); putStringWithMD5(map, "one", "two"); assertConsistencyAwareKeySize(map, 1); @@ -136,15 +136,15 @@ public abstract class BaseMapIntegrationTest extends BaseBlobStoreIntegration protected void addTenObjectsUnderPrefix(String containerName, String prefix) throws InterruptedException { for (int i = 0; i < 10; i++) { - context.getBlobStore().putBlob(containerName, - context.getBlobStore().blobBuilder(prefix + "/" + i).payload(i + "content").build()); + wrapper.getBlobStore().putBlob(containerName, + wrapper.getBlobStore().blobBuilder(prefix + "/" + i).payload(i + "content").build()); } } protected void addTenObjectsUnderRoot(String containerName) throws InterruptedException { for (int i = 0; i < 10; i++) { - context.getBlobStore().putBlob(containerName, - context.getBlobStore().blobBuilder(i + "").payload(i + "content").build()); + wrapper.getBlobStore().putBlob(containerName, + wrapper.getBlobStore().blobBuilder(i + "").payload(i + "content").build()); } } @@ -152,13 +152,13 @@ public abstract class BaseMapIntegrationTest extends BaseBlobStoreIntegration public void testDirectory() throws InterruptedException { String containerName = getContainerName(); String directory = "apps"; - Map rootMap = createMap(context, containerName); - Map rootRecursiveMap = createMap(context, containerName, recursive()); - Map inDirectoryMap = createMap(context, containerName, inDirectory(directory)); - Map inDirectoryRecursiveMap = createMap(context, containerName, inDirectory(directory).recursive()); + Map rootMap = createMap(wrapper, containerName); + Map rootRecursiveMap = createMap(wrapper, containerName, recursive()); + Map inDirectoryMap = createMap(wrapper, containerName, inDirectory(directory)); + Map inDirectoryRecursiveMap = createMap(wrapper, containerName, inDirectory(directory).recursive()); try { - context.getBlobStore().createDirectory(containerName, directory); + wrapper.getBlobStore().createDirectory(containerName, directory); addTenObjectsUnderRoot(containerName); assertEquals(rootMap.size(), 10); assertEquals(ImmutableSortedSet.copyOf(rootMap.keySet()), @@ -184,7 +184,7 @@ public abstract class BaseMapIntegrationTest extends BaseBlobStoreIntegration assertEquals(ImmutableSortedSet.copyOf(inDirectoryRecursiveMap.keySet()), ImmutableSortedSet.of("0", "1", "2", "3", "4", "5", "6", "7", "8", "9")); - context.getBlobStore().createDirectory(containerName, directory + "/" + directory); + wrapper.getBlobStore().createDirectory(containerName, directory + "/" + directory); assertEquals(rootMap.size(), 10); assertEquals(rootRecursiveMap.size(), 20); assertEquals(inDirectoryMap.size(), 10); @@ -252,7 +252,7 @@ public abstract class BaseMapIntegrationTest extends BaseBlobStoreIntegration public void testContainsKey() throws InterruptedException, ExecutionException, TimeoutException, IOException { String containerNameName = getContainerName(); try { - Map map = createMap(context, containerNameName); + Map map = createMap(wrapper, containerNameName); assertConsistencyAwareDoesntContainKey(map); putStringWithMD5(map, "one", "apple"); assertConsistencyAwareContainsKey(map); @@ -294,7 +294,7 @@ public abstract class BaseMapIntegrationTest extends BaseBlobStoreIntegration public void testIsEmpty() throws InterruptedException, ExecutionException, TimeoutException, IOException { String containerNameName = getContainerName(); try { - Map map = createMap(context, containerNameName); + Map map = createMap(wrapper, containerNameName); assertConsistencyAwareEmpty(map); putStringWithMD5(map, "one", "apple"); assertConsistencyAwareNotEmpty(map); @@ -343,7 +343,7 @@ public abstract class BaseMapIntegrationTest extends BaseBlobStoreIntegration public void testListContainer() throws InterruptedException, ExecutionException, TimeoutException { String containerNameName = getContainerName(); try { - ListableMap map = (ListableMap) createMap(context, containerNameName); + ListableMap map = (ListableMap) createMap(wrapper, containerNameName); assertConsistencyAwareListContainer(map, containerNameName); } finally { returnContainer(containerNameName); diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java index 43a5abb102..d207a475e2 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseServiceIntegrationTest.java @@ -41,24 +41,24 @@ public class BaseServiceIntegrationTest extends BaseBlobStoreIntegrationTest { @Test(groups = { "integration", "live" }) void containerDoesntExist() { - Set list = context.getBlobStore().list(); + Set list = wrapper.getBlobStore().list(); assert !list.contains(new MutableStorageMetadataImpl()); } @Test(groups = { "integration", "live" }) public void testAllLocations() throws InterruptedException { - for (final Location location : context.getBlobStore().listAssignableLocations()) { + for (final Location location : wrapper.getBlobStore().listAssignableLocations()) { final String containerName = getScratchContainerName(); try { System.err.printf(" >> creating container in location %s%n", location); - context.getBlobStore().createContainerInLocation(location, containerName); + wrapper.getBlobStore().createContainerInLocation(location, containerName); System.err.printf(" << call complete.. checking%n"); assertConsistencyAware(new Runnable() { @Override public void run() { - PageSet list = context.getBlobStore().list(); + PageSet list = wrapper.getBlobStore().list(); assert Iterables.any(list, new Predicate() { public boolean apply(StorageMetadata md) { return containerName.equals(md.getName()) && location.equals(md.getLocation()); @@ -79,9 +79,9 @@ public class BaseServiceIntegrationTest extends BaseBlobStoreIntegrationTest { @Test(groups = { "integration", "live" }) public void testGetAssignableLocations() throws Exception { - if (context.unwrap() instanceof Location) - assertProvider(Location.class.cast(context.unwrap())); - for (Location location : context.getBlobStore().listAssignableLocations()) { + if (wrapper.unwrap() instanceof Location) + assertProvider(Location.class.cast(wrapper.unwrap())); + for (Location location : wrapper.getBlobStore().listAssignableLocations()) { System.err.printf("location %s%n", location); assert location.getId() != null : location; assert location != location.getParent() : location; diff --git a/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobMapTest.java b/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobMapTest.java index baa5e6309c..de972ccbd6 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobMapTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/internal/BaseBlobMapTest.java @@ -53,8 +53,7 @@ public class BaseBlobMapTest { public void testTypes() { TypeLiteral>> type0 = new TypeLiteral>>() { }; - @SuppressWarnings("rawtypes") - TypeLiteral type1 = TypeLiteral.get(Types.newParameterizedType(Map.class, String.class, + TypeLiteral type1 = TypeLiteral.get(Types.newParameterizedType(Map.class, String.class, Types.newParameterizedType(Map.class, String.class, Blob.class))); assertEquals(type0, type1); diff --git a/common/azure/src/main/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthentication.java b/common/azure/src/main/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthentication.java index a6c38634f9..e722db87c0 100644 --- a/common/azure/src/main/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthentication.java +++ b/common/azure/src/main/java/org/jclouds/azure/storage/filters/SharedKeyLiteAuthentication.java @@ -43,6 +43,8 @@ import org.jclouds.http.internal.SignatureWire; import org.jclouds.http.utils.ModifyRequest; import org.jclouds.io.InputSuppliers; import org.jclouds.logging.Logger; +import org.jclouds.rest.annotations.Credential; +import org.jclouds.rest.annotations.Identity; import org.jclouds.util.Strings2; import com.google.common.annotations.VisibleForTesting; @@ -75,8 +77,8 @@ public class SharedKeyLiteAuthentication implements HttpRequestFilter { Logger signatureLog = Logger.NULL; @Inject - public SharedKeyLiteAuthentication(SignatureWire signatureWire, @Named(Constants.PROPERTY_IDENTITY) String identity, - @Named(Constants.PROPERTY_CREDENTIAL) String encodedKey, @TimeStamp Provider timeStampProvider, + public SharedKeyLiteAuthentication(SignatureWire signatureWire, @Identity String identity, + @Credential String encodedKey, @TimeStamp Provider timeStampProvider, Crypto crypto, HttpUtils utils) { this.crypto = crypto; this.utils = utils; diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/DefaultVCloudReferencesModule.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/DefaultVCloudReferencesModule.java index ec96dfd891..e37f5eb34a 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/DefaultVCloudReferencesModule.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/DefaultVCloudReferencesModule.java @@ -18,14 +18,12 @@ */ package org.jclouds.trmk.vcloud_0_8.config; -import static org.jclouds.Constants.PROPERTY_IDENTITY; - import java.net.URI; import java.util.Map; -import javax.inject.Named; import javax.inject.Singleton; +import org.jclouds.rest.annotations.Identity; import org.jclouds.trmk.vcloud_0_8.domain.Catalog; import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType; @@ -55,7 +53,7 @@ public class DefaultVCloudReferencesModule extends AbstractModule { @org.jclouds.trmk.vcloud_0_8.endpoints.Org @Singleton protected Supplier provideDefaultOrg(DefaultOrgForUser defaultOrgURIForUser, - @Named(PROPERTY_IDENTITY) String user) { + @Identity String user) { return defaultOrgURIForUser.apply(user); } diff --git a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java index 37de990fd3..848eab3d46 100644 --- a/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java +++ b/common/trmk/src/main/java/org/jclouds/trmk/vcloud_0_8/config/TerremarkVCloudRestClientModule.java @@ -25,7 +25,6 @@ import static com.google.common.collect.Iterables.getLast; import static com.google.common.collect.Iterables.transform; import static com.google.common.collect.Maps.transformValues; import static com.google.common.collect.Maps.uniqueIndex; -import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.rest.config.BinderUtils.bindClientAndAsyncClient; import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED; @@ -50,6 +49,7 @@ import org.jclouds.location.suppliers.ImplicitLocationSupplier; import org.jclouds.location.suppliers.LocationsSupplier; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.AuthorizationException; +import org.jclouds.rest.annotations.ApiVersion; import org.jclouds.rest.config.RestClientModule; import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; @@ -311,7 +311,7 @@ public class TerremarkVCloudRestClientModule extends RestClientModule provideAuthenticationURI(final TerremarkVCloudVersionsClient versionService, - @Named(PROPERTY_API_VERSION) final String version) { + @ApiVersion final String version) { return new Supplier() { @Override diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java index c193253b2b..45c4e7bbe3 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/TerremarkClientLiveTest.java @@ -482,7 +482,7 @@ public abstract class TerremarkClientLiveTest(injector.getInstance(SocketOpen.class), 300, 10, TimeUnit.SECONDS);// make @@ -492,7 +492,7 @@ public abstract class TerremarkClientLiveTest(injector.getInstance(TaskSuccess.class), 650, 10, TimeUnit.SECONDS); - connection = (S) RestContext.class.cast(context.unwrap()).getApi(); + connection = (S) RestContext.class.cast(wrapper.unwrap()).getApi(); orgs = listOrgs(); } @@ -514,7 +514,7 @@ public abstract class TerremarkClientLiveTest newContext = null; try { - newContext = createContext( + newContext = createWrapper( overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName())), setupModules()).unwrap(); assertEquals(newContext.getApi().findOrgNamed(null), org); @@ -549,7 +549,7 @@ public abstract class TerremarkClientLiveTest newContext = null; try { - newContext = createContext( + newContext = createWrapper( overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(), VCloudConstants.PROPERTY_VCLOUD_DEFAULT_CATALOG, cat.getName())), setupModules()) .unwrap(); @@ -592,7 +592,7 @@ public abstract class TerremarkClientLiveTest newContext = null; try { - newContext = createContext( + newContext = createWrapper( overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(), VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName(), VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK, net.getName())), setupModules()) @@ -671,7 +671,7 @@ public abstract class TerremarkClientLiveTest newContext = null; try { - newContext = createContext( + newContext = createWrapper( overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(), VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName())), setupModules()) .unwrap(); @@ -703,7 +703,7 @@ public abstract class TerremarkClientLiveTest newContext = null; try { - newContext = createContext( + newContext = createWrapper( overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(), VCloudConstants.PROPERTY_VCLOUD_DEFAULT_TASKSLIST, tasksList.getName())), setupModules()) .unwrap(); @@ -737,7 +737,7 @@ public abstract class TerremarkClientLiveTest listOrgs() { diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/VAppTemplatesInOrgsLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/VAppTemplatesInOrgsLiveTest.java index 181712e8c3..4832de853d 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/VAppTemplatesInOrgsLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/VAppTemplatesInOrgsLiveTest.java @@ -54,7 +54,7 @@ extends BaseComputeServiceContextLiveTest { @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - Injector injector = context.utils().injector(); + Injector injector = wrapper.utils().injector(); tmClient = injector.getInstance(TerremarkVCloudClient.class); allCatalogItemsInOrg = injector.getInstance(AllCatalogItemsInOrg.class); diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java index 453b394d0e..85eb23316f 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java @@ -60,10 +60,10 @@ public abstract class BaseTerremarkClientLiveTest(new InetSocketAddressConnect(), 300, 1, TimeUnit.SECONDS); sshFactory = injector.getInstance(Factory.class); - connection = (S) RestContext.class.cast(context.unwrap()).getApi(); + connection = (S) RestContext.class.cast(wrapper.unwrap()).getApi(); } protected Module getSshModule() { diff --git a/compute/src/main/java/org/jclouds/compute/ComputeServiceContext.java b/compute/src/main/java/org/jclouds/compute/ComputeServiceContext.java index 1d0b93fd5e..771656f1a7 100644 --- a/compute/src/main/java/org/jclouds/compute/ComputeServiceContext.java +++ b/compute/src/main/java/org/jclouds/compute/ComputeServiceContext.java @@ -42,27 +42,20 @@ public interface ComputeServiceContext extends Closeable, Wrapper { ComputeService getComputeService(); /** - * retrieves a list of credentials for resources created within this context, keyed on {@code id} - * of the resource with a namespace prefix (ex. {@code node#}. We are testing this approach for - * resources such as compute nodes, where you could access this externally. - *

- *

accessing credentials for a node

- *

- * the key is in the form {@code node#id}. - *

    - *
  • if the node id is {@code 8}, then the key will be {@code node#8}
  • - *
  • if the node id is {@code us-east-1/i-asdfdas}, then the key will be {@code - * node#us-east-1/i-asdfdas}
  • - *
  • if the node id is {@code http://cloud/instances/1}, then the key will be {@code - * node#http://cloud/instances/1}
  • - *
+ * will be removed in jclouds 1.6 + * + * @see Utils#getCredentialStore() */ + @Deprecated @Beta Map getCredentialStore(); /** - * @see ComputeServiceContext#getCredentialStore + * will be removed in jclouds 1.6 + * + * @see Utils#credentialStore() */ + @Deprecated @Beta Map credentialStore(); @@ -72,7 +65,7 @@ public interface ComputeServiceContext extends Closeable, Wrapper { * @see #getUtils */ Utils utils(); - + /** * will be removed in jclouds 1.6 * diff --git a/compute/src/main/java/org/jclouds/compute/Utils.java b/compute/src/main/java/org/jclouds/compute/Utils.java index d8dc073fc2..0ace4655d2 100644 --- a/compute/src/main/java/org/jclouds/compute/Utils.java +++ b/compute/src/main/java/org/jclouds/compute/Utils.java @@ -42,5 +42,5 @@ public interface Utils extends org.jclouds.rest.Utils { * @return function that gets an ssh client for a node that is available via ssh. */ Function sshForNode(); - + } diff --git a/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java b/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java index dfcfdfdb8f..2b4380dd63 100644 --- a/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java +++ b/compute/src/main/java/org/jclouds/compute/internal/ComputeServiceContextImpl.java @@ -20,12 +20,12 @@ package org.jclouds.compute.internal; import static com.google.common.base.Preconditions.checkNotNull; -import java.io.Closeable; import java.util.Map; import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.Context; import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.Utils; @@ -34,7 +34,6 @@ import org.jclouds.internal.BaseWrapper; import org.jclouds.location.Provider; import org.jclouds.rest.RestContext; -import com.google.common.io.Closeables; import com.google.common.reflect.TypeToken; /** @@ -44,21 +43,31 @@ import com.google.common.reflect.TypeToken; public class ComputeServiceContextImpl extends BaseWrapper implements ComputeServiceContext { private final ComputeService computeService; private final Utils utils; - private final Map credentialStore; @Inject - public ComputeServiceContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, - ComputeService computeService, Map credentialStore, Utils utils) { + public ComputeServiceContextImpl(@Provider Context wrapped, @Provider TypeToken wrappedType, + ComputeService computeService, Utils utils) { super(wrapped, wrappedType); - this.credentialStore = credentialStore; - this.utils = utils; this.computeService = checkNotNull(computeService, "computeService"); + this.utils = checkNotNull(utils, "utils"); } - + + @Override public ComputeService getComputeService() { return computeService; } + @SuppressWarnings("unchecked") + @Override + public RestContext getProviderSpecificContext() { + return (RestContext) delegate(); + } + + @Override + public void close() { + delegate().close(); + } + @Override public Utils getUtils() { return utils(); @@ -69,39 +78,14 @@ public class ComputeServiceContextImpl extends BaseWrapper implements ComputeSer return utils; } - @Override - public Map getCredentialStore() { - return credentialStore; - } - @Override public Map credentialStore() { - return credentialStore; - } - - @SuppressWarnings("unchecked") - @Override - public RestContext getProviderSpecificContext() { - return (RestContext) getWrapped(); + return utils().credentialStore(); } @Override - public void close() { - Closeables.closeQuietly(getWrapped()); - } - - public int hashCode() { - return getWrapped().hashCode(); - } - - @Override - public String toString() { - return getWrapped().toString(); - } - - @Override - public boolean equals(Object obj) { - return getWrapped().equals(obj); + public Map getCredentialStore() { + return utils().credentialStore(); } } diff --git a/compute/src/main/java/org/jclouds/compute/internal/UtilsImpl.java b/compute/src/main/java/org/jclouds/compute/internal/UtilsImpl.java index c360046f68..903c4dd880 100644 --- a/compute/src/main/java/org/jclouds/compute/internal/UtilsImpl.java +++ b/compute/src/main/java/org/jclouds/compute/internal/UtilsImpl.java @@ -18,6 +18,7 @@ */ package org.jclouds.compute.internal; +import java.util.Map; import java.util.concurrent.ExecutorService; import javax.inject.Named; @@ -28,6 +29,7 @@ import org.jclouds.compute.Utils; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.crypto.Crypto; import org.jclouds.date.DateService; +import org.jclouds.domain.Credentials; import org.jclouds.json.Json; import org.jclouds.logging.Logger.LoggerFactory; import org.jclouds.rest.HttpAsyncClient; @@ -53,11 +55,12 @@ public class UtilsImpl extends org.jclouds.rest.internal.UtilsImpl implements Ut @Inject UtilsImpl(Injector injector, Json json, XMLParser xml, HttpClient simpleClient, HttpAsyncClient simpleAsyncClient, - Crypto encryption, DateService date, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads, - @Named(Constants.PROPERTY_IO_WORKER_THREADS) ExecutorService ioThreads, EventBus eventBus, - LoggerFactory loggerFactory, Function sshForNode) { + Crypto encryption, DateService date, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads, + @Named(Constants.PROPERTY_IO_WORKER_THREADS) ExecutorService ioThreads, EventBus eventBus, + Map credentialStore, LoggerFactory loggerFactory, + Function sshForNode) { super(injector, json, xml, simpleClient, simpleAsyncClient, encryption, date, userThreads, ioThreads, eventBus, - loggerFactory); + credentialStore, loggerFactory); this.sshForNode = sshForNode; } diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java index c1c4f90d21..e1580f1ce4 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceContextLiveTest.java @@ -18,70 +18,18 @@ */ package org.jclouds.compute.internal; -import java.io.InputStream; -import java.util.Properties; -import java.util.concurrent.ConcurrentHashMap; - -import org.jclouds.apis.BaseContextLiveTest; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.domain.LoginCredentials; -import org.jclouds.domain.LoginCredentials.Builder; -import org.jclouds.io.CopyInputStreamInputSupplierMap; -import org.jclouds.rest.config.CredentialStoreModule; -import com.google.common.base.Splitter; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterables; -import com.google.common.io.InputSupplier; import com.google.common.reflect.TypeToken; -import com.google.inject.Module; -import com.google.inject.util.Modules; /** * @author Jason King, Adrian Cole */ -public abstract class BaseComputeServiceContextLiveTest extends BaseContextLiveTest { +public abstract class BaseComputeServiceContextLiveTest extends BaseGenericComputeServiceContextLiveTest { - protected String imageId; - protected String loginUser; - protected String authenticateSudo; - protected LoginCredentials loginCredentials = LoginCredentials.builder().user("root").build(); - - // isolate tests from eachother, as default credentialStore is static - protected Module credentialStoreModule = new CredentialStoreModule(new CopyInputStreamInputSupplierMap( - new ConcurrentHashMap>())); - @Override - protected TypeToken contextType() { + protected TypeToken wrapperType() { return TypeToken.of(ComputeServiceContext.class); } - @Override - protected Properties setupProperties() { - Properties overrides = super.setupProperties(); - imageId = setIfTestSystemPropertyPresent(overrides, provider + ".image-id"); - loginUser = setIfTestSystemPropertyPresent(overrides, provider + ".image.login-user"); - authenticateSudo = setIfTestSystemPropertyPresent(overrides, provider + ".image.authenticate-sudo"); - - if (loginUser != null) { - Iterable userPass = Splitter.on(':').split(loginUser); - Builder loginCredentialsBuilder = LoginCredentials.builder(); - loginCredentialsBuilder.user(Iterables.get(userPass, 0)); - if (Iterables.size(userPass) == 2) - loginCredentialsBuilder.password(Iterables.get(userPass, 1)); - if (authenticateSudo != null) - loginCredentialsBuilder.authenticateSudo(Boolean.valueOf(authenticateSudo)); - loginCredentials = loginCredentialsBuilder.build(); - } - return overrides; - } - - @Override - protected Iterable setupModules() { - return ImmutableSet. of(getLoggingModule(), credentialStoreModule, getSshModule()); - } - - protected Module getSshModule() { - return Modules.EMPTY_MODULE; - } } diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java index eff4c31be0..dddeff7639 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseComputeServiceLiveTest.java @@ -156,7 +156,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte protected void buildSocketTester() { - SocketOpen socketOpen = context.utils().injector().getInstance(SocketOpen.class); + SocketOpen socketOpen = wrapper.utils().injector().getInstance(SocketOpen.class); socketTester = new RetryablePredicate(socketOpen, 60, 1, TimeUnit.SECONDS); // wait a maximum of 60 seconds for port 8080 to open. long maxWait = TimeUnit.SECONDS.toMillis(60); @@ -168,7 +168,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte @Override protected void initializeContext() { super.initializeContext(); - client = context.getComputeService(); + client = wrapper.getComputeService(); } // wait up to 5 seconds for an auth exception @@ -326,7 +326,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte } protected void checkHttpGet(NodeMetadata node) { - ComputeTestUtils.checkHttpGet(context.utils().http(), node, 8080); + ComputeTestUtils.checkHttpGet(wrapper.utils().http(), node, 8080); } @Test(enabled = true, dependsOnMethods = "testCompareSizes") @@ -422,7 +422,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte public void testCredentialsCache() throws Exception { initializeContext(); for (NodeMetadata node : nodes) - assert (context.getCredentialStore().get("node#" + node.getId()) != null) : "credentials for " + node.getId(); + assert (wrapper.utils().credentialStore().get("node#" + node.getId()) != null) : "credentials for " + node.getId(); } protected Map runScriptWithCreds(final String group, OperatingSystem os, @@ -437,7 +437,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte assertNotNull(node.getGroup()); assertEquals(node.getGroup(), group); assertEquals(node.getState(), NodeState.RUNNING); - Credentials fromStore = context.getCredentialStore().get("node#" + node.getId()); + Credentials fromStore = wrapper.utils().credentialStore().get("node#" + node.getId()); assertEquals(fromStore, node.getCredentials()); assert node.getPublicAddresses().size() >= 1 || node.getPrivateAddresses().size() >= 1 : "no ips in" + node; assertNotNull(node.getCredentials()); @@ -554,7 +554,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte assertEquals(toDestroy, destroyed.size()); for (NodeMetadata node : filter(client.listNodesDetailsMatching(all()), inGroup(group))) { assert node.getState() == NodeState.TERMINATED : node; - assert context.getCredentialStore().get("node#" + node.getId()) == null : "credential should have been null for " + assert wrapper.utils().credentialStore().get("node#" + node.getId()) == null : "credential should have been null for " + "node#" + node.getId(); } } @@ -697,7 +697,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte getLocationForIp(nodeIp))); } - trackAvailabilityOfProcessOnNode(context.utils().userExecutor().submit(new Callable() { + trackAvailabilityOfProcessOnNode(wrapper.utils().userExecutor().submit(new Callable() { @Override public ExecResponse call() { return client.runScriptOnNode(nodeId, startJBoss(configuration), runAsRoot(false).blockOnComplete(false) @@ -713,7 +713,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte client.runScriptOnNode(nodeId, "/tmp/init-jboss stop", runAsRoot(false).wrapInInitScript(false)); - trackAvailabilityOfProcessOnNode(context.utils().userExecutor().submit(new Callable() { + trackAvailabilityOfProcessOnNode(wrapper.utils().userExecutor().submit(new Callable() { @Override public ExecResponse call() { @@ -734,10 +734,10 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte } protected String getLocationForIp(String ip) throws IOException { - InputStream json = context.utils().http().get(URI.create("http://freegeoip.appspot.com/" + ip)); + InputStream json = wrapper.utils().http().get(URI.create("http://freegeoip.appspot.com/" + ip)); String text = null; if (json != null && (text = Strings2.toStringAndClose(json)).indexOf("}") != -1) { - return context.utils().json().fromJson(text, FreeGeoIPLocation.class).toString(); + return wrapper.utils().json().fromJson(text, FreeGeoIPLocation.class).toString(); } else { getAnonymousLogger().warning("could not get info on ip " + ip + "; check freegeoip"); } @@ -872,7 +872,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte } protected void doCheckJavaIsInstalledViaSsh(NodeMetadata node, String taskName) throws IOException { - SshClient ssh = context.utils().sshForNode().apply(node); + SshClient ssh = wrapper.utils().sshForNode().apply(node); try { ssh.connect(); ExecResponse hello = ssh.exec("echo hello"); diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseGenericComputeServiceContextLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseGenericComputeServiceContextLiveTest.java new file mode 100644 index 0000000000..8ef4329885 --- /dev/null +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseGenericComputeServiceContextLiveTest.java @@ -0,0 +1,81 @@ +/** + * 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.compute.internal; + +import java.io.InputStream; +import java.util.Properties; +import java.util.concurrent.ConcurrentHashMap; + +import org.jclouds.apis.BaseWrapperLiveTest; +import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.domain.LoginCredentials; +import org.jclouds.domain.LoginCredentials.Builder; +import org.jclouds.io.CopyInputStreamInputSupplierMap; +import org.jclouds.rest.config.CredentialStoreModule; + +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; +import com.google.common.io.InputSupplier; +import com.google.inject.Module; +import com.google.inject.util.Modules; + +/** + * @author Jason King, Adrian Cole + */ +public abstract class BaseGenericComputeServiceContextLiveTest extends BaseWrapperLiveTest { + + protected String imageId; + protected String loginUser; + protected String authenticateSudo; + protected LoginCredentials loginCredentials = LoginCredentials.builder().user("root").build(); + + // isolate tests from eachother, as default credentialStore is static + protected Module credentialStoreModule = new CredentialStoreModule(new CopyInputStreamInputSupplierMap( + new ConcurrentHashMap>())); + + @Override + protected Properties setupProperties() { + Properties overrides = super.setupProperties(); + imageId = setIfTestSystemPropertyPresent(overrides, provider + ".image-id"); + loginUser = setIfTestSystemPropertyPresent(overrides, provider + ".image.login-user"); + authenticateSudo = setIfTestSystemPropertyPresent(overrides, provider + ".image.authenticate-sudo"); + + if (loginUser != null) { + Iterable userPass = Splitter.on(':').split(loginUser); + Builder loginCredentialsBuilder = LoginCredentials.builder(); + loginCredentialsBuilder.user(Iterables.get(userPass, 0)); + if (Iterables.size(userPass) == 2) + loginCredentialsBuilder.password(Iterables.get(userPass, 1)); + if (authenticateSudo != null) + loginCredentialsBuilder.authenticateSudo(Boolean.valueOf(authenticateSudo)); + loginCredentials = loginCredentialsBuilder.build(); + } + return overrides; + } + + @Override + protected Iterable setupModules() { + return ImmutableSet. of(getLoggingModule(), credentialStoreModule, getSshModule()); + } + + protected Module getSshModule() { + return Modules.EMPTY_MODULE; + } +} diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseImageExtensionLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseImageExtensionLiveTest.java index 896e1ffdf4..db04c449ee 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseImageExtensionLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseImageExtensionLiveTest.java @@ -53,13 +53,13 @@ public abstract class BaseImageExtensionLiveTest extends BaseComputeServiceConte * @return */ public Template getNodeTemplate() { - return context.getComputeService().templateBuilder().any().build(); + return wrapper.getComputeService().templateBuilder().any().build(); } @Test(groups = { "integration", "live" }, singleThreaded = true) public void testCreateImage() throws RunNodesException, InterruptedException { - ComputeService computeService = context.getComputeService(); + ComputeService computeService = wrapper.getComputeService(); Optional imageExtension = computeService.getImageExtension(); assertTrue("image extension was not present", imageExtension.isPresent()); @@ -87,20 +87,20 @@ public abstract class BaseImageExtensionLiveTest extends BaseComputeServiceConte @Test(groups = { "integration", "live" }, singleThreaded = true, dependsOnMethods = "testCreateImage") public void testSpawnNodeFromImage() throws RunNodesException { - ComputeService computeService = context.getComputeService(); + ComputeService computeService = wrapper.getComputeService(); Template template = computeService.templateBuilder().fromImage(getImage().get()).build(); NodeMetadata node = Iterables.getOnlyElement(computeService.createNodesInGroup("test-create-image", 1, template)); - SshClient client = context.utils().sshForNode().apply(node); + SshClient client = wrapper.utils().sshForNode().apply(node); client.connect(); ExecResponse hello = client.exec("echo hello"); assertEquals(hello.getOutput().trim(), "hello"); - context.getComputeService().destroyNode(node.getId()); + wrapper.getComputeService().destroyNode(node.getId()); } @@ -108,7 +108,7 @@ public abstract class BaseImageExtensionLiveTest extends BaseComputeServiceConte "testSpawnNodeFromImage" }) public void testDeleteImage() { - ComputeService computeService = context.getComputeService(); + ComputeService computeService = wrapper.getComputeService(); Optional imageExtension = computeService.getImageExtension(); assertTrue("image extension was not present", imageExtension.isPresent()); @@ -123,7 +123,7 @@ public abstract class BaseImageExtensionLiveTest extends BaseComputeServiceConte } private Optional getImage() { - return Iterables.tryFind(context.getComputeService().listImages(), new Predicate() { + return Iterables.tryFind(wrapper.getComputeService().listImages(), new Predicate() { @Override public boolean apply(Image input) { return input.getId().contains("test-create-image"); diff --git a/compute/src/test/java/org/jclouds/compute/internal/BaseTemplateBuilderLiveTest.java b/compute/src/test/java/org/jclouds/compute/internal/BaseTemplateBuilderLiveTest.java index 51fe154b80..7c2fc39fa7 100644 --- a/compute/src/test/java/org/jclouds/compute/internal/BaseTemplateBuilderLiveTest.java +++ b/compute/src/test/java/org/jclouds/compute/internal/BaseTemplateBuilderLiveTest.java @@ -63,15 +63,14 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "integration,live") -public abstract class BaseTemplateBuilderLiveTest extends - BaseComputeServiceContextLiveTest { +public abstract class BaseTemplateBuilderLiveTest extends BaseComputeServiceContextLiveTest { public void testCompareSizes() throws Exception { - Hardware defaultSize = context.getComputeService().templateBuilder().build().getHardware(); + Hardware defaultSize = wrapper.getComputeService().templateBuilder().build().getHardware(); - Hardware smallest = context.getComputeService().templateBuilder().smallest().build().getHardware(); - Hardware fastest = context.getComputeService().templateBuilder().fastest().build().getHardware(); - Hardware biggest = context.getComputeService().templateBuilder().biggest().build().getHardware(); + Hardware smallest = wrapper.getComputeService().templateBuilder().smallest().build().getHardware(); + Hardware fastest = wrapper.getComputeService().templateBuilder().fastest().build().getHardware(); + Hardware biggest = wrapper.getComputeService().templateBuilder().biggest().build().getHardware(); System.out.printf("smallest %s%n", smallest); System.out.printf("fastest %s%n", fastest); @@ -90,8 +89,8 @@ public abstract class BaseTemplateBuilderLiveTest extends } public void testFromTemplate() { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); - assertEquals(context.getComputeService().templateBuilder().fromTemplate(defaultTemplate).build().toString(), + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); + assertEquals(wrapper.getComputeService().templateBuilder().fromTemplate(defaultTemplate).build().toString(), defaultTemplate.toString()); } @@ -135,7 +134,7 @@ public abstract class BaseTemplateBuilderLiveTest extends @Test(dataProvider = "osSupported") public void testTemplateBuilderCanFind(OsFamilyVersion64Bit matrix) throws InterruptedException { - TemplateBuilder builder = context.getComputeService().templateBuilder().osFamily(matrix.family) + TemplateBuilder builder = wrapper.getComputeService().templateBuilder().osFamily(matrix.family) .os64Bit(matrix.is64Bit); if (!matrix.version.equals("")) builder.osVersionMatches("^" + matrix.version + "$"); @@ -148,7 +147,7 @@ public abstract class BaseTemplateBuilderLiveTest extends @Test(dataProvider = "osNotSupported", expectedExceptions = NoSuchElementException.class) public void testTemplateBuilderCannotFind(OsFamilyVersion64Bit matrix) throws InterruptedException { - TemplateBuilder builder = context.getComputeService().templateBuilder().osFamily(matrix.family) + TemplateBuilder builder = wrapper.getComputeService().templateBuilder().osFamily(matrix.family) .os64Bit(matrix.is64Bit); if (!matrix.version.equals("")) builder.osVersionMatches("^" + matrix.version + "$"); @@ -157,18 +156,18 @@ public abstract class BaseTemplateBuilderLiveTest extends @Test public void testTemplateBuilderCanUseImageId() throws Exception { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); - context.close(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); + wrapper.close(); setupContext(); - Template template = context.getComputeService().templateBuilder().imageId(defaultTemplate.getImage().getId()) + Template template = wrapper.getComputeService().templateBuilder().imageId(defaultTemplate.getImage().getId()) .locationId(defaultTemplate.getLocation().getId()).build(); assertEquals(template.getImage(), defaultTemplate.getImage()); } @Test public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); assert defaultTemplate.getImage().getOperatingSystem().getVersion().matches("1[012].[10][04]") : defaultTemplate .getImage().getOperatingSystem().getVersion(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); @@ -180,9 +179,8 @@ public abstract class BaseTemplateBuilderLiveTest extends @Test(groups = { "integration", "live" }) public void testGetAssignableLocations() throws Exception { - if (context.unwrap() instanceof Location) - assertProvider(Location.class.cast(context.unwrap())); - for (Location location : context.getComputeService().listAssignableLocations()) { + assertProvider(wrapper.unwrap()); + for (Location location : wrapper.getComputeService().listAssignableLocations()) { System.err.printf("location %s%n", location); assert location.getId() != null : location; assert location != location.getParent() : location; @@ -220,14 +218,14 @@ public abstract class BaseTemplateBuilderLiveTest extends @Test public void testTemplateBuilderWithImageIdSpecified() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); ComputeServiceContext context = null; try { Properties overrides = setupProperties(); overrides.setProperty("jclouds.image-id", defaultTemplate.getImage().getId()); - context = createContext(overrides, setupModules()); + context = createWrapper(overrides, setupModules()); assertEquals(context.getComputeService().templateBuilder().build().toString(), defaultTemplate.toString()); } finally { @@ -240,7 +238,7 @@ public abstract class BaseTemplateBuilderLiveTest extends Properties overrides = setupProperties(); overrides.setProperty(provider + ".image-id", defaultTemplate.getImage().getId()); - context = createContext(overrides, setupModules()); + context = createWrapper(overrides, setupModules()); assertEquals(context.getComputeService().templateBuilder().build().toString(), defaultTemplate.toString()); } finally { @@ -268,7 +266,7 @@ public abstract class BaseTemplateBuilderLiveTest extends boolean auth = authenticateSudo != null ? Boolean.valueOf(authenticateSudo) : true; overrides.setProperty(propertyKey + ".image.authenticate-sudo", auth + ""); - context = createContext(overrides, ImmutableSet.of(credentialStoreModule)); + context = createWrapper(overrides, ImmutableSet.of(credentialStoreModule)); Iterable userPass = Splitter.on(':').split(login); String user = Iterables.get(userPass, 0); diff --git a/core/src/main/java/org/jclouds/Context.java b/core/src/main/java/org/jclouds/Context.java new file mode 100644 index 0000000000..2e70b8732d --- /dev/null +++ b/core/src/main/java/org/jclouds/Context.java @@ -0,0 +1,119 @@ +/** + * 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; + +import java.io.Closeable; +import java.net.URI; +import java.util.Map; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.domain.Credentials; +import org.jclouds.domain.Location; +import org.jclouds.internal.ContextImpl; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.Utils; + +import com.google.common.annotations.Beta; +import com.google.inject.ImplementedBy; + +/** + * Represents an authenticated context to the cloud. + * + *

Note

Please issue {@link #close()} when you are finished with this context in order to + * release resources. + * + * + * @author Adrian Cole + * + */ +@ImplementedBy(ContextImpl.class) +public interface Context extends Location, Closeable { + + /** + * will be removed in jclouds 1.6 + * + * @see Utils#getCredentialStore() + */ + @Deprecated + @Beta + Map getCredentialStore(); + + /** + * will be removed in jclouds 1.6 + * + * @see Utils#credentialStore() + */ + @Deprecated + @Beta + Map credentialStore(); + + /** + * @return the providerMetadata used to create this context + * @see ContextBuilder#newBuilder(org.jclouds.providers.ProviderMetadata) + */ + ProviderMetadata getProviderMetadata(); + + /** + * @return the current login user, access key, email, or whatever the 'identity' field was building the context. + * @see ApiMetadata#getDefaultIdentity + */ + String getIdentity(); + + /** + * will be removed in jclouds 1.6 + * @see #getProviderMetadata() + * @see ProviderMetadata#getEndpoint() + */ + @Deprecated + URI getEndpoint(); + + /** + * will be removed in jclouds 1.6 + * @see #getProviderMetadata() + * @see ProviderMetadata#getApiMetadata() + * @see ApiMetadata#getVersion() + */ + @Deprecated + String getApiVersion(); + + /** + * will be removed in jclouds 1.6 + * @see #getProviderMetadata() + * @see ProviderMetadata#getApiMetadata() + * @see ApiMetadata#getBuildVersion() + */ + @Deprecated + @Nullable + String getBuildVersion(); + + Utils getUtils(); + + /** + * @see #getUtils + */ + Utils utils(); + + /** + * Closes all connections, including executor service + */ + @Override + void close(); + +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/ContextBuilder.java b/core/src/main/java/org/jclouds/ContextBuilder.java index b57dd40359..b9a710e3c4 100644 --- a/core/src/main/java/org/jclouds/ContextBuilder.java +++ b/core/src/main/java/org/jclouds/ContextBuilder.java @@ -19,9 +19,17 @@ package org.jclouds; import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Predicates.containsPattern; import static com.google.common.base.Predicates.instanceOf; +import static com.google.common.base.Predicates.not; +import static com.google.common.base.Predicates.notNull; +import static com.google.common.base.Throwables.propagate; import static com.google.common.collect.Iterables.addAll; import static com.google.common.collect.Iterables.any; +import static com.google.common.collect.Iterables.filter; +import static com.google.common.collect.Iterables.find; +import static com.google.common.collect.Iterables.transform; +import static com.google.common.collect.Lists.newArrayList; import static org.jclouds.Constants.PROPERTY_API; import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; @@ -32,14 +40,12 @@ import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; import static org.jclouds.Constants.PROPERTY_PROVIDER; import static org.jclouds.util.Throwables2.propagateAuthorizationOrOriginalException; -import java.io.Closeable; import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import java.util.Properties; - -import javax.inject.Singleton; +import java.util.Set; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.Apis; @@ -47,6 +53,9 @@ import org.jclouds.concurrent.MoreExecutors; import org.jclouds.concurrent.SingleThreaded; import org.jclouds.concurrent.config.ConfiguresExecutorService; import org.jclouds.concurrent.config.ExecutorServiceModule; +import org.jclouds.config.BindPropertiesToExpandedValues; +import org.jclouds.config.BindRestContextWithWildcardExtendsExplicitAndRawType; +import org.jclouds.domain.Credentials; import org.jclouds.events.config.ConfiguresEventBus; import org.jclouds.events.config.EventBusModule; import org.jclouds.http.config.ConfiguresHttpCommandExecutorService; @@ -54,48 +63,40 @@ import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; import org.jclouds.javax.annotation.Nullable; import org.jclouds.lifecycle.Closer; import org.jclouds.lifecycle.config.LifeCycleModule; -import org.jclouds.location.Provider; import org.jclouds.logging.config.LoggingModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; -import org.jclouds.providers.AnonymousProviderMetadata; import org.jclouds.providers.ProviderMetadata; import org.jclouds.providers.Providers; +import org.jclouds.providers.config.BindProviderMetadataContextAndCredentials; +import org.jclouds.providers.internal.UpdateProviderMetadataFromProperties; import org.jclouds.rest.ConfiguresCredentialStore; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.RestApiMetadata; import org.jclouds.rest.RestContext; -import org.jclouds.rest.config.BindPropertiesToAnnotations; import org.jclouds.rest.config.CredentialStoreModule; import org.jclouds.rest.config.RestClientModule; import org.jclouds.rest.config.RestModule; -import org.jclouds.rest.internal.BaseRestApiMetadata; -import org.jclouds.rest.internal.RestContextImpl; -import org.nnsoft.guice.rocoto.Rocoto; -import org.nnsoft.guice.rocoto.configuration.ConfigurationModule; import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Function; import com.google.common.base.Joiner; import com.google.common.base.Objects; +import com.google.common.base.Optional; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; -import com.google.common.base.Throwables; +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; +import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import com.google.common.collect.ImmutableMultimap.Builder; import com.google.common.reflect.TypeToken; import com.google.common.util.concurrent.ExecutionList; -import com.google.inject.AbstractModule; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Module; -import com.google.inject.Provides; import com.google.inject.Stage; import com.google.inject.TypeLiteral; -import com.google.inject.util.Types; /** * Creates {@link RestContext} or {@link Injector} instances based on the most commonly requested @@ -110,54 +111,7 @@ import com.google.inject.util.Types; * @author Adrian Cole, Andrew Newdigate * @see RestContext */ -public final class ContextBuilder { - - static class ResolveRestContextModule extends AbstractModule { - private final RestApiMetadata restApiMetadata; - - ResolveRestContextModule(RestApiMetadata restApiMetadata) { - this.restApiMetadata = restApiMetadata; - } - - @SuppressWarnings("unchecked") - @Override - protected void configure() { - if (restApiMetadata.getContext().getRawType().equals(RestContext.class)) { - TypeToken concreteType = BaseRestApiMetadata.contextToken(TypeToken.of(restApiMetadata.getApi()), TypeToken - .of(restApiMetadata.getAsyncApi())); - // bind explicit type - bind(TypeLiteral.get(concreteType.getType())).to( - (TypeLiteral) TypeLiteral.get(Types.newParameterizedType(RestContextImpl.class, restApiMetadata - .getApi(), restApiMetadata.getAsyncApi()))); - // bind potentially wildcard type - if (!concreteType.equals(restApiMetadata.getContext())) { - bind(TypeLiteral.get(restApiMetadata.getContext().getType())).to( - (TypeLiteral) TypeLiteral.get(Types.newParameterizedType(RestContextImpl.class, restApiMetadata - .getApi(), restApiMetadata.getAsyncApi()))); - } - // bind w/o types - bind(TypeLiteral.get(RestContext.class)).to( - (TypeLiteral) TypeLiteral.get(Types.newParameterizedType(RestContextImpl.class, restApiMetadata - .getApi(), restApiMetadata.getAsyncApi()))); - } - } - } - - private final class BindDefaultContextQualifiedToProvider extends AbstractModule { - @Override - protected void configure() { - bind(new TypeLiteral>() { - }).annotatedWith(Provider.class).toInstance(apiMetadata.getContext()); - } - - @SuppressWarnings("unused") - @Provides - @Provider - @Singleton - protected Closeable wrapped(Injector i, @Provider TypeToken wrappedType) { - return (Closeable) i.getInstance(Key.get(TypeLiteral.get(wrappedType.getType()))); - } - } +public class ContextBuilder { /** * looks up a provider or api with the given id @@ -177,8 +131,8 @@ public final class ContextBuilder { } } catch (NoSuchElementException e) { Builder builder = ImmutableMultimap. builder(); - builder.putAll("providers", Iterables.transform(Providers.all(), Providers.idFunction())); - builder.putAll("apis", Iterables.transform(Apis.all(), Apis.idFunction())); + builder.putAll("providers", transform(Providers.all(), Providers.idFunction())); + builder.putAll("apis", transform(Apis.all(), Apis.idFunction())); throw new NoSuchElementException(String.format("key [%s] not in the list of providers or apis: %s", providerOrApi, builder.build())); } @@ -200,14 +154,16 @@ public final class ContextBuilder { } } - protected ProviderMetadata providerMetadata; - protected String endpoint; - protected String identity; + protected Optional providerMetadata = Optional.absent(); + protected final String providerId; + protected Optional endpoint = Optional.absent(); + protected Optional identity = Optional.absent(); + @Nullable protected String credential; protected ApiMetadata apiMetadata; protected String apiVersion; protected String buildVersion; - protected Properties overrides = new Properties();; + protected Optional overrides = Optional.absent(); protected List modules = new ArrayList(3); @Override @@ -217,36 +173,37 @@ public final class ContextBuilder { } protected ContextBuilder(ProviderMetadata providerMetadata) { - this(providerMetadata, providerMetadata.getApiMetadata()); + this(providerMetadata, checkNotNull(providerMetadata, "providerMetadata").getApiMetadata()); } protected ContextBuilder(@Nullable ProviderMetadata providerMetadata, ApiMetadata apiMetadata) { this.apiMetadata = checkNotNull(apiMetadata, "apiMetadata"); - this.providerMetadata = providerMetadata; - if (providerMetadata != null) - this.endpoint = providerMetadata.getEndpoint(); - if (apiMetadata.getDefaultIdentity().isPresent()) - identity = apiMetadata.getDefaultIdentity().get(); - if (apiMetadata.getDefaultCredential().isPresent()) - credential = apiMetadata.getDefaultCredential().get(); + if (providerMetadata != null) { + this.providerMetadata = Optional.of(providerMetadata); + this.endpoint = Optional.of(providerMetadata.getEndpoint()); + this.providerId = providerMetadata.getId(); + } else { + this.endpoint = apiMetadata.getDefaultEndpoint(); + this.providerId = apiMetadata.getId(); + } + this.identity = apiMetadata.getDefaultIdentity(); + this.credential = apiMetadata.getDefaultCredential().orNull(); this.apiVersion = apiMetadata.getVersion(); this.buildVersion = apiMetadata.getBuildVersion().or(""); - if (endpoint == null) - endpoint = apiMetadata.getDefaultEndpoint().orNull(); } public ContextBuilder(ApiMetadata apiMetadata) { this(null, apiMetadata); } - public ContextBuilder credentials(String identity, String credential) { - this.identity = identity; + public ContextBuilder credentials(String identity, @Nullable String credential) { + this.identity = Optional.of(checkNotNull(identity, "identity")); this.credential = credential; return this; } public ContextBuilder endpoint(String endpoint) { - this.endpoint = endpoint; + this.endpoint = Optional.of(checkNotNull(endpoint, "endpoint")); return this; } @@ -261,102 +218,136 @@ public final class ContextBuilder { } public ContextBuilder modules(Iterable modules) { - addAll(this.modules, modules); + addAll(this.modules, checkNotNull(modules, "modules")); return this; } public ContextBuilder overrides(Properties overrides) { - this.overrides.putAll(overrides); + this.overrides = Optional.of(checkNotNull(overrides, "overrides")); return this; } - /** - * @throws NoSuchElementException - */ - public static String searchPropertiesForProviderScopedProperty(Properties overrides, String prov, String key, - String defaultVal) { + public static String searchPropertiesForProviderScopedProperty(Properties mutable, String prov, String key) throws NoSuchElementException { try { - return Iterables.find(Lists.newArrayList(overrides.getProperty(prov + "." + key), overrides - .getProperty("jclouds." + key), defaultVal), Predicates.notNull()); - } catch (NoSuchElementException e) { - throw new NoSuchElementException("no " + key + " configured for provider: " + prov); + return find(newArrayList(mutable.getProperty(prov + "." + key), mutable.getProperty("jclouds." + key)), + notNull()); + } finally { + mutable.remove(prov + "." + key); + mutable.remove("jclouds." + key); } } public Injector buildInjector() { - checkNotNull(modules, "modules"); - checkNotNull(overrides, "overrides"); - checkNotNull(apiMetadata, "api"); - final Properties mutable = new Properties(); - mutable.putAll(apiMetadata.getDefaultProperties()); - String providerId; - if (providerMetadata != null) { - mutable.putAll(providerMetadata.getDefaultProperties()); - mutable.setProperty(PROPERTY_PROVIDER, providerId = providerMetadata.getId()); - mutable.setProperty(PROPERTY_ISO3166_CODES, Joiner.on(',').join(providerMetadata.getIso3166Codes())); - } else { - mutable.setProperty(PROPERTY_PROVIDER, providerId = apiMetadata.getId()); - } - mutable.putAll(checkNotNull(overrides, "overrides")); - mutable.putAll(propertiesPrefixedWithJcloudsApiOrProviderId(System.getProperties(), providerId)); + Properties unexpanded = currentStateToUnexpandedProperties(); - mutable.setProperty(PROPERTY_ENDPOINT, searchPropertiesForProviderScopedProperty(mutable, providerId, "endpoint", - endpoint)); - mutable.setProperty(PROPERTY_API, searchPropertiesForProviderScopedProperty(mutable, providerId, "api", - apiMetadata.getName())); - mutable.setProperty(PROPERTY_API_VERSION, searchPropertiesForProviderScopedProperty(mutable, providerId, - "api-version", apiVersion)); - mutable.setProperty(PROPERTY_BUILD_VERSION, searchPropertiesForProviderScopedProperty(mutable, providerId, - "build-version", buildVersion)); - mutable.setProperty(PROPERTY_IDENTITY, searchPropertiesForProviderScopedProperty(mutable, providerId, "identity", - identity)); + ImmutableSet keysToResolve = ImmutableSet.of(PROPERTY_ENDPOINT, PROPERTY_IDENTITY, PROPERTY_CREDENTIAL, + PROPERTY_API, PROPERTY_API_VERSION, PROPERTY_BUILD_VERSION); + + ImmutableSet optionalKeys = apiMetadata.getCredentialName().isPresent() ? ImmutableSet. of() + : ImmutableSet.of(PROPERTY_CREDENTIAL); + + Properties resolved = resolveProperties(unexpanded, providerId, keysToResolve, optionalKeys); + + Properties expanded = expandProperties(resolved); + + Credentials creds = new Credentials(getAndRemove(expanded, PROPERTY_IDENTITY), getAndRemove(expanded, + PROPERTY_CREDENTIAL)); + + ProviderMetadata providerMetadata = new UpdateProviderMetadataFromProperties(apiMetadata, this.providerMetadata).apply(expanded); + + return buildInjector(providerMetadata, creds, modules); + } + + private static String getAndRemove(Properties expanded, String key) { try { - mutable.setProperty(PROPERTY_CREDENTIAL, searchPropertiesForProviderScopedProperty(mutable, providerId, - "credential", credential)); - } catch (NoSuchElementException e) { - if (apiMetadata.getCredentialName().isPresent()) - throw e; + return expanded.getProperty(key); + } finally { + expanded.remove(key); } - if (providerMetadata == null) - providerMetadata = AnonymousProviderMetadata.forApiWithEndpoint(apiMetadata, mutable - .getProperty(PROPERTY_ENDPOINT)); + } + + private Properties currentStateToUnexpandedProperties() { + Properties defaults = new Properties(); + defaults.putAll(apiMetadata.getDefaultProperties()); + defaults.setProperty(PROPERTY_PROVIDER,providerId); + if (providerMetadata.isPresent()) { + defaults.putAll(providerMetadata.get().getDefaultProperties()); + defaults.setProperty(PROPERTY_ISO3166_CODES, Joiner.on(',').join(providerMetadata.get().getIso3166Codes())); + } + if (endpoint.isPresent()) + defaults.setProperty(PROPERTY_ENDPOINT, endpoint.get()); + defaults.setProperty(PROPERTY_API, apiMetadata.getName()); + defaults.setProperty(PROPERTY_API_VERSION, apiVersion); + defaults.setProperty(PROPERTY_BUILD_VERSION, buildVersion); + if (identity.isPresent()) + defaults.setProperty(PROPERTY_IDENTITY, identity.get()); + if (credential != null) + defaults.setProperty(PROPERTY_CREDENTIAL, credential); + if (overrides.isPresent()) + defaults.putAll(checkNotNull(overrides.get(), "overrides")); + defaults.putAll(propertiesPrefixedWithJcloudsApiOrProviderId(getSystemProperties(), apiMetadata.getId(), providerId)); + return defaults; + } - modules.add(Rocoto.expandVariables(new ConfigurationModule() { + @VisibleForTesting + protected Properties getSystemProperties() { + return System.getProperties(); + } - @Override - protected void bindConfigurations() { - bindProperties(mutable); - } - })); + private Properties expandProperties(final Properties resolved) { + return Guice.createInjector(new BindPropertiesToExpandedValues(resolved)).getInstance(Properties.class); + } - boolean restModuleSpecifiedByUser = restClientModulePresent(modules); - Iterable defaultModules = ifSpecifiedByUserDontIncludeDefaultRestModule(restModuleSpecifiedByUser); - Iterables.addAll(modules, defaultModules); - addClientModuleIfNotPresent(modules); - addRestContextBinding(); + public static Injector buildInjector(ProviderMetadata providerMetadata, Credentials creds, List inputModules) { + List modules = newArrayList(); + modules.addAll(inputModules); + boolean restModuleSpecifiedByUser = restClientModulePresent(inputModules); + Iterable defaultModules = ifSpecifiedByUserDontIncludeDefaultRestModule( + providerMetadata.getApiMetadata(), restModuleSpecifiedByUser); + addAll(modules, defaultModules); + addClientModuleIfNotPresent(providerMetadata.getApiMetadata(), modules); + addRestContextBinding(providerMetadata.getApiMetadata(), modules); addLoggingModuleIfNotPresent(modules); addHttpModuleIfNeededAndNotPresent(modules); addExecutorServiceIfNotPresent(modules); addEventBusIfNotPresent(modules); addCredentialStoreIfNotPresent(modules); modules.add(new LifeCycleModule()); - modules.add(new BindPropertiesToAnnotations()); - modules.add(new BindDefaultContextQualifiedToProvider()); + modules.add(new BindProviderMetadataContextAndCredentials(providerMetadata, creds)); Injector returnVal = Guice.createInjector(Stage.PRODUCTION, modules); returnVal.getInstance(ExecutionList.class).execute(); return returnVal; } - void addRestContextBinding() { + static Properties resolveProperties(Properties mutable, String providerId, Set keys, Set optionalKeys) throws NoSuchElementException { + for (String key : keys){ + try { + String scopedProperty = ImmutableList.copyOf(Splitter.on('.').split(key)).get(1); + mutable.setProperty(key, searchPropertiesForProviderScopedProperty(mutable, providerId,scopedProperty)); + } catch (NoSuchElementException e){ + if (!optionalKeys.contains(key)) + throw e; + } + } + return mutable; + } + + static void addRestContextBinding(ApiMetadata apiMetadata, List modules) { if (apiMetadata instanceof RestApiMetadata) { - modules.add(new ResolveRestContextModule(RestApiMetadata.class.cast(apiMetadata))); + try { + modules.add(new BindRestContextWithWildcardExtendsExplicitAndRawType(RestApiMetadata.class + .cast(apiMetadata))); + } catch (IllegalArgumentException e) { + + } } } - private Iterable ifSpecifiedByUserDontIncludeDefaultRestModule(boolean restModuleSpecifiedByUser) { - Iterable defaultModules = Iterables.transform(apiMetadata.getDefaultModules(), + static Iterable ifSpecifiedByUserDontIncludeDefaultRestModule(ApiMetadata apiMetadata, + boolean restModuleSpecifiedByUser) { + Iterable defaultModules = transform(apiMetadata.getDefaultModules(), new Function, Module>() { @Override @@ -364,37 +355,38 @@ public final class ContextBuilder { try { return arg0.newInstance(); } catch (InstantiationException e) { - throw Throwables.propagate(e); + throw propagate(e); } catch (IllegalAccessException e) { - throw Throwables.propagate(e); + throw propagate(e); } } }); if (restModuleSpecifiedByUser) - defaultModules = Iterables.filter(defaultModules, Predicates.not(configuresRest)); + defaultModules = filter(defaultModules, not(configuresRest)); return defaultModules; } @SuppressWarnings( { "unchecked" }) - Map propertiesPrefixedWithJcloudsApiOrProviderId(Properties properties, String providerId) { - return Maps.filterKeys((Map) System.getProperties(), Predicates.containsPattern("^(jclouds|" + providerId + "|" - + apiMetadata.getId() + ").*")); + static Map propertiesPrefixedWithJcloudsApiOrProviderId(Properties properties, String apiId, + String providerId) { + return Maps.filterKeys((Map) properties, containsPattern("^(jclouds|" + providerId + "|" + apiId + + ").*")); } @VisibleForTesting - protected void addLoggingModuleIfNotPresent(List modules) { + static void addLoggingModuleIfNotPresent(List modules) { if (!any(modules, instanceOf(LoggingModule.class))) modules.add(new JDKLoggingModule()); } @VisibleForTesting - void addHttpModuleIfNeededAndNotPresent(List modules) { + static void addHttpModuleIfNeededAndNotPresent(List modules) { if (nothingConfiguresAnHttpService(modules)) modules.add(new JavaUrlHttpCommandExecutorServiceModule()); } - private boolean nothingConfiguresAnHttpService(List modules) { + static boolean nothingConfiguresAnHttpService(List modules) { return (!any(modules, new Predicate() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(ConfiguresHttpCommandExecutorService.class); @@ -404,25 +396,25 @@ public final class ContextBuilder { } @VisibleForTesting - protected void addClientModuleIfNotPresent(List modules) { + static void addClientModuleIfNotPresent(ApiMetadata apiMetadata, List modules) { if (!restClientModulePresent(modules)) { - addClientModule(modules); + addClientModule(apiMetadata, modules); } } - Predicate configuresRest = new Predicate() { + static Predicate configuresRest = new Predicate() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(ConfiguresRestClient.class); } }; - private boolean restClientModulePresent(List modules) { + static boolean restClientModulePresent(List modules) { return any(modules, configuresRest); } @SuppressWarnings("unchecked") - protected void addClientModule(List modules) { + static void addClientModule(ApiMetadata apiMetadata, List modules) { // TODO: move this up if (apiMetadata instanceof RestApiMetadata) { RestApiMetadata rest = RestApiMetadata.class.cast(apiMetadata); @@ -431,9 +423,9 @@ public final class ContextBuilder { modules.add(new RestModule()); } } - + @VisibleForTesting - protected void addEventBusIfNotPresent(List modules) { + static void addEventBusIfNotPresent(List modules) { if (!any(modules, new Predicate() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(ConfiguresEventBus.class); @@ -446,7 +438,7 @@ public final class ContextBuilder { } @VisibleForTesting - protected void addExecutorServiceIfNotPresent(List modules) { + static void addExecutorServiceIfNotPresent(List modules) { if (!any(modules, new Predicate() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(ConfiguresExecutorService.class); @@ -468,7 +460,7 @@ public final class ContextBuilder { } @VisibleForTesting - protected void addCredentialStoreIfNotPresent(List modules) { + static void addCredentialStoreIfNotPresent(List modules) { if (!any(modules, new Predicate() { public boolean apply(Module input) { return input.getClass().isAnnotationPresent(ConfiguresCredentialStore.class); @@ -489,40 +481,55 @@ public final class ContextBuilder { * @see #build(TypeToken) */ @SuppressWarnings("unchecked") - public C build() { + public C build() { return (C) build(apiMetadata.getContext()); } /** - * @see #build(TypeToken) + * @see #buildAndWrapWith(Class) */ - public C build(Class contextType) { - return build(TypeToken.of(checkNotNull(contextType, "contextType"))); + public W build(Class wrapperType) { + return buildAndWrapWith(checkNotNull(wrapperType, "wrapperType")); } /** - * this will build any context supported by the ApiMetadata. This includes the base - * {@link ApiMetadata#getContext() context}, or any {@link ApiMetadata#getWrappers() wrapper} it - * supports. + * @see #buildAndWrapWith(TypeToken) + */ + public W buildAndWrapWith(Class wrapperType) { + return buildAndWrapWith(TypeToken.of(checkNotNull(wrapperType, "wrapperType"))); + } + + /** + * this will build any {@link ApiMetadata#getWrappers() wrapper} supported by the ApiMetadata. * * ex. {@code builder.build(BlobStoreContext.class) } will work, if {@code TypeToken} * is a configured {@link ApiMetadata#getWrappers() wrapper} of this api. * - * */ @SuppressWarnings("unchecked") - public C build(final TypeToken contextType) { + public W buildAndWrapWith(TypeToken wrapperType) { + TypeToken returnType; + try { + returnType = (TypeToken) Apis.findWrapper(apiMetadata, checkNotNull(wrapperType, "wrapperType")); + } catch (NoSuchElementException e) { + throw new IllegalArgumentException(String.format( + "api %s not wrappable as %s; context: %s, wrappers: %s", apiMetadata, + wrapperType, apiMetadata.getContext(), apiMetadata.getWrappers())); + } + return (W) buildInjector().getInstance(Key.get(TypeLiteral.get(returnType.getType()))); + } + + /** + * this will build the {@link ApiMetadata#getContext() context} supported by the current ApiMetadata. + */ + @SuppressWarnings("unchecked") + public C build(TypeToken contextType) { TypeToken returnType = null; if (contextType.isAssignableFrom(apiMetadata.getContext())) returnType = (TypeToken) apiMetadata.getContext(); else - try { - returnType = (TypeToken) Apis.findWrapper(apiMetadata, contextType); - } catch (NoSuchElementException e) { - throw new IllegalArgumentException(String.format( - "api %s not assignable from or transformable to %s; context: %s, wrappers: %s", apiMetadata, - contextType, apiMetadata.getContext(), apiMetadata.getWrappers())); - } + throw new IllegalArgumentException(String.format("api %s not assignable from %s; context: %s", apiMetadata, + contextType, apiMetadata.getContext())); return (C) buildInjector().getInstance(Key.get(TypeLiteral.get(returnType.getType()))); } diff --git a/core/src/main/java/org/jclouds/Wrapper.java b/core/src/main/java/org/jclouds/Wrapper.java index 085cc9ab9a..1695081b49 100644 --- a/core/src/main/java/org/jclouds/Wrapper.java +++ b/core/src/main/java/org/jclouds/Wrapper.java @@ -18,8 +18,6 @@ */ package org.jclouds; -import java.io.Closeable; - import com.google.common.annotations.Beta; import com.google.common.reflect.TypeToken; @@ -57,14 +55,14 @@ public interface Wrapper { * class. * @see #getWrappedType() */ - C unwrap(TypeToken type) throws IllegalArgumentException; + C unwrap(TypeToken type) throws IllegalArgumentException; /** * shortcut for {@code unwrap(TypeToken.of(clazz))} * * @see #unwrap(TypeToken) */ - C unwrap(Class clazz) throws IllegalArgumentException; + C unwrap(Class clazz) throws IllegalArgumentException; /** * shortcut for {@code unwrap(getWrappedType())} @@ -73,6 +71,6 @@ public interface Wrapper { * if the user supplied {@code C} param is not assignableFrom * {@link #getWrappedType()} */ - C unwrap() throws ClassCastException; + C unwrap() throws ClassCastException; } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/apis/ApiMetadata.java b/core/src/main/java/org/jclouds/apis/ApiMetadata.java index 736a0fcdfc..ddf396ea7e 100644 --- a/core/src/main/java/org/jclouds/apis/ApiMetadata.java +++ b/core/src/main/java/org/jclouds/apis/ApiMetadata.java @@ -18,12 +18,12 @@ */ package org.jclouds.apis; -import java.io.Closeable; import java.io.Serializable; import java.net.URI; import java.util.Properties; import java.util.Set; +import org.jclouds.Context; import org.jclouds.Wrapper; import org.jclouds.javax.annotation.Nullable; @@ -56,7 +56,7 @@ public interface ApiMetadata extends Serializable { /** * @see ApiMetadata#getContext() */ - Builder context(TypeToken context); + Builder context(TypeToken context); /** * @see ApiMetadata#getWrappers() @@ -262,7 +262,7 @@ public interface ApiMetadata extends Serializable { /** * @return the primary context of this api, for example {@code RestContext} */ - TypeToken getContext(); + TypeToken getContext(); /** * @return types of contexts this can be transformed into, for example {@code BlobStoreContext} diff --git a/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java b/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java index 861948c39e..01b24ccfb4 100644 --- a/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java +++ b/core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java @@ -28,19 +28,18 @@ import static org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_HOST; import static org.jclouds.Constants.PROPERTY_MAX_CONNECTION_REUSE; import static org.jclouds.Constants.PROPERTY_MAX_SESSION_FAILURES; import static org.jclouds.Constants.PROPERTY_PRETTY_PRINT_PAYLOADS; +import static org.jclouds.Constants.PROPERTY_SCHEDULER_THREADS; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT; import static org.jclouds.Constants.PROPERTY_USER_THREADS; -import static org.jclouds.Constants.PROPERTY_SCHEDULER_THREADS; -import java.io.Closeable; import java.net.URI; import java.util.Properties; import java.util.Set; +import org.jclouds.Context; import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; -import org.jclouds.lifecycle.Closer; import com.google.common.base.Objects; import com.google.common.base.Optional; @@ -95,7 +94,7 @@ public abstract class BaseApiMetadata implements ApiMetadata { protected Properties defaultProperties = BaseApiMetadata.defaultProperties(); protected URI documentation; // - protected TypeToken context = TypeToken.of(Closer.class); + protected TypeToken context = TypeToken.of(Context.class); protected Set> defaultModules = ImmutableSet.of(); /** @@ -235,7 +234,7 @@ public abstract class BaseApiMetadata implements ApiMetadata { * {@inheritDoc} */ @Override - public Builder context(TypeToken context) { + public Builder context(TypeToken context) { this.context = checkNotNull(context, "context"); return this; } @@ -289,7 +288,7 @@ public abstract class BaseApiMetadata implements ApiMetadata { protected final Optional defaultCredential; protected final Properties defaultProperties; protected final URI documentation; - protected final TypeToken context; + protected final TypeToken context; protected final Set> defaultModules; protected BaseApiMetadata(Builder builder) { @@ -302,7 +301,7 @@ public abstract class BaseApiMetadata implements ApiMetadata { public BaseApiMetadata(String id, String name, Set> wrappers, String endpointName, String identityName, Optional credentialName, String version, Optional buildVersion, Optional defaultEndpoint, Optional defaultIdentity, Optional defaultCredential, - Properties defaultProperties, URI documentation, TypeToken context, + Properties defaultProperties, URI documentation, TypeToken context, Set> defaultModules) { this.id = checkNotNull(id, "id"); this.name = checkNotNull(name, "name"); @@ -458,7 +457,7 @@ public abstract class BaseApiMetadata implements ApiMetadata { * {@inheritDoc} */ @Override - public TypeToken getContext() { + public TypeToken getContext() { return context; } diff --git a/core/src/main/java/org/jclouds/config/BindPropertiesToExpandedValues.java b/core/src/main/java/org/jclouds/config/BindPropertiesToExpandedValues.java new file mode 100644 index 0000000000..aadab59c40 --- /dev/null +++ b/core/src/main/java/org/jclouds/config/BindPropertiesToExpandedValues.java @@ -0,0 +1,67 @@ +/** + * 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.config; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Properties; + +import javax.inject.Singleton; + +import org.jclouds.internal.FilterStringsBoundToInjectorByName; +import org.nnsoft.guice.rocoto.Rocoto; +import org.nnsoft.guice.rocoto.configuration.ConfigurationModule; + +import com.google.common.base.Predicates; +import com.google.inject.AbstractModule; +import com.google.inject.Provides; + +/** + * expands properties. + * + * @author Adrian Cole + */ +public class BindPropertiesToExpandedValues extends AbstractModule { + private final Properties resolved; + + public BindPropertiesToExpandedValues(Properties resolved) { + this.resolved = checkNotNull(resolved, "resolved"); + } + + @Override + protected void configure() { + install(Rocoto.expandVariables(new ConfigurationModule() { + + @Override + protected void bindConfigurations() { + bindProperties(resolved); + } + + @SuppressWarnings("unused") + @Provides + @Singleton + protected Properties expanded(FilterStringsBoundToInjectorByName filterStringsBoundByName) { + Properties props = new Properties(); + props.putAll(filterStringsBoundByName.apply(Predicates. alwaysTrue())); + return props; + } + })); + } + +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/config/BindRestContextWithWildcardExtendsExplicitAndRawType.java b/core/src/main/java/org/jclouds/config/BindRestContextWithWildcardExtendsExplicitAndRawType.java new file mode 100644 index 0000000000..6f7cd9eadd --- /dev/null +++ b/core/src/main/java/org/jclouds/config/BindRestContextWithWildcardExtendsExplicitAndRawType.java @@ -0,0 +1,69 @@ +/** + * 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.config; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import org.jclouds.rest.RestApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.internal.BaseRestApiMetadata; +import org.jclouds.rest.internal.RestContextImpl; + +import com.google.common.reflect.TypeToken; +import com.google.inject.AbstractModule; +import com.google.inject.TypeLiteral; +import com.google.inject.util.Types; + +/** + * Allows you to lookup the {@link RestApiMetadata#getContext()} as {@link RestContext}, {@code RestContext}, and {@code + * + * @author Adrian Cole + */ +public class BindRestContextWithWildcardExtendsExplicitAndRawType extends AbstractModule { + private final RestApiMetadata restApiMetadata; + + public BindRestContextWithWildcardExtendsExplicitAndRawType(RestApiMetadata restApiMetadata) + throws IllegalArgumentException { + this.restApiMetadata = checkNotNull(restApiMetadata, "restApiMetadata"); + checkArgument(restApiMetadata.getContext().getRawType().equals(RestContext.class), + "this does not work as %s raw type is not RestContext", restApiMetadata.getContext()); + } + + @SuppressWarnings("unchecked") + @Override + protected void configure() { + TypeToken concreteType = BaseRestApiMetadata.contextToken(TypeToken.of(restApiMetadata.getApi()), TypeToken + .of(restApiMetadata.getAsyncApi())); + // bind explicit type + bind(TypeLiteral.get(concreteType.getType())).to( + (TypeLiteral) TypeLiteral.get(Types.newParameterizedType(RestContextImpl.class, + restApiMetadata.getApi(), restApiMetadata.getAsyncApi()))); + // bind potentially wildcard type + if (!concreteType.equals(restApiMetadata.getContext())) { + bind(TypeLiteral.get(restApiMetadata.getContext().getType())).to( + (TypeLiteral) TypeLiteral.get(Types.newParameterizedType(RestContextImpl.class, restApiMetadata + .getApi(), restApiMetadata.getAsyncApi()))); + } + // bind w/o types + bind(TypeLiteral.get(RestContext.class)).to( + (TypeLiteral) TypeLiteral.get(Types.newParameterizedType(RestContextImpl.class, + restApiMetadata.getApi(), restApiMetadata.getAsyncApi()))); + } +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/http/filters/BasicAuthentication.java b/core/src/main/java/org/jclouds/http/filters/BasicAuthentication.java index ce411075eb..d87ab918f1 100644 --- a/core/src/main/java/org/jclouds/http/filters/BasicAuthentication.java +++ b/core/src/main/java/org/jclouds/http/filters/BasicAuthentication.java @@ -19,13 +19,8 @@ package org.jclouds.http.filters; import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.Constants.PROPERTY_CREDENTIAL; -import static org.jclouds.Constants.PROPERTY_IDENTITY; - -import java.io.UnsupportedEncodingException; import javax.inject.Inject; -import javax.inject.Named; import javax.inject.Singleton; import javax.ws.rs.core.HttpHeaders; @@ -35,6 +30,8 @@ import org.jclouds.http.HttpException; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequestFilter; import org.jclouds.http.utils.ModifyRequest; +import org.jclouds.rest.annotations.Credential; +import org.jclouds.rest.annotations.Identity; /** * Uses Basic Authentication to sign the request. @@ -49,11 +46,10 @@ public class BasicAuthentication implements HttpRequestFilter { private final String header; @Inject - public BasicAuthentication(@Named(PROPERTY_IDENTITY) String user, @Named(PROPERTY_CREDENTIAL) String password, - Crypto crypto) throws UnsupportedEncodingException { + public BasicAuthentication(@Identity String user, @Credential String password, Crypto crypto) { this.header = "Basic " - + CryptoStreams.base64(String.format("%s:%s", checkNotNull(user, "user"), - checkNotNull(password, "password")).getBytes("UTF-8")); + + CryptoStreams.base64(String.format("%s:%s", checkNotNull(user, "user"), + checkNotNull(password, "password")).getBytes()); } @Override diff --git a/core/src/main/java/org/jclouds/internal/BaseWrapper.java b/core/src/main/java/org/jclouds/internal/BaseWrapper.java index d93ac915a7..745dd5d214 100644 --- a/core/src/main/java/org/jclouds/internal/BaseWrapper.java +++ b/core/src/main/java/org/jclouds/internal/BaseWrapper.java @@ -21,56 +21,56 @@ import static com.google.common.base.Objects.equal; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; -import java.io.Closeable; - import javax.inject.Singleton; +import org.jclouds.Context; import org.jclouds.Wrapper; import org.jclouds.location.Provider; import com.google.common.base.Objects; import com.google.common.base.Objects.ToStringHelper; +import com.google.common.collect.ForwardingObject; import com.google.common.reflect.TypeToken; /** * @author Adrian Cole */ @Singleton -public abstract class BaseWrapper implements Wrapper { +public abstract class BaseWrapper extends ForwardingObject implements Wrapper { - private final Closeable wrapped; - private final TypeToken wrappedType; + private final Context wrapped; + private final TypeToken wrappedType; - - protected BaseWrapper(@Provider Closeable wrapped, @Provider TypeToken wrappedType) { + protected BaseWrapper(@Provider Context wrapped, @Provider TypeToken wrappedType) { this.wrapped = checkNotNull(wrapped, "wrapped"); this.wrappedType = checkNotNull(wrappedType, "wrappedType"); } - + @SuppressWarnings("unchecked") @Override - public C unwrap(TypeToken type) { + public C unwrap(TypeToken type) { checkArgument(checkNotNull(type, "type").isAssignableFrom(wrappedType), "wrapped type: %s not assignable from %s", wrappedType, type); return (C) wrapped; } @Override - public C unwrap(Class clazz) { + public C unwrap(Class clazz) { return unwrap (TypeToken.of(checkNotNull(clazz, "clazz"))); } @Override - public TypeToken getWrappedType() { + public TypeToken getWrappedType() { return wrappedType; } @SuppressWarnings("unchecked") @Override - public C unwrap() throws ClassCastException { + public C unwrap() throws ClassCastException { return (C) unwrap(getWrappedType()); } - public Closeable getWrapped() { + @Override + protected Context delegate() { return wrapped; } @@ -81,12 +81,12 @@ public abstract class BaseWrapper implements Wrapper { if (o == null || getClass() != o.getClass()) return false; BaseWrapper that = BaseWrapper.class.cast(o); - return equal(this.getWrapped(), that.getWrapped()) && equal(this.getWrappedType(), that.getWrappedType()); + return equal(this.delegate(), that.delegate()) && equal(this.getWrappedType(), that.getWrappedType()); } @Override public int hashCode() { - return Objects.hashCode(getWrapped(), getWrappedType()); + return Objects.hashCode(delegate(), getWrappedType()); } @Override @@ -95,7 +95,7 @@ public abstract class BaseWrapper implements Wrapper { } protected ToStringHelper string() { - return Objects.toStringHelper("").add("wrapped", getWrapped()).add("wrappedType", getWrappedType()); + return Objects.toStringHelper("").add("wrapped", delegate()).add("wrappedType", getWrappedType()); } diff --git a/core/src/main/java/org/jclouds/internal/ContextImpl.java b/core/src/main/java/org/jclouds/internal/ContextImpl.java new file mode 100644 index 0000000000..114b24917e --- /dev/null +++ b/core/src/main/java/org/jclouds/internal/ContextImpl.java @@ -0,0 +1,220 @@ +/** + * 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.internal; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.net.URI; +import java.util.Map; +import java.util.Set; + +import javax.inject.Inject; + +import org.jclouds.Context; +import org.jclouds.domain.Credentials; +import org.jclouds.domain.Location; +import org.jclouds.domain.LocationScope; +import org.jclouds.lifecycle.Closer; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.Utils; +import org.jclouds.rest.annotations.Identity; + +import com.google.common.base.Objects; +import com.google.common.collect.ImmutableMap; +import com.google.common.io.Closeables; +import com.google.inject.Singleton; + +/** + * @author Adrian Cole + */ +@Singleton +public class ContextImpl implements Context { + + private final ProviderMetadata providerMetadata; + private final String identity; + private final Utils utils; + private final Closer closer; + + @Inject + protected ContextImpl(ProviderMetadata providerMetadata, @Identity String identity, Utils utils, Closer closer) { + this.providerMetadata = checkNotNull(providerMetadata, "providerMetadata"); + this.identity = checkNotNull(identity, "identity"); + this.utils = checkNotNull(utils, "utils"); + this.closer = checkNotNull(closer, "closer"); + } + + /** + * {@inheritDoc} + */ + @Override + public void close() { + Closeables.closeQuietly(closer); + } + + /** + * {@inheritDoc} + */ + @Override + public ProviderMetadata getProviderMetadata() { + return providerMetadata; + } + + /** + * {@inheritDoc} + */ + @Override + public String getIdentity() { + return identity; + } + + /** + * {@inheritDoc} + */ + @Override + public URI getEndpoint() { + return URI.create(providerMetadata.getEndpoint()); + } + + /** + * {@inheritDoc} + */ + @Override + public Utils getUtils() { + return utils(); + } + + @Override + public Utils utils() { + return utils; + } + + /** + * {@inheritDoc} + */ + @Override + public String getApiVersion() { + return providerMetadata.getApiMetadata().getVersion(); + } + + /** + * {@inheritDoc} + */ + @Override + public String getBuildVersion() { + return providerMetadata.getApiMetadata().getBuildVersion().orNull(); + } + + /** + * {@inheritDoc} + */ + @Override + public int hashCode() { + return Objects.hashCode(providerMetadata, identity); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ContextImpl that = ContextImpl.class.cast(obj); + return Objects.equal(this.providerMetadata, that.providerMetadata) && Objects.equal(this.identity, that.identity); + } + + /** + * {@inheritDoc} + */ + @Override + public String toString() { + return Objects.toStringHelper("").add("providerMetadata", providerMetadata).add("identity", identity).toString(); + } + + /** + * {@inheritDoc} + */ + @Override + public String getDescription() { + return providerMetadata.getName(); + } + + /** + * {@inheritDoc} + */ + @Override + public String getId() { + return providerMetadata.getId(); + } + + /** + * {@inheritDoc} + */ + @Override + public Set getIso3166Codes() { + return providerMetadata.getIso3166Codes(); + } + + /** + * {@inheritDoc} + */ + @Override + public Map getMetadata() { + return ImmutableMap. of("endpoint", URI.create(providerMetadata.getEndpoint()), "apiVersion", + providerMetadata.getApiMetadata().getVersion(), "buildVersion", providerMetadata.getApiMetadata() + .getBuildVersion().or(""), "identity", identity); + } + + /** + * {@inheritDoc} + */ + @Override + public Location getParent() { + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public LocationScope getScope() { + return LocationScope.PROVIDER; + } + + /** + * {@inheritDoc} + */ + @Override + public Map credentialStore() { + return utils().credentialStore(); + } + + /** + * {@inheritDoc} + */ + @Override + public Map getCredentialStore() { + return utils().credentialStore(); + } + +} diff --git a/core/src/main/java/org/jclouds/location/suppliers/ProviderURISupplier.java b/core/src/main/java/org/jclouds/location/suppliers/ProviderURISupplier.java index 079b586c8e..d0537691be 100644 --- a/core/src/main/java/org/jclouds/location/suppliers/ProviderURISupplier.java +++ b/core/src/main/java/org/jclouds/location/suppliers/ProviderURISupplier.java @@ -20,12 +20,12 @@ package org.jclouds.location.suppliers; import java.net.URI; -import org.jclouds.location.suppliers.fromconfig.ProviderURIFromConfiguration; +import org.jclouds.location.suppliers.fromconfig.ProviderURIFromProviderMetadata; import com.google.common.base.Supplier; import com.google.inject.ImplementedBy; -@ImplementedBy(ProviderURIFromConfiguration.class) +@ImplementedBy(ProviderURIFromProviderMetadata.class) public interface ProviderURISupplier extends Supplier { } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/location/suppliers/fromconfig/ProviderURIFromConfiguration.java b/core/src/main/java/org/jclouds/location/suppliers/fromconfig/ProviderURIFromProviderMetadata.java similarity index 74% rename from core/src/main/java/org/jclouds/location/suppliers/fromconfig/ProviderURIFromConfiguration.java rename to core/src/main/java/org/jclouds/location/suppliers/fromconfig/ProviderURIFromProviderMetadata.java index 8ac08ad01b..e1ac203739 100644 --- a/core/src/main/java/org/jclouds/location/suppliers/fromconfig/ProviderURIFromConfiguration.java +++ b/core/src/main/java/org/jclouds/location/suppliers/fromconfig/ProviderURIFromProviderMetadata.java @@ -18,22 +18,19 @@ */ package org.jclouds.location.suppliers.fromconfig; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.jclouds.Constants.PROPERTY_ENDPOINT; - import javax.inject.Inject; -import javax.inject.Named; import javax.inject.Singleton; import org.jclouds.location.suppliers.ProviderURISupplier; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.suppliers.URIFromStringSupplier; @Singleton -public class ProviderURIFromConfiguration extends URIFromStringSupplier implements +public class ProviderURIFromProviderMetadata extends URIFromStringSupplier implements ProviderURISupplier { @Inject - protected ProviderURIFromConfiguration(@Named(PROPERTY_ENDPOINT) String endpoint) { - super(checkNotNull(endpoint, PROPERTY_ENDPOINT)); + protected ProviderURIFromProviderMetadata(ProviderMetadata in) { + super(in.getEndpoint()); } } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/providers/ProviderPredicates.java b/core/src/main/java/org/jclouds/providers/ProviderPredicates.java index a36636226d..5079189422 100644 --- a/core/src/main/java/org/jclouds/providers/ProviderPredicates.java +++ b/core/src/main/java/org/jclouds/providers/ProviderPredicates.java @@ -18,8 +18,7 @@ */ package org.jclouds.providers; -import java.io.Closeable; - +import org.jclouds.Context; import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; import org.jclouds.apis.ApiPredicates; @@ -38,9 +37,9 @@ import com.google.common.reflect.TypeToken; public class ProviderPredicates { public static class ContextAssignableFrom implements Predicate { - private final TypeToken type; + private final TypeToken type; - public ContextAssignableFrom(TypeToken type) { + public ContextAssignableFrom(TypeToken type) { Preconditions.checkNotNull(type, "context must be defined"); this.type = type; } @@ -261,7 +260,7 @@ public class ProviderPredicates { * * @return the providers with an context assignable from the given type. */ - public static Predicate contextAssignableFrom(final TypeToken type) { + public static Predicate contextAssignableFrom(final TypeToken type) { return new ContextAssignableFrom(type); } diff --git a/core/src/main/java/org/jclouds/providers/Providers.java b/core/src/main/java/org/jclouds/providers/Providers.java index b866e699ba..8ec2ffb4ae 100644 --- a/core/src/main/java/org/jclouds/providers/Providers.java +++ b/core/src/main/java/org/jclouds/providers/Providers.java @@ -21,10 +21,10 @@ package org.jclouds.providers; import static com.google.common.collect.Iterables.filter; import static com.google.common.collect.Iterables.find; -import java.io.Closeable; import java.util.NoSuchElementException; import java.util.ServiceLoader; +import org.jclouds.Context; import org.jclouds.Wrapper; import org.jclouds.apis.ApiMetadata; @@ -137,8 +137,8 @@ public class Providers { * * @return the providers of the provided context */ - public static Iterable contextAssignableFrom( - TypeToken context) { + public static Iterable contextAssignableFrom( + TypeToken context) { Preconditions.checkNotNull(context, "context must be defined"); return filter(all(), new ProviderPredicates.ContextAssignableFrom(context)); } diff --git a/core/src/main/java/org/jclouds/providers/config/BindProviderMetadataContextAndCredentials.java b/core/src/main/java/org/jclouds/providers/config/BindProviderMetadataContextAndCredentials.java new file mode 100644 index 0000000000..140902c685 --- /dev/null +++ b/core/src/main/java/org/jclouds/providers/config/BindProviderMetadataContextAndCredentials.java @@ -0,0 +1,97 @@ +/** + * 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.providers.config; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Properties; +import java.util.Set; + +import javax.inject.Singleton; + +import org.jclouds.Context; +import org.jclouds.domain.Credentials; +import org.jclouds.location.Iso3166; +import org.jclouds.location.Provider; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.annotations.Api; +import org.jclouds.rest.annotations.ApiVersion; +import org.jclouds.rest.annotations.BuildVersion; +import org.jclouds.rest.annotations.Credential; +import org.jclouds.rest.annotations.Identity; + +import com.google.common.reflect.TypeToken; +import com.google.inject.AbstractModule; +import com.google.inject.Injector; +import com.google.inject.Key; +import com.google.inject.Provides; +import com.google.inject.TypeLiteral; +import com.google.inject.name.Names; + +/** + * Binds data inside {@link ProviderMetadata} to types with scopes qualified with annotations in the + * {@code org.jclouds.location} and {@code org.jclouds.rest.annotations} packages. It also binds the + * properties specified in {@link ProviderMetadata#getDefaultProperties()} {@link ProviderMetadata} + * explicitly. Finally, it bind the context type so that it can be looked up later. + * + * + * @author Adrian Cole + */ +public class BindProviderMetadataContextAndCredentials extends AbstractModule { + + private final ProviderMetadata providerMetadata; + private final Credentials creds; + + public BindProviderMetadataContextAndCredentials(ProviderMetadata providerMetadata, Credentials creds) { + this.providerMetadata = checkNotNull(providerMetadata, "providerMetadata"); + this.creds = checkNotNull(creds, "creds"); + } + + @Override + protected void configure() { + bind(ProviderMetadata.class).toInstance(providerMetadata); + Properties toBind = new Properties(); + toBind.putAll(providerMetadata.getApiMetadata().getDefaultProperties()); + toBind.putAll(providerMetadata.getDefaultProperties()); + Names.bindProperties(binder(), toBind); + bind(Credentials.class).annotatedWith(Provider.class).toInstance(creds); + bindConstant().annotatedWith(Identity.class).to(creds.identity); + // nullable + bind(String.class).annotatedWith(Credential.class).toProvider( + com.google.inject.util.Providers.of(creds.credential)); + bindConstant().annotatedWith(Provider.class).to(providerMetadata.getId()); + bind(new TypeLiteral>() { + }).annotatedWith(Iso3166.class).toInstance(providerMetadata.getIso3166Codes()); + bindConstant().annotatedWith(Api.class).to(providerMetadata.getApiMetadata().getId()); + bindConstant().annotatedWith(ApiVersion.class).to(providerMetadata.getApiMetadata().getVersion()); + // nullable + bind(String.class).annotatedWith(BuildVersion.class).toProvider( + com.google.inject.util.Providers.of(providerMetadata.getApiMetadata().getBuildVersion().orNull())); + bind(new TypeLiteral>() { + }).annotatedWith(Provider.class).toInstance(providerMetadata.getApiMetadata().getContext()); + } + + @Provides + @Provider + @Singleton + protected Context wrapped(Injector i, @Provider TypeToken wrappedType) { + return Context.class.cast(i.getInstance(Key.get(TypeLiteral.get(wrappedType.getType())))); + } + +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/providers/internal/UpdateProviderMetadataFromProperties.java b/core/src/main/java/org/jclouds/providers/internal/UpdateProviderMetadataFromProperties.java new file mode 100644 index 0000000000..7fd5ee6b95 --- /dev/null +++ b/core/src/main/java/org/jclouds/providers/internal/UpdateProviderMetadataFromProperties.java @@ -0,0 +1,102 @@ +/** + * 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.providers.internal; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Predicates.equalTo; +import static com.google.common.base.Predicates.not; +import static com.google.common.collect.Iterables.filter; +import static org.jclouds.Constants.PROPERTY_API; +import static org.jclouds.Constants.PROPERTY_API_VERSION; +import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; +import static org.jclouds.Constants.PROPERTY_ENDPOINT; +import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; +import static org.jclouds.Constants.PROPERTY_PROVIDER; + +import java.util.Properties; + +import org.jclouds.apis.ApiMetadata; +import org.jclouds.providers.AnonymousProviderMetadata; +import org.jclouds.providers.ProviderMetadata; + +import com.google.common.base.Function; +import com.google.common.base.Joiner; +import com.google.common.base.Optional; +import com.google.common.base.Splitter; + +/** + * Updates {@link ProviderMetadata} carrying over the input {@code Properties}, filtering out those which are typed fields in {@link ProviderMetadata} or {@link ApiMetadata} + * + * @author Adrian Cole + */ +public class UpdateProviderMetadataFromProperties implements Function { + private final ApiMetadata apiMetadata; + private final Optional providerMetadata; + + public UpdateProviderMetadataFromProperties(ProviderMetadata providerMetadata) { + this(checkNotNull(providerMetadata, "providerMetadata").getApiMetadata(), Optional.of(providerMetadata)); + } + + public UpdateProviderMetadataFromProperties(ApiMetadata apiMetadata) { + this(checkNotNull(apiMetadata, "apiMetadata"), Optional. absent()); + } + + public UpdateProviderMetadataFromProperties(ApiMetadata apiMetadata, Optional providerMetadata) { + this.apiMetadata = checkNotNull(apiMetadata, "apiMetadata"); + this.providerMetadata = checkNotNull(providerMetadata, "providerMetadata"); + } + + @Override + public ProviderMetadata apply(Properties input) { + Properties mutable = new Properties(); + mutable.putAll(input); + ApiMetadata apiMetadata = this.apiMetadata.toBuilder() + .name(getAndRemove(mutable, PROPERTY_API, this.apiMetadata.getName())) + .version(getAndRemove(mutable, PROPERTY_API_VERSION, this.apiMetadata.getVersion())) + .buildVersion(getAndRemove(mutable, PROPERTY_BUILD_VERSION, this.apiMetadata.getBuildVersion().orNull())).build(); + + String endpoint = getAndRemove(mutable, PROPERTY_ENDPOINT, providerMetadata.isPresent() ? providerMetadata.get() + .getEndpoint() : null); + + String providerId = getAndRemove(mutable, PROPERTY_PROVIDER, providerMetadata.isPresent() ? providerMetadata.get() + .getId() : apiMetadata.getId()); + + String isoCodes = getAndRemove(mutable, PROPERTY_ISO3166_CODES, providerMetadata.isPresent() ? Joiner.on(',').join(providerMetadata.get() + .getIso3166Codes()) : ""); + + ProviderMetadata providerMetadata = this.providerMetadata + .or(AnonymousProviderMetadata.forApiWithEndpoint(apiMetadata, checkNotNull(endpoint, PROPERTY_ENDPOINT))) + .toBuilder() + .apiMetadata(apiMetadata) + .id(providerId) + .iso3166Codes(filter(Splitter.on(',').split(isoCodes), not(equalTo("")))) + .endpoint(endpoint).defaultProperties(mutable).build(); + + return providerMetadata; + } + + private static String getAndRemove(Properties expanded, String key, String defaultVal) { + try { + return expanded.getProperty(key, defaultVal); + } finally { + expanded.remove(key); + } + } + +} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/Providers.java b/core/src/main/java/org/jclouds/rest/Providers.java index 7056cfceec..3a157c7f50 100644 --- a/core/src/main/java/org/jclouds/rest/Providers.java +++ b/core/src/main/java/org/jclouds/rest/Providers.java @@ -18,8 +18,7 @@ */ package org.jclouds.rest; -import java.io.Closeable; - +import org.jclouds.Context; import org.jclouds.Wrapper; import org.jclouds.apis.Apis; @@ -48,7 +47,7 @@ public class Providers { * (supported-clouds). * */ - public static Iterable getSupportedProvidersOfType(TypeToken type) { + public static Iterable getSupportedProvidersOfType(TypeToken type) { Builder builder = ImmutableSet. builder(); builder.addAll(Iterables.transform(Apis.contextWrappableAs(type), Apis.idFunction())); builder.addAll(Iterables.transform(org.jclouds.providers.Providers.contextWrappableAs(type), diff --git a/core/src/main/java/org/jclouds/rest/RestContext.java b/core/src/main/java/org/jclouds/rest/RestContext.java index f564ace886..4a43cafcaf 100644 --- a/core/src/main/java/org/jclouds/rest/RestContext.java +++ b/core/src/main/java/org/jclouds/rest/RestContext.java @@ -18,17 +18,11 @@ */ package org.jclouds.rest; -import java.io.Closeable; -import java.net.URI; -import java.util.Map; import java.util.concurrent.Future; -import org.jclouds.Constants; -import org.jclouds.domain.Credentials; -import org.jclouds.domain.Location; +import org.jclouds.Context; import org.jclouds.rest.internal.RestContextImpl; -import com.google.common.annotations.Beta; import com.google.inject.ImplementedBy; /** @@ -42,7 +36,7 @@ import com.google.inject.ImplementedBy; * */ @ImplementedBy(RestContextImpl.class) -public interface RestContext extends Location, Closeable { +public interface RestContext extends Context { /** * low-level api to the cloud. Threadsafe implementations will return a singleton. @@ -59,45 +53,4 @@ public interface RestContext extends Location, Closeable { */ S getApi(); - URI getEndpoint(); - - /** - * @return version of the api presented by this service - * @see Constants#PROPERTY_API_VERSION - */ - String getApiVersion(); - - /** - * @return version of software this service is running - * @see Constants#PROPERTY_BUILD_VERSION - */ - String getBuildVersion(); - - String getIdentity(); - - /** - * retrieves a list of credentials for resources created within this context, keyed on {@code id} - * of the resource. We are testing this approach for resources such as compute nodes, where you - * could access this externally. - * - */ - @Beta - Map getCredentialStore(); - - @Beta - Map credentialStore(); - - Utils getUtils(); - - /** - * @see #getUtils - */ - Utils utils(); - - /** - * Closes all connections to Cloud Files. - */ - @Override - void close(); - } \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/Utils.java b/core/src/main/java/org/jclouds/rest/Utils.java index b3f0408987..5f233df8af 100644 --- a/core/src/main/java/org/jclouds/rest/Utils.java +++ b/core/src/main/java/org/jclouds/rest/Utils.java @@ -18,10 +18,12 @@ */ package org.jclouds.rest; +import java.util.Map; import java.util.concurrent.ExecutorService; import org.jclouds.crypto.Crypto; import org.jclouds.date.DateService; +import org.jclouds.domain.Credentials; import org.jclouds.json.Json; import org.jclouds.logging.Logger.LoggerFactory; import org.jclouds.rest.internal.UtilsImpl; @@ -41,6 +43,31 @@ import com.google.inject.Injector; @ImplementedBy(UtilsImpl.class) public interface Utils { + /** + * retrieves a list of credentials for resources created within this context, keyed on {@code id} + * of the resource with a namespace prefix (ex. {@code node#}. We are testing this approach for + * resources such as compute nodes, where you could access this externally. + *

+ *

accessing credentials for a node

+ *

+ * the key is in the form {@code node#id}. + *

    + *
  • if the node id is {@code 8}, then the key will be {@code node#8}
  • + *
  • if the node id is {@code us-east-1/i-asdfdas}, then the key will be {@code + * node#us-east-1/i-asdfdas}
  • + *
  • if the node id is {@code http://cloud/instances/1}, then the key will be {@code + * node#http://cloud/instances/1}
  • + *
+ */ + @Beta + Map getCredentialStore(); + + /** + * @see ComputeServiceContext#getCredentialStore + */ + @Beta + Map credentialStore(); + Json getJson(); /** diff --git a/core/src/main/java/org/jclouds/rest/config/BindPropertiesToAnnotations.java b/core/src/main/java/org/jclouds/rest/config/BindPropertiesToAnnotations.java deleted file mode 100644 index 76c8a954b9..0000000000 --- a/core/src/main/java/org/jclouds/rest/config/BindPropertiesToAnnotations.java +++ /dev/null @@ -1,159 +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.config; - -import static com.google.common.base.Predicates.equalTo; -import static com.google.common.base.Predicates.not; -import static com.google.common.base.Splitter.on; -import static com.google.common.collect.Iterables.filter; -import static org.jclouds.Constants.PROPERTY_API; -import static org.jclouds.Constants.PROPERTY_API_VERSION; -import static org.jclouds.Constants.PROPERTY_BUILD_VERSION; -import static org.jclouds.Constants.PROPERTY_CREDENTIAL; -import static org.jclouds.Constants.PROPERTY_IDENTITY; -import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; -import static org.jclouds.Constants.PROPERTY_PROVIDER; -import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX; - -import java.util.Map; -import java.util.Set; - -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.config.ValueOfConfigurationKeyOrNull; -import org.jclouds.domain.Credentials; -import org.jclouds.internal.FilterStringsBoundToInjectorByName; -import org.jclouds.javax.annotation.Nullable; -import org.jclouds.location.Iso3166; -import org.jclouds.location.Provider; -import org.jclouds.rest.annotations.Api; -import org.jclouds.rest.annotations.ApiVersion; -import org.jclouds.rest.annotations.BuildVersion; -import org.jclouds.rest.annotations.Credential; -import org.jclouds.rest.annotations.Identity; -import org.jclouds.util.Maps2; -import org.nnsoft.guice.rocoto.configuration.ConfigurationModule; - -import com.google.common.base.Function; -import com.google.common.base.Predicate; -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Maps; -import com.google.inject.Provides; -import com.google.inject.TypeLiteral; - -public class BindPropertiesToAnnotations extends ConfigurationModule { - - @Provides - @Singleton - @Named("TIMEOUTS") - protected Map timeouts(Function, Map> filterStringsBoundByName) { - Map stringBoundWithTimeoutPrefix = filterStringsBoundByName.apply(new Predicate() { - - @Override - public boolean apply(String input) { - return input.startsWith(PROPERTY_TIMEOUTS_PREFIX); - } - - }); - - Map longsByName = Maps.transformValues(stringBoundWithTimeoutPrefix, new Function() { - - @Override - public Long apply(String input) { - return Long.valueOf(String.valueOf(input)); - } - - }); - return Maps2.transformKeys(longsByName, new Function() { - - @Override - public String apply(String input) { - return input.replaceFirst(PROPERTY_TIMEOUTS_PREFIX, ""); - } - - }); - - } - - @Provides - @Singleton - @Provider - protected String bindProvider(@Named(PROPERTY_PROVIDER) String in){ - return in; - } - - @Provides - @Singleton - @Iso3166 - protected Set bindIsoCodes(@Named(PROPERTY_ISO3166_CODES) String in){ - return ImmutableSet.copyOf(filter(on(',').split( in), - not(equalTo("")))); - } - - @Provides - @Singleton - @Api - protected String bindApi(@Named(PROPERTY_API) String in){ - return in; - } - - @Provides - @Singleton - @ApiVersion - protected String bindApiVersion(@Named(PROPERTY_API_VERSION) String in){ - return in; - } - - @Provides - @Singleton - @BuildVersion - protected String bindBuildVersion(@Named(PROPERTY_BUILD_VERSION) String in){ - return in; - } - - @Provides - @Singleton - @Identity - protected String bindIdentity(@Named(PROPERTY_IDENTITY) String in){ - return in; - } - - @Provides - @Singleton - @Credential - @Nullable - protected String bindCredential(ValueOfConfigurationKeyOrNull config){ - return config.apply(PROPERTY_CREDENTIAL); - } - - @Provides - @Singleton - @Provider - protected Credentials bindProviderCredentials(@Identity String identity, @Nullable @Credential String credential){ - return new Credentials(identity, credential); - } - - @Override - protected void bindConfigurations() { - bind(new TypeLiteral, Map>>() { - }).to(FilterStringsBoundToInjectorByName.class); - } - -} \ No newline at end of file diff --git a/core/src/main/java/org/jclouds/rest/config/RestModule.java b/core/src/main/java/org/jclouds/rest/config/RestModule.java index 429fd59571..4b5e19f829 100644 --- a/core/src/main/java/org/jclouds/rest/config/RestModule.java +++ b/core/src/main/java/org/jclouds/rest/config/RestModule.java @@ -18,6 +18,8 @@ */ package org.jclouds.rest.config; +import static org.jclouds.Constants.PROPERTY_TIMEOUTS_PREFIX; + import java.net.URI; import java.util.Map; import java.util.concurrent.atomic.AtomicReference; @@ -34,6 +36,7 @@ import org.jclouds.http.TransformingHttpCommandExecutorService; import org.jclouds.http.TransformingHttpCommandImpl; import org.jclouds.http.functions.config.SaxParserModule; import org.jclouds.internal.ClassMethodArgs; +import org.jclouds.internal.FilterStringsBoundToInjectorByName; import org.jclouds.json.config.GsonModule; import org.jclouds.location.config.LocationModule; import org.jclouds.rest.AsyncClientFactory; @@ -44,13 +47,16 @@ import org.jclouds.rest.binders.BindToJsonPayloadWrappedWith; import org.jclouds.rest.internal.AsyncRestClientProxy; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.SeedAnnotationCache; +import org.jclouds.util.Maps2; import com.google.common.base.Function; +import com.google.common.base.Predicate; import com.google.common.base.Supplier; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Maps; import com.google.inject.AbstractModule; import com.google.inject.Inject; import com.google.inject.Injector; @@ -96,8 +102,42 @@ public class RestModule extends AbstractModule { // this will help short circuit scenarios that can otherwise lock out users bind(new TypeLiteral>() { }).toInstance(authException); + bind(new TypeLiteral, Map>>() { + }).to(FilterStringsBoundToInjectorByName.class); installLocations(); } + + @Provides + @Singleton + @Named("TIMEOUTS") + protected Map timeouts(Function, Map> filterStringsBoundByName) { + Map stringBoundWithTimeoutPrefix = filterStringsBoundByName.apply(new Predicate() { + + @Override + public boolean apply(String input) { + return input.startsWith(PROPERTY_TIMEOUTS_PREFIX); + } + + }); + + Map longsByName = Maps.transformValues(stringBoundWithTimeoutPrefix, new Function() { + + @Override + public Long apply(String input) { + return Long.valueOf(String.valueOf(input)); + } + + }); + return Maps2.transformKeys(longsByName, new Function() { + + @Override + public String apply(String input) { + return input.replaceFirst(PROPERTY_TIMEOUTS_PREFIX, ""); + } + + }); + + } @Provides @Singleton diff --git a/core/src/main/java/org/jclouds/rest/internal/RestContextImpl.java b/core/src/main/java/org/jclouds/rest/internal/RestContextImpl.java index aff8b644cf..c592d98809 100644 --- a/core/src/main/java/org/jclouds/rest/internal/RestContextImpl.java +++ b/core/src/main/java/org/jclouds/rest/internal/RestContextImpl.java @@ -18,30 +18,17 @@ */ package org.jclouds.rest.internal; -import java.io.IOException; -import java.net.URI; -import java.util.Map; -import java.util.Set; +import static com.google.common.base.Preconditions.checkNotNull; -import javax.annotation.Resource; import javax.inject.Inject; -import org.jclouds.domain.Credentials; -import org.jclouds.domain.Location; -import org.jclouds.domain.LocationScope; +import org.jclouds.internal.ContextImpl; import org.jclouds.lifecycle.Closer; -import org.jclouds.location.Iso3166; -import org.jclouds.location.Provider; -import org.jclouds.logging.Logger; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.RestContext; import org.jclouds.rest.Utils; -import org.jclouds.rest.annotations.ApiVersion; -import org.jclouds.rest.annotations.BuildVersion; import org.jclouds.rest.annotations.Identity; -import com.google.common.base.Objects; -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableMap; import com.google.inject.Injector; import com.google.inject.Key; import com.google.inject.Singleton; @@ -51,57 +38,18 @@ import com.google.inject.TypeLiteral; * @author Adrian Cole */ @Singleton -public class RestContextImpl implements RestContext { +public class RestContextImpl extends ContextImpl implements RestContext { - @Resource - private Logger logger = Logger.NULL; private final A asyncApi; private final S syncApi; - private final Closer closer; - private final Supplier endpoint; - private final String identity; - private final String provider; - private final String apiVersion; - private final String buildVersion; - private final Utils utils; - private final Map credentialStore; - private final Set iso3166Codes; @Inject - protected RestContextImpl(Closer closer, Map credentialStore, Utils utils, Injector injector, - TypeLiteral syncApi, TypeLiteral asyncApi, @Provider Supplier endpoint, @Provider String provider, - @Identity String identity, @ApiVersion String apiVersion, @BuildVersion String buildVersion, - @Iso3166 Set iso3166Codes) { - this.credentialStore = credentialStore; - this.utils = utils; - this.asyncApi = injector.getInstance(Key.get(asyncApi)); - this.syncApi = injector.getInstance(Key.get(syncApi)); - this.closer = closer; - this.endpoint = endpoint; - this.identity = identity; - this.provider = provider; - this.apiVersion = apiVersion; - this.buildVersion = buildVersion; - this.iso3166Codes = iso3166Codes; - } - - /** - * {@inheritDoc} - * - * @see Closer - */ - @Override - public void close() { - try { - closer.close(); - } catch (IOException e) { - logger.error(e, "error closing context"); - } - } - - @Override - public String getIdentity() { - return identity; + protected RestContextImpl(ProviderMetadata providerMetadata, @Identity String identity, Utils utils, Closer closer, + Injector injector, TypeLiteral syncApi, TypeLiteral asyncApi) { + super(providerMetadata, identity, utils, closer); + checkNotNull(injector, "injector"); + this.asyncApi = injector.getInstance(Key.get(checkNotNull(asyncApi, "asyncApi"))); + this.syncApi = injector.getInstance(Key.get(checkNotNull(syncApi, "syncApi"))); } @Override @@ -114,96 +62,4 @@ public class RestContextImpl implements RestContext { return syncApi; } - @Override - public URI getEndpoint() { - return endpoint.get(); - } - - @Override - public Utils getUtils() { - return utils(); - } - - @Override - public Utils utils() { - return utils; - } - - @Override - public String getApiVersion() { - return apiVersion; - } - - @Override - public String getBuildVersion() { - return buildVersion; - } - - - @Override - public int hashCode() { - return Objects.hashCode(provider, endpoint, apiVersion, buildVersion, identity); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - RestContextImpl that = (RestContextImpl) obj; - return Objects.equal(this.provider, that.provider) && Objects.equal(this.endpoint, that.endpoint) - && Objects.equal(this.apiVersion, that.apiVersion) - && Objects.equal(this.buildVersion, that.buildVersion) && Objects.equal(this.identity, that.identity); - } - - @Override - public String toString() { - return Objects.toStringHelper("").add("provider", provider).add("endpoint", endpoint).add("apiVersion", - apiVersion).add("buildVersion", buildVersion).add("identity", identity) - .add("iso3166Codes", iso3166Codes).toString(); - } - - @Override - public Map getCredentialStore() { - return credentialStore; - } - - @Override - public Map credentialStore() { - return credentialStore; - } - - @Override - public String getDescription() { - return null; - } - - @Override - public String getId() { - return provider; - } - - @Override - public Set getIso3166Codes() { - return iso3166Codes; - } - - @Override - public Map getMetadata() { - return ImmutableMap. of("endpoint", endpoint, "apiVersion", apiVersion, "buildVersion", - buildVersion, "identity", identity); - } - - @Override - public Location getParent() { - return null; - } - - @Override - public LocationScope getScope() { - return LocationScope.PROVIDER; - } } diff --git a/core/src/main/java/org/jclouds/rest/internal/UtilsImpl.java b/core/src/main/java/org/jclouds/rest/internal/UtilsImpl.java index 4860bf94dc..d4af5d7fe4 100644 --- a/core/src/main/java/org/jclouds/rest/internal/UtilsImpl.java +++ b/core/src/main/java/org/jclouds/rest/internal/UtilsImpl.java @@ -18,6 +18,7 @@ */ package org.jclouds.rest.internal; +import java.util.Map; import java.util.concurrent.ExecutorService; import javax.inject.Inject; @@ -26,6 +27,7 @@ import javax.inject.Named; import org.jclouds.Constants; import org.jclouds.crypto.Crypto; import org.jclouds.date.DateService; +import org.jclouds.domain.Credentials; import org.jclouds.json.Json; import org.jclouds.logging.Logger.LoggerFactory; import org.jclouds.rest.HttpAsyncClient; @@ -52,6 +54,7 @@ public class UtilsImpl implements Utils { private final ExecutorService userExecutor; private final ExecutorService ioExecutor; private final EventBus eventBus; + private final Map credentialStore; private final LoggerFactory loggerFactory; private Injector injector; private XMLParser xml; @@ -59,8 +62,8 @@ public class UtilsImpl implements Utils { @Inject protected UtilsImpl(Injector injector, Json json, XMLParser xml, HttpClient simpleClient, HttpAsyncClient simpleAsyncClient, Crypto encryption, DateService date, @Named(Constants.PROPERTY_USER_THREADS) ExecutorService userThreads, - @Named(Constants.PROPERTY_IO_WORKER_THREADS) ExecutorService ioThreads, EventBus eventBus, - LoggerFactory loggerFactory) { + @Named(Constants.PROPERTY_IO_WORKER_THREADS) ExecutorService ioThreads, EventBus eventBus, + Map credentialStore, LoggerFactory loggerFactory) { this.injector = injector; this.json = json; this.simpleClient = simpleClient; @@ -70,6 +73,7 @@ public class UtilsImpl implements Utils { this.userExecutor = userThreads; this.ioExecutor = ioThreads; this.eventBus = eventBus; + this.credentialStore = credentialStore; this.loggerFactory = loggerFactory; this.xml = xml; } @@ -186,4 +190,14 @@ public class UtilsImpl implements Utils { return xml; } + @Override + public Map credentialStore() { + return credentialStore; + } + + @Override + public Map getCredentialStore() { + return credentialStore; + } + } diff --git a/core/src/test/java/org/jclouds/ContextBuilderTest.java b/core/src/test/java/org/jclouds/ContextBuilderTest.java index 3d2d4a2ae0..4d9ea2788e 100644 --- a/core/src/test/java/org/jclouds/ContextBuilderTest.java +++ b/core/src/test/java/org/jclouds/ContextBuilderTest.java @@ -20,9 +20,12 @@ package org.jclouds; import static org.testng.Assert.assertEquals; +import java.net.URI; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Properties; +import java.util.Set; import org.jclouds.concurrent.config.ExecutorServiceModule; import org.jclouds.events.config.EventBusModule; @@ -30,17 +33,23 @@ import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestClient; import org.jclouds.http.config.ConfiguresHttpCommandExecutorService; import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule; +import org.jclouds.location.Provider; import org.jclouds.logging.config.LoggingModule; import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.logging.jdk.config.JDKLoggingModule; import org.jclouds.providers.AnonymousProviderMetadata; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.config.CredentialStoreModule; import org.testng.annotations.Test; +import com.google.common.base.Supplier; +import com.google.common.collect.ImmutableSet; import com.google.inject.AbstractModule; import com.google.inject.Binder; +import com.google.inject.Key; import com.google.inject.Module; +import com.google.inject.TypeLiteral; /** * Tests behavior of modules configured in ContextBuilder @@ -63,13 +72,40 @@ public class ContextBuilderTest { return ContextBuilder.newBuilder(AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint( IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost")); } + + @Test + public void testVariablesReplaceOnEndpoint() { + ContextBuilder withVariablesToReplace = testContextBuilder().endpoint("http://${jclouds.identity}.service.com") + .credentials("foo", "bar"); + URI endpoint = withVariablesToReplace.buildInjector().getInstance( + Key.get(new TypeLiteral>(){}, Provider.class)).get(); + assertEquals(endpoint, URI.create("http://foo.service.com")); + } + + @Test + public void testProviderMetadataBoundWithCorrectEndpoint() { + ContextBuilder withVariablesToReplace = testContextBuilder().endpoint("http://${jclouds.identity}.service.com") + .credentials("foo", "bar"); + String endpoint = withVariablesToReplace.buildInjector().getInstance(ProviderMetadata.class).getEndpoint(); + assertEquals(endpoint, "http://foo.service.com"); + } + + @Test + public void testProviderMetadataWithEmptyIsoCodePropertyHasEmptySet() { + Properties overrides = new Properties(); + overrides.setProperty(Constants.PROPERTY_ISO3166_CODES, ""); + ContextBuilder withVariablesToReplace = testContextBuilder().overrides(overrides).credentials("foo", "bar"); + Set codes = withVariablesToReplace.buildInjector().getInstance(ProviderMetadata.class).getIso3166Codes(); + assertEquals(codes, ImmutableSet. of()); + } + @Test public void testAddHttpModuleIfNotPresent() { List modules = new ArrayList(); HttpModule module = new HttpModule(); modules.add(module); - testContextBuilder().addHttpModuleIfNeededAndNotPresent(modules); + ContextBuilder.addHttpModuleIfNeededAndNotPresent(modules); assertEquals(modules.size(), 1); assertEquals(modules.remove(0), module); } @@ -79,7 +115,7 @@ public class ContextBuilderTest { List modules = new ArrayList(); LoggingModule module = new NullLoggingModule(); modules.add(module); - testContextBuilder().addLoggingModuleIfNotPresent(modules); + ContextBuilder.addLoggingModuleIfNotPresent(modules); assertEquals(modules.size(), 1); assertEquals(modules.remove(0), module); } @@ -89,7 +125,7 @@ public class ContextBuilderTest { List modules = new ArrayList(); EventBusModule module = new EventBusModule(); modules.add(module); - testContextBuilder().addEventBusIfNotPresent(modules); + ContextBuilder.addEventBusIfNotPresent(modules); assertEquals(modules.size(), 1); assertEquals(modules.remove(0), module); } @@ -99,7 +135,7 @@ public class ContextBuilderTest { List modules = new ArrayList(); ExecutorServiceModule module = new ExecutorServiceModule(); modules.add(module); - testContextBuilder().addExecutorServiceIfNotPresent(modules); + ContextBuilder.addExecutorServiceIfNotPresent(modules); assertEquals(modules.size(), 1); assertEquals(modules.remove(0), module); } @@ -109,7 +145,7 @@ public class ContextBuilderTest { List modules = new ArrayList(); CredentialStoreModule module = new CredentialStoreModule(); modules.add(module); - testContextBuilder().addCredentialStoreIfNotPresent(modules); + ContextBuilder.addCredentialStoreIfNotPresent(modules); assertEquals(modules.size(), 1); assertEquals(modules.remove(0), module); } @@ -121,9 +157,8 @@ public class ContextBuilderTest { modules.add(loggingModule); HttpModule httpModule = new HttpModule(); modules.add(httpModule); - ContextBuilder builder = testContextBuilder(); - builder.addHttpModuleIfNeededAndNotPresent(modules); - builder.addLoggingModuleIfNotPresent(modules); + ContextBuilder.addHttpModuleIfNeededAndNotPresent(modules); + ContextBuilder.addLoggingModuleIfNotPresent(modules); assertEquals(modules.size(), 2); assertEquals(modules.remove(0), loggingModule); assertEquals(modules.remove(0), httpModule); @@ -140,9 +175,8 @@ public class ContextBuilderTest { @Test public void testAddBothWhenDefault() { List modules = new ArrayList(); - ContextBuilder builder = testContextBuilder(); - builder.addHttpModuleIfNeededAndNotPresent(modules); - builder.addLoggingModuleIfNotPresent(modules); + ContextBuilder.addHttpModuleIfNeededAndNotPresent(modules); + ContextBuilder.addLoggingModuleIfNotPresent(modules); assertEquals(modules.size(), 2); assert modules.remove(0) instanceof JavaUrlHttpCommandExecutorServiceModule; assert modules.remove(0) instanceof JDKLoggingModule; @@ -151,9 +185,8 @@ public class ContextBuilderTest { @Test public void testAddBothWhenLive() { List modules = new ArrayList(); - ContextBuilder builder = testContextBuilder(); - builder.addHttpModuleIfNeededAndNotPresent(modules); - builder.addLoggingModuleIfNotPresent(modules); + ContextBuilder.addHttpModuleIfNeededAndNotPresent(modules); + ContextBuilder.addLoggingModuleIfNotPresent(modules); assertEquals(modules.size(), 2); assert modules.remove(0) instanceof JavaUrlHttpCommandExecutorServiceModule; assert modules.remove(0) instanceof JDKLoggingModule; diff --git a/core/src/test/java/org/jclouds/apis/Balancer.java b/core/src/test/java/org/jclouds/apis/Balancer.java index 1b6fe0be48..93c8d5cd5e 100644 --- a/core/src/test/java/org/jclouds/apis/Balancer.java +++ b/core/src/test/java/org/jclouds/apis/Balancer.java @@ -18,8 +18,7 @@ */ package org.jclouds.apis; -import java.io.Closeable; - +import org.jclouds.Context; import org.jclouds.internal.BaseWrapper; import org.jclouds.location.Provider; @@ -32,7 +31,7 @@ import com.google.inject.Inject; public class Balancer extends BaseWrapper { @Inject - public Balancer(@Provider Closeable ctx, @Provider TypeToken inputType) { + public Balancer(@Provider Context ctx, @Provider TypeToken inputType) { super(ctx, inputType); } } diff --git a/core/src/test/java/org/jclouds/apis/BaseContextLiveTest.java b/core/src/test/java/org/jclouds/apis/BaseContextLiveTest.java index deb4c08ce2..d8c2891598 100644 --- a/core/src/test/java/org/jclouds/apis/BaseContextLiveTest.java +++ b/core/src/test/java/org/jclouds/apis/BaseContextLiveTest.java @@ -20,15 +20,13 @@ package org.jclouds.apis; import static com.google.common.base.Preconditions.checkNotNull; -import java.io.Closeable; import java.util.NoSuchElementException; import java.util.Properties; import java.util.logging.Logger; import org.jclouds.Constants; +import org.jclouds.Context; import org.jclouds.ContextBuilder; -import org.jclouds.apis.ApiMetadata; -import org.jclouds.apis.Apis; import org.jclouds.logging.LoggingModules; import org.jclouds.logging.config.LoggingModule; import org.jclouds.providers.ProviderMetadata; @@ -45,7 +43,7 @@ import com.google.inject.Module; * * @author Adrian Cole */ -public abstract class BaseContextLiveTest { +public abstract class BaseContextLiveTest { protected String prefix = System.getProperty("user.name"); protected String provider; diff --git a/core/src/test/java/org/jclouds/apis/BaseWrapperLiveTest.java b/core/src/test/java/org/jclouds/apis/BaseWrapperLiveTest.java new file mode 100644 index 0000000000..8a90d06894 --- /dev/null +++ b/core/src/test/java/org/jclouds/apis/BaseWrapperLiveTest.java @@ -0,0 +1,56 @@ +/** + * 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.apis; + +import java.util.Properties; + +import org.jclouds.Context; +import org.jclouds.Wrapper; + +import com.google.common.io.Closeables; +import com.google.common.reflect.TypeToken; +import com.google.inject.Module; + +/** + * + * @author Adrian Cole + */ +public abstract class BaseWrapperLiveTest extends BaseContextLiveTest{ + + protected volatile W wrapper; + + @Override + protected void initializeContext() { + Closeables.closeQuietly(context); + wrapper = createWrapper(setupProperties(), setupModules()); + context = wrapper.unwrap(); + } + + protected abstract TypeToken wrapperType(); + + @Override + protected TypeToken contextType() { + return TypeToken.of(Context.class); + } + + protected W createWrapper(Properties props, Iterable modules) { + return newBuilder().modules(modules).overrides(props).buildAndWrapWith(wrapperType()); + } + +} diff --git a/core/src/test/java/org/jclouds/apis/Compute.java b/core/src/test/java/org/jclouds/apis/Compute.java index 41bbc31787..1f6e53b0a0 100644 --- a/core/src/test/java/org/jclouds/apis/Compute.java +++ b/core/src/test/java/org/jclouds/apis/Compute.java @@ -18,8 +18,7 @@ */ package org.jclouds.apis; -import java.io.Closeable; - +import org.jclouds.Context; import org.jclouds.internal.BaseWrapper; import org.jclouds.location.Provider; @@ -30,7 +29,7 @@ import com.google.common.reflect.TypeToken; */ public class Compute extends BaseWrapper { - public Compute(@Provider Closeable ctx, @Provider TypeToken inputType) { + public Compute(@Provider Context ctx, @Provider TypeToken inputType) { super(ctx, inputType); } } diff --git a/core/src/test/java/org/jclouds/apis/Storage.java b/core/src/test/java/org/jclouds/apis/Storage.java index b16df9976e..c4f0f8f8cf 100644 --- a/core/src/test/java/org/jclouds/apis/Storage.java +++ b/core/src/test/java/org/jclouds/apis/Storage.java @@ -18,8 +18,7 @@ */ package org.jclouds.apis; -import java.io.Closeable; - +import org.jclouds.Context; import org.jclouds.internal.BaseWrapper; import org.jclouds.location.Provider; @@ -32,7 +31,7 @@ import com.google.inject.Inject; public class Storage extends BaseWrapper { @Inject - public Storage(@Provider Closeable ctx, @Provider TypeToken inputType) { + public Storage(@Provider Context ctx, @Provider TypeToken inputType) { super(ctx, inputType); } } diff --git a/core/src/test/java/org/jclouds/config/BindPropertiesToExpandedValuesTest.java b/core/src/test/java/org/jclouds/config/BindPropertiesToExpandedValuesTest.java new file mode 100644 index 0000000000..22290b0b81 --- /dev/null +++ b/core/src/test/java/org/jclouds/config/BindPropertiesToExpandedValuesTest.java @@ -0,0 +1,49 @@ +/** + * 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.config; + +import static org.testng.Assert.assertEquals; + +import java.util.Properties; + +import org.testng.annotations.Test; + +import com.google.inject.Guice; + +/** + * Tests behavior of BindPropertiesToExpandedValues + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "BindPropertiesToExpandedValuesTest") +public class BindPropertiesToExpandedValuesTest { + + @Test + public void testExpand() { + Properties input = new Properties(); + input.setProperty("id", "1234"); + input.setProperty("path", "path:${id}"); + Properties output = Guice.createInjector(new BindPropertiesToExpandedValues(input)).getInstance(Properties.class); + + Properties expected = new Properties(); + expected.setProperty("id", "1234"); + expected.setProperty("path", "path:1234"); + assertEquals(output, expected); + } +} diff --git a/core/src/test/java/org/jclouds/config/BindRestContextWithWildcardExtendsExplicitAndRawTypeTest.java b/core/src/test/java/org/jclouds/config/BindRestContextWithWildcardExtendsExplicitAndRawTypeTest.java new file mode 100644 index 0000000000..59e201b13c --- /dev/null +++ b/core/src/test/java/org/jclouds/config/BindRestContextWithWildcardExtendsExplicitAndRawTypeTest.java @@ -0,0 +1,127 @@ +/** + * 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.config; + +import static org.easymock.EasyMock.createMock; +import static org.testng.Assert.assertEquals; + +import javax.inject.Inject; + +import org.jclouds.domain.Credentials; +import org.jclouds.http.IntegrationTestAsyncClient; +import org.jclouds.http.IntegrationTestClient; +import org.jclouds.providers.AnonymousProviderMetadata; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.providers.config.BindProviderMetadataContextAndCredentials; +import org.jclouds.rest.RestApiMetadata; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.Utils; +import org.jclouds.rest.internal.BaseRestClientTest.MockModule; +import org.testng.annotations.Test; + +import com.google.common.reflect.TypeToken; +import com.google.inject.AbstractModule; +import com.google.inject.Guice; +import com.google.inject.Injector; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "BindRestContextWithWildcardExtendsExplicitAndRawTypeTest") +public class BindRestContextWithWildcardExtendsExplicitAndRawTypeTest { + + @SuppressWarnings( { "unused", "unchecked" }) + private static class ExpectedBindings { + + private final RestContext raw; + private final RestContext explicit; + + @Inject + public ExpectedBindings(RestContext raw, + RestContext explicit) { + this.raw = raw; + this.explicit = explicit; + } + + } + + @Test + public void testRawAndExplicit() { + ProviderMetadata md = AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint( + IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost"); + + ExpectedBindings bindings = injectorFor(md).getInstance(ExpectedBindings.class); + assertEquals(bindings.raw, bindings.explicit); + } + + private Injector injectorFor(ProviderMetadata md) { + return Guice.createInjector( + new BindProviderMetadataContextAndCredentials(md, new Credentials("user", "pass")), + new BindRestContextWithWildcardExtendsExplicitAndRawType(RestApiMetadata.class.cast(md + .getApiMetadata())), + + // stuff needed for RestContextImpl + new MockModule(), + new AbstractModule() { + + @Override + protected void configure() { + bind(Utils.class).toInstance(createMock(Utils.class)); + bind(IntegrationTestClient.class).toInstance(createMock(IntegrationTestClient.class)); + bind(IntegrationTestAsyncClient.class).toInstance(createMock(IntegrationTestAsyncClient.class)); + } + }); + } + + @SuppressWarnings( { "unused", "unchecked" }) + private static class ExpectedBindingsWithWildCardExtends { + + private final RestContext raw; + private final RestContext explicit; + private final RestContext wildcardExtends; + + @Inject + public ExpectedBindingsWithWildCardExtends(RestContext raw, + RestContext explicit, + RestContext wildcardExtends) { + this.raw = raw; + this.explicit = explicit; + this.wildcardExtends = wildcardExtends; + } + + } + + @SuppressWarnings("unchecked") + @Test + public void testRawExplicitAndWildCardExtends() { + ProviderMetadata md = AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint( + IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost"); + + TypeToken wildCardExtendsType = new TypeToken>() { + private static final long serialVersionUID = -8170268554700397860L; + }; + + md = md.toBuilder().apiMetadata(md.getApiMetadata().toBuilder().context(wildCardExtendsType).build()).build(); + + ExpectedBindingsWithWildCardExtends bindings = injectorFor(md).getInstance(ExpectedBindingsWithWildCardExtends.class); + assertEquals(bindings.raw, bindings.explicit); + assertEquals(bindings.explicit, bindings.wildcardExtends); + } +} diff --git a/core/src/test/java/org/jclouds/events/config/EventBusModuleTest.java b/core/src/test/java/org/jclouds/events/config/EventBusModuleTest.java index 5deafb7df6..5992ca7293 100644 --- a/core/src/test/java/org/jclouds/events/config/EventBusModuleTest.java +++ b/core/src/test/java/org/jclouds/events/config/EventBusModuleTest.java @@ -40,9 +40,8 @@ import com.google.inject.name.Names; * * @author Ignasi Barrera */ -@Test(groups = "unit") -public class EventBusModuleTest -{ +@Test(groups = "unit", testName = "EventBusModuleTest") +public class EventBusModuleTest { private Injector injector; @BeforeMethod diff --git a/core/src/test/java/org/jclouds/internal/BaseWrapperTest.java b/core/src/test/java/org/jclouds/internal/BaseWrapperTest.java index ebda6dfbbe..e2746f2c02 100644 --- a/core/src/test/java/org/jclouds/internal/BaseWrapperTest.java +++ b/core/src/test/java/org/jclouds/internal/BaseWrapperTest.java @@ -18,12 +18,14 @@ */ package org.jclouds.internal; +import static org.easymock.EasyMock.createMock; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertNotEquals; -import java.io.Closeable; - +import org.jclouds.lifecycle.Closer; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.Utils; import org.testng.annotations.Test; import com.google.common.base.Objects; @@ -34,23 +36,38 @@ import com.google.common.reflect.TypeToken; */ @Test(groups = "unit", testName = "BaseWrapperTest") public class BaseWrapperTest { - private static class Water implements Closeable { + private static class Water extends ContextImpl { + + protected Water() { + super(createMock(ProviderMetadata.class), "identity", createMock(Utils.class), createMock(Closer.class)); + } @Override public void close() { } + @Override public boolean equals(Object in){ return Objects.equal(in.getClass(), getClass()); } } - private static interface PeanutButter extends Closeable { + private static class PeanutButter extends ContextImpl { + + protected PeanutButter() { + super(createMock(ProviderMetadata.class), "identity", createMock(Utils.class), createMock(Closer.class)); + } @Override - void close(); + public void close() { + } + + @Override + public boolean equals(Object in){ + return Objects.equal(in.getClass(), getClass()); + } } - + private static class Wine extends BaseWrapper { protected Wine() { diff --git a/core/src/test/java/org/jclouds/providers/config/BindProviderMetadataContextAndCredentialsTest.java b/core/src/test/java/org/jclouds/providers/config/BindProviderMetadataContextAndCredentialsTest.java new file mode 100644 index 0000000000..1a0d071fa2 --- /dev/null +++ b/core/src/test/java/org/jclouds/providers/config/BindProviderMetadataContextAndCredentialsTest.java @@ -0,0 +1,163 @@ +/** + * 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.providers.config; + +import static org.testng.Assert.assertEquals; + +import java.util.Properties; +import java.util.Set; + +import javax.inject.Inject; + +import org.jclouds.Constants; +import org.jclouds.Context; +import org.jclouds.apis.ApiMetadata; +import org.jclouds.domain.Credentials; +import org.jclouds.domain.LoginCredentials; +import org.jclouds.http.IntegrationTestAsyncClient; +import org.jclouds.http.IntegrationTestClient; +import org.jclouds.internal.FilterStringsBoundToInjectorByName; +import org.jclouds.javax.annotation.Nullable; +import org.jclouds.location.Iso3166; +import org.jclouds.location.Provider; +import org.jclouds.providers.AnonymousProviderMetadata; +import org.jclouds.providers.ProviderMetadata; +import org.jclouds.rest.annotations.Api; +import org.jclouds.rest.annotations.ApiVersion; +import org.jclouds.rest.annotations.BuildVersion; +import org.jclouds.rest.annotations.Credential; +import org.jclouds.rest.annotations.Identity; +import org.testng.annotations.Test; + +import com.google.common.base.Predicates; +import com.google.common.reflect.TypeToken; +import com.google.inject.Guice; +import com.google.inject.Key; +import com.google.inject.name.Names; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "BindProviderMetadataContextAndCredentialsTest") +public class BindProviderMetadataContextAndCredentialsTest { + + @SuppressWarnings("unused") + private static class ExpectedBindings { + private final javax.inject.Provider wrapped; + private final ProviderMetadata providerMetadata; + private final Credentials creds; + private final String identity; + private final String credential; + private final String providerId; + private final Set iso3166Codes; + private final String apiId; + private final String apiVersion; + private final String buildVersion; + + @Inject + private ExpectedBindings(@Provider javax.inject.Provider wrapped, ProviderMetadata providerMetadata, + @Provider Credentials creds, @Identity String identity, @Nullable @Credential String credential, + @Provider String providerId, @Iso3166 Set iso3166Codes, @Api String apiId, + @ApiVersion String apiVersion, @Nullable @BuildVersion String buildVersion, + @Provider TypeToken wrappedToken, FilterStringsBoundToInjectorByName filter) { + this.wrapped = wrapped; + assertEquals(wrappedToken, providerMetadata.getApiMetadata().getContext()); + this.providerMetadata = providerMetadata; + Properties props = new Properties(); + props.putAll(filter.apply(Predicates. alwaysTrue())); + Properties expected = new Properties(); + expected.putAll(providerMetadata.getApiMetadata().getDefaultProperties()); + expected.putAll(providerMetadata.getDefaultProperties()); + assertEquals(props, expected); + this.creds = creds; + this.identity = identity; + assertEquals(identity, creds.identity); + this.credential = credential; + assertEquals(credential, creds.credential); + this.providerId = providerId; + assertEquals(providerId, providerMetadata.getId()); + this.iso3166Codes = iso3166Codes; + assertEquals(iso3166Codes, providerMetadata.getIso3166Codes()); + this.apiId = apiId; + assertEquals(apiId, providerMetadata.getApiMetadata().getId()); + this.apiVersion = apiVersion; + assertEquals(apiVersion, providerMetadata.getApiMetadata().getVersion()); + this.buildVersion = buildVersion; + assertEquals(buildVersion, providerMetadata.getApiMetadata().getBuildVersion().orNull()); + } + + } + + @Test + public void testExpectedBindingsWhenCredentialIsNotNull() { + + ProviderMetadata md = AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint( + IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost"); + Credentials creds = LoginCredentials.builder().user("user").password("password").build(); + + ExpectedBindings bindings = Guice.createInjector(new BindProviderMetadataContextAndCredentials(md, creds)) + .getInstance(ExpectedBindings.class); + assertEquals(bindings.identity, "user"); + assertEquals(bindings.credential, "password"); + } + + @Test + public void testExpectedBindingsWhenCredentialIsNull() { + + ProviderMetadata md = AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint( + IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost"); + Credentials creds = LoginCredentials.builder().user("user").build(); + + ExpectedBindings bindings = Guice.createInjector(new BindProviderMetadataContextAndCredentials(md, creds)) + .getInstance(ExpectedBindings.class); + assertEquals(bindings.identity, "user"); + assertEquals(bindings.credential, null); + } + + @Test + public void testExpectedBindingsWhenBuildVersionAbsent() { + + ProviderMetadata md = AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint( + IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost"); + ApiMetadata apiMd = md.getApiMetadata().toBuilder().buildVersion(null).build(); + md = md.toBuilder().apiMetadata(apiMd).build(); + Credentials creds = LoginCredentials.builder().user("user").build(); + + ExpectedBindings bindings = Guice.createInjector(new BindProviderMetadataContextAndCredentials(md, creds)) + .getInstance(ExpectedBindings.class); + assertEquals(bindings.buildVersion, null); + } + + @Test + public void testProviderOverridesApiMetadataProperty() { + + ProviderMetadata md = AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint( + IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost"); + Properties defaultProps = md.getDefaultProperties(); + defaultProps.setProperty(Constants.PROPERTY_SESSION_INTERVAL, Integer.MAX_VALUE + ""); + md = md.toBuilder().defaultProperties(defaultProps).build(); + + Credentials creds = LoginCredentials.builder().user("user").build(); + + int session = Guice.createInjector(new BindProviderMetadataContextAndCredentials(md, creds)).getInstance( + Key.get(int.class, Names.named(Constants.PROPERTY_SESSION_INTERVAL))); + assertEquals(session, Integer.MAX_VALUE); + } +} diff --git a/core/src/test/java/org/jclouds/providers/internal/UpdateProviderMetadataFromPropertiesTest.java b/core/src/test/java/org/jclouds/providers/internal/UpdateProviderMetadataFromPropertiesTest.java new file mode 100644 index 0000000000..cebe3ba45d --- /dev/null +++ b/core/src/test/java/org/jclouds/providers/internal/UpdateProviderMetadataFromPropertiesTest.java @@ -0,0 +1,73 @@ +/** + * 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.providers.internal; + +import static org.jclouds.Constants.PROPERTY_ISO3166_CODES; +import static org.testng.Assert.assertEquals; + +import java.util.Properties; + +import org.jclouds.Constants; +import org.jclouds.http.IntegrationTestAsyncClient; +import org.jclouds.http.IntegrationTestClient; +import org.jclouds.providers.AnonymousProviderMetadata; +import org.jclouds.providers.ProviderMetadata; +import org.testng.annotations.Test; + +import com.google.common.collect.ImmutableSet; + +/** + * + * @author Adrian Cole + */ +@Test(groups = "unit", testName = "UpdateProviderMetadataFromPropertiesTest") +public class UpdateProviderMetadataFromPropertiesTest { + + @Test + public void testProviderMetadataWithUpdatedEndpointUpdatesAndRetainsAllDefaultPropertiesExceptEndpoint() { + ProviderMetadata md = AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint( + IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost"); + + Properties props = new Properties(); + props.putAll(md.getDefaultProperties()); + props.setProperty(Constants.PROPERTY_ENDPOINT, "http://nonlocal"); + + ProviderMetadata newMd = new UpdateProviderMetadataFromProperties(md).apply(props); + + assertEquals(newMd.getEndpoint(), "http://nonlocal"); + assertEquals(newMd.getDefaultProperties(), md.getDefaultProperties()); + } + + @Test + public void testProviderMetadataWithUpdatedIso3166CodesUpdatesAndRetainsAllDefaultPropertiesExceptIso3166Codes() { + ProviderMetadata md = AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint( + IntegrationTestClient.class, IntegrationTestAsyncClient.class, "http://localhost"); + + Properties props = new Properties(); + props.putAll(md.getDefaultProperties()); + props.setProperty(PROPERTY_ISO3166_CODES, "US-CA"); + + ProviderMetadata newMd = new UpdateProviderMetadataFromProperties(md).apply(props); + + assertEquals(newMd.getIso3166Codes(), ImmutableSet.of("US-CA")); + assertEquals(newMd.getDefaultProperties(), md.getDefaultProperties()); + } + + //TODO: add all the rest of the tests +} diff --git a/core/src/test/java/org/jclouds/util/ProvidersTest.java b/core/src/test/java/org/jclouds/util/ProvidersTest.java index 81ee659d3f..b265eb4f0c 100644 --- a/core/src/test/java/org/jclouds/util/ProvidersTest.java +++ b/core/src/test/java/org/jclouds/util/ProvidersTest.java @@ -32,6 +32,7 @@ import com.google.common.collect.Sets; public class ProvidersTest { @Test + @Deprecated public void testSupportedProviders() { Iterable providers = org.jclouds.rest.Providers.getSupportedProviders(); assertEquals(Sets.newLinkedHashSet(providers), ImmutableSet. of("test-blobstore-api", "test-compute-api", diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSTemplateBuilderLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSTemplateBuilderLiveTest.java index 5f5844e624..6318ade9b0 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSTemplateBuilderLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/compute/GleSYSTemplateBuilderLiveTest.java @@ -81,7 +81,7 @@ public class GleSYSTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { @Test public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getId(), "Ubuntu 11.04 64-bit"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); diff --git a/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSClientLiveTest.java b/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSClientLiveTest.java index 9c826505a0..6dabd932d4 100644 --- a/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSClientLiveTest.java +++ b/labs/glesys/src/test/java/org/jclouds/glesys/internal/BaseGleSYSClientLiveTest.java @@ -61,7 +61,7 @@ public class BaseGleSYSClientLiveTest extends BaseComputeServiceContextLiveTest @Override public void setupContext() { super.setupContext(); - gleContext = context.unwrap(); + gleContext = wrapper.unwrap(); } protected void createDomain(String domain) { diff --git a/labs/nodepool/src/main/java/org/jclouds/nodepool/internal/BasePooledComputeService.java b/labs/nodepool/src/main/java/org/jclouds/nodepool/internal/BasePooledComputeService.java index 9bc399077c..725be05e85 100644 --- a/labs/nodepool/src/main/java/org/jclouds/nodepool/internal/BasePooledComputeService.java +++ b/labs/nodepool/src/main/java/org/jclouds/nodepool/internal/BasePooledComputeService.java @@ -23,6 +23,7 @@ import java.util.Set; import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeServiceContext; +import org.jclouds.compute.ImageExtension; import org.jclouds.compute.RunNodesException; import org.jclouds.compute.RunScriptOnNodesException; import org.jclouds.compute.domain.ComputeMetadata; @@ -35,13 +36,12 @@ import org.jclouds.compute.domain.Template; import org.jclouds.compute.domain.TemplateBuilder; import org.jclouds.compute.options.RunScriptOptions; import org.jclouds.compute.options.TemplateOptions; -import org.jclouds.compute.predicates.NodePredicates; import org.jclouds.domain.Location; import org.jclouds.nodepool.PooledComputeService; import org.jclouds.scriptbuilder.domain.Statement; +import com.google.common.base.Optional; import com.google.common.base.Predicate; -import com.google.common.base.Predicates; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; import com.google.common.collect.Sets; @@ -262,4 +262,9 @@ public class BasePooledComputeService implements PooledComputeService { return backingComputeService.runScriptOnNode(id, runScript); } + @Override + public Optional getImageExtension() { + return Optional.absent(); + } + } diff --git a/labs/nodepool/src/test/java/org/jclouds/nodepool/AppTest.java b/labs/nodepool/src/test/java/org/jclouds/nodepool/AppTest.java index 1b07aafaf8..4c1668e43f 100644 --- a/labs/nodepool/src/test/java/org/jclouds/nodepool/AppTest.java +++ b/labs/nodepool/src/test/java/org/jclouds/nodepool/AppTest.java @@ -32,8 +32,9 @@ import java.util.logging.Logger; import junit.framework.TestCase; import org.jclouds.Constants; +import org.jclouds.ContextBuilder; import org.jclouds.compute.ComputeService; -import org.jclouds.compute.ComputeServiceContextFactory; +import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.RunNodesException; import org.jclouds.compute.domain.ComputeMetadata; import org.jclouds.compute.domain.NodeMetadata; @@ -191,8 +192,10 @@ public class AppTest extends TestCase { } Iterable modules = ImmutableSet. of(new SshjSshClientModule(), new SLF4JLoggingModule(), new EnterpriseConfigurationModule()); - this.compute = new ComputeServiceContextFactory().createContext(this.providerName, this.identity, - this.credential, modules, overrides).getComputeService(); + this.compute = ContextBuilder.newBuilder(providerName) + .credentials(identity, credential) + .modules(modules) + .overrides(overrides).buildAndWrapWith(ComputeServiceContext.class).getComputeService(); } private void createAndStartPool() { diff --git a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java index ddae92f080..f1434b9dd8 100644 --- a/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java +++ b/labs/savvis-symphonyvpdc/src/main/java/org/jclouds/savvis/vpdc/config/VPDCRestClientModule.java @@ -20,7 +20,6 @@ package org.jclouds.savvis.vpdc.config; import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkState; -import static org.jclouds.Constants.PROPERTY_IDENTITY; import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; import static org.jclouds.rest.config.BinderUtils.bindClientAndAsyncClient; import static org.jclouds.savvis.vpdc.reference.VPDCConstants.PROPERTY_VPDC_TIMEOUT_TASK_COMPLETED; @@ -42,6 +41,7 @@ import org.jclouds.location.Provider; import org.jclouds.location.suppliers.ImplicitLocationSupplier; import org.jclouds.predicates.RetryablePredicate; import org.jclouds.rest.ConfiguresRestClient; +import org.jclouds.rest.annotations.Identity; import org.jclouds.rest.config.RestClientModule; import org.jclouds.rest.suppliers.MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier; import org.jclouds.savvis.vpdc.VPDCAsyncClient; @@ -105,7 +105,7 @@ public class VPDCRestClientModule extends RestClientModule> provideOrgs(Supplier cache, - @Named(PROPERTY_IDENTITY) final String user) { + @Identity final String user) { return Suppliers.compose(new Function>() { @Override diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCTemplateBuilderLiveTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCTemplateBuilderLiveTest.java index d37882e876..326d0588ae 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCTemplateBuilderLiveTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/compute/VPDCTemplateBuilderLiveTest.java @@ -69,7 +69,7 @@ public class VPDCTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { @Override public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "5"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.RHEL); diff --git a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java index cb645f8346..0e8c8426e9 100644 --- a/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java +++ b/labs/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMClientLiveTest.java @@ -279,7 +279,7 @@ public class VMClientLiveTest extends BaseVPDCClientLiveTest { protected void checkSSH(IPSocket socket) { socketTester.apply(socket); - SshClient client = context.utils().sshFactory() + SshClient client = wrapper.utils().sshFactory() .create(socket, LoginCredentials.builder().user(username).password(password).build()); try { client.connect(); diff --git a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorContextImpl.java b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorContextImpl.java index 456c65bf1e..ef8d276ec4 100644 --- a/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorContextImpl.java +++ b/labs/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/internal/VCloudDirectorContextImpl.java @@ -18,21 +18,13 @@ */ package org.jclouds.vcloud.director.v1_5.internal; -import java.net.URI; -import java.util.Map; -import java.util.Set; - import javax.inject.Inject; import javax.inject.Singleton; -import org.jclouds.domain.Credentials; import org.jclouds.lifecycle.Closer; -import org.jclouds.location.Iso3166; -import org.jclouds.location.Provider; +import org.jclouds.providers.ProviderMetadata; import org.jclouds.rest.RestContext; import org.jclouds.rest.Utils; -import org.jclouds.rest.annotations.ApiVersion; -import org.jclouds.rest.annotations.BuildVersion; import org.jclouds.rest.annotations.Identity; import org.jclouds.rest.internal.RestContextImpl; import org.jclouds.vcloud.director.v1_5.VCloudDirectorContext; @@ -41,7 +33,6 @@ import org.jclouds.vcloud.director.v1_5.admin.VCloudDirectorAdminClient; import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient; import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; -import com.google.common.base.Supplier; import com.google.inject.Injector; import com.google.inject.TypeLiteral; @@ -54,14 +45,10 @@ public class VCloudDirectorContextImpl extends RestContextImpl adminContext; @Inject - VCloudDirectorContextImpl(Closer closer, Map credentialStore, Utils utils, Injector injector, - TypeLiteral syncApi, TypeLiteral asyncApi, - @Provider Supplier endpoint, @Provider String provider, - @Identity String identity, @ApiVersion String apiVersion, @BuildVersion String buildVersion, - @Iso3166 Set iso3166Codes, - RestContext adminContext) { - super(closer, credentialStore, utils, injector, syncApi, asyncApi, endpoint, provider, - identity, apiVersion, buildVersion, iso3166Codes); + VCloudDirectorContextImpl(ProviderMetadata providerMetadata, @Identity String identity, Utils utils, Closer closer, + Injector injector, RestContext adminContext) { + super(providerMetadata, identity, utils, closer, injector, TypeLiteral.get(VCloudDirectorClient.class), + TypeLiteral.get(VCloudDirectorAsyncClient.class)); this.adminContext = adminContext; } diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClientExperimentLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClientExperimentLiveTest.java index a6d5c931b6..2375017e99 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClientExperimentLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorClientExperimentLiveTest.java @@ -34,7 +34,7 @@ public class VCloudDirectorClientExperimentLiveTest extends BaseVCloudDirectorCl public void testImplicitSession() { Session session = context.getApi().getCurrentSession(); - assertEquals(session.getHref().toASCIIString(), context.getEndpoint().toASCIIString() + "/session/"); + assertEquals(session.getHref().toASCIIString(), context.getProviderMetadata().getEndpoint() + "/session/"); } /** diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/handlers/InvalidateSessionAndRetryOn401AndLogoutOnCloseTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/handlers/InvalidateSessionAndRetryOn401AndLogoutOnCloseTest.java index 24183b5695..ec0f1dc55e 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/handlers/InvalidateSessionAndRetryOn401AndLogoutOnCloseTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/handlers/InvalidateSessionAndRetryOn401AndLogoutOnCloseTest.java @@ -42,6 +42,7 @@ import com.google.common.cache.LoadingCache; */ @Test(groups = "unit", testName = "InvalidateSessionAndRetryOn401AndLogoutOnCloseTest") public class InvalidateSessionAndRetryOn401AndLogoutOnCloseTest { + @SuppressWarnings("unchecked") @Test public void test401ShouldInvalidateSessionAndRetry() { HttpCommand command = createMock(HttpCommand.class); diff --git a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java index ba581fd874..3cb1e1743f 100644 --- a/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java +++ b/labs/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/login/SessionClientLiveTest.java @@ -32,6 +32,7 @@ import org.jclouds.rest.RestContext; import org.jclouds.vcloud.director.testng.FormatApiResultsListener; import org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants; import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken; +import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Listeners; import org.testng.annotations.Test; diff --git a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java index 120c862921..399813766a 100644 --- a/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java +++ b/labs/virtualbox/src/main/java/org/jclouds/virtualbox/config/VirtualBoxComputeServiceContextModule.java @@ -27,7 +27,6 @@ import java.io.File; import java.io.InputStream; import java.net.URI; import java.util.Map; -import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -40,12 +39,11 @@ import org.jclouds.byon.Node; import org.jclouds.byon.functions.NodeToNodeMetadata; import org.jclouds.byon.suppliers.SupplyFromProviderURIOrNodesProperty; import org.jclouds.compute.ComputeServiceAdapter; -import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ImageExtension; +import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials; import org.jclouds.compute.config.ComputeServiceAdapterContextModule; import org.jclouds.compute.domain.Hardware; -import org.jclouds.compute.domain.HardwareBuilder; import org.jclouds.compute.domain.Image; import org.jclouds.compute.domain.NodeMetadata; import org.jclouds.compute.domain.NodeState; @@ -81,7 +79,6 @@ import org.jclouds.virtualbox.functions.admin.ImagesToYamlImagesFromYamlDescript import org.jclouds.virtualbox.functions.admin.PreseedCfgServer; import org.jclouds.virtualbox.functions.admin.StartVBoxIfNotAlreadyRunning; import org.jclouds.virtualbox.predicates.SshResponds; -import org.testng.internal.annotations.Sets; import org.virtualbox_4_1.IMachine; import org.virtualbox_4_1.LockType; import org.virtualbox_4_1.MachineState; diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/BaseVirtualBoxClientLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/BaseVirtualBoxClientLiveTest.java index 33477e5d2d..85a8124610 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/BaseVirtualBoxClientLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/BaseVirtualBoxClientLiveTest.java @@ -137,7 +137,7 @@ public class BaseVirtualBoxClientLiveTest extends BaseComputeServiceContextLiveT @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - context.utils().injector().injectMembers(this); + wrapper.utils().injector().injectMembers(this); YamlImage image = getDefaultImage(); @@ -145,13 +145,13 @@ public class BaseVirtualBoxClientLiveTest extends BaseComputeServiceContextLiveT masterVmName = VIRTUALBOX_IMAGE_PREFIX + image.id; isosDir = workingDir + File.separator + "isos"; - hostVersion = Iterables.get(Splitter.on('r').split(context.utils().injector().getInstance(Key.get(String.class, BuildVersion.class))), 0); + hostVersion = Iterables.get(Splitter.on('r').split(wrapper.utils().injector().getInstance(Key.get(String.class, BuildVersion.class))), 0); operatingSystemIso = String.format("%s/%s.iso", isosDir, image.name); guestAdditionsIso = String.format("%s/VBoxGuestAdditions_%s.iso", isosDir, hostVersion); // try and get a master from the cache, this will initialize the config/download isos and // prepare everything IF a master is not available, subsequent calls should be pretty fast - Template template = context.getComputeService().templateBuilder().build(); + Template template = wrapper.getComputeService().templateBuilder().build(); checkNotNull(mastersCache.apply(template.getImage())); } @@ -195,7 +195,7 @@ public class BaseVirtualBoxClientLiveTest extends BaseComputeServiceContextLiveT VmSpec sourceVmSpec = VmSpec.builder().id(masterName).name(masterName).osTypeId("").memoryMB(512) .cleanUpMode(CleanupMode.Full).controller(ideController).forceOverwrite(true).build(); - Injector injector = context.utils().injector(); + Injector injector = wrapper.utils().injector(); Function configProperties = injector.getInstance(ValueOfConfigurationKeyOrNull.class); IsoSpec isoSpec = IsoSpec .builder() @@ -226,8 +226,8 @@ public class BaseVirtualBoxClientLiveTest extends BaseComputeServiceContextLiveT @AfterClass(groups = "live") protected void tearDown() throws Exception { - if (context != null) - context.close(); + if (wrapper != null) + wrapper.close(); } @AfterSuite diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/compute/VirtualBoxComputeServiceAdapterLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/compute/VirtualBoxComputeServiceAdapterLiveTest.java index 525331adf8..1ab7cdb455 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/compute/VirtualBoxComputeServiceAdapterLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/compute/VirtualBoxComputeServiceAdapterLiveTest.java @@ -52,7 +52,7 @@ public class VirtualBoxComputeServiceAdapterLiveTest extends BaseVirtualBoxClien public void testCreatedNodeHasExpectedNameAndWeCanConnectViaSsh() { String group = "foo"; String name = "foo-ef4"; - Template template = context.getComputeService().templateBuilder().build(); + Template template = wrapper.getComputeService().templateBuilder().build(); machine = adapter.createNodeWithGroupEncodedIntoName(group, name, template); assertTrue(machine.getNode().getName().contains(group)); assertTrue(machine.getNode().getName().contains(name)); @@ -61,7 +61,7 @@ public class VirtualBoxComputeServiceAdapterLiveTest extends BaseVirtualBoxClien } protected void doConnectViaSsh(IMachine machine, LoginCredentials creds) { - SshClient ssh = context.utils().injector().getInstance(IMachineToSshClient.class).apply(machine); + SshClient ssh = wrapper.utils().injector().getInstance(IMachineToSshClient.class).apply(machine); try { ssh.connect(); ExecResponse hello = ssh.exec("echo hello"); diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CloneAndRegisterMachineFromIMachineIfNotAlreadyExistsLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CloneAndRegisterMachineFromIMachineIfNotAlreadyExistsLiveTest.java index 8c8b1445ac..1eede069af 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CloneAndRegisterMachineFromIMachineIfNotAlreadyExistsLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CloneAndRegisterMachineFromIMachineIfNotAlreadyExistsLiveTest.java @@ -75,7 +75,7 @@ public class CloneAndRegisterMachineFromIMachineIfNotAlreadyExistsLiveTest exten VmSpec instanceVmSpec = VmSpec.builder().id(instanceName).name(instanceName).osTypeId("").memoryMB(512) .cleanUpMode(CleanupMode.Full).controller(ideController).forceOverwrite(true).build(); - Injector injector = context.utils().injector(); + Injector injector = wrapper.utils().injector(); Function configProperties = injector.getInstance(ValueOfConfigurationKeyOrNull.class); IsoSpec isoSpec = IsoSpec .builder() @@ -108,7 +108,7 @@ public class CloneAndRegisterMachineFromIMachineIfNotAlreadyExistsLiveTest exten private IMachine getVmWithGuestAdditionsInstalled() { MasterSpec masterSpecForTest = super.getMasterSpecForTest(); try { - Injector injector = context.utils().injector(); + Injector injector = wrapper.utils().injector(); return injector.getInstance(CreateAndInstallVm.class).apply(masterSpecForTest); } catch (IllegalStateException e) { // already created diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndInstallVmLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndInstallVmLiveTest.java index 45bd5dfa11..d16e4ecb1d 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndInstallVmLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndInstallVmLiveTest.java @@ -133,7 +133,7 @@ public class CreateAndInstallVmLiveTest extends BaseVirtualBoxClientLiveTest { VmSpec instanceVmSpec = VmSpec.builder().id(instanceName).name(instanceName).osTypeId("").memoryMB(512) .cleanUpMode(CleanupMode.Full).controller(ideController).forceOverwrite(true).build(); - injector = context.utils().injector(); + injector = wrapper.utils().injector(); Function configProperties = injector.getInstance(ValueOfConfigurationKeyOrNull.class); IsoSpec isoSpec = IsoSpec .builder() @@ -190,7 +190,7 @@ public class CreateAndInstallVmLiveTest extends BaseVirtualBoxClientLiveTest { private IMachine getVmWithGuestAdditionsInstalled() { MasterSpec masterSpecForTest = super.getMasterSpecForTest(); try { - Injector injector = context.utils().injector(); + Injector injector = wrapper.utils().injector(); return injector.getInstance(CreateAndInstallVm.class).apply(masterSpecForTest); } catch (IllegalStateException e) { // already created diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest.java index dafab24618..f37a23dcb1 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/functions/CreateAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest.java @@ -84,7 +84,7 @@ public class CreateAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest extends B .iso(IsoSpec.builder().sourcePath(operatingSystemIso).installationScript("").build()).vm(vmSpec) .network(networkSpec).build(); // undoVm(vmSpec); - IMachine debianNode = context.utils().injector() + IMachine debianNode = wrapper.utils().injector() .getInstance(CreateAndRegisterMachineFromIsoIfNotAlreadyExists.class).apply(machineSpec); IMachine machine = manager.get().getVBox().findMachine(vmName); assertEquals(debianNode.getName(), machine.getName()); @@ -107,7 +107,7 @@ public class CreateAndRegisterMachineFromIsoIfNotAlreadyExistsLiveTest extends B NetworkSpec networkSpec = NetworkSpec.builder().build(); MasterSpec machineSpec = MasterSpec.builder().iso(isoSpec).vm(vmSpec).network(networkSpec).build(); try { - Injector injector = context.utils().injector(); + Injector injector = wrapper.utils().injector(); injector.getInstance(CreateAndRegisterMachineFromIsoIfNotAlreadyExists.class).apply(machineSpec); fail(); } catch (VBoxException e) { diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/GuestAdditionsInstallerLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/GuestAdditionsInstallerLiveTest.java index e611e50848..1016756301 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/GuestAdditionsInstallerLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/GuestAdditionsInstallerLiveTest.java @@ -72,7 +72,7 @@ public class GuestAdditionsInstallerLiveTest extends BaseVirtualBoxClientLiveTes @BeforeClass(groups = "live") public void setupContext() { super.setupContext(); - injector = context.utils().injector(); + injector = wrapper.utils().injector(); String instanceName = VIRTUALBOX_IMAGE_PREFIX + CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_HYPHEN, getClass().getSimpleName()); @@ -152,7 +152,7 @@ public class GuestAdditionsInstallerLiveTest extends BaseVirtualBoxClientLiveTes private IMachine getVmWithGuestAdditionsInstalled() { MasterSpec masterSpecForTest = super.getMasterSpecForTest(); try { - Injector injector = context.utils().injector(); + Injector injector = wrapper.utils().injector(); return injector.getInstance(CreateAndInstallVm.class).apply(masterSpecForTest); } catch (IllegalStateException e) { // already created diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/IMachinePredicatesLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/IMachinePredicatesLiveTest.java index a1e2815b9d..8602a15d33 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/IMachinePredicatesLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/predicates/IMachinePredicatesLiveTest.java @@ -79,7 +79,7 @@ public class IMachinePredicatesLiveTest extends BaseVirtualBoxClientLiveTest { VmSpec instanceVmSpec = VmSpec.builder().id(instanceName).name(instanceName).osTypeId("").memoryMB(512) .cleanUpMode(CleanupMode.Full).controller(ideController).forceOverwrite(true).build(); - Injector injector = context.utils().injector(); + Injector injector = wrapper.utils().injector(); Function configProperties = injector.getInstance(ValueOfConfigurationKeyOrNull.class); IsoSpec isoSpec = IsoSpec .builder() @@ -111,7 +111,7 @@ public class IMachinePredicatesLiveTest extends BaseVirtualBoxClientLiveTest { private IMachine getVmWithGuestAdditionsInstalled() { MasterSpec masterSpecForTest = super.getMasterSpecForTest(); try { - Injector injector = context.utils().injector(); + Injector injector = wrapper.utils().injector(); return injector.getInstance(CreateAndInstallVm.class).apply(masterSpecForTest); } catch (IllegalStateException e) { // already created diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineControllerLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineControllerLiveTest.java index 8d90ea2028..6c2051c818 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineControllerLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineControllerLiveTest.java @@ -76,7 +76,7 @@ public class MachineControllerLiveTest extends BaseVirtualBoxClientLiveTest { VmSpec instanceVmSpec = VmSpec.builder().id(instanceName).name(instanceName).osTypeId("").memoryMB(512) .cleanUpMode(CleanupMode.Full).controller(ideController).forceOverwrite(true).build(); - Injector injector = context.utils().injector(); + Injector injector = wrapper.utils().injector(); Function configProperties = injector.getInstance(ValueOfConfigurationKeyOrNull.class); IsoSpec isoSpec = IsoSpec .builder() @@ -121,7 +121,7 @@ public class MachineControllerLiveTest extends BaseVirtualBoxClientLiveTest { private IMachine getVmWithGuestAdditionsInstalled() { MasterSpec masterSpecForTest = super.getMasterSpecForTest(); try { - Injector injector = context.utils().injector(); + Injector injector = wrapper.utils().injector(); return injector.getInstance(CreateAndInstallVm.class).apply(masterSpecForTest); } catch (IllegalStateException e) { // already created diff --git a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineUtilsLiveTest.java b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineUtilsLiveTest.java index d5c9725f51..94bbf8c23b 100644 --- a/labs/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineUtilsLiveTest.java +++ b/labs/virtualbox/src/test/java/org/jclouds/virtualbox/util/MachineUtilsLiveTest.java @@ -76,7 +76,7 @@ public class MachineUtilsLiveTest extends BaseVirtualBoxClientLiveTest { VmSpec instanceVmSpec = VmSpec.builder().id(instanceName).name(instanceName).osTypeId("").memoryMB(512) .cleanUpMode(CleanupMode.Full).controller(ideController).forceOverwrite(true).build(); - Injector injector = context.utils().injector(); + Injector injector = wrapper.utils().injector(); Function configProperties = injector.getInstance(ValueOfConfigurationKeyOrNull.class); IsoSpec isoSpec = IsoSpec .builder() @@ -123,7 +123,7 @@ public class MachineUtilsLiveTest extends BaseVirtualBoxClientLiveTest { private IMachine getVmWithGuestAdditionsInstalled() { MasterSpec masterSpecForTest = super.getMasterSpecForTest(); try { - Injector injector = context.utils().injector(); + Injector injector = wrapper.utils().injector(); return injector.getInstance(CreateAndInstallVm.class).apply(masterSpecForTest); } catch (IllegalStateException e) { // already created diff --git a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/LoadBalancerServiceContextImpl.java b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/LoadBalancerServiceContextImpl.java index 022a7b116d..2401fb6dd3 100644 --- a/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/LoadBalancerServiceContextImpl.java +++ b/loadbalancer/src/main/java/org/jclouds/loadbalancer/internal/LoadBalancerServiceContextImpl.java @@ -20,11 +20,10 @@ package org.jclouds.loadbalancer.internal; import static com.google.common.base.Preconditions.checkNotNull; -import java.io.Closeable; - import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.Context; import org.jclouds.internal.BaseWrapper; import org.jclouds.loadbalancer.LoadBalancerService; import org.jclouds.loadbalancer.LoadBalancerServiceContext; @@ -44,8 +43,8 @@ public class LoadBalancerServiceContextImpl extends BaseWrapper implements LoadB private final Utils utils; @Inject - public LoadBalancerServiceContextImpl(@Provider Closeable wrapped, - @Provider TypeToken wrappedType, LoadBalancerService loadBalancerService, Utils utils) { + public LoadBalancerServiceContextImpl(@Provider Context wrapped, + @Provider TypeToken wrappedType, LoadBalancerService loadBalancerService, Utils utils) { super(wrapped, wrappedType); this.utils = utils; this.loadBalancerService = checkNotNull(loadBalancerService, "loadBalancerService"); @@ -69,26 +68,26 @@ public class LoadBalancerServiceContextImpl extends BaseWrapper implements LoadB @SuppressWarnings("unchecked") @Override public RestContext getProviderSpecificContext() { - return (RestContext) getWrapped(); + return (RestContext) delegate(); } @Override public void close() { - Closeables.closeQuietly(getWrapped()); + Closeables.closeQuietly(delegate()); } public int hashCode() { - return getWrapped().hashCode(); + return delegate().hashCode(); } @Override public String toString() { - return getWrapped().toString(); + return delegate().toString(); } @Override public boolean equals(Object obj) { - return getWrapped().equals(obj); + return delegate().equals(obj); } } diff --git a/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java b/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java index f814e722e8..65f26cee35 100644 --- a/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java +++ b/loadbalancer/src/test/java/org/jclouds/loadbalancer/BaseLoadBalancerServiceLiveTest.java @@ -30,7 +30,7 @@ import java.util.concurrent.TimeoutException; import org.jclouds.Constants; import org.jclouds.ContextBuilder; -import org.jclouds.apis.BaseContextLiveTest; +import org.jclouds.apis.BaseWrapperLiveTest; import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.RunNodesException; import org.jclouds.compute.domain.NodeMetadata; @@ -58,7 +58,7 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true) -public abstract class BaseLoadBalancerServiceLiveTest extends BaseContextLiveTest { +public abstract class BaseLoadBalancerServiceLiveTest extends BaseWrapperLiveTest { protected String imageId; protected String loginUser; @@ -185,7 +185,7 @@ public abstract class BaseLoadBalancerServiceLiveTest extends BaseContextLiveTes } @Override - protected TypeToken contextType() { + protected TypeToken wrapperType() { return TypeToken.of(LoadBalancerServiceContext.class); } } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java index 78c25d8b8f..a75ea1eec4 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/AWSEC2ProviderMetadata.java @@ -38,6 +38,9 @@ import org.jclouds.providers.internal.BaseProviderMetadata; */ public class AWSEC2ProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; + public static Builder builder() { return new Builder(); } diff --git a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java index bdff743e5d..76ab793207 100644 --- a/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java +++ b/providers/aws-ec2/src/main/java/org/jclouds/aws/ec2/compute/internal/AWSEC2ComputeServiceContextImpl.java @@ -18,16 +18,13 @@ */ package org.jclouds.aws.ec2.compute.internal; -import java.io.Closeable; -import java.util.Map; - import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.Context; import org.jclouds.aws.ec2.compute.AWSEC2ComputeService; import org.jclouds.aws.ec2.compute.AWSEC2ComputeServiceContext; import org.jclouds.compute.Utils; -import org.jclouds.domain.Credentials; import org.jclouds.ec2.compute.internal.EC2ComputeServiceContextImpl; import org.jclouds.location.Provider; @@ -37,11 +34,12 @@ import com.google.common.reflect.TypeToken; * @author Adrian Cole */ @Singleton -public class AWSEC2ComputeServiceContextImpl extends EC2ComputeServiceContextImpl implements AWSEC2ComputeServiceContext { +public class AWSEC2ComputeServiceContextImpl extends EC2ComputeServiceContextImpl implements + AWSEC2ComputeServiceContext { @Inject - public AWSEC2ComputeServiceContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, - AWSEC2ComputeService computeService, Map credentialStore, Utils utils){ - super(wrapped, wrappedType, computeService, credentialStore, utils); + public AWSEC2ComputeServiceContextImpl(@Provider Context wrapped, + @Provider TypeToken wrappedType, AWSEC2ComputeService computeService, Utils utils) { + super(wrapped, wrappedType, computeService, utils); } @Override diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java index a57c2801a5..e5ce2d3566 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2ComputeServiceLiveTest.java @@ -93,12 +93,12 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { String region = "us-west-2"; AWSSecurityGroupClient securityGroupClient = AWSEC2Client.class.cast( - context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()).getSecurityGroupServices(); + wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()).getSecurityGroupServices(); - KeyPairClient keyPairClient = EC2Client.class.cast(context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()) + KeyPairClient keyPairClient = EC2Client.class.cast(wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()) .getKeyPairServices(); - InstanceClient instanceClient = EC2Client.class.cast(context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()) + InstanceClient instanceClient = EC2Client.class.cast(wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()) .getInstanceServices(); String group = this.group + "o"; @@ -230,13 +230,13 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest { } private void runIncidentalResourcesGetCleanedUpOnlyOnLastInstanceDestroy(Function destroyer) throws Exception { - AWSSecurityGroupClient securityGroupClient = AWSEC2Client.class.cast(context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()) + AWSSecurityGroupClient securityGroupClient = AWSEC2Client.class.cast(wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()) .getSecurityGroupServices(); - KeyPairClient keyPairClient = EC2Client.class.cast(context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()) + KeyPairClient keyPairClient = EC2Client.class.cast(wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()) .getKeyPairServices(); - InstanceClient instanceClient = EC2Client.class.cast(context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()) + InstanceClient instanceClient = EC2Client.class.cast(wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()) .getInstanceServices(); String group = this.group + "incidental"; diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java index 02391a390a..bb0e5efdf8 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/compute/AWSEC2TemplateBuilderLiveTest.java @@ -96,7 +96,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { @Test public void testTemplateBuilderM1MEDIUMWithNegativeLookaroundDoesntMatchTestImages() { - Template template = context.getComputeService().templateBuilder().hardwareId(InstanceType.M1_MEDIUM) + Template template = wrapper.getComputeService().templateBuilder().hardwareId(InstanceType.M1_MEDIUM) // need to select versions with double-digits so that lexicographic // doesn't end up prefering 9.x vs 11.x .osVersionMatches("1[012].[10][04]") @@ -122,7 +122,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { @Test public void testUbuntuInstanceStoreGoesM1SmallNegativeLookaroundDoesntMatchTestImages() { - Template template = context.getComputeService().templateBuilder() + Template template = wrapper.getComputeService().templateBuilder() .imageMatches(EC2ImagePredicates.rootDeviceType(RootDeviceType.INSTANCE_STORE)) // need to select versions with double-digits so that lexicographic // doesn't end up prefering 9.x vs 11.x @@ -148,7 +148,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { @Test public void testTemplateBuilderCanUseImageIdAndhardwareIdAndAZ() { - Template template = context.getComputeService().templateBuilder().imageId("us-east-1/ami-ccb35ea5") + Template template = wrapper.getComputeService().templateBuilder().imageId("us-east-1/ami-ccb35ea5") .hardwareId(InstanceType.M2_2XLARGE).locationId("us-east-1a").build(); System.out.println(template.getHardware()); @@ -168,7 +168,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { @Test public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); assert (defaultTemplate.getImage().getProviderId().startsWith("ami-")) : defaultTemplate; assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "pv-2012.03.rc-0"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); @@ -182,7 +182,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { @Test public void testAmazonLinuxInstanceStore() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().osFamily(OsFamily.AMZN_LINUX) + Template defaultTemplate = wrapper.getComputeService().templateBuilder().osFamily(OsFamily.AMZN_LINUX) .imageMatches(EC2ImagePredicates.rootDeviceType(RootDeviceType.INSTANCE_STORE)).build(); assert (defaultTemplate.getImage().getProviderId().startsWith("ami-")) : defaultTemplate; assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "pv-2012.03.rc-0"); @@ -196,7 +196,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { @Test public void testFastestTemplateBuilder() throws IOException { - Template fastestTemplate = context.getComputeService().templateBuilder().fastest().osFamily(OsFamily.AMZN_LINUX) + Template fastestTemplate = wrapper.getComputeService().templateBuilder().fastest().osFamily(OsFamily.AMZN_LINUX) .build(); assert (fastestTemplate.getImage().getProviderId().startsWith("ami-")) : fastestTemplate; assertEquals(fastestTemplate.getHardware().getProviderId(), InstanceType.CC2_8XLARGE); @@ -208,7 +208,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { assertEquals(getCores(fastestTemplate.getHardware()), 16.0d); assertEquals(fastestTemplate.getImage().getOperatingSystem().getArch(), "hvm"); - fastestTemplate = context.getComputeService().templateBuilder().fastest().build(); + fastestTemplate = wrapper.getComputeService().templateBuilder().fastest().build(); System.out.println(fastestTemplate.getImage()); assert (fastestTemplate.getImage().getProviderId().startsWith("ami-")) : fastestTemplate; assertEquals(fastestTemplate.getHardware().getProviderId(), InstanceType.CC2_8XLARGE); @@ -224,7 +224,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { @Test public void testTemplateBuilderMicro() throws IOException { - Template microTemplate = context.getComputeService().templateBuilder().hardwareId(InstanceType.T1_MICRO) + Template microTemplate = wrapper.getComputeService().templateBuilder().hardwareId(InstanceType.T1_MICRO) .osFamily(OsFamily.UBUNTU).osVersionMatches("10.10").os64Bit(true).build(); assert (microTemplate.getImage().getProviderId().startsWith("ami-")) : microTemplate; @@ -246,7 +246,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_AMI_QUERY, ""); overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY, ""); - context = createContext(overrides, setupModules()); + context = createWrapper(overrides, setupModules()); assertEquals(context.getComputeService().listImages().size(), 0); @@ -280,7 +280,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { overrides.setProperty(EC2Constants.PROPERTY_EC2_AMI_OWNERS, ""); overrides.setProperty(AWSEC2Constants.PROPERTY_EC2_CC_AMI_QUERY, ""); - context = createContext(overrides, setupModules()); + context = createWrapper(overrides, setupModules()); assertEquals(context.getComputeService().listImages().size(), 0); @@ -318,17 +318,17 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { final List commandsInvoked = Lists.newArrayList(); - context = createContext( + context = createWrapper( overrides, ImmutableSet. of(new Log4JLoggingModule(), TrackingJavaUrlHttpCommandExecutorService.newTrackingModule(commandsInvoked))); - assert context.getComputeService().listAssignableLocations().size() < this.context.getComputeService() + assert context.getComputeService().listAssignableLocations().size() < this.wrapper.getComputeService() .listAssignableLocations().size(); assertOnlyOneRegionQueriedForAvailabilityZone(commandsInvoked); - assert context.getComputeService().listImages().size() < this.context.getComputeService().listImages().size(); + assert context.getComputeService().listImages().size() < this.wrapper.getComputeService().listImages().size(); Template template = context.getComputeService().templateBuilder().imageId("eu-west-1/ami-a33b06d7").build(); assert (template.getImage().getProviderId().startsWith("ami-")) : template; @@ -362,7 +362,7 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { // This is the id of a public image, not owned by one of the four default // owners String imageId = "us-east-1/ami-44d02f2d"; - Template defaultTemplate = context.getComputeService().templateBuilder().imageId(imageId) + Template defaultTemplate = wrapper.getComputeService().templateBuilder().imageId(imageId) .imageMatches(EC2ImagePredicates.rootDeviceType(RootDeviceType.INSTANCE_STORE)).build(); assert (defaultTemplate.getImage().getProviderId().startsWith("ami-")) : defaultTemplate; assertEquals(defaultTemplate.getImage().getId(), imageId); @@ -370,8 +370,8 @@ public class AWSEC2TemplateBuilderLiveTest extends EC2TemplateBuilderLiveTest { @Test public void testAssignability() { - context.unwrap(EC2ApiMetadata.CONTEXT_TOKEN); - context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN); + wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN); + wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN); } @Override diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java index 556426ad44..4e8e482025 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AMIClientLiveTest.java @@ -79,7 +79,7 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest { @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getAMIServices(); + client = wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getAMIServices(); } public void testDescribeImageNotExists() { @@ -92,7 +92,7 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest { } public void testDescribeImages() { - for (String region : context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { + for (String region : wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { Set allResults = client.describeImagesInRegion(region); assertNotNull(allResults); assert allResults.size() >= 2 : allResults.size(); @@ -153,7 +153,7 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest { @Test public void testNewlyRegisteredImageCanBeListed() throws Exception { - ComputeService computeService = context.getComputeService(); + ComputeService computeService = wrapper.getComputeService(); Snapshot snapshot = createSnapshot(computeService); // List of images before... @@ -184,10 +184,10 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest { Set nodes = computeService.createNodesInGroup("jcloudstest", 1, options); try { String instanceId = Iterables.getOnlyElement(nodes).getProviderId(); - Reservation reservation = Iterables.getOnlyElement(context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getInstanceServices().describeInstancesInRegion(null, instanceId)); + Reservation reservation = Iterables.getOnlyElement(wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getInstanceServices().describeInstancesInRegion(null, instanceId)); RunningInstance instance = Iterables.getOnlyElement(reservation); BlockDevice device = instance.getEbsBlockDevices().get("/dev/sda1"); - Snapshot snapshot = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticBlockStoreServices().createSnapshotInRegion(null, device.getVolumeId()); + Snapshot snapshot = wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticBlockStoreServices().createSnapshotInRegion(null, device.getVolumeId()); snapshotsToDelete.add(snapshot.getId()); return snapshot; } finally { @@ -269,7 +269,7 @@ public class AMIClientLiveTest extends BaseComputeServiceContextLiveTest { for (String imageId : imagesToDeregister) client.deregisterImageInRegion(null, imageId); for (String snapshotId : snapshotsToDelete) - context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticBlockStoreServices().deleteSnapshotInRegion(null, snapshotId); + wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticBlockStoreServices().deleteSnapshotInRegion(null, snapshotId); } } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIClientLiveTest.java index fee3d039ea..76169fb838 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSAMIClientLiveTest.java @@ -63,7 +63,7 @@ public class AWSAMIClientLiveTest extends BaseComputeServiceContextLiveTest { @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getAMIServices(); + client = wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getAMIServices(); } public void testDescribeImageNotExists() { @@ -76,7 +76,7 @@ public class AWSAMIClientLiveTest extends BaseComputeServiceContextLiveTest { } public void testDescribeImages() { - for (String region : context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { + for (String region : wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { Set allResults = Sets.newLinkedHashSet(client.describeImagesInRegion(region)); assertNotNull(allResults); assert allResults.size() >= 2 : allResults.size(); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java index de125a3107..64ce87c2db 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSInstanceClientLiveTest.java @@ -48,12 +48,12 @@ public class AWSInstanceClientLiveTest extends BaseComputeServiceContextLiveTest @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getInstanceServices(); + client = wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getInstanceServices(); } @Test void testDescribeInstances() { - for (String region : context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { + for (String region : wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) { Set> allResults = client.describeInstancesInRegion(region); assertNotNull(allResults); assert allResults.size() >= 0 : allResults.size(); diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java index 3ba56147d3..25614ea38d 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/AWSKeyPairClientLiveTest.java @@ -71,25 +71,25 @@ public class AWSKeyPairClientLiveTest extends BaseComputeServiceContextLiveTest @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getKeyPairServices(); + client = wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getKeyPairServices(); } public void testNoSsh() throws Exception { Map keyPair = ComputeTestUtils.setupKeyPair(); - AWSInstanceClient instanceClient = AWSEC2Client.class.cast(context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()).getInstanceServices(); + AWSInstanceClient instanceClient = AWSEC2Client.class.cast(wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi()).getInstanceServices(); String group = PREFIX + "unssh"; - context.getComputeService().destroyNodesMatching(inGroup(group)); + wrapper.getComputeService().destroyNodesMatching(inGroup(group)); - TemplateOptions options = context.getComputeService().templateOptions(); + TemplateOptions options = wrapper.getComputeService().templateOptions(); options.authorizePublicKey(keyPair.get("public")).as(AWSEC2TemplateOptions.class); ComputeServiceContext noSshContext = null; try { - noSshContext = createContext(setupProperties(), ImmutableSet. of(new Log4JLoggingModule())); + noSshContext = createWrapper(setupProperties(), ImmutableSet. of(new Log4JLoggingModule())); Set nodes = noSshContext.getComputeService().createNodesInGroup(group, 1, options); @@ -104,7 +104,7 @@ public class AWSKeyPairClientLiveTest extends BaseComputeServiceContextLiveTest assertEquals(instance.getKeyName(), "jclouds#" + group); - Map responses = context.getComputeService() + Map responses = wrapper.getComputeService() .runScriptOnNodesMatching( runningInGroup(group), exec("echo hello"), @@ -117,7 +117,7 @@ public class AWSKeyPairClientLiveTest extends BaseComputeServiceContextLiveTest } finally { noSshContext.close(); - context.getComputeService().destroyNodesMatching(inGroup(group)); + wrapper.getComputeService().destroyNodesMatching(inGroup(group)); } } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringClientLiveTest.java index 595dec84b6..5a2a6a1379 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/MonitoringClientLiveTest.java @@ -47,7 +47,7 @@ public class MonitoringClientLiveTest extends BaseComputeServiceContextLiveTest @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getMonitoringServices(); + client = wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getMonitoringServices(); } @Test(enabled = false) diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java index 1e5662434a..4c11dd4c1d 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/PlacementGroupClientLiveTest.java @@ -72,7 +72,7 @@ public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveT @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi(); + client = wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi(); availableTester = new RetryablePredicate(new PlacementGroupAvailable(client), 60, 1, TimeUnit.SECONDS); @@ -129,7 +129,7 @@ public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveT public void testStartCCInstance() throws Exception { - Template template = context.getComputeService().templateBuilder().fastest().osFamily(OsFamily.AMZN_LINUX).build(); + Template template = wrapper.getComputeService().templateBuilder().fastest().osFamily(OsFamily.AMZN_LINUX).build(); assert template != null : "The returned template was null, but it should have a value."; assertEquals(template.getHardware().getProviderId(), InstanceType.CC2_8XLARGE); assertEquals(template.getImage().getUserMetadata().get("rootDeviceType"), "ebs"); @@ -140,12 +140,12 @@ public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveT Statements.newStatementList(AdminAccess.standard(), InstallJDK.fromOpenJDK())); String group = PREFIX + "cccluster"; - context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group)); + wrapper.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group)); // TODO make this not lookup an explicit region client.getPlacementGroupServices().deletePlacementGroupInRegion(null, "jclouds#" + group + "#us-east-1"); try { - Set nodes = context.getComputeService().createNodesInGroup(group, 1, template); + Set nodes = wrapper.getComputeService().createNodesInGroup(group, 1, template); NodeMetadata node = getOnlyElement(nodes); getOnlyElement(getOnlyElement(client.getInstanceServices().describeInstancesInRegion(null, @@ -155,7 +155,7 @@ public class PlacementGroupClientLiveTest extends BaseComputeServiceContextLiveT System.err.println(e.getNodeErrors().keySet()); Throwables.propagate(e); } finally { - context.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group)); + wrapper.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group)); } } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java index 36726832a7..335bbe7f6f 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/SpotInstanceClientLiveTest.java @@ -70,7 +70,7 @@ public class SpotInstanceClientLiveTest extends BaseComputeServiceContextLiveTe @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi(); + client = wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi(); activeTester = new RetryablePredicate(new SpotInstanceRequestActive(client), SPOT_DELAY_SECONDS, 1, 1, TimeUnit.SECONDS); } diff --git a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java index 13723dc0e8..dbf1ce4d7b 100644 --- a/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java +++ b/providers/aws-ec2/src/test/java/org/jclouds/aws/ec2/services/TagClientLiveTest.java @@ -56,22 +56,22 @@ public class TagClientLiveTest extends BaseComputeServiceContextLiveTest { @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - client = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getTagServices(); + client = wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getTagServices(); try { - testGroup = context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getSecurityGroupServices().createSecurityGroupInRegionAndReturnId(null, + testGroup = wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getSecurityGroupServices().createSecurityGroupInRegionAndReturnId(null, "test-group", "test-group"); } catch (IllegalStateException e) { // already exists testGroup = Iterables.get( - context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getSecurityGroupServices().describeSecurityGroupsInRegion(null, "test-group"), 0) + wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getSecurityGroupServices().describeSecurityGroupsInRegion(null, "test-group"), 0) .getId(); } } @AfterGroups(groups = { "live" }) public void deleteSecurityGroup() { - context.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getSecurityGroupServices().deleteSecurityGroupInRegionById(null, testGroup); + wrapper.unwrap(AWSEC2ApiMetadata.CONTEXT_TOKEN).getApi().getSecurityGroupServices().deleteSecurityGroupInRegionById(null, testGroup); } public static final String PREFIX = System.getProperty("user.name") + "-ec2"; diff --git a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/internal/AWSS3BlobStoreContextImpl.java b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/internal/AWSS3BlobStoreContextImpl.java index 4ba96d14a2..870366f6d9 100644 --- a/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/internal/AWSS3BlobStoreContextImpl.java +++ b/providers/aws-s3/src/main/java/org/jclouds/aws/s3/blobstore/internal/AWSS3BlobStoreContextImpl.java @@ -18,11 +18,10 @@ */ package org.jclouds.aws.s3.blobstore.internal; -import java.io.Closeable; - import javax.inject.Inject; import javax.inject.Singleton; +import org.jclouds.Context; import org.jclouds.aws.s3.blobstore.AWSS3AsyncBlobStore; import org.jclouds.aws.s3.blobstore.AWSS3BlobStore; import org.jclouds.aws.s3.blobstore.AWSS3BlobStoreContext; @@ -45,7 +44,7 @@ import com.google.common.reflect.TypeToken; public class AWSS3BlobStoreContextImpl extends S3BlobStoreContextImpl implements AWSS3BlobStoreContext { @Inject - public AWSS3BlobStoreContextImpl(@Provider Closeable wrapped, @Provider TypeToken wrappedType, + public AWSS3BlobStoreContextImpl(@Provider Context wrapped, @Provider TypeToken wrappedType, BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel, InputStreamMap.Factory inputStreamMapFactory, AsyncBlobStore ablobStore, BlobStore blobStore, BlobRequestSigner blobRequestSigner) { diff --git a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java index 603d3b8dae..a387dde397 100644 --- a/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java +++ b/providers/aws-s3/src/test/java/org/jclouds/aws/s3/AWSS3ClientLiveTest.java @@ -71,7 +71,7 @@ public class AWSS3ClientLiveTest extends S3ClientLiveTest { @Override public AWSS3Client getApi() { - return (AWSS3Client) context.unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getApi(); + return (AWSS3Client) wrapper.unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getApi(); } @BeforeClass(groups = { "integration", "live" }) @@ -150,7 +150,7 @@ public class AWSS3ClientLiveTest extends S3ClientLiveTest { String containerName = getContainerName(); try { - BlobStore blobStore = context.getBlobStore(); + BlobStore blobStore = wrapper.getBlobStore(); blobStore.createContainerInLocation(null, containerName); Blob blob = blobStore.blobBuilder("const.txt") .payload(new File("target/const.txt")).build(); @@ -165,14 +165,14 @@ public class AWSS3ClientLiveTest extends S3ClientLiveTest { String containerName = getContainerName(); try { String blobName = "test-rrs"; - BlobStore blobStore = context.getBlobStore(); + BlobStore blobStore = wrapper.getBlobStore(); blobStore.createContainerInLocation(null, containerName); Blob blob = blobStore.blobBuilder(blobName).payload("something").build(); blobStore.putBlob(containerName, blob, storageClass(StorageClass.REDUCED_REDUNDANCY)); - S3Client s3Client = S3Client.class.cast(context.unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getApi()); + S3Client s3Client = S3Client.class.cast(wrapper.unwrap(AWSS3ApiMetadata.CONTEXT_TOKEN).getApi()); ListBucketResponse response = s3Client.listBucket(containerName, withPrefix(blobName)); ObjectMetadata metadata = response.iterator().next(); diff --git a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java index d010bf7332..016c5317f9 100644 --- a/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java +++ b/providers/azureblob/src/test/java/org/jclouds/azureblob/AzureBlobClientLiveTest.java @@ -65,7 +65,7 @@ public class AzureBlobClientLiveTest extends BaseBlobStoreIntegrationTest { } public AzureBlobClient getApi() { - return context.unwrap(AzureBlobApiMetadata.CONTEXT_TOKEN).getApi(); + return wrapper.unwrap(AzureBlobApiMetadata.CONTEXT_TOKEN).getApi(); } @Test @@ -99,7 +99,7 @@ public class AzureBlobClientLiveTest extends BaseBlobStoreIntegrationTest { long containerCount = response.size(); assertTrue(containerCount >= 1); ListBlobsResponse list = getApi().listBlobs(privateContainer); - assertEquals(list.getUrl(), URI.create(String.format("https://%s.blob.core.windows.net/%s", context.unwrap( + assertEquals(list.getUrl(), URI.create(String.format("https://%s.blob.core.windows.net/%s", wrapper.unwrap( AzureBlobApiMetadata.CONTEXT_TOKEN).getIdentity(), privateContainer))); // TODO .. check to see the container actually exists } @@ -155,7 +155,7 @@ public class AzureBlobClientLiveTest extends BaseBlobStoreIntegrationTest { } } ListBlobsResponse list = getApi().listBlobs(); - assertEquals(list.getUrl(), URI.create(String.format("https://%s.blob.core.windows.net/$root", context.unwrap( + assertEquals(list.getUrl(), URI.create(String.format("https://%s.blob.core.windows.net/$root", wrapper.unwrap( AzureBlobApiMetadata.CONTEXT_TOKEN).getIdentity()))); } diff --git a/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/compute/BluelockVCloudZone01TemplateBuilderLiveTest.java b/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/compute/BluelockVCloudZone01TemplateBuilderLiveTest.java index 2c3a037763..4e979b0990 100644 --- a/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/compute/BluelockVCloudZone01TemplateBuilderLiveTest.java +++ b/providers/bluelock-vcloud-zone01/src/test/java/org/jclouds/bluelock/vcloud/zone01/compute/BluelockVCloudZone01TemplateBuilderLiveTest.java @@ -67,7 +67,7 @@ public class BluelockVCloudZone01TemplateBuilderLiveTest extends BaseTemplateBui @Override public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), ""); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java index b774ef1f4e..1edd4ef6a3 100644 --- a/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java +++ b/providers/cloudfiles-uk/src/test/java/org/jclouds/rackspace/cloudfiles/CloudFilesUKClientLiveTest.java @@ -41,7 +41,7 @@ public class CloudFilesUKClientLiveTest extends CloudFilesClientLiveTest { @Override public CloudFilesClient getApi() { - return context.unwrap(CloudFilesApiMetadata.CONTEXT_TOKEN).getApi(); + return wrapper.unwrap(CloudFilesApiMetadata.CONTEXT_TOKEN).getApi(); } @Override diff --git a/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java b/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java index 7867c833fb..fddc0c4c22 100644 --- a/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java +++ b/providers/cloudloadbalancers-uk/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUKProviderMetadata.java @@ -41,6 +41,9 @@ import org.jclouds.providers.internal.BaseProviderMetadata; */ public class CloudLoadBalancersUKProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 5566019798179959163L; + public static Builder builder() { return new Builder(); } diff --git a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java index 1a7164ed8c..198e632a1b 100644 --- a/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java +++ b/providers/cloudloadbalancers-us/src/main/java/org/jclouds/rackspace/cloudloadbalancers/CloudLoadBalancersUSProviderMetadata.java @@ -44,6 +44,9 @@ import com.google.common.base.Joiner; */ public class CloudLoadBalancersUSProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = -1336822093264044850L; + public static Builder builder() { return new Builder(); } diff --git a/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java b/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java index cfb4fcef46..742b6b63e6 100644 --- a/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java +++ b/providers/cloudonestorage/src/main/java/org/jclouds/cloudonestorage/CloudOneStorageProviderMetadata.java @@ -33,6 +33,9 @@ import org.jclouds.providers.internal.BaseProviderMetadata; */ public class CloudOneStorageProviderMetadata extends BaseProviderMetadata { + /** The serialVersionUID */ + private static final long serialVersionUID = 1L; + public static Builder builder() { return new Builder(); } diff --git a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java index 82af2d5621..4ac3d2dcaa 100644 --- a/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java +++ b/providers/cloudservers-uk/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUKTemplateBuilderLiveTest.java @@ -72,7 +72,7 @@ public class CloudServersUKTemplateBuilderLiveTest extends BaseTemplateBuilderLi @Test public void testTemplateBuilder() { - Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); + Template defaultTemplate = this.wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java index efa7594281..f034e44582 100644 --- a/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java +++ b/providers/cloudservers-us/src/test/java/org/jclouds/rackspace/cloudservers/compute/CloudServersUSTemplateBuilderLiveTest.java @@ -72,7 +72,7 @@ public class CloudServersUSTemplateBuilderLiveTest extends BaseTemplateBuilderLi @Test public void testTemplateBuilder() { - Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); + Template defaultTemplate = this.wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java b/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java index af76f6b037..e3af652691 100644 --- a/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java +++ b/providers/cloudsigma-lvs/src/main/java/org/jclouds/cloudsigma/CloudSigmaLasVegasProviderMetadata.java @@ -30,9 +30,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class CloudSigmaLasVegasProviderMetadata - extends - BaseProviderMetadata { +public class CloudSigmaLasVegasProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 7837335150409122683L; public static Builder builder() { return new Builder(); diff --git a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java b/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java index 23ea49b737..4566bf38a3 100644 --- a/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java +++ b/providers/cloudsigma-lvs/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaLasVegasTemplateBuilderLiveTest.java @@ -24,9 +24,6 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.cloudsigma.CloudSigmaAsyncClient; -import org.jclouds.cloudsigma.CloudSigmaClient; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; @@ -42,9 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", testName = "CloudSigmaLasVegasTemplateBuilderLiveTest") -public class CloudSigmaLasVegasTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest { +public class CloudSigmaLasVegasTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public CloudSigmaLasVegasTemplateBuilderLiveTest() { provider = "cloudsigma-lvs"; @@ -81,7 +76,7 @@ public class CloudSigmaLasVegasTemplateBuilderLiveTest @Override public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getId(), "6aab1938-71b3-4252-ac1c-a3cb17c284ab"); diff --git a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java index df6afde0e9..c794ee4d4c 100644 --- a/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java +++ b/providers/cloudsigma-zrh/src/main/java/org/jclouds/cloudsigma/CloudSigmaZurichProviderMetadata.java @@ -30,9 +30,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class CloudSigmaZurichProviderMetadata - extends - BaseProviderMetadata { +public class CloudSigmaZurichProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -7104853865766042528L; public static Builder builder() { return new Builder(); diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichComputeServiceLiveTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichComputeServiceLiveTest.java index ab32b70988..3b158c6a9c 100644 --- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichComputeServiceLiveTest.java +++ b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichComputeServiceLiveTest.java @@ -26,6 +26,7 @@ import static org.testng.Assert.assertTrue; import java.util.Set; +import org.jclouds.cloudsigma.CloudSigmaApiMetadata; import org.jclouds.cloudsigma.CloudSigmaClient; import org.jclouds.cloudsigma.compute.options.CloudSigmaTemplateOptions; import org.jclouds.cloudsigma.domain.AffinityType; @@ -63,8 +64,8 @@ public class CloudSigmaZurichComputeServiceLiveTest extends CloudSigmaComputeSer Set nodes = client.createNodesInGroup(group, 1, template); NodeMetadata node = get(nodes, 0); - CloudSigmaClient api = CloudSigmaClient.class.cast(client.getContext() - .getProviderSpecificContext().getApi()); + CloudSigmaClient api = CloudSigmaClient.class.cast(client.getContext().unwrap( + CloudSigmaApiMetadata.CONTEXT_TOKEN).getApi()); // Note: I wanted to use node.getHardware().getVolumes() but there is no // way to go from a Volume to a DriveInfo diff --git a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java index 79391351c9..7a5f8639b8 100644 --- a/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java +++ b/providers/cloudsigma-zrh/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaZurichTemplateBuilderLiveTest.java @@ -24,9 +24,6 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Set; -import org.jclouds.cloudsigma.CloudSigmaAsyncClient; -import org.jclouds.cloudsigma.CloudSigmaClient; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; @@ -42,9 +39,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live", singleThreaded = true, testName = "CloudSigmaZurichTemplateBuilderLiveTest") -public class CloudSigmaZurichTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest { +public class CloudSigmaZurichTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public CloudSigmaZurichTemplateBuilderLiveTest() { provider = "cloudsigma-zrh"; @@ -77,7 +72,7 @@ public class CloudSigmaZurichTemplateBuilderLiveTest @Override public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), ""); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getId(), "c9df6b90-420c-4c46-b7f2-8d9e99929a09"); diff --git a/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java b/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java index 0d7b1caeea..21e68cd8ad 100644 --- a/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java +++ b/providers/elastichosts-lax-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LosAngelesProviderMetadata.java @@ -31,9 +31,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class ElasticHostsPeer1LosAngelesProviderMetadata - extends - BaseProviderMetadata { +public class ElasticHostsPeer1LosAngelesProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = -4027094214969340248L; public static Builder builder() { return new Builder(); diff --git a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java index c62a93e7f3..602cbf247c 100644 --- a/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java +++ b/providers/elastichosts-lax-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest.java @@ -23,13 +23,10 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest { +public class ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest() { provider = "elastichosts-lax-p"; @@ -75,7 +70,7 @@ public class ElasticHostsPeer1LosAngelesTemplateBuilderLiveTest @Test public void testTemplateBuilder() { - Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); + Template defaultTemplate = this.wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java index 0174d908c0..e9a56ab569 100644 --- a/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java +++ b/providers/elastichosts-lon-b/src/main/java/org/jclouds/elastichosts/ElasticHostsBlueSquareLondonProviderMetadata.java @@ -27,11 +27,13 @@ import org.jclouds.providers.internal.BaseProviderMetadata; /** * Implementation of {@link org.jclouds.types.ProviderMetadata} for ElasticHosts London BlueSquare. + * * @author Adrian Cole */ -public class ElasticHostsBlueSquareLondonProviderMetadata - extends - BaseProviderMetadata { +public class ElasticHostsBlueSquareLondonProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 5409915816774748887L; public static Builder builder() { return new Builder(); diff --git a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java index 9285774c86..ecdab80d22 100644 --- a/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java +++ b/providers/elastichosts-lon-b/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsBlueSquareLondonTemplateBuilderLiveTest.java @@ -23,13 +23,10 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class ElasticHostsBlueSquareLondonTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest { +public class ElasticHostsBlueSquareLondonTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public ElasticHostsBlueSquareLondonTemplateBuilderLiveTest() { provider = "elastichosts-lon-b"; @@ -76,7 +71,7 @@ public class ElasticHostsBlueSquareLondonTemplateBuilderLiveTest @Test public void testTemplateBuilder() { - Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); + Template defaultTemplate = this.wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java b/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java index c8dc1ccce5..316c5cab34 100644 --- a/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java +++ b/providers/elastichosts-lon-p/src/main/java/org/jclouds/elastichosts/ElasticHostsPeer1LondonProviderMetadata.java @@ -30,9 +30,10 @@ import org.jclouds.providers.internal.BaseProviderMetadata; * * @author Adrian Cole */ -public class ElasticHostsPeer1LondonProviderMetadata - extends - BaseProviderMetadata { +public class ElasticHostsPeer1LondonProviderMetadata extends BaseProviderMetadata { + + /** The serialVersionUID */ + private static final long serialVersionUID = 5018671212772677582L; public static Builder builder() { return new Builder(); diff --git a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java index c8a12e0f30..69fbfa21ce 100644 --- a/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java +++ b/providers/elastichosts-lon-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1LondonTemplateBuilderLiveTest.java @@ -23,13 +23,10 @@ import static org.testng.Assert.assertEquals; import java.util.Set; -import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.domain.OsFamily; import org.jclouds.compute.domain.OsFamilyVersion64Bit; import org.jclouds.compute.domain.Template; import org.jclouds.compute.internal.BaseTemplateBuilderLiveTest; -import org.jclouds.elasticstack.ElasticStackAsyncClient; -import org.jclouds.elasticstack.ElasticStackClient; import org.testng.annotations.Test; import com.google.common.base.Predicate; @@ -41,9 +38,7 @@ import com.google.common.collect.ImmutableSet; * @author Adrian Cole */ @Test(groups = "live") -public class ElasticHostsPeer1LondonTemplateBuilderLiveTest - extends - BaseTemplateBuilderLiveTest { +public class ElasticHostsPeer1LondonTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { public ElasticHostsPeer1LondonTemplateBuilderLiveTest() { provider = "elastichosts-lon-p"; @@ -76,7 +71,7 @@ public class ElasticHostsPeer1LondonTemplateBuilderLiveTest @Test public void testTemplateBuilder() { - Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); + Template defaultTemplate = this.wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java index 499dc1826d..644d8902e7 100644 --- a/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java +++ b/providers/elastichosts-sat-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest.java @@ -70,7 +70,7 @@ public class ElasticHostsPeer1SanAntonioTemplateBuilderLiveTest extends BaseTemp @Test public void testTemplateBuilder() { - Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); + Template defaultTemplate = this.wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java b/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java index 9bce8c72a2..5f700c6491 100644 --- a/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java +++ b/providers/elastichosts-tor-p/src/test/java/org/jclouds/elastichosts/compute/ElasticHostsPeer1TorontoTemplateBuilderLiveTest.java @@ -70,7 +70,7 @@ public class ElasticHostsPeer1TorontoTemplateBuilderLiveTest extends BaseTemplat @Test public void testTemplateBuilder() { - Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); + Template defaultTemplate = this.wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java index 9849146e67..2b6564445b 100644 --- a/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java +++ b/providers/eucalyptus-partnercloud-ec2/src/test/java/org/jclouds/epc/compute/EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest.java @@ -72,7 +72,7 @@ public class EucalyptusPartnerCloudEucalyptusTemplateBuilderLiveTest extends Bas @Test public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); assert (defaultTemplate.getImage().getProviderId().startsWith("emi-")) : defaultTemplate; assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); diff --git a/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/compute/Go2CloudJohannesburg1TemplateBuilderLiveTest.java b/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/compute/Go2CloudJohannesburg1TemplateBuilderLiveTest.java index 0b5bc44fb3..a23f9d87a0 100644 --- a/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/compute/Go2CloudJohannesburg1TemplateBuilderLiveTest.java +++ b/providers/go2cloud-jhb1/src/test/java/org/jclouds/go2cloud/compute/Go2CloudJohannesburg1TemplateBuilderLiveTest.java @@ -68,7 +68,7 @@ public class Go2CloudJohannesburg1TemplateBuilderLiveTest extends BaseTemplateBu @Test public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); + Template defaultTemplate = this.wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/gogrid/src/main/java/org/jclouds/gogrid/filters/SharedKeyLiteAuthentication.java b/providers/gogrid/src/main/java/org/jclouds/gogrid/filters/SharedKeyLiteAuthentication.java index 11f1adea89..5c1a8d79d5 100644 --- a/providers/gogrid/src/main/java/org/jclouds/gogrid/filters/SharedKeyLiteAuthentication.java +++ b/providers/gogrid/src/main/java/org/jclouds/gogrid/filters/SharedKeyLiteAuthentication.java @@ -19,8 +19,6 @@ package org.jclouds.gogrid.filters; import static java.lang.String.format; -import static org.jclouds.Constants.PROPERTY_CREDENTIAL; -import static org.jclouds.Constants.PROPERTY_IDENTITY; import java.net.URI; @@ -37,6 +35,8 @@ import org.jclouds.http.HttpUtils; import org.jclouds.http.utils.ModifyRequest; import org.jclouds.io.InputSuppliers; import org.jclouds.logging.Logger; +import org.jclouds.rest.annotations.Credential; +import org.jclouds.rest.annotations.Identity; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Multimap; @@ -56,8 +56,8 @@ public class SharedKeyLiteAuthentication implements HttpRequestFilter { Logger signatureLog = Logger.NULL; @Inject - public SharedKeyLiteAuthentication(@Named(PROPERTY_IDENTITY) String apiKey, - @Named(PROPERTY_CREDENTIAL) String secret, @TimeStamp Long timeStamp, HttpUtils utils) { + public SharedKeyLiteAuthentication(@Identity String apiKey, @Credential String secret, @TimeStamp Long timeStamp, + HttpUtils utils) { this.apiKey = apiKey; this.secret = secret; this.timeStamp = timeStamp; diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java index 5ceffc0066..54871138d1 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/GoGridLiveTestDisabled.java @@ -97,7 +97,7 @@ public class GoGridLiveTestDisabled extends BaseComputeServiceContextLiveTest { @Override public void setupContext() { super.setupContext(); - gocontext = context.unwrap(); + gocontext = wrapper.unwrap(); client = gocontext.getApi(); serverLatestJobCompleted = new RetryablePredicate(new ServerLatestJobCompleted(client.getJobServices()), diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java index b633266c28..2a99623bb1 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridComputeServiceLiveTest.java @@ -71,7 +71,7 @@ public class GoGridComputeServiceLiveTest extends BaseComputeServiceLiveTest { public void testResizeRam() throws Exception { String group = this.group + "ram"; - RestContext providerContext = context.unwrap(); + RestContext providerContext = wrapper.unwrap(); try { client.destroyNodesMatching(inGroup(group)); } catch (Exception e) { diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java index 45a751bdd1..04cb647266 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/compute/GoGridTemplateBuilderLiveTest.java @@ -71,7 +71,7 @@ public class GoGridTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTest { @Test public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java index ebe8a1daa8..a92dbf2a57 100644 --- a/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java +++ b/providers/gogrid/src/test/java/org/jclouds/gogrid/services/BaseGoGridClientLiveTest.java @@ -43,7 +43,7 @@ public class BaseGoGridClientLiveTest extends BaseComputeServiceContextLiveTest @Override public void setupContext() { super.setupContext(); - restContext = context.unwrap(); + restContext = wrapper.unwrap(); } diff --git a/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java index 0276f110f9..ba1affe0db 100644 --- a/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java +++ b/providers/greenhousedata-element-vcloud/src/test/java/org/jclouds/greenhousedata/element/vcloud/compute/GreenHouseDataElementVCloudTemplateBuilderLiveTest.java @@ -63,7 +63,7 @@ public class GreenHouseDataElementVCloudTemplateBuilderLiveTest extends BaseTemp @Override public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), ""); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/compute/HPCloudComputeTemplateBuilderLiveTest.java b/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/compute/HPCloudComputeTemplateBuilderLiveTest.java index 23531f1a8c..8824bfa9fa 100644 --- a/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/compute/HPCloudComputeTemplateBuilderLiveTest.java +++ b/providers/hpcloud-compute/src/test/java/org/jclouds/hpcloud/compute/compute/HPCloudComputeTemplateBuilderLiveTest.java @@ -69,7 +69,7 @@ public class HPCloudComputeTemplateBuilderLiveTest extends BaseTemplateBuilderLi @Test public void testTemplateBuilder() { - Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); + Template defaultTemplate = this.wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java index 816d02f6d1..174b1fbe95 100644 --- a/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java +++ b/providers/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java @@ -43,7 +43,7 @@ public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTes @Override public HPCloudObjectStorageClient getApi() { - return context.unwrap(HPCloudObjectStorageApiMetadata.CONTEXT_TOKEN).getApi(); + return wrapper.unwrap(HPCloudObjectStorageApiMetadata.CONTEXT_TOKEN).getApi(); } @Override diff --git a/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/compute/NinefoldComputeTemplateBuilderLiveTest.java b/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/compute/NinefoldComputeTemplateBuilderLiveTest.java index 7cbb42aec5..9c6a801ccc 100644 --- a/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/compute/NinefoldComputeTemplateBuilderLiveTest.java +++ b/providers/ninefold-compute/src/test/java/org/jclouds/ninefold/compute/compute/NinefoldComputeTemplateBuilderLiveTest.java @@ -70,7 +70,7 @@ public class NinefoldComputeTemplateBuilderLiveTest extends BaseTemplateBuilderL @Test public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); + Template defaultTemplate = this.wrapper.getComputeService().templateBuilder().build(); if (imageId == null) { assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); @@ -78,7 +78,7 @@ public class NinefoldComputeTemplateBuilderLiveTest extends BaseTemplateBuilderL assertEquals(defaultTemplate.getLocation().getId(), "1"); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); } else { - assertEquals(defaultTemplate.getImage(), this.context.getComputeService().templateBuilder().imageId(imageId) + assertEquals(defaultTemplate.getImage(), this.wrapper.getComputeService().templateBuilder().imageId(imageId) .build().getImage()); } } diff --git a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java index 841a737a00..04a9ba32e5 100644 --- a/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java +++ b/providers/openhosting-east1/src/test/java/org/jclouds/openhosting/compute/OpenHostingEast1TemplateBuilderLiveTest.java @@ -70,7 +70,7 @@ public class OpenHostingEast1TemplateBuilderLiveTest extends BaseTemplateBuilder @Test public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); + Template defaultTemplate = this.wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/filters/RimuHostingAuthentication.java b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/filters/RimuHostingAuthentication.java index 9e2bdfb008..c816f176d1 100644 --- a/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/filters/RimuHostingAuthentication.java +++ b/providers/rimuhosting/src/main/java/org/jclouds/rimuhosting/miro/filters/RimuHostingAuthentication.java @@ -21,15 +21,14 @@ package org.jclouds.rimuhosting.miro.filters; import static com.google.common.base.Preconditions.checkNotNull; import javax.inject.Inject; -import javax.inject.Named; import javax.inject.Singleton; import javax.ws.rs.core.HttpHeaders; -import org.jclouds.Constants; import org.jclouds.http.HttpException; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequestFilter; import org.jclouds.http.utils.ModifyRequest; +import org.jclouds.rest.annotations.Identity; /** * RimuHosting Authentication is a Authorization Header. @@ -43,7 +42,7 @@ public class RimuHostingAuthentication implements HttpRequestFilter { private final String header; @Inject - public RimuHostingAuthentication(@Named(Constants.PROPERTY_IDENTITY) String apikey) { + public RimuHostingAuthentication(@Identity String apikey) { this.header = String.format("rimuhosting apikey=%s", checkNotNull(apikey, "apikey")); } diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java index 46d76aa8c6..1be0472961 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/RimuHostingClientLiveTest.java @@ -56,7 +56,7 @@ public class RimuHostingClientLiveTest @Override public void setupContext() { super.setupContext(); - restContext = context.unwrap(); + restContext = wrapper.unwrap(); this.connection = restContext.getApi(); } diff --git a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java index de99137bfd..631b3b918e 100644 --- a/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java +++ b/providers/rimuhosting/src/test/java/org/jclouds/rimuhosting/miro/compute/RimuHostingTemplateBuilderLiveTest.java @@ -67,7 +67,7 @@ public class RimuHostingTemplateBuilderLiveTest extends BaseTemplateBuilderLiveT @Test public void testTemplateBuilder() { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java index 7e461a3f5e..e6f9926380 100644 --- a/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java +++ b/providers/serverlove-z1-man/src/test/java/org/jclouds/serverlove/compute/ServerloveManchesterTemplateBuilderLiveTest.java @@ -69,7 +69,7 @@ public class ServerloveManchesterTemplateBuilderLiveTest extends BaseTemplateBui @Test public void testTemplateBuilder() { - Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); + Template defaultTemplate = this.wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java index 6e47b62efd..af11e464f8 100644 --- a/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java +++ b/providers/skalicloud-sdg-my/src/test/java/org/jclouds/skalicloud/compute/SkaliCloudMalaysiaTemplateBuilderLiveTest.java @@ -73,7 +73,7 @@ public class SkaliCloudMalaysiaTemplateBuilderLiveTest @Override public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); + Template defaultTemplate = this.wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/slicehost/src/main/java/org/jclouds/slicehost/filters/SlicehostBasic.java b/providers/slicehost/src/main/java/org/jclouds/slicehost/filters/SlicehostBasic.java index 253d229590..e71794148f 100644 --- a/providers/slicehost/src/main/java/org/jclouds/slicehost/filters/SlicehostBasic.java +++ b/providers/slicehost/src/main/java/org/jclouds/slicehost/filters/SlicehostBasic.java @@ -21,16 +21,15 @@ package org.jclouds.slicehost.filters; import static com.google.common.base.Preconditions.checkNotNull; import javax.inject.Inject; -import javax.inject.Named; import javax.inject.Singleton; import javax.ws.rs.core.HttpHeaders; -import org.jclouds.Constants; import org.jclouds.crypto.CryptoStreams; import org.jclouds.http.HttpException; import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequestFilter; import org.jclouds.http.utils.ModifyRequest; +import org.jclouds.rest.annotations.Identity; /** * @@ -41,7 +40,7 @@ public class SlicehostBasic implements HttpRequestFilter { private final String apikey; @Inject - public SlicehostBasic(@Named(Constants.PROPERTY_IDENTITY) String apikey) { + public SlicehostBasic(@Identity String apikey) { this.apikey = checkNotNull(apikey, "apikey"); } diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java index 48cac3fca5..6ba6cc4df5 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/SlicehostClientLiveTest.java @@ -68,7 +68,7 @@ public class SlicehostClientLiveTest extends BaseComputeServiceContextLiveTest { @Override public void setupContext() { super.setupContext(); - Injector injector = context.utils().injector(); + Injector injector = wrapper.utils().injector(); client = injector.getInstance(SlicehostClient.class); sshFactory = injector.getInstance(SshClient.Factory.class); diff --git a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java index 73db547fb9..53f775560e 100644 --- a/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java +++ b/providers/slicehost/src/test/java/org/jclouds/slicehost/compute/SlicehostTemplateBuilderLiveTest.java @@ -78,7 +78,7 @@ public class SlicehostTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes @Test public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java index e784ee8a37..87862055b5 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerComputeServiceAdapterLiveTest.java @@ -52,7 +52,7 @@ public class SoftLayerComputeServiceAdapterLiveTest extends BaseSoftLayerClientL @BeforeGroups(groups = { "live" }) public void setupContext() { super.setupContext(); - adapter = context.utils().injector().getInstance(SoftLayerComputeServiceAdapter.class); + adapter = wrapper.utils().injector().getInstance(SoftLayerComputeServiceAdapter.class); } @Test @@ -67,7 +67,7 @@ public class SoftLayerComputeServiceAdapterLiveTest extends BaseSoftLayerClientL public void testCreateNodeWithGroupEncodedIntoNameThenStoreCredentials() { String group = "foo"; String name = "node" + new Random().nextInt(); - Template template = context.getComputeService().templateBuilder().build(); + Template template = wrapper.getComputeService().templateBuilder().build(); // test passing custom options template.getOptions().as(SoftLayerTemplateOptions.class).domainName("me.org"); @@ -82,7 +82,7 @@ public class SoftLayerComputeServiceAdapterLiveTest extends BaseSoftLayerClientL } protected void doConnectViaSsh(VirtualGuest guest, LoginCredentials creds) { - SshClient ssh = context.utils().sshFactory().create(new IPSocket(guest.getPrimaryIpAddress(), 22), creds); + SshClient ssh = wrapper.utils().sshFactory().create(new IPSocket(guest.getPrimaryIpAddress(), 22), creds); try { ssh.connect(); ExecResponse hello = ssh.exec("echo hello"); diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java index da61c86bc6..80ecd83f31 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/compute/SoftLayerTemplateBuilderLiveTest.java @@ -84,7 +84,7 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes @Test public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); @@ -103,7 +103,7 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED, "1000"); - context = createContext(overrides, setupModules()); + context = createWrapper(overrides, setupModules()); // TODO add something to the template about port speed? context.getComputeService().templateBuilder().build(); @@ -121,7 +121,7 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_PORT_SPEED, "100"); - context = createContext(overrides, setupModules()); + context = createWrapper(overrides, setupModules()); // TODO add something to the template about port speed? context.getComputeService().templateBuilder().build(); @@ -139,7 +139,7 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_DISK0_TYPE, "SAN"); - context = createContext(overrides, setupModules()); + context = createWrapper(overrides, setupModules()); Template template = context.getComputeService().templateBuilder().biggest().build(); assertEquals(getCores(template.getHardware()), 16.0d); @@ -159,7 +159,7 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX, "Private [0-9]+ x ([.0-9]+) GHz Core[s]?"); - context = createContext(overrides, setupModules()); + context = createWrapper(overrides, setupModules()); Template template = context.getComputeService().templateBuilder().build(); assertEquals(getCores(template.getHardware()), 1.0d); @@ -179,7 +179,7 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes Properties overrides = setupProperties(); overrides.setProperty(PROPERTY_SOFTLAYER_VIRTUALGUEST_CPU_REGEX, "Private [0-9]+ x ([.0-9]+) GHz Core[s]?"); - context = createContext(overrides, setupModules()); + context = createWrapper(overrides, setupModules()); Template template = context.getComputeService().templateBuilder().biggest().build(); assertEquals(getCores(template.getHardware()), 8.0d); @@ -194,7 +194,7 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes @Test public void testFastestTemplateBuilder() throws IOException { - Template template = context.getComputeService().templateBuilder().fastest().build(); + Template template = wrapper.getComputeService().templateBuilder().fastest().build(); assertEquals(getCores(template.getHardware()), 16.0d); assertEquals(template.getHardware().getRam(), 1); assertEquals(getSpace(template.getHardware()), 25.0d); @@ -203,7 +203,7 @@ public class SoftLayerTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTes @Test public void testBiggestTemplateBuilder() throws IOException { - Template template = context.getComputeService().templateBuilder().biggest().build(); + Template template = wrapper.getComputeService().templateBuilder().biggest().build(); assertEquals(getCores(template.getHardware()), 16.0d); assertEquals(template.getHardware().getRam(), 16); assertEquals(getSpace(template.getHardware()), 100.0d); diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java index 43268d1d5c..e12ba4eb29 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/BaseSoftLayerClientLiveTest.java @@ -39,7 +39,7 @@ public class BaseSoftLayerClientLiveTest extends BaseComputeServiceContextLiveTe @Override public void setupContext() { super.setupContext(); - socontext = context.unwrap(); + socontext = wrapper.unwrap(); } } diff --git a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestClientLiveTest.java b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestClientLiveTest.java index 9568245675..1f2c324699 100644 --- a/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestClientLiveTest.java +++ b/providers/softlayer/src/test/java/org/jclouds/softlayer/features/VirtualGuestClientLiveTest.java @@ -116,7 +116,7 @@ public class VirtualGuestClientLiveTest extends BaseSoftLayerClientLiveTest { osToProductItem.get("Ubuntu Linux 8 LTS Hardy Heron - Minimal Install (64 bit)")); Builder prices = ImmutableSet.builder(); - prices.addAll(context.utils().injector().getInstance(Key.get(new TypeLiteral>() { + prices.addAll(wrapper.utils().injector().getInstance(Key.get(new TypeLiteral>() { }))); prices.add(ramPrice); prices.add(cpuPrice); diff --git a/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/compute/StratoGenVCloudMyCloudTemplateBuilderLiveTest.java b/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/compute/StratoGenVCloudMyCloudTemplateBuilderLiveTest.java index d43aad1b79..2f88b12d72 100644 --- a/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/compute/StratoGenVCloudMyCloudTemplateBuilderLiveTest.java +++ b/providers/stratogen-vcloud-mycloud/src/test/java/org/jclouds/stratogen/vcloud/mycloud/compute/StratoGenVCloudMyCloudTemplateBuilderLiveTest.java @@ -70,7 +70,7 @@ public class StratoGenVCloudMyCloudTemplateBuilderLiveTest extends BaseTemplateB @Override public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getName(), "Ubuntu server 11.04 64bit no GUI (base)"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), ""); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java index 0476d839dc..7714dbeb49 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudComputeServiceLiveTest.java @@ -104,7 +104,7 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv assert node.getLocation() != null; assertEquals(node.getType(), ComputeType.NODE); NodeMetadata allData = client.getNodeMetadata(node.getId()); - RestContext tmContext = context.unwrap(); + RestContext tmContext = wrapper.unwrap(); VApp vApp = tmContext.getApi().findVAppInOrgVDCNamed(allData.getLocation().getParent().getDescription(), allData.getLocation().getDescription(), allData.getName()); assertEquals(vApp.getName(), allData.getName()); diff --git a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudTemplateBuilderLiveTest.java b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudTemplateBuilderLiveTest.java index 7c7090835d..d5db3d3b23 100644 --- a/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudTemplateBuilderLiveTest.java +++ b/providers/trmk-ecloud/src/test/java/org/jclouds/trmk/ecloud/compute/TerremarkECloudTemplateBuilderLiveTest.java @@ -81,7 +81,7 @@ public class TerremarkECloudTemplateBuilderLiveTest extends BaseTemplateBuilderL @Test public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java index 87d95fed58..b68fc80453 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/InternetServiceLiveTest.java @@ -88,7 +88,7 @@ public class InternetServiceLiveTest @BeforeClass(groups = { "integration", "live" }) public void setupContext() { super.setupContext(); - tmClient = context.unwrap(TerremarkVCloudExpressApiMetadata.CONTEXT_TOKEN).getApi(); + tmClient = wrapper.unwrap(TerremarkVCloudExpressApiMetadata.CONTEXT_TOKEN).getApi(); } diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java index 4fe542a463..c27a91567b 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressComputeServiceLiveTest.java @@ -96,7 +96,7 @@ public class TerremarkVCloudExpressComputeServiceLiveTest extends BaseComputeSer assertEquals(node.getType(), ComputeType.NODE); NodeMetadata allData = client.getNodeMetadata(node.getId()); System.out.println(allData.getHardware()); - RestContext tmContext = context.unwrap(); + RestContext tmContext = wrapper.unwrap(); VApp vApp = tmContext.getApi().findVAppInOrgVDCNamed(null, null, allData.getName()); assertEquals(vApp.getName(), allData.getName()); } diff --git a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java index 109305fd13..f350d5be47 100644 --- a/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java +++ b/providers/trmk-vcloudexpress/src/test/java/org/jclouds/trmk/vcloudexpress/compute/TerremarkVCloudExpressTemplateBuilderLiveTest.java @@ -68,7 +68,7 @@ public class TerremarkVCloudExpressTemplateBuilderLiveTest extends BaseTemplateB @Test public void testDefaultTemplateBuilder() throws IOException { - Template defaultTemplate = context.getComputeService().templateBuilder().build(); + Template defaultTemplate = wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04"); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/compute/TryStackNovaTemplateBuilderLiveTest.java b/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/compute/TryStackNovaTemplateBuilderLiveTest.java index a23f3e92ff..b20006e2e8 100644 --- a/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/compute/TryStackNovaTemplateBuilderLiveTest.java +++ b/providers/trystack-nova/src/test/java/org/jclouds/trystack/nova/compute/TryStackNovaTemplateBuilderLiveTest.java @@ -64,7 +64,7 @@ public class TryStackNovaTemplateBuilderLiveTest extends BaseTemplateBuilderLive @Test public void testTemplateBuilder() { - Template defaultTemplate = this.context.getComputeService().templateBuilder().build(); + Template defaultTemplate = this.wrapper.getComputeService().templateBuilder().build(); assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "11.10"); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); diff --git a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/InitBuilder.java b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/InitBuilder.java index 74fc896a3f..45f4f72b87 100644 --- a/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/InitBuilder.java +++ b/scriptbuilder/src/main/java/org/jclouds/scriptbuilder/InitBuilder.java @@ -36,6 +36,8 @@ import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; /** + * will be removed in jclouds 1.6 + * * Creates an init script file * * @see InitScript diff --git a/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/InitBuilderTest.java b/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/InitBuilderTest.java index 0981d6b72b..60a2000e7c 100644 --- a/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/InitBuilderTest.java +++ b/scriptbuilder/src/test/java/org/jclouds/scriptbuilder/InitBuilderTest.java @@ -42,6 +42,7 @@ import com.google.common.io.Resources; * * @author Adrian Cole */ +@Deprecated public class InitBuilderTest { InitBuilder testInitBuilder = new InitBuilder("mkebsboot", "/mnt/tmp", "/mnt/tmp", ImmutableMap.of("tmpDir", diff --git a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilderTest.java b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilderTest.java index 87b85a2f84..cc5a3ebf2e 100644 --- a/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilderTest.java +++ b/skeletons/standalone-compute/src/test/java/org/jclouds/servermanager/compute/ServerManagerComputeServiceContextBuilderTest.java @@ -24,7 +24,7 @@ import java.util.Properties; import org.jclouds.ContextBuilder; import org.jclouds.compute.ComputeServiceContext; -import org.jclouds.lifecycle.Closer; +import org.jclouds.internal.ContextImpl; import org.jclouds.servermanager.ServerManagerApiMetadata; import org.testng.annotations.Test; @@ -66,7 +66,7 @@ public class ServerManagerComputeServiceContextBuilderTest { public void testUnwrapIsCorrectType() { ComputeServiceContext context = ContextBuilder.newBuilder("servermanager").build(ComputeServiceContext.class); - assertEquals(context.unwrap().getClass(), Closer.class); + assertEquals(context.unwrap().getClass(), ContextImpl.class); context.close(); }