mirror of https://github.com/apache/jclouds.git
Issue 154: added Transient blobstore
This commit is contained in:
parent
cb0928afae
commit
e04784373e
|
@ -26,7 +26,7 @@ import org.jclouds.atmosonline.saas.AtmosStorage;
|
||||||
import org.jclouds.atmosonline.saas.AtmosStorageAsyncClient;
|
import org.jclouds.atmosonline.saas.AtmosStorageAsyncClient;
|
||||||
import org.jclouds.atmosonline.saas.AtmosStorageClient;
|
import org.jclouds.atmosonline.saas.AtmosStorageClient;
|
||||||
import org.jclouds.atmosonline.saas.internal.StubAtmosStorageAsyncClient;
|
import org.jclouds.atmosonline.saas.internal.StubAtmosStorageAsyncClient;
|
||||||
import org.jclouds.blobstore.integration.config.StubBlobStoreModule;
|
import org.jclouds.blobstore.config.TransientBlobStoreModule;
|
||||||
import org.jclouds.concurrent.internal.SyncProxy;
|
import org.jclouds.concurrent.internal.SyncProxy;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ import com.google.inject.Provides;
|
||||||
public class AtmosStorageStubClientModule extends AbstractModule {
|
public class AtmosStorageStubClientModule extends AbstractModule {
|
||||||
|
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
install(new StubBlobStoreModule());
|
install(new TransientBlobStoreModule());
|
||||||
bind(AtmosStorageAsyncClient.class).to(StubAtmosStorageAsyncClient.class).asEagerSingleton();
|
bind(AtmosStorageAsyncClient.class).to(StubAtmosStorageAsyncClient.class).asEagerSingleton();
|
||||||
bind(URI.class).annotatedWith(AtmosStorage.class).toInstance(
|
bind(URI.class).annotatedWith(AtmosStorage.class).toInstance(
|
||||||
URI.create("https://localhost/azurestub"));
|
URI.create("https://localhost/azurestub"));
|
||||||
|
|
|
@ -40,10 +40,10 @@ import org.jclouds.atmosonline.saas.domain.DirectoryEntry;
|
||||||
import org.jclouds.atmosonline.saas.domain.SystemMetadata;
|
import org.jclouds.atmosonline.saas.domain.SystemMetadata;
|
||||||
import org.jclouds.atmosonline.saas.domain.UserMetadata;
|
import org.jclouds.atmosonline.saas.domain.UserMetadata;
|
||||||
import org.jclouds.atmosonline.saas.options.ListOptions;
|
import org.jclouds.atmosonline.saas.options.ListOptions;
|
||||||
|
import org.jclouds.blobstore.TransientAsyncBlobStore;
|
||||||
import org.jclouds.blobstore.domain.Blob;
|
import org.jclouds.blobstore.domain.Blob;
|
||||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||||
import org.jclouds.blobstore.functions.HttpGetOptionsListToGetOptions;
|
import org.jclouds.blobstore.functions.HttpGetOptionsListToGetOptions;
|
||||||
import org.jclouds.blobstore.integration.internal.StubAsyncBlobStore;
|
|
||||||
import org.jclouds.http.options.GetOptions;
|
import org.jclouds.http.options.GetOptions;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -58,7 +58,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
*/
|
*/
|
||||||
public class StubAtmosStorageAsyncClient implements AtmosStorageAsyncClient {
|
public class StubAtmosStorageAsyncClient implements AtmosStorageAsyncClient {
|
||||||
private final HttpGetOptionsListToGetOptions httpGetOptionsConverter;
|
private final HttpGetOptionsListToGetOptions httpGetOptionsConverter;
|
||||||
private final StubAsyncBlobStore blobStore;
|
private final TransientAsyncBlobStore blobStore;
|
||||||
private final AtmosObject.Factory objectProvider;
|
private final AtmosObject.Factory objectProvider;
|
||||||
private final ObjectToBlob object2Blob;
|
private final ObjectToBlob object2Blob;
|
||||||
private final BlobToObject blob2Object;
|
private final BlobToObject blob2Object;
|
||||||
|
@ -67,7 +67,7 @@ public class StubAtmosStorageAsyncClient implements AtmosStorageAsyncClient {
|
||||||
private final ResourceMetadataListToDirectoryEntryList resource2ObjectList;
|
private final ResourceMetadataListToDirectoryEntryList resource2ObjectList;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private StubAtmosStorageAsyncClient(StubAsyncBlobStore blobStore,
|
private StubAtmosStorageAsyncClient(TransientAsyncBlobStore blobStore,
|
||||||
AtmosObject.Factory objectProvider,
|
AtmosObject.Factory objectProvider,
|
||||||
HttpGetOptionsListToGetOptions httpGetOptionsConverter, ObjectToBlob object2Blob,
|
HttpGetOptionsListToGetOptions httpGetOptionsConverter, ObjectToBlob object2Blob,
|
||||||
BlobToObject blob2Object, BlobMetadataToObject blob2ObjectInfo,
|
BlobToObject blob2Object, BlobMetadataToObject blob2ObjectInfo,
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.jclouds.aws.s3.S3;
|
||||||
import org.jclouds.aws.s3.S3AsyncClient;
|
import org.jclouds.aws.s3.S3AsyncClient;
|
||||||
import org.jclouds.aws.s3.S3Client;
|
import org.jclouds.aws.s3.S3Client;
|
||||||
import org.jclouds.aws.s3.internal.StubS3AsyncClient;
|
import org.jclouds.aws.s3.internal.StubS3AsyncClient;
|
||||||
import org.jclouds.blobstore.integration.config.StubBlobStoreModule;
|
import org.jclouds.blobstore.config.TransientBlobStoreModule;
|
||||||
import org.jclouds.concurrent.internal.SyncProxy;
|
import org.jclouds.concurrent.internal.SyncProxy;
|
||||||
import org.jclouds.http.functions.config.ParserModule;
|
import org.jclouds.http.functions.config.ParserModule;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
|
@ -44,7 +44,7 @@ public class S3StubClientModule extends AbstractModule {
|
||||||
|
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
install(new ParserModule());
|
install(new ParserModule());
|
||||||
install(new StubBlobStoreModule());
|
install(new TransientBlobStoreModule());
|
||||||
bind(S3AsyncClient.class).to(StubS3AsyncClient.class).asEagerSingleton();
|
bind(S3AsyncClient.class).to(StubS3AsyncClient.class).asEagerSingleton();
|
||||||
bind(URI.class).annotatedWith(S3.class).toInstance(URI.create("https://localhost/s3stub"));
|
bind(URI.class).annotatedWith(S3.class).toInstance(URI.create("https://localhost/s3stub"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,11 +59,11 @@ import org.jclouds.aws.s3.options.PutBucketOptions;
|
||||||
import org.jclouds.aws.s3.options.PutObjectOptions;
|
import org.jclouds.aws.s3.options.PutObjectOptions;
|
||||||
import org.jclouds.blobstore.AsyncBlobStore;
|
import org.jclouds.blobstore.AsyncBlobStore;
|
||||||
import org.jclouds.blobstore.KeyNotFoundException;
|
import org.jclouds.blobstore.KeyNotFoundException;
|
||||||
|
import org.jclouds.blobstore.TransientAsyncBlobStore;
|
||||||
import org.jclouds.blobstore.domain.Blob;
|
import org.jclouds.blobstore.domain.Blob;
|
||||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||||
import org.jclouds.blobstore.domain.MutableBlobMetadata;
|
import org.jclouds.blobstore.domain.MutableBlobMetadata;
|
||||||
import org.jclouds.blobstore.functions.HttpGetOptionsListToGetOptions;
|
import org.jclouds.blobstore.functions.HttpGetOptionsListToGetOptions;
|
||||||
import org.jclouds.blobstore.integration.internal.StubAsyncBlobStore;
|
|
||||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||||
import org.jclouds.concurrent.ConcurrentUtils;
|
import org.jclouds.concurrent.ConcurrentUtils;
|
||||||
import org.jclouds.date.DateService;
|
import org.jclouds.date.DateService;
|
||||||
|
@ -95,7 +95,7 @@ public class StubS3AsyncClient implements S3AsyncClient {
|
||||||
private final ConcurrentMap<String, ConcurrentMap<String, Blob>> containerToBlobs;
|
private final ConcurrentMap<String, ConcurrentMap<String, Blob>> containerToBlobs;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private StubS3AsyncClient(StubAsyncBlobStore blobStore,
|
private StubS3AsyncClient(TransientAsyncBlobStore blobStore,
|
||||||
ConcurrentMap<String, ConcurrentMap<String, Blob>> containerToBlobs,
|
ConcurrentMap<String, ConcurrentMap<String, Blob>> containerToBlobs,
|
||||||
DateService dateService, S3Object.Factory objectProvider, Blob.Factory blobProvider,
|
DateService dateService, S3Object.Factory objectProvider, Blob.Factory blobProvider,
|
||||||
HttpGetOptionsListToGetOptions httpGetOptionsConverter, ObjectToBlob object2Blob,
|
HttpGetOptionsListToGetOptions httpGetOptionsConverter, ObjectToBlob object2Blob,
|
||||||
|
@ -156,25 +156,25 @@ public class StubS3AsyncClient implements S3AsyncClient {
|
||||||
Blob object = source.get(sourceObject);
|
Blob object = source.get(sourceObject);
|
||||||
if (options.getIfMatch() != null) {
|
if (options.getIfMatch() != null) {
|
||||||
if (!object.getMetadata().getETag().equals(options.getIfMatch()))
|
if (!object.getMetadata().getETag().equals(options.getIfMatch()))
|
||||||
return immediateFailedFuture(StubAsyncBlobStore.returnResponseException(412));
|
return immediateFailedFuture(TransientAsyncBlobStore.returnResponseException(412));
|
||||||
}
|
}
|
||||||
if (options.getIfNoneMatch() != null) {
|
if (options.getIfNoneMatch() != null) {
|
||||||
if (object.getMetadata().getETag().equals(options.getIfNoneMatch()))
|
if (object.getMetadata().getETag().equals(options.getIfNoneMatch()))
|
||||||
return immediateFailedFuture(StubAsyncBlobStore.returnResponseException(412));
|
return immediateFailedFuture(TransientAsyncBlobStore.returnResponseException(412));
|
||||||
}
|
}
|
||||||
if (options.getIfModifiedSince() != null) {
|
if (options.getIfModifiedSince() != null) {
|
||||||
Date modifiedSince = dateService.rfc822DateParse(options.getIfModifiedSince());
|
Date modifiedSince = dateService.rfc822DateParse(options.getIfModifiedSince());
|
||||||
if (modifiedSince.after(object.getMetadata().getLastModified()))
|
if (modifiedSince.after(object.getMetadata().getLastModified()))
|
||||||
return immediateFailedFuture(StubAsyncBlobStore.returnResponseException(412));
|
return immediateFailedFuture(TransientAsyncBlobStore.returnResponseException(412));
|
||||||
|
|
||||||
}
|
}
|
||||||
if (options.getIfUnmodifiedSince() != null) {
|
if (options.getIfUnmodifiedSince() != null) {
|
||||||
Date unmodifiedSince = dateService.rfc822DateParse(options.getIfUnmodifiedSince());
|
Date unmodifiedSince = dateService.rfc822DateParse(options.getIfUnmodifiedSince());
|
||||||
if (unmodifiedSince.before(object.getMetadata().getLastModified()))
|
if (unmodifiedSince.before(object.getMetadata().getLastModified()))
|
||||||
return immediateFailedFuture(StubAsyncBlobStore.returnResponseException(412));
|
return immediateFailedFuture(TransientAsyncBlobStore.returnResponseException(412));
|
||||||
}
|
}
|
||||||
Blob sourceS3 = source.get(sourceObject);
|
Blob sourceS3 = source.get(sourceObject);
|
||||||
MutableBlobMetadata newMd = StubAsyncBlobStore.copy(sourceS3.getMetadata(),
|
MutableBlobMetadata newMd = TransientAsyncBlobStore.copy(sourceS3.getMetadata(),
|
||||||
destinationObject);
|
destinationObject);
|
||||||
if (options.getAcl() != null)
|
if (options.getAcl() != null)
|
||||||
keyToAcl.put(destinationBucket + "/" + destinationObject, options.getAcl());
|
keyToAcl.put(destinationBucket + "/" + destinationObject, options.getAcl());
|
||||||
|
@ -183,7 +183,7 @@ public class StubS3AsyncClient implements S3AsyncClient {
|
||||||
Blob newBlob = blobProvider.create(newMd);
|
Blob newBlob = blobProvider.create(newMd);
|
||||||
newBlob.setPayload(sourceS3.getContent());
|
newBlob.setPayload(sourceS3.getContent());
|
||||||
dest.put(destinationObject, newBlob);
|
dest.put(destinationObject, newBlob);
|
||||||
return immediateFuture((ObjectMetadata) blob2ObjectMetadata.apply(StubAsyncBlobStore
|
return immediateFuture((ObjectMetadata) blob2ObjectMetadata.apply(TransientAsyncBlobStore
|
||||||
.copy(newMd)));
|
.copy(newMd)));
|
||||||
}
|
}
|
||||||
return immediateFailedFuture(new KeyNotFoundException(sourceBucket, sourceObject,
|
return immediateFailedFuture(new KeyNotFoundException(sourceBucket, sourceObject,
|
||||||
|
|
|
@ -26,7 +26,7 @@ import org.jclouds.azure.storage.AzureBlob;
|
||||||
import org.jclouds.azure.storage.blob.AzureBlobAsyncClient;
|
import org.jclouds.azure.storage.blob.AzureBlobAsyncClient;
|
||||||
import org.jclouds.azure.storage.blob.AzureBlobClient;
|
import org.jclouds.azure.storage.blob.AzureBlobClient;
|
||||||
import org.jclouds.azure.storage.blob.internal.StubAzureBlobAsyncClient;
|
import org.jclouds.azure.storage.blob.internal.StubAzureBlobAsyncClient;
|
||||||
import org.jclouds.blobstore.integration.config.StubBlobStoreModule;
|
import org.jclouds.blobstore.config.TransientBlobStoreModule;
|
||||||
import org.jclouds.concurrent.internal.SyncProxy;
|
import org.jclouds.concurrent.internal.SyncProxy;
|
||||||
import org.jclouds.http.functions.config.ParserModule;
|
import org.jclouds.http.functions.config.ParserModule;
|
||||||
import org.jclouds.rest.ConfiguresRestClient;
|
import org.jclouds.rest.ConfiguresRestClient;
|
||||||
|
@ -44,7 +44,7 @@ public class AzureBlobStubClientModule extends AbstractModule {
|
||||||
|
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
install(new ParserModule());
|
install(new ParserModule());
|
||||||
install(new StubBlobStoreModule());
|
install(new TransientBlobStoreModule());
|
||||||
bind(AzureBlobAsyncClient.class).to(StubAzureBlobAsyncClient.class).asEagerSingleton();
|
bind(AzureBlobAsyncClient.class).to(StubAzureBlobAsyncClient.class).asEagerSingleton();
|
||||||
bind(URI.class).annotatedWith(AzureBlob.class).toInstance(
|
bind(URI.class).annotatedWith(AzureBlob.class).toInstance(
|
||||||
URI.create("https://localhost/azurestub"));
|
URI.create("https://localhost/azurestub"));
|
||||||
|
|
|
@ -45,10 +45,10 @@ import org.jclouds.azure.storage.blob.options.ListBlobsOptions;
|
||||||
import org.jclouds.azure.storage.domain.BoundedSet;
|
import org.jclouds.azure.storage.domain.BoundedSet;
|
||||||
import org.jclouds.azure.storage.domain.internal.BoundedHashSet;
|
import org.jclouds.azure.storage.domain.internal.BoundedHashSet;
|
||||||
import org.jclouds.azure.storage.options.ListOptions;
|
import org.jclouds.azure.storage.options.ListOptions;
|
||||||
|
import org.jclouds.blobstore.TransientAsyncBlobStore;
|
||||||
import org.jclouds.blobstore.domain.Blob;
|
import org.jclouds.blobstore.domain.Blob;
|
||||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||||
import org.jclouds.blobstore.functions.HttpGetOptionsListToGetOptions;
|
import org.jclouds.blobstore.functions.HttpGetOptionsListToGetOptions;
|
||||||
import org.jclouds.blobstore.integration.internal.StubAsyncBlobStore;
|
|
||||||
import org.jclouds.http.options.GetOptions;
|
import org.jclouds.http.options.GetOptions;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
@ -63,7 +63,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
*/
|
*/
|
||||||
public class StubAzureBlobAsyncClient implements AzureBlobAsyncClient {
|
public class StubAzureBlobAsyncClient implements AzureBlobAsyncClient {
|
||||||
private final HttpGetOptionsListToGetOptions httpGetOptionsConverter;
|
private final HttpGetOptionsListToGetOptions httpGetOptionsConverter;
|
||||||
private final StubAsyncBlobStore blobStore;
|
private final TransientAsyncBlobStore blobStore;
|
||||||
private final AzureBlob.Factory objectProvider;
|
private final AzureBlob.Factory objectProvider;
|
||||||
private final AzureBlobToBlob object2Blob;
|
private final AzureBlobToBlob object2Blob;
|
||||||
private final BlobToAzureBlob blob2Object;
|
private final BlobToAzureBlob blob2Object;
|
||||||
|
@ -73,7 +73,7 @@ public class StubAzureBlobAsyncClient implements AzureBlobAsyncClient {
|
||||||
private final ConcurrentMap<String, ConcurrentMap<String, Blob>> containerToBlobs;
|
private final ConcurrentMap<String, ConcurrentMap<String, Blob>> containerToBlobs;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private StubAzureBlobAsyncClient(StubAsyncBlobStore blobStore,
|
private StubAzureBlobAsyncClient(TransientAsyncBlobStore blobStore,
|
||||||
ConcurrentMap<String, ConcurrentMap<String, Blob>> containerToBlobs,
|
ConcurrentMap<String, ConcurrentMap<String, Blob>> containerToBlobs,
|
||||||
AzureBlob.Factory objectProvider,
|
AzureBlob.Factory objectProvider,
|
||||||
HttpGetOptionsListToGetOptions httpGetOptionsConverter, AzureBlobToBlob object2Blob,
|
HttpGetOptionsListToGetOptions httpGetOptionsConverter, AzureBlobToBlob object2Blob,
|
||||||
|
|
|
@ -108,7 +108,7 @@
|
||||||
<systemProperties>
|
<systemProperties>
|
||||||
<property>
|
<property>
|
||||||
<name>jclouds.test.initializer</name>
|
<name>jclouds.test.initializer</name>
|
||||||
<value>org.jclouds.blobstore.integration.StubTestInitializer</value>
|
<value>org.jclouds.blobstore.integration.TransientBlobStoreTestInitializer</value>
|
||||||
</property>
|
</property>
|
||||||
<property>
|
<property>
|
||||||
<name>jclouds.blobstore.httpstream.url</name>
|
<name>jclouds.blobstore.httpstream.url</name>
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
package org.jclouds.blobstore.integration.internal;
|
package org.jclouds.blobstore;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.google.common.base.Preconditions.checkState;
|
import static com.google.common.base.Preconditions.checkState;
|
||||||
|
@ -50,9 +50,6 @@ import javax.inject.Named;
|
||||||
import javax.ws.rs.core.HttpHeaders;
|
import javax.ws.rs.core.HttpHeaders;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
import org.jclouds.blobstore.BlobStoreContext;
|
|
||||||
import org.jclouds.blobstore.ContainerNotFoundException;
|
|
||||||
import org.jclouds.blobstore.KeyNotFoundException;
|
|
||||||
import org.jclouds.blobstore.domain.Blob;
|
import org.jclouds.blobstore.domain.Blob;
|
||||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||||
import org.jclouds.blobstore.domain.MutableBlobMetadata;
|
import org.jclouds.blobstore.domain.MutableBlobMetadata;
|
||||||
|
@ -95,7 +92,7 @@ import com.google.inject.internal.Nullable;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
* @author James Murty
|
* @author James Murty
|
||||||
*/
|
*/
|
||||||
public class StubAsyncBlobStore extends BaseAsyncBlobStore {
|
public class TransientAsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
|
|
||||||
protected final DateService dateService;
|
protected final DateService dateService;
|
||||||
protected final EncryptionService encryptionService;
|
protected final EncryptionService encryptionService;
|
||||||
|
@ -105,7 +102,7 @@ public class StubAsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
protected final Factory blobFactory;
|
protected final Factory blobFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
protected StubAsyncBlobStore(BlobStoreContext context, DateService dateService,
|
protected TransientAsyncBlobStore(BlobStoreContext context, DateService dateService,
|
||||||
EncryptionService encryptionService,
|
EncryptionService encryptionService,
|
||||||
ConcurrentMap<String, ConcurrentMap<String, Blob>> containerToBlobs,
|
ConcurrentMap<String, ConcurrentMap<String, Blob>> containerToBlobs,
|
||||||
HttpGetOptionsListToGetOptions httpGetOptionsConverter,
|
HttpGetOptionsListToGetOptions httpGetOptionsConverter,
|
||||||
|
@ -267,14 +264,6 @@ public class StubAsyncBlobStore extends BaseAsyncBlobStore {
|
||||||
return newMd;
|
return newMd;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public BlobMetadata metadata(final String container, final String key) {
|
|
||||||
// if (!getContainerToBlobs().containsKey(container))
|
|
||||||
// return immediateFailedFuture(new ContainerNotFoundException(container));
|
|
||||||
// Map<String, Blob> realContents = getContainerToBlobs().get(container);
|
|
||||||
// if (!realContents.containsKey(key))
|
|
||||||
// return immediateFailedFuture(new KeyNotFoundException(container, key));
|
|
||||||
// return copy(realContents.get(key).getMetadata());
|
|
||||||
// }
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
|
@ -16,36 +16,45 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
package org.jclouds.blobstore.integration;
|
package org.jclouds.blobstore;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import org.jclouds.PropertiesBuilder;
|
import org.jclouds.blobstore.config.TransientBlobStoreContextModule;
|
||||||
|
import org.jclouds.blobstore.config.TransientBlobStoreModule;
|
||||||
|
|
||||||
|
import com.google.inject.Module;
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds properties used in Stub Connections
|
|
||||||
*
|
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class StubPropertiesBuilder extends PropertiesBuilder {
|
public class TransientBlobStoreContextBuilder extends
|
||||||
|
BlobStoreContextBuilder<AsyncBlobStore, BlobStore> {
|
||||||
|
|
||||||
public StubPropertiesBuilder(Properties properties) {
|
/**
|
||||||
super(properties);
|
* This is only to have the same syntax.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public TransientBlobStoreContextBuilder(Properties props) {
|
||||||
|
this();
|
||||||
}
|
}
|
||||||
|
|
||||||
public StubPropertiesBuilder(String id, String secret) {
|
public TransientBlobStoreContextBuilder() {
|
||||||
super();
|
super(new TypeLiteral<AsyncBlobStore>() {
|
||||||
|
}, new TypeLiteral<BlobStore>() {
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PropertiesBuilder withCredentials(String account, String key) {
|
public void addContextModule(List<Module> modules) {
|
||||||
return this;
|
modules.add(new TransientBlobStoreContextModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PropertiesBuilder withEndpoint(URI endpoint) {
|
protected void addClientModule(List<Module> modules) {
|
||||||
return this;
|
modules.add(new TransientBlobStoreModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package org.jclouds.blobstore;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.jclouds.PropertiesBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds properties used in transient blobstores
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class TransientBlobStorePropertiesBuilder extends PropertiesBuilder {
|
||||||
|
@Override
|
||||||
|
protected Properties defaultProperties() {
|
||||||
|
Properties properties = super.defaultProperties();
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TransientBlobStorePropertiesBuilder(Properties properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TransientBlobStorePropertiesBuilder(String id, String secret) {
|
||||||
|
super();
|
||||||
|
withCredentials(id, secret);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TransientBlobStorePropertiesBuilder withCredentials(String id, String secret) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TransientBlobStorePropertiesBuilder withEndpoint(URI endpoint) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
package org.jclouds.blobstore.config;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.blobstore.AsyncBlobStore;
|
||||||
|
import org.jclouds.blobstore.BlobStore;
|
||||||
|
import org.jclouds.blobstore.BlobStoreContext;
|
||||||
|
import org.jclouds.blobstore.TransientAsyncBlobStore;
|
||||||
|
import org.jclouds.blobstore.attr.ConsistencyModel;
|
||||||
|
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
||||||
|
import org.jclouds.concurrent.Timeout;
|
||||||
|
import org.jclouds.concurrent.internal.SyncProxy;
|
||||||
|
import org.jclouds.lifecycle.Closer;
|
||||||
|
import org.jclouds.rest.RestContext;
|
||||||
|
import org.jclouds.rest.internal.RestContextImpl;
|
||||||
|
|
||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
import com.google.inject.Provides;
|
||||||
|
import com.google.inject.Scopes;
|
||||||
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the {@link TransientBlobStoreContext}; requires {@link TransientAsyncBlobStore} bound.
|
||||||
|
*
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
public class TransientBlobStoreContextModule extends AbstractModule {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure() {
|
||||||
|
install(new BlobStoreObjectModule<AsyncBlobStore, BlobStore>(
|
||||||
|
new TypeLiteral<AsyncBlobStore>() {
|
||||||
|
}, new TypeLiteral<BlobStore>() {
|
||||||
|
}));
|
||||||
|
install(new BlobStoreMapModule());
|
||||||
|
bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT);
|
||||||
|
bind(AsyncBlobStore.class).to(TransientAsyncBlobStore.class).asEagerSingleton();
|
||||||
|
bind(BlobStoreContext.class)
|
||||||
|
.to(
|
||||||
|
new TypeLiteral<BlobStoreContextImpl<AsyncBlobStore, BlobStore>>() {
|
||||||
|
}).in(Scopes.SINGLETON);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
|
||||||
|
private static interface TransientBlobStore extends BlobStore {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
public BlobStore provideClient(AsyncBlobStore client) throws IllegalArgumentException,
|
||||||
|
SecurityException, NoSuchMethodException {
|
||||||
|
return SyncProxy.create(TransientBlobStore.class, client);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
@Singleton
|
||||||
|
RestContext<AsyncBlobStore, BlobStore> provideContext(Closer closer, final AsyncBlobStore async,
|
||||||
|
final BlobStore sync) {
|
||||||
|
return new RestContextImpl<AsyncBlobStore, BlobStore>(closer, async, sync, URI
|
||||||
|
.create("http://localhost/transient"), System.getProperty("user.name"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -16,21 +16,21 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
package org.jclouds.blobstore.integration.config;
|
package org.jclouds.blobstore.config;
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentMap;
|
import java.util.concurrent.ConcurrentMap;
|
||||||
|
|
||||||
import org.jclouds.Constants;
|
import org.jclouds.Constants;
|
||||||
|
import org.jclouds.blobstore.TransientAsyncBlobStore;
|
||||||
import org.jclouds.blobstore.domain.Blob;
|
import org.jclouds.blobstore.domain.Blob;
|
||||||
import org.jclouds.blobstore.integration.internal.StubAsyncBlobStore;
|
|
||||||
import org.jclouds.util.Jsr330;
|
import org.jclouds.util.Jsr330;
|
||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Scopes;
|
import com.google.inject.Scopes;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
|
|
||||||
public class StubBlobStoreModule extends AbstractModule {
|
public class TransientBlobStoreModule extends AbstractModule {
|
||||||
|
|
||||||
// must be singleton for all threads and all objects or tests may fail;
|
// must be singleton for all threads and all objects or tests may fail;
|
||||||
static final ConcurrentHashMap<String, ConcurrentMap<String, Blob>> map = new ConcurrentHashMap<String, ConcurrentMap<String, Blob>>();
|
static final ConcurrentHashMap<String, ConcurrentMap<String, Blob>> map = new ConcurrentHashMap<String, ConcurrentMap<String, Blob>>();
|
||||||
|
@ -39,7 +39,7 @@ public class StubBlobStoreModule extends AbstractModule {
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
bind(new TypeLiteral<ConcurrentMap<String, ConcurrentMap<String, Blob>>>() {
|
bind(new TypeLiteral<ConcurrentMap<String, ConcurrentMap<String, Blob>>>() {
|
||||||
}).toInstance(map);
|
}).toInstance(map);
|
||||||
bind(StubAsyncBlobStore.class).in(Scopes.SINGLETON);
|
bind(TransientAsyncBlobStore.class).in(Scopes.SINGLETON);
|
||||||
bindConstant().annotatedWith(Jsr330.named(Constants.PROPERTY_USER_THREADS)).to(0);
|
bindConstant().annotatedWith(Jsr330.named(Constants.PROPERTY_USER_THREADS)).to(0);
|
||||||
bindConstant().annotatedWith(Jsr330.named(Constants.PROPERTY_IO_WORKER_THREADS)).to(0);
|
bindConstant().annotatedWith(Jsr330.named(Constants.PROPERTY_IO_WORKER_THREADS)).to(0);
|
||||||
}
|
}
|
|
@ -27,3 +27,5 @@ cloudfiles.contextbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesContextBuil
|
||||||
cloudfiles.propertiesbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesPropertiesBuilder
|
cloudfiles.propertiesbuilder=org.jclouds.rackspace.cloudfiles.CloudFilesPropertiesBuilder
|
||||||
s3.contextbuilder=org.jclouds.aws.s3.S3ContextBuilder
|
s3.contextbuilder=org.jclouds.aws.s3.S3ContextBuilder
|
||||||
s3.propertiesbuilder=org.jclouds.aws.s3.S3PropertiesBuilder
|
s3.propertiesbuilder=org.jclouds.aws.s3.S3PropertiesBuilder
|
||||||
|
transient.contextbuilder=org.jclouds.blobstore.TransientBlobStoreContextBuilder
|
||||||
|
transient.propertiesbuilder=org.jclouds.blobstore.TransientBlobStorePropertiesBuilder
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
(ns org.jclouds.blobstore-test
|
(ns org.jclouds.blobstore-test
|
||||||
(:use [org.jclouds.blobstore] :reload-all)
|
(:use [org.jclouds.blobstore] :reload-all)
|
||||||
(:use clojure.test)
|
(:use clojure.test)
|
||||||
(:import org.jclouds.blobstore.integration.StubBlobStoreContextBuilder))
|
(:import org.jclouds.blobstore.TransientBlobStoreContextBuilder))
|
||||||
|
|
||||||
(def stub-context (.buildBlobStoreContext (StubBlobStoreContextBuilder.)))
|
(def stub-context (.buildBlobStoreContext (TransientBlobStoreContextBuilder.)))
|
||||||
(def stub-blobstore (.getBlobStore stub-context))
|
(def stub-blobstore (.getBlobStore stub-context))
|
||||||
|
|
||||||
(defn clean-stub-fixture [f]
|
(defn clean-stub-fixture [f]
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 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.blobstore;
|
||||||
|
|
||||||
|
import static org.testng.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.testng.annotations.BeforeTest;
|
||||||
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
import com.google.common.io.Resources;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Adrian Cole
|
||||||
|
*/
|
||||||
|
@Test(groups = "unit", testName = "blobstore.PropertiesTest")
|
||||||
|
public class PropertiesTest {
|
||||||
|
private Properties properties;
|
||||||
|
|
||||||
|
@BeforeTest
|
||||||
|
public void setUp() throws IOException {
|
||||||
|
properties = new Properties();
|
||||||
|
properties.load(Resources.newInputStreamSupplier(
|
||||||
|
Resources.getResource("blobstore.properties")).getInput());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testTransient() {
|
||||||
|
assertEquals(properties.getProperty("transient.contextbuilder"),
|
||||||
|
TransientBlobStoreContextBuilder.class.getName());
|
||||||
|
assertEquals(properties.getProperty("transient.propertiesbuilder"),
|
||||||
|
TransientBlobStorePropertiesBuilder.class.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -27,9 +27,9 @@ import java.net.URI;
|
||||||
import javax.ws.rs.core.HttpHeaders;
|
import javax.ws.rs.core.HttpHeaders;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
|
import org.jclouds.blobstore.TransientBlobStoreContextBuilder;
|
||||||
import org.jclouds.blobstore.domain.Blob;
|
import org.jclouds.blobstore.domain.Blob;
|
||||||
import org.jclouds.blobstore.domain.Blob.Factory;
|
import org.jclouds.blobstore.domain.Blob.Factory;
|
||||||
import org.jclouds.blobstore.integration.StubBlobStoreContextBuilder;
|
|
||||||
import org.jclouds.http.HttpRequest;
|
import org.jclouds.http.HttpRequest;
|
||||||
import org.jclouds.util.Utils;
|
import org.jclouds.util.Utils;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
@ -48,7 +48,7 @@ public class BindBlobToMultipartFormTest {
|
||||||
public static final Blob TEST_BLOB;
|
public static final Blob TEST_BLOB;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
blobProvider = new StubBlobStoreContextBuilder().buildInjector().getInstance(
|
blobProvider = new TransientBlobStoreContextBuilder().buildInjector().getInstance(
|
||||||
Blob.Factory.class);
|
Blob.Factory.class);
|
||||||
StringBuilder builder = new StringBuilder("--");
|
StringBuilder builder = new StringBuilder("--");
|
||||||
addData(BOUNDRY, "hello", builder);
|
addData(BOUNDRY, "hello", builder);
|
||||||
|
|
|
@ -1,115 +0,0 @@
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Copyright (C) 2009 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.blobstore.integration;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
|
|
||||||
import org.jclouds.blobstore.AsyncBlobStore;
|
|
||||||
import org.jclouds.blobstore.BlobStore;
|
|
||||||
import org.jclouds.blobstore.BlobStoreContext;
|
|
||||||
import org.jclouds.blobstore.BlobStoreContextBuilder;
|
|
||||||
import org.jclouds.blobstore.attr.ConsistencyModel;
|
|
||||||
import org.jclouds.blobstore.config.BlobStoreMapModule;
|
|
||||||
import org.jclouds.blobstore.config.BlobStoreObjectModule;
|
|
||||||
import org.jclouds.blobstore.integration.config.StubBlobStoreModule;
|
|
||||||
import org.jclouds.blobstore.integration.internal.StubAsyncBlobStore;
|
|
||||||
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
|
||||||
import org.jclouds.concurrent.internal.SyncProxy;
|
|
||||||
import org.jclouds.lifecycle.Closer;
|
|
||||||
import org.jclouds.rest.RestContext;
|
|
||||||
import org.jclouds.rest.internal.RestContextImpl;
|
|
||||||
|
|
||||||
import com.google.inject.AbstractModule;
|
|
||||||
import com.google.inject.Module;
|
|
||||||
import com.google.inject.Provides;
|
|
||||||
import com.google.inject.Scopes;
|
|
||||||
import com.google.inject.TypeLiteral;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Adrian Cole
|
|
||||||
*/
|
|
||||||
public class StubBlobStoreContextBuilder extends BlobStoreContextBuilder<AsyncBlobStore, BlobStore> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is only to have the same syntax.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public StubBlobStoreContextBuilder(Properties props) {
|
|
||||||
this();
|
|
||||||
}
|
|
||||||
|
|
||||||
public StubBlobStoreContextBuilder() {
|
|
||||||
super(new TypeLiteral<AsyncBlobStore>() {
|
|
||||||
}, new TypeLiteral<BlobStore>() {
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
|
|
||||||
private static interface StubBlobStore extends BlobStore {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addContextModule(List<Module> modules) {
|
|
||||||
modules.add(new BlobStoreObjectModule<AsyncBlobStore, BlobStore>(
|
|
||||||
new TypeLiteral<AsyncBlobStore>() {
|
|
||||||
}, new TypeLiteral<BlobStore>() {
|
|
||||||
}));
|
|
||||||
modules.add(new BlobStoreMapModule());
|
|
||||||
modules.add(new AbstractModule() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void configure() {
|
|
||||||
bind(AsyncBlobStore.class).to(StubAsyncBlobStore.class).asEagerSingleton();
|
|
||||||
bind(ConsistencyModel.class).toInstance(ConsistencyModel.STRICT);
|
|
||||||
bind(BlobStoreContext.class).to(new TypeLiteral<BlobStoreContextImpl<AsyncBlobStore, BlobStore>>(){}).in(Scopes.SINGLETON);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
public BlobStore provideClient(AsyncBlobStore client) throws IllegalArgumentException,
|
|
||||||
SecurityException, NoSuchMethodException {
|
|
||||||
return SyncProxy.create(StubBlobStore.class, client);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Provides
|
|
||||||
@Singleton
|
|
||||||
RestContext<AsyncBlobStore, BlobStore> provideContext(Closer closer,
|
|
||||||
final AsyncBlobStore async, final BlobStore sync) {
|
|
||||||
return new RestContextImpl<AsyncBlobStore, BlobStore>(closer, async, sync, URI
|
|
||||||
.create("http://localhost/blobstub"), "foo");
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void addClientModule(List<Module> modules) {
|
|
||||||
modules.add(new StubBlobStoreModule());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -26,7 +26,7 @@ import org.testng.annotations.Test;
|
||||||
* @author James Murty
|
* @author James Murty
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "integration" }, testName = "blobstore.StubBlobIntegrationTest")
|
@Test(groups = { "integration" }, testName = "blobstore.TransientBlobIntegrationTest")
|
||||||
public class StubBlobIntegrationTest extends BaseBlobIntegrationTest {
|
public class TransientBlobIntegrationTest extends BaseBlobIntegrationTest {
|
||||||
|
|
||||||
}
|
}
|
|
@ -25,7 +25,7 @@ import org.testng.annotations.Test;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Test(groups = { "integration", "live" }, testName = "blobstore.StubBlobMapIntegrationTest")
|
@Test(groups = { "integration", "live" }, testName = "blobstore.TransientBlobMapIntegrationTest")
|
||||||
public class StubBlobMapIntegrationTest extends BaseBlobMapIntegrationTest {
|
public class TransientBlobMapIntegrationTest extends BaseBlobMapIntegrationTest {
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,7 +18,10 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.blobstore.integration;
|
package org.jclouds.blobstore.integration;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.jclouds.blobstore.BlobStoreContext;
|
import org.jclouds.blobstore.BlobStoreContext;
|
||||||
|
import org.jclouds.blobstore.BlobStoreContextFactory;
|
||||||
import org.jclouds.blobstore.integration.internal.BaseTestInitializer;
|
import org.jclouds.blobstore.integration.internal.BaseTestInitializer;
|
||||||
|
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
@ -27,17 +30,17 @@ import com.google.inject.Module;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class StubTestInitializer extends BaseTestInitializer {
|
public class TransientBlobStoreTestInitializer extends BaseTestInitializer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BlobStoreContext createLiveContext(Module configurationModule, String url, String app,
|
protected BlobStoreContext createLiveContext(Module configurationModule, String url, String app,
|
||||||
String account, String key) {
|
String account, String key) throws IOException {
|
||||||
return createStubContext();
|
return createStubContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected BlobStoreContext createStubContext() {
|
protected BlobStoreContext createStubContext() throws IOException {
|
||||||
return new StubBlobStoreContextBuilder().buildBlobStoreContext();
|
return new BlobStoreContextFactory().createContext("transient", "foo", "bar");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -25,7 +25,7 @@ import org.testng.annotations.Test;
|
||||||
* @author James Murty
|
* @author James Murty
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "integration", "live" }, testName = "blobstore.StubContainerIntegrationTest")
|
@Test(groups = { "integration", "live" }, testName = "blobstore.TransientContainerIntegrationTest")
|
||||||
public class StubContainerIntegrationTest extends BaseContainerIntegrationTest {
|
public class TransientContainerIntegrationTest extends BaseContainerIntegrationTest {
|
||||||
|
|
||||||
}
|
}
|
|
@ -24,7 +24,7 @@ import org.testng.annotations.Test;
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "integration", "live" }, testName = "blobstore.StubInputStreamMapIntegrationTest")
|
@Test(groups = { "integration", "live" }, testName = "blobstore.TransientInputStreamMapIntegrationTest")
|
||||||
public class StubInputStreamMapIntegrationTest extends BaseInputStreamMapIntegrationTest {
|
public class TransientInputStreamMapIntegrationTest extends BaseInputStreamMapIntegrationTest {
|
||||||
|
|
||||||
}
|
}
|
|
@ -24,7 +24,7 @@ import org.testng.annotations.Test;
|
||||||
/**
|
/**
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Test(groups = { "integration", "live" }, testName = "blobstore.StubServiceIntegrationTest")
|
@Test(groups = { "integration", "live" }, testName = "blobstore.TransientServiceIntegrationTest")
|
||||||
public class StubServiceIntegrationTest extends BaseServiceIntegrationTest {
|
public class TransientServiceIntegrationTest extends BaseServiceIntegrationTest {
|
||||||
|
|
||||||
}
|
}
|
|
@ -48,7 +48,7 @@ public abstract class BaseTestInitializer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract BlobStoreContext createStubContext();
|
protected abstract BlobStoreContext createStubContext() throws IOException;
|
||||||
|
|
||||||
protected abstract BlobStoreContext createLiveContext(Module configurationModule, String url,
|
protected abstract BlobStoreContext createLiveContext(Module configurationModule, String url,
|
||||||
String app, String account, String key) throws IOException;
|
String app, String account, String key) throws IOException;
|
||||||
|
|
|
@ -23,8 +23,8 @@ import static org.testng.Assert.assertEquals;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.blobstore.BlobStoreContext;
|
import org.jclouds.blobstore.BlobStoreContext;
|
||||||
|
import org.jclouds.blobstore.TransientBlobStoreContextBuilder;
|
||||||
import org.jclouds.blobstore.domain.Blob;
|
import org.jclouds.blobstore.domain.Blob;
|
||||||
import org.jclouds.blobstore.integration.StubBlobStoreContextBuilder;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
import org.testng.annotations.BeforeClass;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ public class BaseBlobMapTest {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
void addDefaultObjectsSoThatTestsWillPass() {
|
void addDefaultObjectsSoThatTestsWillPass() {
|
||||||
context = new StubBlobStoreContextBuilder().buildBlobStoreContext();
|
context = new TransientBlobStoreContextBuilder().buildBlobStoreContext();
|
||||||
map = (InputStreamMapImpl) context.createInputStreamMap("test");
|
map = (InputStreamMapImpl) context.createInputStreamMap("test");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.rackspace.cloudfiles.config;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.blobstore.integration.config.StubBlobStoreModule;
|
import org.jclouds.blobstore.config.TransientBlobStoreModule;
|
||||||
import org.jclouds.concurrent.internal.SyncProxy;
|
import org.jclouds.concurrent.internal.SyncProxy;
|
||||||
import org.jclouds.http.functions.config.ParserModule;
|
import org.jclouds.http.functions.config.ParserModule;
|
||||||
import org.jclouds.rackspace.cloudfiles.CloudFilesAsyncClient;
|
import org.jclouds.rackspace.cloudfiles.CloudFilesAsyncClient;
|
||||||
|
@ -36,7 +36,7 @@ public class CloudFilesStubClientModule extends AbstractModule {
|
||||||
|
|
||||||
protected void configure() {
|
protected void configure() {
|
||||||
install(new ParserModule());
|
install(new ParserModule());
|
||||||
install(new StubBlobStoreModule());
|
install(new TransientBlobStoreModule());
|
||||||
bind(CloudFilesAsyncClient.class).to(StubCloudFilesAsyncClient.class).asEagerSingleton();
|
bind(CloudFilesAsyncClient.class).to(StubCloudFilesAsyncClient.class).asEagerSingleton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,11 +30,11 @@ import java.util.concurrent.ConcurrentMap;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
import org.jclouds.blobstore.TransientAsyncBlobStore;
|
||||||
import org.jclouds.blobstore.domain.Blob;
|
import org.jclouds.blobstore.domain.Blob;
|
||||||
import org.jclouds.blobstore.domain.BlobMetadata;
|
import org.jclouds.blobstore.domain.BlobMetadata;
|
||||||
import org.jclouds.blobstore.domain.PageSet;
|
import org.jclouds.blobstore.domain.PageSet;
|
||||||
import org.jclouds.blobstore.functions.HttpGetOptionsListToGetOptions;
|
import org.jclouds.blobstore.functions.HttpGetOptionsListToGetOptions;
|
||||||
import org.jclouds.blobstore.integration.internal.StubAsyncBlobStore;
|
|
||||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||||
import org.jclouds.http.options.GetOptions;
|
import org.jclouds.http.options.GetOptions;
|
||||||
import org.jclouds.rackspace.cloudfiles.CloudFilesAsyncClient;
|
import org.jclouds.rackspace.cloudfiles.CloudFilesAsyncClient;
|
||||||
|
@ -64,7 +64,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class StubCloudFilesAsyncClient implements CloudFilesAsyncClient {
|
public class StubCloudFilesAsyncClient implements CloudFilesAsyncClient {
|
||||||
private final HttpGetOptionsListToGetOptions httpGetOptionsConverter;
|
private final HttpGetOptionsListToGetOptions httpGetOptionsConverter;
|
||||||
private final StubAsyncBlobStore blobStore;
|
private final TransientAsyncBlobStore blobStore;
|
||||||
private final CFObject.Factory objectProvider;
|
private final CFObject.Factory objectProvider;
|
||||||
private final ObjectToBlob object2Blob;
|
private final ObjectToBlob object2Blob;
|
||||||
private final BlobToObject blob2Object;
|
private final BlobToObject blob2Object;
|
||||||
|
@ -74,7 +74,7 @@ public class StubCloudFilesAsyncClient implements CloudFilesAsyncClient {
|
||||||
private final ConcurrentMap<String, ConcurrentMap<String, Blob>> containerToBlobs;
|
private final ConcurrentMap<String, ConcurrentMap<String, Blob>> containerToBlobs;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private StubCloudFilesAsyncClient(StubAsyncBlobStore blobStore,
|
private StubCloudFilesAsyncClient(TransientAsyncBlobStore blobStore,
|
||||||
ConcurrentMap<String, ConcurrentMap<String, Blob>> containerToBlobs,
|
ConcurrentMap<String, ConcurrentMap<String, Blob>> containerToBlobs,
|
||||||
CFObject.Factory objectProvider,
|
CFObject.Factory objectProvider,
|
||||||
HttpGetOptionsListToGetOptions httpGetOptionsConverter, ObjectToBlob object2Blob,
|
HttpGetOptionsListToGetOptions httpGetOptionsConverter, ObjectToBlob object2Blob,
|
||||||
|
|
Loading…
Reference in New Issue