diff --git a/labs/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStoragePropertiesBuilder.java b/labs/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStoragePropertiesBuilder.java index ddc16fbfa6..23094b5367 100644 --- a/labs/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStoragePropertiesBuilder.java +++ b/labs/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStoragePropertiesBuilder.java @@ -39,12 +39,14 @@ public class HPCloudObjectStoragePropertiesBuilder extends SwiftPropertiesBuilde @Override protected Properties defaultProperties() { - Properties properties = super.defaultProperties(); - properties.setProperty(KeystoneProperties.SERVICE_TYPE, ServiceType.OBJECT_STORE); - properties.setProperty(PROPERTY_ISO3166_CODES, "US-NV"); - properties.setProperty(PROPERTY_ENDPOINT, "https://region-a.geo-1.identity.hpcloudsvc.com:35357"); - properties.setProperty(PROPERTY_API_VERSION, "2.0"); - + Properties properties = super.defaultProperties(); + properties.setProperty(KeystoneProperties.SERVICE_TYPE, ServiceType.OBJECT_STORE); + // TODO: this doesn't actually do anything yet. + properties.setProperty(KeystoneProperties.VERSION, "2.0"); + properties.setProperty(PROPERTY_ISO3166_CODES, "US-NV"); + properties.setProperty(PROPERTY_ENDPOINT, "https://region-a.geo-1.identity.hpcloudsvc.com:35357"); + properties.setProperty(PROPERTY_API_VERSION, "1.0"); + return properties; } diff --git a/labs/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java b/labs/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java index c8cc3a1058..d2d54efd0b 100644 --- a/labs/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java +++ b/labs/hpcloud-objectstorage/src/main/java/org/jclouds/hpcloud/objectstorage/config/HPCloudObjectStorageRestClientModule.java @@ -24,6 +24,7 @@ import java.net.URI; import javax.inject.Singleton; +import com.google.inject.Scopes; import org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageAsyncClient; import org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageClient; import org.jclouds.hpcloud.services.HPExtensionCDN; @@ -35,8 +36,12 @@ import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.ServerError; import org.jclouds.json.config.GsonModule.DateAdapter; import org.jclouds.json.config.GsonModule.Iso8601DateAdapter; +import org.jclouds.location.suppliers.ImplicitLocationSupplier; import org.jclouds.location.suppliers.RegionIdToURISupplier; +import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstRegionOptionallyMatchingRegionId; +import org.jclouds.location.suppliers.implicit.OnlyLocationOrFirstZone; import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule; +import org.jclouds.openstack.keystone.v2_0.suppliers.RegionIdToURIFromAccessForTypeAndVersionSupplier; import org.jclouds.openstack.services.ServiceType; import org.jclouds.openstack.swift.CommonSwiftAsyncClient; import org.jclouds.openstack.swift.CommonSwiftClient; @@ -59,24 +64,24 @@ import com.google.inject.Provides; public class HPCloudObjectStorageRestClientModule extends RestClientModule { - private final KeystoneAuthenticationModule authModule; - public HPCloudObjectStorageRestClientModule() { - this(new KeystoneAuthenticationModule()); - } - - public HPCloudObjectStorageRestClientModule(KeystoneAuthenticationModule authModule) { super(HPCloudObjectStorageClient.class, HPCloudObjectStorageAsyncClient.class); - this.authModule = authModule; } protected void configure() { - install(authModule); install(new SwiftObjectModule()); bind(DateAdapter.class).to(Iso8601DateAdapter.class); super.configure(); } - + + @Override + protected void installLocations() { + super.installLocations(); + // TODO: select this from KeystoneProperties.VERSION; + install(KeystoneAuthenticationModule.forRegions()); + bind(ImplicitLocationSupplier.class).to(OnlyLocationOrFirstRegionOptionallyMatchingRegionId.class).in(Scopes.SINGLETON); + } + @Override protected void bindErrorHandlers() { bind(HttpErrorHandler.class).annotatedWith(Redirection.class).to(ParseSwiftErrorFromHttpResponse.class); diff --git a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java index 0c394d4139..39f5ee1b98 100644 --- a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java +++ b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageClientLiveTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.hpcloud.objectstorage.lvs; +package org.jclouds.hpcloud.objectstorage; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertTrue; @@ -24,8 +24,8 @@ import static org.testng.Assert.assertTrue; import java.net.URI; import java.util.Set; -import org.jclouds.hpcloud.objectstorage.lvs.domain.ContainerCDNMetadata; -import org.jclouds.hpcloud.objectstorage.lvs.options.ListCDNContainerOptions; +import org.jclouds.hpcloud.objectstorage.domain.ContainerCDNMetadata; +import org.jclouds.hpcloud.objectstorage.options.ListCDNContainerOptions; import org.jclouds.openstack.swift.CommonSwiftClientLiveTest; import org.jclouds.openstack.swift.domain.SwiftObject; import org.testng.annotations.Test; @@ -34,12 +34,12 @@ import org.testng.annotations.Test; * * @author Adrian Cole */ -@Test(groups = "live", testName = "HPCloudObjectStorageLasVegasClientLiveTest") -public class HPCloudObjectStorageLasVegasClientLiveTest extends CommonSwiftClientLiveTest { +@Test(groups = "live", testName = "HPCloudObjectStorageClientLiveTest") +public class HPCloudObjectStorageClientLiveTest extends CommonSwiftClientLiveTest { @Override - public HPCloudObjectStorageLasVegasClient getApi() { - return (HPCloudObjectStorageLasVegasClient) context.getProviderSpecificContext().getApi(); + public HPCloudObjectStorageClient getApi() { + return (HPCloudObjectStorageClient) context.getProviderSpecificContext().getApi(); } @Override diff --git a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderTest.java b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderTest.java index c068997061..b552bd06e4 100644 --- a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderTest.java +++ b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/HPCloudObjectStorageProviderTest.java @@ -16,22 +16,22 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.hpcloud.objectstorage.lvs; +package org.jclouds.hpcloud.objectstorage; import org.jclouds.providers.BaseProviderMetadataTest; import org.jclouds.providers.ProviderMetadata; import org.testng.annotations.Test; /** - * The HPCloudObjectStorageLasVegasProviderTest tests the {@link org.jclouds.hpcloud.objectstorage.lvs.HPCloudObjectStorageLasVegasProviderMetadata} class. + * The HPCloudObjectStorageProviderTest tests the {@link org.jclouds.hpcloud.objectstorage.HPCloudObjectStorageProviderMetadata} class. * * @author Jeremy Daggett */ -@Test(groups = "unit", testName = "HPCloudObjectStorageLasVegasProviderTest") -public class HPCloudObjectStorageLasVegasProviderTest extends BaseProviderMetadataTest { +@Test(groups = "unit", testName = "HPCloudObjectStorageProviderTest") +public class HPCloudObjectStorageProviderTest extends BaseProviderMetadataTest { - public HPCloudObjectStorageLasVegasProviderTest() { - super(new HPCloudObjectStorageLasVegasProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); + public HPCloudObjectStorageProviderTest() { + super(new HPCloudObjectStorageProviderMetadata(), ProviderMetadata.BLOBSTORE_TYPE); } } diff --git a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobIntegrationLiveTest.java b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobIntegrationLiveTest.java index 8778fda3b1..d500d58aa0 100644 --- a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobIntegrationLiveTest.java +++ b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobIntegrationLiveTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.hpcloud.objectstorage.lvs.blobstore.integration; +package org.jclouds.hpcloud.objectstorage.blobstore.integration; import org.jclouds.blobstore.domain.Blob; import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobIntegrationLiveTest; @@ -26,7 +26,7 @@ import org.testng.annotations.Test; * @author Jeremy Daggett */ @Test(groups = "live") -public class HPCloudObjectStorageLasVegasBlobIntegrationLiveTest extends SwiftBlobIntegrationLiveTest { +public class HPCloudObjectStorageBlobIntegrationLiveTest extends SwiftBlobIntegrationLiveTest { @Override protected void checkContentDisposition(Blob blob, String contentDisposition) { assert blob.getPayload().getContentMetadata().getContentDisposition().startsWith(contentDisposition) : blob diff --git a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobLiveTest.java b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobLiveTest.java index 4be59d2247..d56de82499 100644 --- a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobLiveTest.java +++ b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobLiveTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.hpcloud.objectstorage.lvs.blobstore.integration; +package org.jclouds.hpcloud.objectstorage.blobstore.integration; import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobLiveTest; import org.testng.annotations.Test; @@ -25,6 +25,6 @@ import org.testng.annotations.Test; * @author Jeremy Daggett */ @Test(groups = { "live" }) -public class HPCloudObjectStorageLasVegasBlobLiveTest extends SwiftBlobLiveTest { +public class HPCloudObjectStorageBlobLiveTest extends SwiftBlobLiveTest { } diff --git a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobMapIntegrationLiveTest.java b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobMapIntegrationLiveTest.java index ef113697ed..88a67ddae6 100644 --- a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobMapIntegrationLiveTest.java +++ b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobMapIntegrationLiveTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.hpcloud.objectstorage.lvs.blobstore.integration; +package org.jclouds.hpcloud.objectstorage.blobstore.integration; import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobMapIntegrationLiveTest; import org.testng.annotations.Test; @@ -25,6 +25,6 @@ import org.testng.annotations.Test; * @author Jeremy Daggett */ @Test(groups = "live") -public class HPCloudObjectStorageLasVegasBlobMapIntegrationLiveTest extends SwiftBlobMapIntegrationLiveTest { +public class HPCloudObjectStorageBlobMapIntegrationLiveTest extends SwiftBlobMapIntegrationLiveTest { } diff --git a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobSignerLiveTest.java b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobSignerLiveTest.java index f4c40f806b..21b6e07f56 100644 --- a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobSignerLiveTest.java +++ b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageBlobSignerLiveTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.hpcloud.objectstorage.lvs.blobstore.integration; +package org.jclouds.hpcloud.objectstorage.blobstore.integration; import org.jclouds.openstack.swift.blobstore.integration.SwiftBlobSignerLiveTest; import org.testng.annotations.Test; @@ -25,6 +25,6 @@ import org.testng.annotations.Test; * @author Jeremy Daggett */ @Test(groups = { "live" }) -public class HPCloudObjectStorageLasVegasBlobSignerLiveTest extends SwiftBlobSignerLiveTest { +public class HPCloudObjectStorageBlobSignerLiveTest extends SwiftBlobSignerLiveTest { } diff --git a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageContainerIntegrationLiveTest.java b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageContainerIntegrationLiveTest.java index 8917ef071a..73e717d4a3 100644 --- a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageContainerIntegrationLiveTest.java +++ b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageContainerIntegrationLiveTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.hpcloud.objectstorage.lvs.blobstore.integration; +package org.jclouds.hpcloud.objectstorage.blobstore.integration; import org.jclouds.openstack.swift.blobstore.integration.SwiftContainerIntegrationLiveTest; import org.testng.annotations.Test; @@ -25,6 +25,6 @@ import org.testng.annotations.Test; * @author Jeremy Daggett */ @Test(groups = "live") -public class HPCloudObjectStorageLasVegasContainerIntegrationLiveTest extends SwiftContainerIntegrationLiveTest { +public class HPCloudObjectStorageContainerIntegrationLiveTest extends SwiftContainerIntegrationLiveTest { } diff --git a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageContainerLiveTest.java b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageContainerLiveTest.java index 1e765bca0f..44e70e3159 100644 --- a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageContainerLiveTest.java +++ b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageContainerLiveTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.hpcloud.objectstorage.lvs.blobstore.integration; +package org.jclouds.hpcloud.objectstorage.blobstore.integration; import java.io.IOException; import java.net.MalformedURLException; @@ -28,7 +28,7 @@ import org.testng.annotations.Test; * @author Jeremy Daggett */ @Test(groups = { "live" }) -public class HPCloudObjectStorageLasVegasContainerLiveTest extends BaseContainerLiveTest { +public class HPCloudObjectStorageContainerLiveTest extends BaseContainerLiveTest { @Test(enabled = false) //@Test(expectedExceptions=UnsupportedOperationException.class) diff --git a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageInputStreamMapIntegrationLiveTest.java b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageInputStreamMapIntegrationLiveTest.java index 415f58aa32..34907f3417 100644 --- a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageInputStreamMapIntegrationLiveTest.java +++ b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageInputStreamMapIntegrationLiveTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.hpcloud.objectstorage.lvs.blobstore.integration; +package org.jclouds.hpcloud.objectstorage.blobstore.integration; import org.jclouds.openstack.swift.blobstore.integration.SwiftInputStreamMapIntegrationLiveTest; import org.testng.annotations.Test; @@ -25,6 +25,6 @@ import org.testng.annotations.Test; * @author Jeremy Daggett */ @Test(groups = "live") -public class HPCloudObjectStorageLasVegasInputStreamMapIntegrationLiveTest extends SwiftInputStreamMapIntegrationLiveTest { +public class HPCloudObjectStorageInputStreamMapIntegrationLiveTest extends SwiftInputStreamMapIntegrationLiveTest { } diff --git a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageServiceIntegrationLiveTest.java b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageServiceIntegrationLiveTest.java index 50cfade7eb..5b28ee5c55 100644 --- a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageServiceIntegrationLiveTest.java +++ b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageServiceIntegrationLiveTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.hpcloud.objectstorage.lvs.blobstore.integration; +package org.jclouds.hpcloud.objectstorage.blobstore.integration; import java.util.Set; @@ -29,7 +29,7 @@ import com.google.common.collect.ImmutableSet; * @author Jeremy Daggett */ @Test(groups = "live") -public class HPCloudObjectStorageLasVegasServiceIntegrationLiveTest extends SwiftServiceIntegrationLiveTest { +public class HPCloudObjectStorageServiceIntegrationLiveTest extends SwiftServiceIntegrationLiveTest { @Override protected Set getIso3166Codes() { return ImmutableSet. of("US-NV"); diff --git a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageTestInitializer.java b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageTestInitializer.java index 5e4407d44a..cc64b10643 100644 --- a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageTestInitializer.java +++ b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/blobstore/integration/HPCloudObjectStorageTestInitializer.java @@ -16,16 +16,16 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.hpcloud.objectstorage.lvs.blobstore.integration; +package org.jclouds.hpcloud.objectstorage.blobstore.integration; import org.jclouds.openstack.swift.blobstore.integration.SwiftTestInitializer; /** * @author Jeremy Daggett */ -public class HPCloudObjectStorageLasVegasTestInitializer extends SwiftTestInitializer { +public class HPCloudObjectStorageTestInitializer extends SwiftTestInitializer { - public HPCloudObjectStorageLasVegasTestInitializer() { + public HPCloudObjectStorageTestInitializer() { provider = "hpcloud-objectstorage-lvs"; } diff --git a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/functions/ParseContainerCDNMetadataListFromJsonResponseTest.java b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/functions/ParseContainerCDNMetadataListFromJsonResponseTest.java index 87719f7964..8bc5b33d20 100644 --- a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/functions/ParseContainerCDNMetadataListFromJsonResponseTest.java +++ b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/functions/ParseContainerCDNMetadataListFromJsonResponseTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.hpcloud.objectstorage.lvs.functions; +package org.jclouds.hpcloud.objectstorage.functions; import static org.testng.Assert.assertEquals; @@ -25,7 +25,7 @@ import java.net.URI; import java.util.Set; import java.util.SortedSet; -import org.jclouds.hpcloud.objectstorage.lvs.domain.ContainerCDNMetadata; +import org.jclouds.hpcloud.objectstorage.domain.ContainerCDNMetadata; import org.jclouds.http.HttpResponse; import org.jclouds.http.functions.ParseJson; import org.jclouds.io.Payloads; diff --git a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java new file mode 100644 index 0000000000..4ed6ddc274 --- /dev/null +++ b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/HPCloudObjectStorageExpectTest.java @@ -0,0 +1,65 @@ +package org.jclouds.hpcloud.objectstorage.internal; + +import com.google.common.base.Function; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.collect.ImmutableSet; +import com.google.inject.Module; +import org.jclouds.blobstore.BlobStore; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; +import org.jclouds.domain.Location; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.jclouds.logging.config.NullLoggingModule; +import org.jclouds.rest.BaseRestClientExpectTest; +import org.testng.annotations.Test; + +import java.net.URI; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +@Test(groups = "unit", testName = "HPCloudObjectStorageExpectTest") +public class HPCloudObjectStorageExpectTest extends BaseRestClientExpectTest { + + + protected HttpRequest keystoneAuthWithUsernameAndPassword; + protected HttpRequest keystoneAuthWithAccessKeyAndSecretKey; + protected String authToken; + protected HttpResponse responseWithKeystoneAccess; + + public HPCloudObjectStorageExpectTest() { + provider = "hpcloud-objectstorage"; + keystoneAuthWithUsernameAndPassword = KeystoneFixture.INSTANCE.initialAuthWithUsernameAndPassword(identity, + credential); + keystoneAuthWithAccessKeyAndSecretKey = KeystoneFixture.INSTANCE.initialAuthWithAccessKeyAndSecretKey(identity, + credential); + authToken = KeystoneFixture.INSTANCE.getAuthToken(); + responseWithKeystoneAccess = KeystoneFixture.INSTANCE.responseWithAccess(); + + identity = KeystoneFixture.INSTANCE.getTenantName() + ":" + identity; + } + + public BlobStore createClient(Function fn, Module module, Properties props) { + return new BlobStoreContextFactory(setupRestProperties()) + .createContext(provider, identity, credential, ImmutableSet.of(new ExpectModule(fn), + new NullLoggingModule(), module), props) + .getBlobStore(); + } + + public void testListObjectsWhenResponseIs2xx() throws Exception { + Map requestResponseMap = ImmutableMap. builder().put( + keystoneAuthWithAccessKeyAndSecretKey, responseWithKeystoneAccess).build(); + + BlobStore clientWhenServersExist = requestsSendResponses(requestResponseMap); + + Set locations = clientWhenServersExist.listAssignableLocations(); + assertNotNull(locations); + assertEquals(locations.size(), 1); + assertEquals(locations.iterator().next().getId(), "region-a.geo-1"); + } +} diff --git a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/KeystoneFixture.java b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/KeystoneFixture.java new file mode 100644 index 0000000000..3811ea6a9c --- /dev/null +++ b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/internal/KeystoneFixture.java @@ -0,0 +1,92 @@ +/** + * 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.hpcloud.objectstorage.internal; + +import com.google.common.base.Throwables; +import com.google.common.collect.ImmutableMultimap; +import com.google.common.net.HttpHeaders; +import org.jclouds.http.HttpRequest; +import org.jclouds.http.HttpResponse; +import org.jclouds.io.Payload; +import org.jclouds.util.Strings2; + +import java.io.IOException; +import java.net.URI; + +import static java.lang.String.format; +import static org.jclouds.rest.BaseRestClientExpectTest.payloadFromStringWithContentType; + +/** + * Base class for writing HP Cloud Object Storage Rest Client Expect tests + * + * @author Michael Arnold + */ +public enum KeystoneFixture { + INSTANCE; + + public String getTenantName(){ + return "12346637803162"; + } + + public HttpRequest initialAuthWithUsernameAndPassword(String username, String password){ + return HttpRequest + .builder() + .method("POST") + .endpoint(URI.create("https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/tokens")) + .headers(ImmutableMultimap.of(HttpHeaders.ACCEPT, "application/json")) + .payload( + payloadFromStringWithContentType( + format( + "{\"auth\":{\"passwordCredentials\":{\"username\":\"%s\",\"password\":\"%s\"},\"tenantName\":\"%s\"}}", + username, password, getTenantName()), "application/json")).build(); + } + + public HttpRequest initialAuthWithAccessKeyAndSecretKey(String accessKey, String secretKey){ + return HttpRequest + .builder() + .method("POST") + .endpoint(URI.create("https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/tokens")) + .headers(ImmutableMultimap.of(HttpHeaders.ACCEPT, "application/json")) + .payload( + payloadFromStringWithContentType( + format( + "{\"auth\":{\"apiAccessKeyCredentials\":{\"accessKey\":\"%s\",\"secretKey\":\"%s\"},\"tenantName\":\"%s\"}}", + accessKey, secretKey, getTenantName()), "application/json")).build(); + } + + public String getAuthToken(){ + return "Auth_4f173437e4b013bee56d1007"; + } + + public HttpResponse responseWithAccess(){ + return HttpResponse.builder().statusCode(200).message("HTTP/1.1 200").payload( + payloadFromResourceWithContentType("/keystoneAuthResponse.json", "application/json")).build(); + } + + + public Payload payloadFromResourceWithContentType(String resource, String contentType) { + try { + return payloadFromStringWithContentType(Strings2.toStringAndClose(getClass().getResourceAsStream(resource)), + contentType); + } catch (IOException e) { + throw Throwables.propagate(e); + } + + } +} diff --git a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/options/CreateContainerOptionsTest.java b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/options/CreateContainerOptionsTest.java index 4548eaaeaa..1238aa345b 100644 --- a/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/options/CreateContainerOptionsTest.java +++ b/labs/hpcloud-objectstorage/src/test/java/org/jclouds/hpcloud/objectstorage/options/CreateContainerOptionsTest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.jclouds.hpcloud.objectstorage.lvs.options; +package org.jclouds.hpcloud.objectstorage.options; import static org.testng.Assert.assertEquals;