diff --git a/apis/s3/src/test/java/org/jclouds/s3/blobstore/S3BlobRequestSignerTest.java b/apis/s3/src/test/java/org/jclouds/s3/blobstore/S3BlobRequestSignerTest.java index 046836d6ee..112fa4f3c4 100644 --- a/apis/s3/src/test/java/org/jclouds/s3/blobstore/S3BlobRequestSignerTest.java +++ b/apis/s3/src/test/java/org/jclouds/s3/blobstore/S3BlobRequestSignerTest.java @@ -23,13 +23,14 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; +import javax.inject.Provider; + import org.jclouds.blobstore.BlobRequestSigner; import org.jclouds.blobstore.domain.Blob; -import org.jclouds.blobstore.domain.Blob.Factory; +import org.jclouds.blobstore.domain.BlobBuilder; import org.jclouds.date.TimeStamp; import org.jclouds.http.HttpRequest; import org.jclouds.http.RequiresHttp; -import org.jclouds.io.payloads.PhantomPayload; import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.s3.BaseS3AsyncClientTest; @@ -59,7 +60,7 @@ public class S3BlobRequestSignerTest extends BaseS3AsyncClientTest blobFactory; public void testSignGetBlob() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException, NoSuchMethodException, IOException { @@ -89,12 +90,8 @@ public class S3BlobRequestSignerTest extends BaseS3AsyncClientTest - * Blob blob = context.getBlobStore.newBlob(); - * blob.getMetadata().setName("name"); - * blob.setPayload(new PhantomPayload(length, md5)); - * blob.getPayload().setContentType("text/plain"); + * Blob blob = context.getBlobStore.blobBuilder().name("name").forSigning().contentType("text/plain") + * .contentLength(length).build(); * * * @param container @@ -77,7 +75,7 @@ public interface BlobRequestSigner { * what to upload * @throws UnsupportedOperationException * if not supported by the provider - * @see PhantomPayload + * @see BlobBuilder#forSigning */ HttpRequest signPutBlob(String container, Blob blob); } diff --git a/blobstore/src/main/java/org/jclouds/blobstore/domain/BlobBuilder.java b/blobstore/src/main/java/org/jclouds/blobstore/domain/BlobBuilder.java index bb39a2c767..96aa495255 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/domain/BlobBuilder.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/domain/BlobBuilder.java @@ -71,6 +71,11 @@ public interface BlobBuilder { */ PayloadBlobBuilder payload(InputStream payload); + /** + * If you are creating a blob only for signing, use this. {@see BlobRequestSigner} + */ + PayloadBlobBuilder forSigning(); + /** * * @param payload diff --git a/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobBuilderImpl.java b/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobBuilderImpl.java index db4b0a0b26..a43a069fd2 100644 --- a/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobBuilderImpl.java +++ b/blobstore/src/main/java/org/jclouds/blobstore/domain/internal/BlobBuilderImpl.java @@ -38,6 +38,7 @@ import org.jclouds.blobstore.domain.StorageType; import org.jclouds.crypto.Crypto; import org.jclouds.io.Payload; import org.jclouds.io.Payloads; +import org.jclouds.io.payloads.PhantomPayload; import com.google.common.base.Throwables; import com.google.common.collect.Maps; @@ -225,5 +226,15 @@ public class BlobBuilderImpl implements BlobBuilder { return this; } + @Override + public PayloadBlobBuilder forSigning() { + return builder.forSigning(); + } + + } + + @Override + public PayloadBlobBuilder forSigning() { + return payload(new PhantomPayload()); } } diff --git a/blobstore/src/test/java/org/jclouds/blobstore/TransientBlobRequestSignerTest.java b/blobstore/src/test/java/org/jclouds/blobstore/TransientBlobRequestSignerTest.java index 3c6df510f9..690bd6639f 100644 --- a/blobstore/src/test/java/org/jclouds/blobstore/TransientBlobRequestSignerTest.java +++ b/blobstore/src/test/java/org/jclouds/blobstore/TransientBlobRequestSignerTest.java @@ -24,10 +24,11 @@ import static org.testng.Assert.assertEquals; import java.io.IOException; import java.util.Properties; +import javax.inject.Provider; + import org.jclouds.blobstore.domain.Blob; -import org.jclouds.blobstore.domain.Blob.Factory; +import org.jclouds.blobstore.domain.BlobBuilder; import org.jclouds.http.HttpRequest; -import org.jclouds.io.payloads.PhantomPayload; import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextSpec; @@ -47,7 +48,7 @@ import com.google.inject.TypeLiteral; public class TransientBlobRequestSignerTest extends RestClientTest { private BlobRequestSigner signer; - private Factory blobFactory; + private Provider blobFactory; public void testSignGetBlob() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException, NoSuchMethodException, IOException { @@ -73,12 +74,8 @@ public class TransientBlobRequestSignerTest extends RestClientTest