googlestorage supports streaming

This commit is contained in:
Adrian Cole 2011-01-29 10:12:42 -08:00
parent 81223bcbca
commit 68baca4062
22 changed files with 390 additions and 160 deletions

View File

@ -57,6 +57,6 @@ public class S3ContextBuilder extends BlobStoreContextBuilder<S3Client, S3AsyncC
@Override
protected void addClientModule(List<Module> modules) {
modules.add(new S3RestClientModule());
modules.add(S3RestClientModule.create());
}
}

View File

@ -52,9 +52,13 @@ import com.google.inject.Scopes;
*/
@ConfiguresRestClient
@RequiresHttp
public class S3RestClientModule extends AWSRestClientModule<S3Client, S3AsyncClient> {
public S3RestClientModule() {
super(S3Client.class, S3AsyncClient.class);
public class S3RestClientModule<S extends S3Client, A extends S3AsyncClient> extends AWSRestClientModule<S, A> {
public static S3RestClientModule<S3Client, S3AsyncClient> create() {
return new S3RestClientModule<S3Client, S3AsyncClient>(S3Client.class, S3AsyncClient.class);
}
public S3RestClientModule(Class<S> sync, Class<A> async) {
super(sync, async);
}
@Override
@ -91,7 +95,7 @@ public class S3RestClientModule extends AWSRestClientModule<S3Client, S3AsyncCli
@TimeStamp
@Singleton
protected Supplier<String> provideTimeStampCache(@Named(Constants.PROPERTY_SESSION_INTERVAL) long seconds,
final DateService dateService) {
final DateService dateService) {
return Suppliers.memoizeWithExpiration(new Supplier<String>() {
public String get() {
return dateService.rfc822DateFormat();

View File

@ -36,17 +36,13 @@ public class ProvidersInPropertiesTest {
@Test
public void testSupportedProviders() {
Iterable<String> providers = Providers.getSupportedProviders();
assert Iterables.contains(providers, "s3") : providers;
assert Iterables.contains(providers, "walrus") : providers;
assert Iterables.contains(providers, "googlestorage") : providers;
assert Iterables.contains(providers, "s3") : providers;;
}
@Test
public void testSupportedBlobStoreProviders() {
Iterable<String> providers = BlobStoreUtils.getSupportedProviders();
assert Iterables.contains(providers, "s3") : providers;
assert Iterables.contains(providers, "walrus") : providers;
assert Iterables.contains(providers, "googlestorage") : providers;
}
}

View File

@ -26,6 +26,22 @@ import java.lang.reflect.Array;
import java.lang.reflect.Method;
import org.jclouds.aws.domain.Region;
import org.jclouds.blobstore.binders.BindBlobToMultipartFormTest;
import org.jclouds.blobstore.functions.ReturnFalseOnContainerNotFound;
import org.jclouds.blobstore.functions.ReturnFalseOnKeyNotFound;
import org.jclouds.blobstore.functions.ReturnNullOnKeyNotFound;
import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404;
import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404;
import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.functions.ParseETagHeader;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.ReturnTrueIf2xx;
import org.jclouds.http.options.GetOptions;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.s3.config.S3RestClientModule;
import org.jclouds.s3.domain.AccessControlList;
import org.jclouds.s3.domain.BucketLogging;
@ -50,22 +66,6 @@ import org.jclouds.s3.xml.ListAllMyBucketsHandler;
import org.jclouds.s3.xml.ListBucketHandler;
import org.jclouds.s3.xml.LocationConstraintHandler;
import org.jclouds.s3.xml.PayerHandler;
import org.jclouds.blobstore.binders.BindBlobToMultipartFormTest;
import org.jclouds.blobstore.functions.ReturnFalseOnContainerNotFound;
import org.jclouds.blobstore.functions.ReturnFalseOnKeyNotFound;
import org.jclouds.blobstore.functions.ReturnNullOnKeyNotFound;
import org.jclouds.blobstore.functions.ThrowContainerNotFoundOn404;
import org.jclouds.blobstore.functions.ThrowKeyNotFoundOn404;
import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.functions.ParseETagHeader;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.ReturnTrueIf2xx;
import org.jclouds.http.options.GetOptions;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.util.Strings2;
import org.testng.annotations.Test;
@ -85,8 +85,8 @@ public class S3AsyncClientTest extends BaseS3AsyncClientTest {
protected String url = "s3.amazonaws.com";
public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException {
Method method = S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class,
Array.newInstance(PutBucketOptions.class, 0).getClass());
Method method = S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, Array.newInstance(
PutBucketOptions.class, 0).getClass());
for (String region : Region.ALL_S3) {
processor.createRequest(method, region, "bucket-name");
}
@ -104,8 +104,8 @@ public class S3AsyncClientTest extends BaseS3AsyncClientTest {
assertRequestLineEquals(request, "GET https://bucket." + url + "/?location HTTP/1.1");
assertNonPayloadHeadersEqual(request,
"Authorization: AWS identity:2fFTeYJTDwiJmaAkKj732RjNbOg=\nDate: 2009-11-08T15:54:08.897Z\nHost: bucket."
+ url + "\n");
"Authorization: AWS identity:2fFTeYJTDwiJmaAkKj732RjNbOg=\nDate: 2009-11-08T15:54:08.897Z\nHost: bucket."
+ url + "\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -137,7 +137,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClientTest {
assertRequestLineEquals(request, "PUT https://bucket." + url + "/?requestPayment HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
assertPayloadEquals(request, "<RequestPaymentConfiguration xmlns=\"http://" + url
+ "/doc/2006-03-01/\"><Payer>BucketOwner</Payer></RequestPaymentConfiguration>", "text/xml", false);
+ "/doc/2006-03-01/\"><Payer>BucketOwner</Payer></RequestPaymentConfiguration>", "text/xml", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
@ -153,7 +153,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClientTest {
assertRequestLineEquals(request, "PUT https://bucket." + url + "/?requestPayment HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
assertPayloadEquals(request, "<RequestPaymentConfiguration xmlns=\"http://" + url
+ "/doc/2006-03-01/\"><Payer>Requester</Payer></RequestPaymentConfiguration>", "text/xml", false);
+ "/doc/2006-03-01/\"><Payer>Requester</Payer></RequestPaymentConfiguration>", "text/xml", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
@ -163,8 +163,8 @@ public class S3AsyncClientTest extends BaseS3AsyncClientTest {
}
public void testListBucket() throws SecurityException, NoSuchMethodException, IOException {
Method method = S3AsyncClient.class.getMethod("listBucket", String.class,
Array.newInstance(ListBucketOptions.class, 0).getClass());
Method method = S3AsyncClient.class.getMethod("listBucket", String.class, Array.newInstance(
ListBucketOptions.class, 0).getClass());
HttpRequest request = processor.createRequest(method, "bucket");
assertRequestLineEquals(request, "GET https://bucket." + url + "/ HTTP/1.1");
@ -195,23 +195,23 @@ public class S3AsyncClientTest extends BaseS3AsyncClientTest {
@Test(expectedExceptions = IllegalArgumentException.class)
public void testCopyObjectInvalidName() throws ArrayIndexOutOfBoundsException, SecurityException,
IllegalArgumentException, NoSuchMethodException, IOException {
IllegalArgumentException, NoSuchMethodException, IOException {
Method method = S3AsyncClient.class.getMethod("copyObject", String.class, String.class, String.class,
String.class, Array.newInstance(CopyObjectOptions.class, 0).getClass());
String.class, Array.newInstance(CopyObjectOptions.class, 0).getClass());
processor.createRequest(method, "sourceBucket", "sourceObject", "destinationBucket", "destinationObject");
}
public void testCopyObject() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException,
NoSuchMethodException, IOException {
NoSuchMethodException, IOException {
Method method = S3AsyncClient.class.getMethod("copyObject", String.class, String.class, String.class,
String.class, Array.newInstance(CopyObjectOptions.class, 0).getClass());
String.class, Array.newInstance(CopyObjectOptions.class, 0).getClass());
HttpRequest request = processor.createRequest(method, "sourceBucket", "sourceObject", "destinationbucket",
"destinationObject");
"destinationObject");
assertRequestLineEquals(request, "PUT https://destinationbucket." + url + "/destinationObject HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: destinationbucket." + url
+ "\nx-amz-copy-source: /sourceBucket/sourceObject\n");
+ "\nx-amz-copy-source: /sourceBucket/sourceObject\n");
assertPayloadEquals(request, null, null, false);
assertResponseParserClassEquals(method, request, ParseSax.class);
@ -268,7 +268,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClientTest {
}
public void testGetObject() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException,
NoSuchMethodException, IOException {
NoSuchMethodException, IOException {
Method method = S3AsyncClient.class.getMethod("getObject", String.class, String.class, GetOptions[].class);
HttpRequest request = processor.createRequest(method, "bucket", "object");
@ -353,17 +353,17 @@ public class S3AsyncClientTest extends BaseS3AsyncClientTest {
public void testPutBucketACL() throws SecurityException, NoSuchMethodException, IOException {
Method method = S3AsyncClient.class.getMethod("putBucketACL", String.class, AccessControlList.class);
HttpRequest request = processor.createRequest(method, "bucket",
AccessControlList.fromCannedAccessPolicy(CannedAccessPolicy.PRIVATE, "1234"));
HttpRequest request = processor.createRequest(method, "bucket", AccessControlList.fromCannedAccessPolicy(
CannedAccessPolicy.PRIVATE, "1234"));
assertRequestLineEquals(request, "PUT https://bucket." + url + "/?acl HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
assertPayloadEquals(
request,
"<AccessControlPolicy xmlns=\"http://"
+ url
+ "/doc/2006-03-01/\"><Owner><ID>1234</ID></Owner><AccessControlList><Grant><Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"CanonicalUser\"><ID>1234</ID></Grantee><Permission>FULL_CONTROL</Permission></Grant></AccessControlList></AccessControlPolicy>",
"text/xml", false);
request,
"<AccessControlPolicy xmlns=\"http://"
+ url
+ "/doc/2006-03-01/\"><Owner><ID>1234</ID></Owner><AccessControlList><Grant><Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"CanonicalUser\"><ID>1234</ID></Grantee><Permission>FULL_CONTROL</Permission></Grant></AccessControlList></AccessControlPolicy>",
"text/xml", false);
assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
assertSaxResponseParserClassEquals(method, null);
@ -373,9 +373,9 @@ public class S3AsyncClientTest extends BaseS3AsyncClientTest {
}
public void testPutBucketDefault() throws ArrayIndexOutOfBoundsException, SecurityException,
IllegalArgumentException, NoSuchMethodException, IOException {
Method method = S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class,
Array.newInstance(PutBucketOptions.class, 0).getClass());
IllegalArgumentException, NoSuchMethodException, IOException {
Method method = S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, Array.newInstance(
PutBucketOptions.class, 0).getClass());
HttpRequest request = processor.createRequest(method, (String) null, "bucket");
assertRequestLineEquals(request, "PUT https://bucket." + url + "/ HTTP/1.1");
@ -390,16 +390,16 @@ public class S3AsyncClientTest extends BaseS3AsyncClientTest {
}
public void testPutBucketEu() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException,
NoSuchMethodException, IOException {
Method method = S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class,
Array.newInstance(PutBucketOptions.class, 0).getClass());
NoSuchMethodException, IOException {
Method method = S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, Array.newInstance(
PutBucketOptions.class, 0).getClass());
HttpRequest request = processor.createRequest(method, "EU", "bucket");
assertRequestLineEquals(request, "PUT https://bucket." + url + "/ HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
assertPayloadEquals(request,
"<CreateBucketConfiguration><LocationConstraint>EU</LocationConstraint></CreateBucketConfiguration>",
"text/xml", false);
"<CreateBucketConfiguration><LocationConstraint>EU</LocationConstraint></CreateBucketConfiguration>",
"text/xml", false);
assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
assertSaxResponseParserClassEquals(method, null);
@ -409,12 +409,12 @@ public class S3AsyncClientTest extends BaseS3AsyncClientTest {
}
public void testPutObject() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException,
NoSuchMethodException, IOException {
NoSuchMethodException, IOException {
Method method = S3AsyncClient.class
.getMethod("putObject", String.class, S3Object.class, PutObjectOptions[].class);
HttpRequest request = processor.createRequest(method, "bucket",
blobToS3Object.apply(BindBlobToMultipartFormTest.TEST_BLOB));
.getMethod("putObject", String.class, S3Object.class, PutObjectOptions[].class);
HttpRequest request = processor.createRequest(method, "bucket", blobToS3Object
.apply(BindBlobToMultipartFormTest.TEST_BLOB));
assertRequestLineEquals(request, "PUT https://bucket." + url + "/hello HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
@ -429,18 +429,18 @@ public class S3AsyncClientTest extends BaseS3AsyncClientTest {
public void testPutObjectACL() throws SecurityException, NoSuchMethodException, IOException {
Method method = S3AsyncClient.class
.getMethod("putObjectACL", String.class, String.class, AccessControlList.class);
HttpRequest request = processor.createRequest(method, "bucket", "key",
AccessControlList.fromCannedAccessPolicy(CannedAccessPolicy.PRIVATE, "1234"));
.getMethod("putObjectACL", String.class, String.class, AccessControlList.class);
HttpRequest request = processor.createRequest(method, "bucket", "key", AccessControlList.fromCannedAccessPolicy(
CannedAccessPolicy.PRIVATE, "1234"));
assertRequestLineEquals(request, "PUT https://bucket." + url + "/key?acl HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
assertPayloadEquals(
request,
"<AccessControlPolicy xmlns=\"http://"
+ url
+ "/doc/2006-03-01/\"><Owner><ID>1234</ID></Owner><AccessControlList><Grant><Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"CanonicalUser\"><ID>1234</ID></Grantee><Permission>FULL_CONTROL</Permission></Grant></AccessControlList></AccessControlPolicy>",
"text/xml", false);
request,
"<AccessControlPolicy xmlns=\"http://"
+ url
+ "/doc/2006-03-01/\"><Owner><ID>1234</ID></Owner><AccessControlList><Grant><Grantee xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:type=\"CanonicalUser\"><ID>1234</ID></Grantee><Permission>FULL_CONTROL</Permission></Grant></AccessControlList></AccessControlPolicy>",
"text/xml", false);
assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
assertSaxResponseParserClassEquals(method, null);
@ -471,7 +471,7 @@ public class S3AsyncClientTest extends BaseS3AsyncClientTest {
assertRequestLineEquals(request, "PUT https://bucket." + url + "/?logging HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
assertPayloadEquals(request, "<BucketLoggingStatus xmlns=\"http://" + url + "/doc/2006-03-01/\"/>", "text/xml",
false);
false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
@ -483,16 +483,13 @@ public class S3AsyncClientTest extends BaseS3AsyncClientTest {
public void testEnableBucketLoggingOwner() throws SecurityException, NoSuchMethodException, IOException {
Method method = S3AsyncClient.class.getMethod("enableBucketLogging", String.class, BucketLogging.class);
HttpRequest request = processor
.createRequest(
method,
"bucket",
new BucketLogging("mylogs", "access_log-", ImmutableSet.<Grant> of(new Grant(new EmailAddressGrantee(
"adrian@jclouds.org"), Permission.FULL_CONTROL))));
.createRequest(method, "bucket", new BucketLogging("mylogs", "access_log-", ImmutableSet
.<Grant> of(new Grant(new EmailAddressGrantee("adrian@jclouds.org"), Permission.FULL_CONTROL))));
assertRequestLineEquals(request, "PUT https://bucket." + url + "/?logging HTTP/1.1");
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/bucket_logging.xml")),
"text/xml", false);
"text/xml", false);
assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
assertSaxResponseParserClassEquals(method, null);
@ -503,10 +500,10 @@ public class S3AsyncClientTest extends BaseS3AsyncClientTest {
@RequiresHttp
@ConfiguresRestClient
protected static final class TestS3RestClientModule extends S3RestClientModule {
@Override
protected void configure() {
super.configure();
private static final class TestS3RestClientModule extends S3RestClientModule<S3Client, S3AsyncClient> {
public TestS3RestClientModule() {
super(S3Client.class, S3AsyncClient.class);
}
@Override

View File

@ -24,8 +24,6 @@ import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.util.Properties;
import org.jclouds.s3.S3AsyncClient;
import org.jclouds.s3.config.S3RestClientModule;
import org.jclouds.blobstore.BlobRequestSigner;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.Blob.Factory;
@ -38,6 +36,9 @@ import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.s3.S3AsyncClient;
import org.jclouds.s3.S3Client;
import org.jclouds.s3.config.S3RestClientModule;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@ -128,10 +129,10 @@ public class S3BlobRequestSignerTest extends RestClientTest<S3AsyncClient> {
@RequiresHttp
@ConfiguresRestClient
private static final class TestS3RestClientModule extends S3RestClientModule {
@Override
protected void configure() {
super.configure();
private static final class TestS3RestClientModule extends S3RestClientModule<S3Client, S3AsyncClient> {
public TestS3RestClientModule() {
super(S3Client.class, S3AsyncClient.class);
}
@Override

View File

@ -33,6 +33,8 @@ import org.jclouds.http.handlers.DelegatingRetryHandler;
import org.jclouds.logging.config.NullLoggingModule;
import org.jclouds.rest.BaseRestClientTest.MockModule;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.s3.S3AsyncClient;
import org.jclouds.s3.S3Client;
import org.jclouds.s3.handlers.ParseS3ErrorFromXmlContent;
import org.testng.annotations.Test;
@ -55,7 +57,7 @@ public class S3RestClientModuleTest {
@Test
void testUpdatesOnlyOncePerSecond() throws NoSuchMethodException, InterruptedException {
S3RestClientModule module = new S3RestClientModule();
S3RestClientModule<S3Client, S3AsyncClient> module = S3RestClientModule.create();
Supplier<String> map = module.provideTimeStampCache(1, new SimpleDateFormatDateService());
String timeStamp = map.get();

View File

@ -105,12 +105,11 @@
<priority value="DEBUG" />
<appender-ref ref="ASYNCWIRE" />
</category>
<category name="jclouds.wire">
<priority value="DEBUG" />
<appender-ref ref="ASYNCWIRE" />
</category>
<!--
NOTE enabling this will break stream tests <category
name="jclouds.wire"> <priority value="DEBUG" /> <appender-ref
ref="ASYNCWIRE" /> </category>
-->
<category name="jclouds.blobstore">
<priority value="DEBUG" />
<appender-ref ref="ASYNCBLOBSTORE" />

View File

@ -174,13 +174,13 @@ cloudfiles-us.propertiesbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesUSPro
cloudfiles-uk.contextbuilder=org.jclouds.cloudfiles.CloudFilesContextBuilder
cloudfiles-uk.propertiesbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesUKPropertiesBuilder
walrus.contextbuilder=org.jclouds.s3.S3ContextBuilder
walrus.contextbuilder=org.jclouds.walrus.WalrusContextBuilder
walrus.propertiesbuilder=org.jclouds.walrus.WalrusPropertiesBuilder
eucalyptus-partnercloud-s3.contextbuilder=org.jclouds.s3.S3ContextBuilder
eucalyptus-partnercloud-s3.propertiesbuilder=org.jclouds.epc.EucalyptusPartnerCloudWalrusPropertiesBuilder
googlestorage.contextbuilder=org.jclouds.s3.S3ContextBuilder
googlestorage.contextbuilder=org.jclouds.googlestorage.GoogleStorageContextBuilder
googlestorage.propertiesbuilder=org.jclouds.googlestorage.GoogleStoragePropertiesBuilder
scaleup-storage.contextbuilder=org.jclouds.scaleup.storage.ScaleUpStorageContextBuilder

View File

@ -19,25 +19,13 @@
package org.jclouds.epc.blobstore;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import org.jclouds.blobstore.integration.internal.BaseBlobIntegrationTest;
import org.jclouds.walrus.blobstore.WalrusBlobIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusBlobIntegrationLiveTest")
public class EucalyptusPartnerCloudWalrusBlobIntegrationLiveTest extends BaseBlobIntegrationTest {
public EucalyptusPartnerCloudWalrusBlobIntegrationLiveTest() {
containerCount = 5;
}
@Override
@Test(expectedExceptions = IllegalArgumentException.class)
public void testPutObjectStream() throws InterruptedException, IOException, ExecutionException {
super.testPutObjectStream();
}
public class EucalyptusPartnerCloudWalrusBlobIntegrationLiveTest extends WalrusBlobIntegrationLiveTest {
}

View File

@ -19,15 +19,13 @@
package org.jclouds.epc.blobstore;
import org.jclouds.blobstore.integration.internal.BaseBlobLiveTest;
import org.jclouds.walrus.blobstore.WalrusBlobLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusBlobLiveTest")
public class EucalyptusPartnerCloudWalrusBlobLiveTest extends BaseBlobLiveTest {
public EucalyptusPartnerCloudWalrusBlobLiveTest() {
containerCount = 5;
}
public class EucalyptusPartnerCloudWalrusBlobLiveTest extends WalrusBlobLiveTest {
}

View File

@ -19,15 +19,12 @@
package org.jclouds.epc.blobstore;
import org.jclouds.blobstore.integration.internal.BaseBlobMapIntegrationTest;
import org.jclouds.walrus.blobstore.WalrusBlobMapIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusBlobMapIntegrationLiveTest")
public class EucalyptusPartnerCloudWalrusBlobMapIntegrationLiveTest extends BaseBlobMapIntegrationTest {
public EucalyptusPartnerCloudWalrusBlobMapIntegrationLiveTest() {
containerCount = 5;
}
public class EucalyptusPartnerCloudWalrusBlobMapIntegrationLiveTest extends WalrusBlobMapIntegrationLiveTest {
}

View File

@ -19,7 +19,7 @@
package org.jclouds.epc.blobstore;
import org.jclouds.blobstore.integration.internal.BaseBlobSignerLiveTest;
import org.jclouds.walrus.blobstore.WalrusBlobSignerLiveTest;
import org.testng.annotations.Test;
/**
@ -27,8 +27,6 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusBlobSignerLiveTest")
public class EucalyptusPartnerCloudWalrusBlobSignerLiveTest extends BaseBlobSignerLiveTest {
public EucalyptusPartnerCloudWalrusBlobSignerLiveTest() {
containerCount = 5;
}
public class EucalyptusPartnerCloudWalrusBlobSignerLiveTest extends WalrusBlobSignerLiveTest {
}

View File

@ -19,15 +19,13 @@
package org.jclouds.epc.blobstore;
import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest;
import org.jclouds.walrus.blobstore.WalrusContainerIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusContainerIntegrationLiveTest")
public class EucalyptusPartnerCloudWalrusContainerIntegrationLiveTest extends BaseContainerIntegrationTest {
public EucalyptusPartnerCloudWalrusContainerIntegrationLiveTest() {
containerCount = 5;
}
public class EucalyptusPartnerCloudWalrusContainerIntegrationLiveTest extends WalrusContainerIntegrationLiveTest {
}

View File

@ -19,15 +19,13 @@
package org.jclouds.epc.blobstore;
import org.jclouds.blobstore.integration.internal.BaseContainerLiveTest;
import org.jclouds.walrus.blobstore.WalrusContainerLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusContainerLiveTest")
public class EucalyptusPartnerCloudWalrusContainerLiveTest extends BaseContainerLiveTest {
public EucalyptusPartnerCloudWalrusContainerLiveTest() {
containerCount = 5;
}
public class EucalyptusPartnerCloudWalrusContainerLiveTest extends WalrusContainerLiveTest {
}

View File

@ -19,15 +19,13 @@
package org.jclouds.epc.blobstore;
import org.jclouds.blobstore.integration.internal.BaseInputStreamMapIntegrationTest;
import org.jclouds.walrus.blobstore.WalrusInputStreamMapIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusInputStreamMapIntegrationLiveTest")
public class EucalyptusPartnerCloudWalrusInputStreamMapIntegrationLiveTest extends BaseInputStreamMapIntegrationTest {
public EucalyptusPartnerCloudWalrusInputStreamMapIntegrationLiveTest() {
containerCount = 5;
}
public class EucalyptusPartnerCloudWalrusInputStreamMapIntegrationLiveTest extends WalrusInputStreamMapIntegrationLiveTest {
}

View File

@ -19,15 +19,13 @@
package org.jclouds.epc.blobstore;
import org.jclouds.blobstore.integration.internal.BaseServiceIntegrationTest;
import org.jclouds.walrus.blobstore.WalrusServiceIntegrationLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "EucalyptusPartnerCloudWalrusServiceIntegrationLiveTest")
public class EucalyptusPartnerCloudWalrusServiceIntegrationLiveTest extends BaseServiceIntegrationTest {
public EucalyptusPartnerCloudWalrusServiceIntegrationLiveTest() {
containerCount = 5;
}
public class EucalyptusPartnerCloudWalrusServiceIntegrationLiveTest extends WalrusServiceIntegrationLiveTest {
}

View File

@ -19,33 +19,18 @@
package org.jclouds.epc.blobstore;
import java.io.IOException;
import org.jclouds.walrus.blobstore.WalrusTestInitializer;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.BlobStoreContextFactory;
import org.jclouds.blobstore.integration.TransientBlobStoreTestInitializer;
import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
public class EucalyptusPartnerCloudWalrusTestInitializer extends TransientBlobStoreTestInitializer {
public class EucalyptusPartnerCloudWalrusTestInitializer extends WalrusTestInitializer {
public EucalyptusPartnerCloudWalrusTestInitializer() {
provider = "eucalyptus-partnercloud-s3";
BaseBlobStoreIntegrationTest.SANITY_CHECK_RETURNED_BUCKET_NAME = true;
}
@Override
protected BlobStoreContext createLiveContext(Module configurationModule, String endpoint, String apiversion,
String app, String identity, String credential) throws IOException {
return new BlobStoreContextFactory().createContext(provider, ImmutableSet.of(configurationModule,
new Log4JLoggingModule()), setupProperties(endpoint, apiversion, identity, credential));
}
}

View File

@ -0,0 +1,45 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.googlestorage;
import java.util.List;
import java.util.Properties;
import org.jclouds.googlestorage.config.GoogleStorageRestClientModule;
import org.jclouds.s3.S3ContextBuilder;
import com.google.inject.Module;
/**
*
*
* @author Adrian Cole
*/
public class GoogleStorageContextBuilder extends S3ContextBuilder {
public GoogleStorageContextBuilder(Properties props) {
super(props);
}
@Override
protected void addClientModule(List<Module> modules) {
modules.add(new GoogleStorageRestClientModule());
}
}

View File

@ -0,0 +1,78 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.googlestorage.binders;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.core.HttpHeaders;
import org.jclouds.blobstore.binders.BindUserMetadataToHeadersWithPrefix;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.utils.ModifyRequest;
import org.jclouds.s3.binders.BindS3ObjectMetadataToRequest;
import org.jclouds.s3.blobstore.functions.ObjectToBlob;
import org.jclouds.s3.domain.S3Object;
/**
*
* @author Adrian Cole
*/
@Singleton
public class BindGoogleStorageObjectMetadataToRequest extends BindS3ObjectMetadataToRequest {
private final BindUserMetadataToHeadersWithPrefix blobBinder;
private final ObjectToBlob object2Blob;
@Inject
public BindGoogleStorageObjectMetadataToRequest(ObjectToBlob object2Blob,
BindUserMetadataToHeadersWithPrefix blobBinder) {
super(object2Blob, blobBinder);
this.blobBinder = checkNotNull(blobBinder, "blobBinder");
this.object2Blob = checkNotNull(object2Blob, "object2Blob");
}
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
checkArgument(checkNotNull(input, "input") instanceof S3Object, "this binder is only valid for S3Object!");
checkNotNull(request, "request");
S3Object s3Object = S3Object.class.cast(input);
checkArgument(s3Object.getMetadata().getKey() != null, "s3Object.getMetadata().getKey() must be set!");
if (s3Object.getPayload().getContentMetadata().getContentLength() != null
&& s3Object.getPayload().getContentMetadata().getContentLength() >= 0) {
checkArgument(s3Object.getPayload().getContentMetadata().getContentLength() <= 5l * 1024 * 1024 * 1024,
"maximum size for put object is 5GB");
} else {
// Enable "chunked"/"streamed" data, where the size needn't be known in advance.
request = ModifyRequest.replaceHeader(request, "Transfer-Encoding", "chunked");
}
request = blobBinder.bindToRequest(request, object2Blob.apply(s3Object));
if (s3Object.getMetadata().getCacheControl() != null) {
request = ModifyRequest.replaceHeader(request, HttpHeaders.CACHE_CONTROL, s3Object.getMetadata()
.getCacheControl());
}
return request;
}
}

View File

@ -0,0 +1,29 @@
package org.jclouds.googlestorage.config;
import org.jclouds.googlestorage.binders.BindGoogleStorageObjectMetadataToRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.s3.S3AsyncClient;
import org.jclouds.s3.S3Client;
import org.jclouds.s3.binders.BindS3ObjectMetadataToRequest;
import org.jclouds.s3.config.S3RestClientModule;
/**
*
* @author Adrian Cole
*/
@ConfiguresRestClient
@RequiresHttp
public class GoogleStorageRestClientModule extends S3RestClientModule<S3Client, S3AsyncClient> {
public GoogleStorageRestClientModule() {
super(S3Client.class, S3AsyncClient.class);
}
@Override
protected void configure() {
bind(BindS3ObjectMetadataToRequest.class).to(BindGoogleStorageObjectMetadataToRequest.class);
super.configure();
}
}

View File

@ -0,0 +1,113 @@
package org.jclouds.googlestorage.binders;
import static org.testng.Assert.assertEquals;
import java.io.File;
import java.net.URI;
import javax.ws.rs.HttpMethod;
import org.jclouds.http.HttpRequest;
import org.jclouds.io.Payload;
import org.jclouds.io.Payloads;
import org.jclouds.s3.BaseS3AsyncClientTest;
import org.jclouds.s3.domain.S3Object;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
/**
* Tests behavior of {@code BindGoogleStorageObjectMetadataToRequest}
*
* @author Adrian Cole
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
@Test(groups = "unit", testName = "BindGoogleStorageObjectMetadataToRequestTest")
public class BindGoogleStorageObjectMetadataToRequestTest extends BaseS3AsyncClientTest {
@Test
public void testPassWithMinimumDetailsAndPayload5GB() {
S3Object object = injector.getInstance(S3Object.Factory.class).create(null);
Payload payload = Payloads.newStringPayload("");
payload.getContentMetadata().setContentLength(5 * 1024 * 1024 * 1024l);
object.setPayload(payload);
object.getMetadata().setKey("foo");
HttpRequest request = HttpRequest.builder().method("PUT").endpoint(URI.create("http://localhost")).build();
BindGoogleStorageObjectMetadataToRequest binder = injector.getInstance(BindGoogleStorageObjectMetadataToRequest.class);
assertEquals(binder.bindToRequest(request, object), HttpRequest.builder().method("PUT").endpoint(
URI.create("http://localhost")).build());
}
@Test
public void testExtendedPropertiesBind() {
S3Object object = injector.getInstance(S3Object.Factory.class).create(null);
Payload payload = Payloads.newStringPayload("");
payload.getContentMetadata().setContentLength(5 * 1024 * 1024 * 1024l);
object.setPayload(payload);
object.getMetadata().setKey("foo");
object.getMetadata().getUserMetadata().putAll(ImmutableMap.of("foo", "bar"));
HttpRequest request = HttpRequest.builder().method("PUT").endpoint(URI.create("http://localhost")).build();
BindGoogleStorageObjectMetadataToRequest binder = injector.getInstance(BindGoogleStorageObjectMetadataToRequest.class);
assertEquals(binder.bindToRequest(request, object), HttpRequest.builder().method("PUT").endpoint(
URI.create("http://localhost")).headers(ImmutableMultimap.of("x-amz-meta-foo", "bar")).build());
}
public void testNoContentLengthIsChunked() {
S3Object object = injector.getInstance(S3Object.Factory.class).create(null);
Payload payload = Payloads.newStringPayload("");
payload.getContentMetadata().setContentLength(null);
object.setPayload(payload);
object.getMetadata().setKey("foo");
HttpRequest request = HttpRequest.builder().method("PUT").endpoint(URI.create("http://localhost")).build();
BindGoogleStorageObjectMetadataToRequest binder = injector.getInstance(BindGoogleStorageObjectMetadataToRequest.class);
assertEquals(binder.bindToRequest(request, object), HttpRequest.builder().method("PUT").endpoint(
URI.create("http://localhost")).headers(ImmutableMultimap.of("Transfer-Encoding", "chunked")).build());
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void testNoNameIsBad() {
S3Object object = injector.getInstance(S3Object.Factory.class).create(null);
Payload payload = Payloads.newStringPayload("");
payload.getContentMetadata().setContentLength(5368709120000l);
object.setPayload(payload);
HttpRequest request = HttpRequest.builder().method("PUT").endpoint(URI.create("http://localhost")).build();
BindGoogleStorageObjectMetadataToRequest binder = injector.getInstance(BindGoogleStorageObjectMetadataToRequest.class);
binder.bindToRequest(request, object);
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void testOver5GBIsBad() {
S3Object object = injector.getInstance(S3Object.Factory.class).create(null);
Payload payload = Payloads.newStringPayload("");
payload.getContentMetadata().setContentLength(5 * 1024 * 1024 * 1024l + 1);
object.setPayload(payload);
object.getMetadata().setKey("foo");
HttpRequest request = HttpRequest.builder().method("PUT").endpoint(URI.create("http://localhost")).build();
BindGoogleStorageObjectMetadataToRequest binder = injector.getInstance(BindGoogleStorageObjectMetadataToRequest.class);
binder.bindToRequest(request, object);
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void testMustBeS3Object() {
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
injector.getInstance(BindGoogleStorageObjectMetadataToRequest.class).bindToRequest(request, new File("foo"));
}
@Test(expectedExceptions = { NullPointerException.class, IllegalStateException.class })
public void testNullIsBad() {
BindGoogleStorageObjectMetadataToRequest binder = injector.getInstance(BindGoogleStorageObjectMetadataToRequest.class);
HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build();
binder.bindToRequest(request, null);
}
}

View File

@ -19,6 +19,8 @@
package org.jclouds.googlestorage.blobstore;
import java.io.IOException;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.integration.internal.BaseBlobIntegrationTest;
import org.testng.annotations.Test;
@ -35,4 +37,10 @@ public class GoogleStorageBlobIntegrationLiveTest extends BaseBlobIntegrationTes
assert blob.getPayload().getContentMetadata().getContentLanguage() == null;
assert blob.getMetadata().getContentMetadata().getContentLanguage() == null;
}
// double range not supported
@Test(groups = { "integration", "live" })
public void testGetTwoRanges() throws InterruptedException, IOException {
}
}