mirror of https://github.com/apache/jclouds.git
wrapper -> view
This commit is contained in:
parent
2756040b7e
commit
df7d2acbb4
|
@ -82,7 +82,7 @@ public class ComputeTaskUtils {
|
||||||
return ContextBuilder.newBuilder(provider)
|
return ContextBuilder.newBuilder(provider)
|
||||||
.credentials(creds.identity, creds.credential)
|
.credentials(creds.identity, creds.credential)
|
||||||
.modules(modules)
|
.modules(modules)
|
||||||
.overrides(props).buildAndWrapWith(ComputeServiceContext.class);
|
.overrides(props).buildView(ComputeServiceContext.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class AtmosApiMetadata extends BaseRestApiMetadata {
|
||||||
.version("1.4.0")
|
.version("1.4.0")
|
||||||
.defaultEndpoint("https://accesspoint.atmosonline.com")
|
.defaultEndpoint("https://accesspoint.atmosonline.com")
|
||||||
.defaultProperties(AtmosApiMetadata.defaultProperties())
|
.defaultProperties(AtmosApiMetadata.defaultProperties())
|
||||||
.wrapper(TypeToken.of(BlobStoreContext.class))
|
.view(TypeToken.of(BlobStoreContext.class))
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(AtmosRestClientModule.class, AtmosBlobStoreContextModule.class));
|
.defaultModules(ImmutableSet.<Class<? extends Module>>of(AtmosRestClientModule.class, AtmosBlobStoreContextModule.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ import com.google.common.collect.Sets;
|
||||||
public class AtmosClientLiveTest extends BaseBlobStoreIntegrationTest {
|
public class AtmosClientLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
|
|
||||||
public AtmosClient getApi() {
|
public AtmosClient getApi() {
|
||||||
return wrapper.unwrap(AtmosApiMetadata.CONTEXT_TOKEN).getApi();
|
return view.unwrap(AtmosApiMetadata.CONTEXT_TOKEN).getApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final class HeadMatches implements Runnable {
|
private static final class HeadMatches implements Runnable {
|
||||||
|
|
|
@ -34,6 +34,6 @@ public class AtmosLiveTest extends BaseBlobLiveTest {
|
||||||
}
|
}
|
||||||
protected void checkMD5(String container, String name, byte[] md5) {
|
protected void checkMD5(String container, String name, byte[] md5) {
|
||||||
// atmos does not support content-md5 yet
|
// atmos does not support content-md5 yet
|
||||||
assertEquals(wrapper.getBlobStore().blobMetadata(container, name).getContentMetadata().getContentMD5(), null);
|
assertEquals(view.getBlobStore().blobMetadata(container, name).getContentMetadata().getContentMD5(), null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class BYONApiMetadata extends BaseApiMetadata {
|
||||||
.documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/apis/byon"))
|
.documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/apis/byon"))
|
||||||
.version(String.format("%s.%s", JcloudsVersion.get().majorVersion, JcloudsVersion.get().minorVersion))
|
.version(String.format("%s.%s", JcloudsVersion.get().majorVersion, JcloudsVersion.get().minorVersion))
|
||||||
.buildVersion(JcloudsVersion.get().toString())
|
.buildVersion(JcloudsVersion.get().toString())
|
||||||
.wrapper(ComputeServiceContext.class)
|
.view(ComputeServiceContext.class)
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(YamlNodeStoreModule.class, BYONComputeServiceContextModule.class));
|
.defaultModules(ImmutableSet.<Class<? extends Module>>of(YamlNodeStoreModule.class, BYONComputeServiceContextModule.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class CloudFilesApiMetadata extends BaseRestApiMetadata {
|
||||||
.documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html"))
|
.documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html"))
|
||||||
.version(OpenStackAuthAsyncClient.VERSION)
|
.version(OpenStackAuthAsyncClient.VERSION)
|
||||||
.defaultProperties(CloudFilesApiMetadata.defaultProperties())
|
.defaultProperties(CloudFilesApiMetadata.defaultProperties())
|
||||||
.wrapper(TypeToken.of(BlobStoreContext.class))
|
.view(TypeToken.of(BlobStoreContext.class))
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudFilesRestClientModule.class, CloudFilesBlobStoreContextModule.class));
|
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudFilesRestClientModule.class, CloudFilesBlobStoreContextModule.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
* Provides asynchronous access to Cloud Files via their REST API.
|
* Provides asynchronous access to Cloud Files via their REST API.
|
||||||
* <p/>
|
* <p/>
|
||||||
* All commands return a ListenableFuture of the result from Cloud Files. Any exceptions incurred
|
* All commands return a ListenableFuture of the result from Cloud Files. Any exceptions incurred
|
||||||
* during processing will be wrapped in an {@link ExecutionException} as documented in
|
* during processing will be backend in an {@link ExecutionException} as documented in
|
||||||
* {@link ListenableFuture#get()}.
|
* {@link ListenableFuture#get()}.
|
||||||
*
|
*
|
||||||
* @see CloudFilesClient
|
* @see CloudFilesClient
|
||||||
|
|
|
@ -33,7 +33,7 @@ import org.jclouds.openstack.swift.CommonSwiftClient;
|
||||||
* Provides access to Cloud Files via their REST API.
|
* Provides access to Cloud Files via their REST API.
|
||||||
* <p/>
|
* <p/>
|
||||||
* All commands return a Future of the result from Cloud Files. Any exceptions incurred during
|
* All commands return a Future of the result from Cloud Files. Any exceptions incurred during
|
||||||
* processing will be wrapped in an {@link ExecutionException} as documented in {@link Future#get()}.
|
* processing will be backend in an {@link ExecutionException} as documented in {@link Future#get()}.
|
||||||
*
|
*
|
||||||
* @see <a href="http://www.rackspacecloud.com/cf-devguide-20090812.pdf" />
|
* @see <a href="http://www.rackspacecloud.com/cf-devguide-20090812.pdf" />
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class CloudFilesClientLiveTest extends CommonSwiftClientLiveTest<CloudFil
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CloudFilesClient getApi() {
|
public CloudFilesClient getApi() {
|
||||||
return wrapper.unwrap(CloudFilesApiMetadata.CONTEXT_TOKEN).getApi();
|
return view.unwrap(CloudFilesApiMetadata.CONTEXT_TOKEN).getApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata {
|
||||||
.version(OpenStackAuthAsyncClient.VERSION)
|
.version(OpenStackAuthAsyncClient.VERSION)
|
||||||
.defaultEndpoint("https://auth.api.rackspacecloud.com")
|
.defaultEndpoint("https://auth.api.rackspacecloud.com")
|
||||||
.defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties())
|
.defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties())
|
||||||
.wrapper(TypeToken.of(LoadBalancerServiceContext.class))
|
.view(TypeToken.of(LoadBalancerServiceContext.class))
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudLoadBalancersRestClientModule.class, CloudLoadBalancersLoadBalancerContextModule.class));
|
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudLoadBalancersRestClientModule.class, CloudLoadBalancersLoadBalancerContextModule.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.cloudloadbalancers.internal;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.jclouds.apis.BaseWrapperLiveTest;
|
import org.jclouds.apis.BaseViewLiveTest;
|
||||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
|
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
|
||||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
|
import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
|
||||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
|
import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
|
||||||
|
@ -42,7 +42,7 @@ import com.google.inject.Injector;
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
public class BaseCloudLoadBalancersClientLiveTest extends BaseWrapperLiveTest<LoadBalancerServiceContext> {
|
public class BaseCloudLoadBalancersClientLiveTest extends BaseViewLiveTest<LoadBalancerServiceContext> {
|
||||||
|
|
||||||
public BaseCloudLoadBalancersClientLiveTest() {
|
public BaseCloudLoadBalancersClientLiveTest() {
|
||||||
provider = "cloudloadbalancers";
|
provider = "cloudloadbalancers";
|
||||||
|
@ -61,7 +61,7 @@ public class BaseCloudLoadBalancersClientLiveTest extends BaseWrapperLiveTest<Lo
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
lbContext = wrapper.unwrap();
|
lbContext = view.unwrap();
|
||||||
|
|
||||||
client = lbContext.getApi();
|
client = lbContext.getApi();
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ public class BaseCloudLoadBalancersClientLiveTest extends BaseWrapperLiveTest<Lo
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeToken<LoadBalancerServiceContext> wrapperType() {
|
protected TypeToken<LoadBalancerServiceContext> viewType() {
|
||||||
return TypeToken.of(LoadBalancerServiceContext.class);
|
return TypeToken.of(LoadBalancerServiceContext.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class CloudServersApiMetadata extends BaseRestApiMetadata {
|
||||||
.version(OpenStackAuthAsyncClient.VERSION)
|
.version(OpenStackAuthAsyncClient.VERSION)
|
||||||
.defaultEndpoint("https://auth.api.rackspacecloud.com")
|
.defaultEndpoint("https://auth.api.rackspacecloud.com")
|
||||||
.defaultProperties(CloudServersApiMetadata.defaultProperties())
|
.defaultProperties(CloudServersApiMetadata.defaultProperties())
|
||||||
.wrapper(TypeToken.of(ComputeServiceContext.class))
|
.view(TypeToken.of(ComputeServiceContext.class))
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudServersRestClientModule.class, CloudServersComputeServiceContextModule.class));
|
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudServersRestClientModule.class, CloudServersComputeServiceContextModule.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
* Provides asynchronous access to Cloud Servers via their REST API.
|
* Provides asynchronous access to Cloud Servers via their REST API.
|
||||||
* <p/>
|
* <p/>
|
||||||
* All commands return a ListenableFuture of the result from Cloud Servers. Any exceptions incurred
|
* All commands return a ListenableFuture of the result from Cloud Servers. Any exceptions incurred
|
||||||
* during processing will be wrapped in an {@link ExecutionException} as documented in
|
* during processing will be backend in an {@link ExecutionException} as documented in
|
||||||
* {@link ListenableFuture#get()}.
|
* {@link ListenableFuture#get()}.
|
||||||
*
|
*
|
||||||
* @see CloudServersClient
|
* @see CloudServersClient
|
||||||
|
|
|
@ -44,7 +44,7 @@ import org.jclouds.rest.ResourceNotFoundException;
|
||||||
* Provides access to Cloud Servers via their REST API.
|
* Provides access to Cloud Servers via their REST API.
|
||||||
* <p/>
|
* <p/>
|
||||||
* All commands return a Future of the result from Cloud Servers. Any exceptions incurred during
|
* All commands return a Future of the result from Cloud Servers. Any exceptions incurred during
|
||||||
* processing will be wrapped in an {@link ExecutionException} as documented in {@link Future#get()}.
|
* processing will be backend in an {@link ExecutionException} as documented in {@link Future#get()}.
|
||||||
*
|
*
|
||||||
* @see CloudServersAsyncClient
|
* @see CloudServersAsyncClient
|
||||||
* @see <a href="http://docs.rackspacecloud.com/servers/api/cs-devguide-latest.pdf" />
|
* @see <a href="http://docs.rackspacecloud.com/servers/api/cs-devguide-latest.pdf" />
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class CloudServersClientLiveTest extends BaseComputeServiceContextLiveTes
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
Injector injector = wrapper.utils().injector();
|
Injector injector = view.utils().injector();
|
||||||
client = injector.getInstance(CloudServersClient.class);
|
client = injector.getInstance(CloudServersClient.class);
|
||||||
sshFactory = injector.getInstance(SshClient.Factory.class);
|
sshFactory = injector.getInstance(SshClient.Factory.class);
|
||||||
SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
|
SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class CloudSigmaApiMetadata extends BaseRestApiMetadata {
|
||||||
.version("1.0")
|
.version("1.0")
|
||||||
.defaultEndpoint("https://api.cloudsigma.com")
|
.defaultEndpoint("https://api.cloudsigma.com")
|
||||||
.defaultProperties(CloudSigmaApiMetadata.defaultProperties())
|
.defaultProperties(CloudSigmaApiMetadata.defaultProperties())
|
||||||
.wrapper(TypeToken.of(ComputeServiceContext.class))
|
.view(TypeToken.of(ComputeServiceContext.class))
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudSigmaRestClientModule.class, CloudSigmaComputeServiceContextModule.class));
|
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudSigmaRestClientModule.class, CloudSigmaComputeServiceContextModule.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
cloudSigmaContext = wrapper.unwrap();
|
cloudSigmaContext = view.unwrap();
|
||||||
|
|
||||||
client = cloudSigmaContext.getApi();
|
client = cloudSigmaContext.getApi();
|
||||||
driveNotClaimed = new RetryablePredicate<DriveInfo>(Predicates.not(new DriveClaimed(client)), maxDriveImageTime,
|
driveNotClaimed = new RetryablePredicate<DriveInfo>(Predicates.not(new DriveClaimed(client)), maxDriveImageTime,
|
||||||
|
@ -98,7 +98,7 @@ public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest
|
||||||
TimeUnit.SECONDS);
|
TimeUnit.SECONDS);
|
||||||
|
|
||||||
if (Strings.emptyToNull(imageId) == null) {
|
if (Strings.emptyToNull(imageId) == null) {
|
||||||
imageId = wrapper.getComputeService().templateBuilder().build().getImage().getId();
|
imageId = view.getComputeService().templateBuilder().build().getImage().getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class CloudStackApiMetadata extends BaseRestApiMetadata {
|
||||||
.documentation(URI.create("http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html"))
|
.documentation(URI.create("http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html"))
|
||||||
.defaultEndpoint("http://localhost:8080/client/api")
|
.defaultEndpoint("http://localhost:8080/client/api")
|
||||||
.version("2.2")
|
.version("2.2")
|
||||||
.wrapper(TypeToken.of(CloudStackContext.class))
|
.view(TypeToken.of(CloudStackContext.class))
|
||||||
.defaultProperties(CloudStackApiMetadata.defaultProperties())
|
.defaultProperties(CloudStackApiMetadata.defaultProperties())
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudStackRestClientModule.class, CloudStackComputeServiceContextModule.class));
|
.defaultModules(ImmutableSet.<Class<? extends Module>>of(CloudStackRestClientModule.class, CloudStackComputeServiceContextModule.class));
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,10 +46,10 @@ public class ParseAsyncJobsFromHttpResponse implements Function<HttpResponse, Se
|
||||||
private final ParseTypedAsyncJob parseTyped;
|
private final ParseTypedAsyncJob parseTyped;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ParseAsyncJobsFromHttpResponse(ParseTypedAsyncJob parseTyped, GsonWrapper gsonWrapper) {
|
public ParseAsyncJobsFromHttpResponse(ParseTypedAsyncJob parseTyped, GsonWrapper gsonView) {
|
||||||
this.parseTyped = checkNotNull(parseTyped, "parseTyped");
|
this.parseTyped = checkNotNull(parseTyped, "parseTyped");
|
||||||
this.parser = new ParseFirstJsonValueNamed<Set<AsyncJob<Map<String, JsonBall>>>>(
|
this.parser = new ParseFirstJsonValueNamed<Set<AsyncJob<Map<String, JsonBall>>>>(
|
||||||
checkNotNull(gsonWrapper, "gsonWrapper"),
|
checkNotNull(gsonView, "gsonView"),
|
||||||
new TypeLiteral<Set<AsyncJob<Map<String, JsonBall>>>>() { },
|
new TypeLiteral<Set<AsyncJob<Map<String, JsonBall>>>>() { },
|
||||||
"asyncjobs");
|
"asyncjobs");
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,8 +54,8 @@ public class ParseEventTypesFromHttpResponse implements Function<HttpResponse, S
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ParseEventTypesFromHttpResponse(GsonWrapper gsonWrapper) {
|
public ParseEventTypesFromHttpResponse(GsonWrapper gsonView) {
|
||||||
this.parser = new ParseFirstJsonValueNamed<Set<EventType>>(checkNotNull(gsonWrapper, "gsonWrapper"),
|
this.parser = new ParseFirstJsonValueNamed<Set<EventType>>(checkNotNull(gsonView, "gsonView"),
|
||||||
new TypeLiteral<Set<EventType>>() {
|
new TypeLiteral<Set<EventType>>() {
|
||||||
}, "eventtype");
|
}, "eventtype");
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,8 +78,8 @@ public class ParseIdToNameFromHttpResponse implements Function<HttpResponse, Map
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ParseIdToNameFromHttpResponse(GsonWrapper gsonWrapper) {
|
public ParseIdToNameFromHttpResponse(GsonWrapper gsonView) {
|
||||||
this.parser = new ParseFirstJsonValueNamed<Set<IdName>>(checkNotNull(gsonWrapper, "gsonWrapper"),
|
this.parser = new ParseFirstJsonValueNamed<Set<IdName>>(checkNotNull(gsonView, "gsonView"),
|
||||||
new TypeLiteral<Set<IdName>>() {
|
new TypeLiteral<Set<IdName>>() {
|
||||||
}, "oscategory");
|
}, "oscategory");
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class ParseLoginResponseFromHttpResponse implements Function<HttpResponse
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ParseLoginResponseFromHttpResponse(GsonWrapper gson) {
|
ParseLoginResponseFromHttpResponse(GsonWrapper gson) {
|
||||||
this.parser = new ParseFirstJsonValueNamed<LoginResponse>(checkNotNull(gson, "gsonWrapper"),
|
this.parser = new ParseFirstJsonValueNamed<LoginResponse>(checkNotNull(gson, "gsonView"),
|
||||||
new TypeLiteral<LoginResponse>(){}, "loginresponse");
|
new TypeLiteral<LoginResponse>(){}, "loginresponse");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,8 +73,8 @@ public class ParseNamesFromHttpResponse implements Function<HttpResponse, Set<St
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ParseNamesFromHttpResponse(GsonWrapper gsonWrapper) {
|
public ParseNamesFromHttpResponse(GsonWrapper gsonView) {
|
||||||
this.parser = new ParseFirstJsonValueNamed<Set<Name>>(checkNotNull(gsonWrapper, "gsonWrapper"),
|
this.parser = new ParseFirstJsonValueNamed<Set<Name>>(checkNotNull(gsonView, "gsonView"),
|
||||||
new TypeLiteral<Set<Name>>() {
|
new TypeLiteral<Set<Name>>() {
|
||||||
}, "hypervisor");
|
}, "hypervisor");
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,11 +46,11 @@ public class CloudStackContextImpl extends ComputeServiceContextImpl implements
|
||||||
private final RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext;
|
private final RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public CloudStackContextImpl(@Provider Context wrapped, @Provider TypeToken<? extends Context> wrappedType,
|
public CloudStackContextImpl(@Provider Context backend, @Provider TypeToken<? extends Context> backendType,
|
||||||
ComputeService computeService, Utils utils,
|
ComputeService computeService, Utils utils,
|
||||||
RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext,
|
RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext,
|
||||||
RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext) {
|
RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext) {
|
||||||
super(wrapped, wrappedType, computeService, utils);
|
super(backend, backendType, computeService, utils);
|
||||||
this.domainContext = domainContext;
|
this.domainContext = domainContext;
|
||||||
this.globalContext = globalContext;
|
this.globalContext = globalContext;
|
||||||
}
|
}
|
||||||
|
|
|
@ -157,7 +157,7 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien
|
||||||
public void testCreateNodeWithGroupEncodedIntoName() throws InterruptedException {
|
public void testCreateNodeWithGroupEncodedIntoName() throws InterruptedException {
|
||||||
String group = prefix + "-foo";
|
String group = prefix + "-foo";
|
||||||
String name = group + "-node-" + new Random().nextInt();
|
String name = group + "-node-" + new Random().nextInt();
|
||||||
Template template = wrapper.getComputeService().templateBuilder().build();
|
Template template = view.getComputeService().templateBuilder().build();
|
||||||
|
|
||||||
if (!client
|
if (!client
|
||||||
.getTemplateClient()
|
.getTemplateClient()
|
||||||
|
|
|
@ -90,9 +90,9 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
Network network = null;
|
Network network = null;
|
||||||
Set<? extends NodeMetadata> nodes = null;
|
Set<? extends NodeMetadata> nodes = null;
|
||||||
try {
|
try {
|
||||||
assert wrapper.getComputeService().listAssignableLocations().size() > 0;
|
assert view.getComputeService().listAssignableLocations().size() > 0;
|
||||||
|
|
||||||
Template template = wrapper.getComputeService().templateBuilder().build();
|
Template template = view.getComputeService().templateBuilder().build();
|
||||||
|
|
||||||
// get the zone we are launching into
|
// get the zone we are launching into
|
||||||
long zoneId = Long.parseLong(template.getLocation().getId());
|
long zoneId = Long.parseLong(template.getLocation().getId());
|
||||||
|
@ -115,7 +115,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
template.getOptions().as(CloudStackTemplateOptions.class).networkId(network.getId());
|
template.getOptions().as(CloudStackTemplateOptions.class).networkId(network.getId());
|
||||||
|
|
||||||
// launch the VM
|
// launch the VM
|
||||||
nodes = wrapper.getComputeService().createNodesInGroup(group, 1, template);
|
nodes = view.getComputeService().createNodesInGroup(group, 1, template);
|
||||||
|
|
||||||
assert nodes.size() > 0;
|
assert nodes.size() > 0;
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
nodes = newTreeSet(concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet()));
|
nodes = newTreeSet(concat(e.getSuccessfulNodes(), e.getNodeErrors().keySet()));
|
||||||
} finally {
|
} finally {
|
||||||
if (nodes != null)
|
if (nodes != null)
|
||||||
wrapper.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
|
view.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
|
||||||
if (network != null)
|
if (network != null)
|
||||||
domainAdminContext.getApi().getNetworkClient().deleteNetwork(network.getId());
|
domainAdminContext.getApi().getNetworkClient().deleteNetwork(network.getId());
|
||||||
}
|
}
|
||||||
|
@ -143,14 +143,14 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
SshKeyPair keyPair = client.getSSHKeyPairClient().createSSHKeyPair(keyPairName);
|
SshKeyPair keyPair = client.getSSHKeyPairClient().createSSHKeyPair(keyPairName);
|
||||||
|
|
||||||
String group = prefix + "-windows-test";
|
String group = prefix + "-windows-test";
|
||||||
Template template = wrapper.getComputeService().templateBuilder()
|
Template template = view.getComputeService().templateBuilder()
|
||||||
.imageId("290").locationId("1")
|
.imageId("290").locationId("1")
|
||||||
.options(new CloudStackTemplateOptions().setupStaticNat(false).keyPair(keyPairName))
|
.options(new CloudStackTemplateOptions().setupStaticNat(false).keyPair(keyPairName))
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
NodeMetadata node = null;
|
NodeMetadata node = null;
|
||||||
try {
|
try {
|
||||||
node = getOnlyElement(wrapper.getComputeService()
|
node = getOnlyElement(view.getComputeService()
|
||||||
.createNodesInGroup(group, 1, template));
|
.createNodesInGroup(group, 1, template));
|
||||||
|
|
||||||
String encryptedPassword = client.getVirtualMachineClient()
|
String encryptedPassword = client.getVirtualMachineClient()
|
||||||
|
@ -165,7 +165,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
wrapper.getComputeService().destroyNode(node.getId());
|
view.getComputeService().destroyNode(node.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class BaseCloudStackClientLiveTest extends BaseGenericComputeServiceConte
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeToken<CloudStackContext> wrapperType() {
|
protected TypeToken<CloudStackContext> viewType() {
|
||||||
return TypeToken.of(CloudStackContext.class);
|
return TypeToken.of(CloudStackContext.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,14 +199,14 @@ public class BaseCloudStackClientLiveTest extends BaseGenericComputeServiceConte
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
computeClient = wrapper.getComputeService();
|
computeClient = view.getComputeService();
|
||||||
cloudStackContext = wrapper.unwrap();
|
cloudStackContext = view.unwrap();
|
||||||
client = cloudStackContext.getApi();
|
client = cloudStackContext.getApi();
|
||||||
user = verifyCurrentUserIsOfType(cloudStackContext, Account.Type.USER);
|
user = verifyCurrentUserIsOfType(cloudStackContext, Account.Type.USER);
|
||||||
|
|
||||||
domainAdminEnabled = setupDomainAdminProperties() != null;
|
domainAdminEnabled = setupDomainAdminProperties() != null;
|
||||||
if (domainAdminEnabled) {
|
if (domainAdminEnabled) {
|
||||||
domainAdminComputeContext = createWrapper(setupDomainAdminProperties(), setupModules());
|
domainAdminComputeContext = createView(setupDomainAdminProperties(), setupModules());
|
||||||
domainAdminContext = domainAdminComputeContext.getDomainContext();
|
domainAdminContext = domainAdminComputeContext.getDomainContext();
|
||||||
domainAdminClient = domainAdminContext.getApi();
|
domainAdminClient = domainAdminContext.getApi();
|
||||||
domainAdminUser = verifyCurrentUserIsOfType(domainAdminContext, Account.Type.DOMAIN_ADMIN);
|
domainAdminUser = verifyCurrentUserIsOfType(domainAdminContext, Account.Type.DOMAIN_ADMIN);
|
||||||
|
@ -215,7 +215,7 @@ public class BaseCloudStackClientLiveTest extends BaseGenericComputeServiceConte
|
||||||
|
|
||||||
globalAdminEnabled = setupGlobalAdminProperties() != null;
|
globalAdminEnabled = setupGlobalAdminProperties() != null;
|
||||||
if (globalAdminEnabled) {
|
if (globalAdminEnabled) {
|
||||||
globalAdminComputeContext = createWrapper(setupGlobalAdminProperties(), setupModules());
|
globalAdminComputeContext = createView(setupGlobalAdminProperties(), setupModules());
|
||||||
globalAdminContext = globalAdminComputeContext.getGlobalContext();
|
globalAdminContext = globalAdminComputeContext.getGlobalContext();
|
||||||
globalAdminClient = globalAdminContext.getApi();
|
globalAdminClient = globalAdminContext.getApi();
|
||||||
globalAdminUser = verifyCurrentUserIsOfType(globalAdminContext, Account.Type.ADMIN);
|
globalAdminUser = verifyCurrentUserIsOfType(globalAdminContext, Account.Type.ADMIN);
|
||||||
|
|
|
@ -84,7 +84,7 @@ public class GlobalUserClientLiveTest extends BaseCloudStackClientLiveTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkAuthAsUser(ApiKeyPair keyPair) {
|
private void checkAuthAsUser(ApiKeyPair keyPair) {
|
||||||
ComputeServiceContext context = createWrapper(credentialsAsProperties(keyPair), setupModules());
|
ComputeServiceContext context = createView(credentialsAsProperties(keyPair), setupModules());
|
||||||
|
|
||||||
CloudStackClient client = context.unwrap(CloudStackApiMetadata.CONTEXT_TOKEN).getApi();
|
CloudStackClient client = context.unwrap(CloudStackApiMetadata.CONTEXT_TOKEN).getApi();
|
||||||
Set<Account> accounts = client.getAccountClient().listAccounts();
|
Set<Account> accounts = client.getAccountClient().listAccounts();
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.cloudwatch;
|
package org.jclouds.cloudwatch;
|
||||||
|
|
||||||
import org.jclouds.Wrapper;
|
import org.jclouds.View;
|
||||||
import org.jclouds.rest.internal.BaseRestApiMetadataTest;
|
import org.jclouds.rest.internal.BaseRestApiMetadataTest;
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
|
@ -34,6 +34,6 @@ public class CloudWatchApiMetadataTest extends BaseRestApiMetadataTest {
|
||||||
|
|
||||||
// no monitoring abstraction, yet
|
// no monitoring abstraction, yet
|
||||||
public CloudWatchApiMetadataTest() {
|
public CloudWatchApiMetadataTest() {
|
||||||
super(new CloudWatchApiMetadata(), ImmutableSet.<TypeToken<? extends Wrapper>> of());
|
super(new CloudWatchApiMetadata(), ImmutableSet.<TypeToken<? extends View>> of());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class DeltacloudApiMetadata extends BaseRestApiMetadata {
|
||||||
.version("0.3.0")
|
.version("0.3.0")
|
||||||
.defaultEndpoint("http://localhost:3001/api")
|
.defaultEndpoint("http://localhost:3001/api")
|
||||||
.defaultProperties(DeltacloudApiMetadata.defaultProperties())
|
.defaultProperties(DeltacloudApiMetadata.defaultProperties())
|
||||||
.wrapper(TypeToken.of(ComputeServiceContext.class))
|
.view(TypeToken.of(ComputeServiceContext.class))
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(DeltacloudRestClientModule.class, DeltacloudComputeServiceContextModule.class));
|
.defaultModules(ImmutableSet.<Class<? extends Module>>of(DeltacloudRestClientModule.class, DeltacloudComputeServiceContextModule.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class ReadOnlyDeltacloudClientLiveTest extends BaseComputeServiceContextL
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
client = wrapper.unwrap(DeltacloudApiMetadata.CONTEXT_TOKEN).getApi();
|
client = view.unwrap(DeltacloudApiMetadata.CONTEXT_TOKEN).getApi();
|
||||||
socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), 180, 1, TimeUnit.SECONDS);
|
socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), 180, 1, TimeUnit.SECONDS);
|
||||||
stateChanges = ImmutableMap.<Instance.State, Predicate<Instance>> of(//
|
stateChanges = ImmutableMap.<Instance.State, Predicate<Instance>> of(//
|
||||||
Instance.State.RUNNING, new RetryablePredicate<Instance>(new InstanceRunning(client), 600, 1,
|
Instance.State.RUNNING, new RetryablePredicate<Instance>(new InstanceRunning(client), 600, 1,
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class DeltacloudTemplateBuilderLiveTest extends BaseTemplateBuilderLiveTe
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTemplateBuilder() {
|
public void testTemplateBuilder() {
|
||||||
Template defaultTemplate = this.wrapper.getComputeService().templateBuilder().build();
|
Template defaultTemplate = this.view.getComputeService().templateBuilder().build();
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04");
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getVersion(), "10.04");
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU);
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class EC2ApiMetadata extends BaseRestApiMetadata {
|
||||||
.version(EC2AsyncClient.VERSION)
|
.version(EC2AsyncClient.VERSION)
|
||||||
.defaultProperties(EC2ApiMetadata.defaultProperties())
|
.defaultProperties(EC2ApiMetadata.defaultProperties())
|
||||||
.context(CONTEXT_TOKEN)
|
.context(CONTEXT_TOKEN)
|
||||||
.wrapper(EC2ComputeServiceContext.class)
|
.view(EC2ComputeServiceContext.class)
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(EC2RestClientModule.class, EC2ResolveImagesModule.class, EC2ComputeServiceContextModule.class));
|
.defaultModules(ImmutableSet.<Class<? extends Module>>of(EC2RestClientModule.class, EC2ResolveImagesModule.class, EC2ComputeServiceContextModule.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,9 +36,9 @@ import com.google.common.reflect.TypeToken;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class EC2ComputeServiceContextImpl extends ComputeServiceContextImpl implements EC2ComputeServiceContext {
|
public class EC2ComputeServiceContextImpl extends ComputeServiceContextImpl implements EC2ComputeServiceContext {
|
||||||
@Inject
|
@Inject
|
||||||
public EC2ComputeServiceContextImpl(@Provider Context wrapped, @Provider TypeToken<? extends Context> wrappedType,
|
public EC2ComputeServiceContextImpl(@Provider Context backend, @Provider TypeToken<? extends Context> backendType,
|
||||||
EC2ComputeService computeService, Utils utils) {
|
EC2ComputeService computeService, Utils utils) {
|
||||||
super(wrapped, wrappedType, computeService, utils);
|
super(backend, backendType, computeService, utils);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -95,7 +95,7 @@ public class CloudApplicationArchitecturesEC2ClientLiveTest extends BaseComputeS
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
Injector injector = wrapper.utils().injector();
|
Injector injector = view.utils().injector();
|
||||||
client = injector.getInstance(EC2Client.class);
|
client = injector.getInstance(EC2Client.class);
|
||||||
sshFactory = injector.getInstance(SshClient.Factory.class);
|
sshFactory = injector.getInstance(SshClient.Factory.class);
|
||||||
runningTester = new RetryablePredicate<RunningInstance>(new InstanceStateRunning(client), 180, 5,
|
runningTester = new RetryablePredicate<RunningInstance>(new InstanceStateRunning(client), 180, 5,
|
||||||
|
|
|
@ -126,7 +126,7 @@ public class EBSBootEC2ClientLiveTest extends BaseComputeServiceContextLiveTest
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
Injector injector = wrapper.utils().injector();
|
Injector injector = view.utils().injector();
|
||||||
client = injector.getInstance(EC2Client.class);
|
client = injector.getInstance(EC2Client.class);
|
||||||
sshFactory = injector.getInstance(SshClient.Factory.class);
|
sshFactory = injector.getInstance(SshClient.Factory.class);
|
||||||
SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
|
SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
|
||||||
|
|
|
@ -102,13 +102,13 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testCompareSizes")
|
@Test(enabled = true, dependsOnMethods = "testCompareSizes")
|
||||||
public void testExtendedOptionsAndLogin() throws Exception {
|
public void testExtendedOptionsAndLogin() throws Exception {
|
||||||
SecurityGroupClient securityGroupClient = EC2Client.class.cast(wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi())
|
SecurityGroupClient securityGroupClient = EC2Client.class.cast(view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi())
|
||||||
.getSecurityGroupServices();
|
.getSecurityGroupServices();
|
||||||
|
|
||||||
KeyPairClient keyPairClient = EC2Client.class.cast(wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi())
|
KeyPairClient keyPairClient = EC2Client.class.cast(view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi())
|
||||||
.getKeyPairServices();
|
.getKeyPairServices();
|
||||||
|
|
||||||
InstanceClient instanceClient = EC2Client.class.cast(wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi())
|
InstanceClient instanceClient = EC2Client.class.cast(view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi())
|
||||||
.getInstanceServices();
|
.getInstanceServices();
|
||||||
|
|
||||||
String group = this.group + "o";
|
String group = this.group + "o";
|
||||||
|
@ -181,7 +181,7 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
Properties overrides = setupProperties();
|
Properties overrides = setupProperties();
|
||||||
overrides.setProperty(EC2Constants.PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS, "true");
|
overrides.setProperty(EC2Constants.PROPERTY_EC2_AUTO_ALLOCATE_ELASTIC_IPS, "true");
|
||||||
|
|
||||||
context = createWrapper(overrides, setupModules());
|
context = createView(overrides, setupModules());
|
||||||
|
|
||||||
// create a node
|
// create a node
|
||||||
Set<? extends NodeMetadata> nodes =
|
Set<? extends NodeMetadata> nodes =
|
||||||
|
@ -233,19 +233,19 @@ public class EC2ComputeServiceLiveTest extends BaseComputeServiceLiveTest {
|
||||||
@Test(enabled = true)
|
@Test(enabled = true)
|
||||||
public void testMapEBS() throws Exception {
|
public void testMapEBS() throws Exception {
|
||||||
|
|
||||||
InstanceClient instanceClient = EC2Client.class.cast(wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi())
|
InstanceClient instanceClient = EC2Client.class.cast(view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi())
|
||||||
.getInstanceServices();
|
.getInstanceServices();
|
||||||
|
|
||||||
ElasticBlockStoreClient ebsClient = EC2Client.class.cast(wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi())
|
ElasticBlockStoreClient ebsClient = EC2Client.class.cast(view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi())
|
||||||
.getElasticBlockStoreServices();
|
.getElasticBlockStoreServices();
|
||||||
|
|
||||||
String group = this.group + "e";
|
String group = this.group + "e";
|
||||||
int volumeSize = 8;
|
int volumeSize = 8;
|
||||||
|
|
||||||
final Template template = wrapper.getComputeService().templateBuilder().hardwareId(InstanceType.M1_SMALL)
|
final Template template = view.getComputeService().templateBuilder().hardwareId(InstanceType.M1_SMALL)
|
||||||
.osFamily(OsFamily.UBUNTU).osVersionMatches("10.04").imageDescriptionMatches(".*ebs.*").build();
|
.osFamily(OsFamily.UBUNTU).osVersionMatches("10.04").imageDescriptionMatches(".*ebs.*").build();
|
||||||
|
|
||||||
Location zone = Iterables.find(wrapper.getComputeService().listAssignableLocations(), new Predicate<Location>() {
|
Location zone = Iterables.find(view.getComputeService().listAssignableLocations(), new Predicate<Location>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Location arg0) {
|
public boolean apply(Location arg0) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ public abstract class EC2TemplateBuilderLiveTest extends BaseTemplateBuilderLive
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTemplateBuilderCanUseImageIdWithoutFetchingAllImages() throws Exception {
|
public void testTemplateBuilderCanUseImageIdWithoutFetchingAllImages() throws Exception {
|
||||||
Template defaultTemplate = wrapper.getComputeService().templateBuilder().build();
|
Template defaultTemplate = view.getComputeService().templateBuilder().build();
|
||||||
String defaultImageId = defaultTemplate.getImage().getId();
|
String defaultImageId = defaultTemplate.getImage().getId();
|
||||||
String defaultImageProviderId = defaultTemplate.getImage().getProviderId();
|
String defaultImageProviderId = defaultTemplate.getImage().getProviderId();
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ public abstract class EC2TemplateBuilderLiveTest extends BaseTemplateBuilderLive
|
||||||
try {
|
try {
|
||||||
// Track http commands
|
// Track http commands
|
||||||
final List<HttpCommand> commandsInvoked = Lists.newArrayList();
|
final List<HttpCommand> commandsInvoked = Lists.newArrayList();
|
||||||
context = createWrapper(
|
context = createView(
|
||||||
setupProperties(),
|
setupProperties(),
|
||||||
ImmutableSet.<Module> of(new Log4JLoggingModule(),
|
ImmutableSet.<Module> of(new Log4JLoggingModule(),
|
||||||
TrackingJavaUrlHttpCommandExecutorService.newTrackingModule(commandsInvoked)));
|
TrackingJavaUrlHttpCommandExecutorService.newTrackingModule(commandsInvoked)));
|
||||||
|
|
|
@ -39,18 +39,18 @@ public class TestCanRecreateGroupLiveTest extends BaseComputeServiceContextLiveT
|
||||||
public void testCanRecreateGroup() throws Exception {
|
public void testCanRecreateGroup() throws Exception {
|
||||||
|
|
||||||
String tag = PREFIX + "recreate";
|
String tag = PREFIX + "recreate";
|
||||||
wrapper.getComputeService().destroyNodesMatching(NodePredicates.inGroup(tag));
|
view.getComputeService().destroyNodesMatching(NodePredicates.inGroup(tag));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Template template = wrapper.getComputeService().templateBuilder().build();
|
Template template = view.getComputeService().templateBuilder().build();
|
||||||
wrapper.getComputeService().createNodesInGroup(tag, 1, template);
|
view.getComputeService().createNodesInGroup(tag, 1, template);
|
||||||
wrapper.getComputeService().destroyNodesMatching(NodePredicates.inGroup(tag));
|
view.getComputeService().destroyNodesMatching(NodePredicates.inGroup(tag));
|
||||||
wrapper.getComputeService().createNodesInGroup(tag, 1, template);
|
view.getComputeService().createNodesInGroup(tag, 1, template);
|
||||||
} catch (RunNodesException e) {
|
} catch (RunNodesException e) {
|
||||||
System.err.println(e.getNodeErrors().keySet());
|
System.err.println(e.getNodeErrors().keySet());
|
||||||
Throwables.propagate(e);
|
Throwables.propagate(e);
|
||||||
} finally {
|
} finally {
|
||||||
wrapper.getComputeService().destroyNodesMatching(NodePredicates.inGroup(tag));
|
view.getComputeService().destroyNodesMatching(NodePredicates.inGroup(tag));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class AvailabilityZoneAndRegionClientLiveTest extends BaseComputeServiceC
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
client = wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices();
|
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDescribeAvailabilityZones() {
|
public void testDescribeAvailabilityZones() {
|
||||||
|
|
|
@ -61,12 +61,12 @@ public class ElasticBlockStoreClientLiveTest extends BaseComputeServiceContextLi
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
client = wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticBlockStoreServices();
|
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticBlockStoreServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testDescribeVolumes() {
|
void testDescribeVolumes() {
|
||||||
for (String region : wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
|
for (String region : view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getAvailabilityZoneAndRegionServices().describeRegions().keySet()) {
|
||||||
SortedSet<Volume> allResults = Sets.newTreeSet(client.describeVolumesInRegion(region));
|
SortedSet<Volume> allResults = Sets.newTreeSet(client.describeVolumesInRegion(region));
|
||||||
assertNotNull(allResults);
|
assertNotNull(allResults);
|
||||||
if (allResults.size() >= 1) {
|
if (allResults.size() >= 1) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class ElasticIPAddressClientLiveTest extends BaseComputeServiceContextLiv
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
client = wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticIPAddressServices();
|
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getElasticIPAddressServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class InstanceClientLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
client = wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getInstanceServices();
|
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getInstanceServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class KeyPairClientLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
client = wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getKeyPairServices();
|
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getKeyPairServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTe
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
client = wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getSecurityGroupServices();
|
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getSecurityGroupServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -281,6 +281,6 @@ public class SecurityGroupClientLiveTest extends BaseComputeServiceContextLiveTe
|
||||||
|
|
||||||
@AfterTest
|
@AfterTest
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
wrapper.close();
|
view.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,8 +76,8 @@ public class WindowsClientLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
client = wrapper.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getWindowsServices();
|
client = view.unwrap(EC2ApiMetadata.CONTEXT_TOKEN).getApi().getWindowsServices();
|
||||||
computeService = wrapper.getComputeService();
|
computeService = view.getComputeService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ public class WindowsClientLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
node.getCredentials().getPrivateKey());
|
node.getCredentials().getPrivateKey());
|
||||||
|
|
||||||
// And apply it to the decryption function
|
// And apply it to the decryption function
|
||||||
WindowsLoginCredentialsFromEncryptedData f = wrapper.getUtils().getInjector().getInstance(WindowsLoginCredentialsFromEncryptedData.class);
|
WindowsLoginCredentialsFromEncryptedData f = view.getUtils().getInjector().getInstance(WindowsLoginCredentialsFromEncryptedData.class);
|
||||||
LoginCredentials credentials = f.apply(dataAndKey);
|
LoginCredentials credentials = f.apply(dataAndKey);
|
||||||
|
|
||||||
assertEquals(credentials.getUser(), "Administrator");
|
assertEquals(credentials.getUser(), "Administrator");
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class ElasticStackApiMetadata extends BaseRestApiMetadata {
|
||||||
.version("1.0")
|
.version("1.0")
|
||||||
.defaultEndpoint("https://api.lon-p.elastichosts.com")
|
.defaultEndpoint("https://api.lon-p.elastichosts.com")
|
||||||
.defaultProperties(ElasticStackApiMetadata.defaultProperties())
|
.defaultProperties(ElasticStackApiMetadata.defaultProperties())
|
||||||
.wrapper(TypeToken.of(ComputeServiceContext.class))
|
.view(TypeToken.of(ComputeServiceContext.class))
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(ElasticStackRestClientModule.class, ElasticStackComputeServiceContextModule.class));
|
.defaultModules(ImmutableSet.<Class<? extends Module>>of(ElasticStackRestClientModule.class, ElasticStackComputeServiceContextModule.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ public class ElasticStackClientLiveTest
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
cloudStackContext = wrapper.unwrap();
|
cloudStackContext = view.unwrap();
|
||||||
|
|
||||||
client = cloudStackContext.getApi();
|
client = cloudStackContext.getApi();
|
||||||
driveNotClaimed = new RetryablePredicate<DriveInfo>(Predicates.not(new DriveClaimed(client)), maxDriveImageTime,
|
driveNotClaimed = new RetryablePredicate<DriveInfo>(Predicates.not(new DriveClaimed(client)), maxDriveImageTime,
|
||||||
|
@ -97,7 +97,7 @@ public class ElasticStackClientLiveTest
|
||||||
TimeUnit.SECONDS);
|
TimeUnit.SECONDS);
|
||||||
|
|
||||||
if (Strings.emptyToNull(imageId) == null) {
|
if (Strings.emptyToNull(imageId) == null) {
|
||||||
imageId = wrapper.getComputeService().templateBuilder().build().getImage().getId();
|
imageId = view.getComputeService().templateBuilder().build().getImage().getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class FilesystemApiMetadata extends BaseApiMetadata {
|
||||||
.defaultCredential("bar")
|
.defaultCredential("bar")
|
||||||
.version("1")
|
.version("1")
|
||||||
.documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide"))
|
.documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide"))
|
||||||
.wrapper(BlobStoreContext.class)
|
.view(BlobStoreContext.class)
|
||||||
.defaultModule(FilesystemBlobStoreContextModule.class);
|
.defaultModule(FilesystemBlobStoreContextModule.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,14 +62,14 @@ public class FilesystemContainerIntegrationTestDisabled extends BaseContainerInt
|
||||||
|
|
||||||
// NOTE all metadata in jclouds comes out as lowercase, in an effort to normalize the
|
// NOTE all metadata in jclouds comes out as lowercase, in an effort to normalize the
|
||||||
// providers.
|
// providers.
|
||||||
Blob object = wrapper.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("Adrian", "powderpuff"))
|
Blob object = view.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("Adrian", "powderpuff"))
|
||||||
.payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).build();
|
.payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).build();
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
addBlobToContainer(containerName, object);
|
addBlobToContainer(containerName, object);
|
||||||
validateContent(containerName, key);
|
validateContent(containerName, key);
|
||||||
|
|
||||||
PageSet<? extends StorageMetadata> container = wrapper.getBlobStore().list(containerName, maxResults(1));
|
PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName, maxResults(1));
|
||||||
|
|
||||||
BlobMetadata metadata = (BlobMetadata) Iterables.getOnlyElement(container);
|
BlobMetadata metadata = (BlobMetadata) Iterables.getOnlyElement(container);
|
||||||
// transient container should be lenient and not return metadata on undetailed listing.
|
// transient container should be lenient and not return metadata on undetailed listing.
|
||||||
|
|
|
@ -76,7 +76,7 @@ public class NovaApiMetadata extends BaseRestApiMetadata {
|
||||||
.version("1.1")
|
.version("1.1")
|
||||||
.defaultEndpoint("http://localhost:5000")
|
.defaultEndpoint("http://localhost:5000")
|
||||||
.defaultProperties(NovaApiMetadata.defaultProperties())
|
.defaultProperties(NovaApiMetadata.defaultProperties())
|
||||||
.wrapper(TypeToken.of(ComputeServiceContext.class))
|
.view(TypeToken.of(ComputeServiceContext.class))
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(NovaRestClientModule.class, NovaComputeServiceContextModule.class));
|
.defaultModules(ImmutableSet.<Class<? extends Module>>of(NovaRestClientModule.class, NovaComputeServiceContextModule.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
||||||
* Provides asynchronous access to OpenStack Nova via their REST API.
|
* Provides asynchronous access to OpenStack Nova via their REST API.
|
||||||
* <p/>
|
* <p/>
|
||||||
* All commands return a ListenableFuture of the result from OpenStack Nova. Any exceptions incurred
|
* All commands return a ListenableFuture of the result from OpenStack Nova. Any exceptions incurred
|
||||||
* during processing will be wrapped in an {@link ExecutionException} as documented in
|
* during processing will be backend in an {@link ExecutionException} as documented in
|
||||||
* {@link ListenableFuture#get()}.
|
* {@link ListenableFuture#get()}.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
|
|
@ -40,7 +40,7 @@ import org.jclouds.rest.ResourceNotFoundException;
|
||||||
* Provides access to OpenStack Nova via their REST API.
|
* Provides access to OpenStack Nova via their REST API.
|
||||||
* <p/>
|
* <p/>
|
||||||
* All commands return a Future of the result from OpenStack Nova. Any exceptions incurred
|
* All commands return a Future of the result from OpenStack Nova. Any exceptions incurred
|
||||||
* during processing will be wrapped in an {@link ExecutionException} as documented in
|
* during processing will be backend in an {@link ExecutionException} as documented in
|
||||||
* {@link Future#get()}.
|
* {@link Future#get()}.
|
||||||
*
|
*
|
||||||
* @see NovaAsyncClient
|
* @see NovaAsyncClient
|
||||||
|
|
|
@ -78,7 +78,7 @@ public class NovaClientLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
Injector injector = wrapper.utils().injector();
|
Injector injector = view.utils().injector();
|
||||||
client = injector.getInstance(NovaClient.class);
|
client = injector.getInstance(NovaClient.class);
|
||||||
sshFactory = injector.getInstance(SshClient.Factory.class);
|
sshFactory = injector.getInstance(SshClient.Factory.class);
|
||||||
SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
|
SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
|
||||||
|
|
|
@ -94,7 +94,7 @@ public class NovaApiMetadata extends BaseRestApiMetadata {
|
||||||
.version("1.1")
|
.version("1.1")
|
||||||
.defaultEndpoint("http://localhost:5000")
|
.defaultEndpoint("http://localhost:5000")
|
||||||
.defaultProperties(NovaApiMetadata.defaultProperties())
|
.defaultProperties(NovaApiMetadata.defaultProperties())
|
||||||
.wrapper(TypeToken.of(ComputeServiceContext.class))
|
.view(TypeToken.of(ComputeServiceContext.class))
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(NovaRestClientModule.class, NovaComputeServiceContextModule.class));
|
.defaultModules(ImmutableSet.<Class<? extends Module>>of(NovaRestClientModule.class, NovaComputeServiceContextModule.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,8 +151,8 @@ public class NovaComputeService extends BaseComputeService {
|
||||||
Optional<KeyPairClient> keyPairClient = novaClient.getKeyPairExtensionForZone(zoneId);
|
Optional<KeyPairClient> keyPairClient = novaClient.getKeyPairExtensionForZone(zoneId);
|
||||||
if (keyPairClient.isPresent()) {
|
if (keyPairClient.isPresent()) {
|
||||||
for (String group : groups) {
|
for (String group : groups) {
|
||||||
for (Map<String, KeyPair> wrapper : keyPairClient.get().listKeyPairs()) {
|
for (Map<String, KeyPair> view : keyPairClient.get().listKeyPairs()) {
|
||||||
for (KeyPair pair : Iterables.filter(wrapper.values(),
|
for (KeyPair pair : Iterables.filter(view.values(),
|
||||||
KeyPairPredicates.nameMatches(namingConvention.create().containsGroup(group)))) {
|
KeyPairPredicates.nameMatches(namingConvention.create().containsGroup(group)))) {
|
||||||
ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, pair.getName());
|
ZoneAndName zoneAndName = ZoneAndName.fromZoneAndName(zoneId, pair.getName());
|
||||||
logger.debug(">> deleting keypair(%s)", zoneAndName);
|
logger.debug(">> deleting keypair(%s)", zoneAndName);
|
||||||
|
|
|
@ -55,13 +55,13 @@ public class NovaParserModule extends AbstractModule {
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public static class HostResourceUsageAdapter implements JsonSerializer<HostResourceUsage>, JsonDeserializer<HostResourceUsage> {
|
public static class HostResourceUsageAdapter implements JsonSerializer<HostResourceUsage>, JsonDeserializer<HostResourceUsage> {
|
||||||
public HostResourceUsage apply(HostResourceUsageWrapper in) {
|
public HostResourceUsage apply(HostResourceUsageView in) {
|
||||||
return in.resource.toBuilder().build();
|
return in.resource.toBuilder().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HostResourceUsage deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException {
|
public HostResourceUsage deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext context) throws JsonParseException {
|
||||||
return apply((HostResourceUsageWrapper) context.deserialize(jsonElement, HostResourceUsageWrapper.class));
|
return apply((HostResourceUsageView) context.deserialize(jsonElement, HostResourceUsageView.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,7 +69,7 @@ public class NovaParserModule extends AbstractModule {
|
||||||
return context.serialize(hostResourceUsage);
|
return context.serialize(hostResourceUsage);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class HostResourceUsageWrapper {
|
private static class HostResourceUsageView {
|
||||||
protected HostResourceUsageInternal resource;
|
protected HostResourceUsageInternal resource;
|
||||||
}
|
}
|
||||||
private static class HostResourceUsageInternal extends HostResourceUsage {
|
private static class HostResourceUsageInternal extends HostResourceUsage {
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class BaseNovaClientLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
@Override
|
@Override
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
novaContext = wrapper.unwrap();
|
novaContext = view.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -108,7 +108,7 @@ public class S3ApiMetadata extends BaseRestApiMetadata {
|
||||||
.version(S3AsyncClient.VERSION)
|
.version(S3AsyncClient.VERSION)
|
||||||
.defaultProperties(S3ApiMetadata.defaultProperties())
|
.defaultProperties(S3ApiMetadata.defaultProperties())
|
||||||
.context(CONTEXT_TOKEN)
|
.context(CONTEXT_TOKEN)
|
||||||
.wrapper(TypeToken.of(S3BlobStoreContext.class))
|
.view(TypeToken.of(S3BlobStoreContext.class))
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(S3RestClientModule.class, S3BlobStoreContextModule.class));
|
.defaultModules(ImmutableSet.<Class<? extends Module>>of(S3RestClientModule.class, S3BlobStoreContextModule.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ import com.google.inject.Provides;
|
||||||
* Provides asynchronous access to S3 via their REST API.
|
* Provides asynchronous access to S3 via their REST API.
|
||||||
* <p/>
|
* <p/>
|
||||||
* All commands return a ListenableFuture of the result from S3. Any exceptions incurred during
|
* All commands return a ListenableFuture of the result from S3. Any exceptions incurred during
|
||||||
* processing will be wrapped in an {@link ExecutionException} as documented in
|
* processing will be backend in an {@link ExecutionException} as documented in
|
||||||
* {@link ListenableFuture#get()}.
|
* {@link ListenableFuture#get()}.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
|
|
@ -44,7 +44,7 @@ import com.google.inject.Provides;
|
||||||
* Provides access to S3 via their REST API.
|
* Provides access to S3 via their REST API.
|
||||||
* <p/>
|
* <p/>
|
||||||
* All commands return a Future of the result from S3. Any exceptions incurred during
|
* All commands return a Future of the result from S3. Any exceptions incurred during
|
||||||
* processing will be wrapped in an {@link ExecutionException} as documented in
|
* processing will be backend in an {@link ExecutionException} as documented in
|
||||||
* {@link Future#get()}.
|
* {@link Future#get()}.
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
|
|
@ -44,11 +44,11 @@ import com.google.common.reflect.TypeToken;
|
||||||
public class S3BlobStoreContextImpl extends BlobStoreContextImpl implements S3BlobStoreContext {
|
public class S3BlobStoreContextImpl extends BlobStoreContextImpl implements S3BlobStoreContext {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public S3BlobStoreContextImpl(@Provider Context wrapped, @Provider TypeToken<? extends Context> wrappedType,
|
public S3BlobStoreContextImpl(@Provider Context backend, @Provider TypeToken<? extends Context> backendType,
|
||||||
BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel,
|
BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel,
|
||||||
InputStreamMap.Factory inputStreamMapFactory, AsyncBlobStore ablobStore, BlobStore blobStore,
|
InputStreamMap.Factory inputStreamMapFactory, AsyncBlobStore ablobStore, BlobStore blobStore,
|
||||||
BlobRequestSigner blobRequestSigner) {
|
BlobRequestSigner blobRequestSigner) {
|
||||||
super(wrapped, wrappedType, blobMapFactory, utils, consistencyModel, inputStreamMapFactory, ablobStore,
|
super(backend, backendType, blobMapFactory, utils, consistencyModel, inputStreamMapFactory, ablobStore,
|
||||||
blobStore, blobRequestSigner);
|
blobStore, blobRequestSigner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class S3ClientLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public S3Client getApi() {
|
public S3Client getApi() {
|
||||||
return wrapper.unwrap(S3ApiMetadata.CONTEXT_TOKEN).getApi();
|
return view.unwrap(S3ApiMetadata.CONTEXT_TOKEN).getApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class BucketsLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
public S3Client getApi() {
|
public S3Client getApi() {
|
||||||
return (S3Client) wrapper.unwrap(S3ApiMetadata.CONTEXT_TOKEN).getApi();
|
return (S3Client) view.unwrap(S3ApiMetadata.CONTEXT_TOKEN).getApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class SwiftApiMetadata extends BaseRestApiMetadata {
|
||||||
.documentation(URI.create("http://api.openstack.org/"))
|
.documentation(URI.create("http://api.openstack.org/"))
|
||||||
.version(OpenStackAuthAsyncClient.VERSION)
|
.version(OpenStackAuthAsyncClient.VERSION)
|
||||||
.defaultProperties(SwiftApiMetadata.defaultProperties())
|
.defaultProperties(SwiftApiMetadata.defaultProperties())
|
||||||
.wrapper(TypeToken.of(BlobStoreContext.class))
|
.view(TypeToken.of(BlobStoreContext.class))
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(SwiftRestClientModule.class, SwiftBlobStoreContextModule.class));
|
.defaultModules(ImmutableSet.<Class<? extends Module>>of(SwiftRestClientModule.class, SwiftBlobStoreContextModule.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class SwiftClientLiveTest extends CommonSwiftClientLiveTest<SwiftClient>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SwiftClient getApi() {
|
public SwiftClient getApi() {
|
||||||
return wrapper.unwrap(SwiftApiMetadata.CONTEXT_TOKEN).getApi();
|
return view.unwrap(SwiftApiMetadata.CONTEXT_TOKEN).getApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class SwiftBlobIntegrationLiveTest extends BaseBlobIntegrationTest {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
BlobStore blobStore = wrapper.getBlobStore();
|
BlobStore blobStore = view.getBlobStore();
|
||||||
blobStore.createContainerInLocation(null, containerName);
|
blobStore.createContainerInLocation(null, containerName);
|
||||||
Blob blob = blobStore.blobBuilder("const.txt")
|
Blob blob = blobStore.blobBuilder("const.txt")
|
||||||
.payload(new File("target/const.txt")).contentMD5(oneHundredOneConstitutionsMD5).build();
|
.payload(new File("target/const.txt")).contentMD5(oneHundredOneConstitutionsMD5).build();
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class VCloudApiMetadata extends BaseRestApiMetadata {
|
||||||
.documentation(URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html"))
|
.documentation(URI.create("http://www.vmware.com/support/pubs/vcd_pubs.html"))
|
||||||
.version("1.0")
|
.version("1.0")
|
||||||
.defaultProperties(VCloudApiMetadata.defaultProperties())
|
.defaultProperties(VCloudApiMetadata.defaultProperties())
|
||||||
.wrapper(TypeToken.of(ComputeServiceContext.class))
|
.view(TypeToken.of(ComputeServiceContext.class))
|
||||||
.defaultModules(ImmutableSet.<Class<? extends Module>>of(VCloudRestClientModule.class, VCloudComputeServiceContextModule.class));
|
.defaultModules(ImmutableSet.<Class<? extends Module>>of(VCloudRestClientModule.class, VCloudComputeServiceContextModule.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class CatalogClientLiveTest extends BaseVCloudClientLiveTest {
|
||||||
public void testFindCatalogIsWriteableIfNotVersion1_5() throws Exception {
|
public void testFindCatalogIsWriteableIfNotVersion1_5() throws Exception {
|
||||||
// when we are in vCloud 1.0.0 public catalogs don't work, so our default
|
// when we are in vCloud 1.0.0 public catalogs don't work, so our default
|
||||||
// catalog is private
|
// catalog is private
|
||||||
if (!wrapper.utils().injector().getInstance(Key.get(String.class, ApiVersion.class)).startsWith("1.5"))
|
if (!view.utils().injector().getInstance(Key.get(String.class, ApiVersion.class)).startsWith("1.5"))
|
||||||
assertTrue(getVCloudApi().getCatalogClient().findCatalogInOrgNamed(null, null).isReadOnly());
|
assertTrue(getVCloudApi().getCatalogClient().findCatalogInOrgNamed(null, null).isReadOnly());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -45,14 +45,14 @@ public abstract class BaseVCloudClientLiveTest extends BaseComputeServiceContext
|
||||||
}
|
}
|
||||||
|
|
||||||
protected VCloudClient getVCloudApi() {
|
protected VCloudClient getVCloudApi() {
|
||||||
return VCloudClient.class.cast(wrapper.unwrap(VCloudApiMetadata.CONTEXT_TOKEN).getApi());
|
return VCloudClient.class.cast(view.unwrap(VCloudApiMetadata.CONTEXT_TOKEN).getApi());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
client = wrapper.getComputeService();
|
client = view.getComputeService();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.jclouds.blobstore;
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
|
|
||||||
import org.jclouds.Wrapper;
|
import org.jclouds.View;
|
||||||
import org.jclouds.blobstore.attr.ConsistencyModel;
|
import org.jclouds.blobstore.attr.ConsistencyModel;
|
||||||
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
|
||||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||||
|
@ -37,7 +37,7 @@ import com.google.inject.ImplementedBy;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ImplementedBy(BlobStoreContextImpl.class)
|
@ImplementedBy(BlobStoreContextImpl.class)
|
||||||
public interface BlobStoreContext extends Closeable, Wrapper {
|
public interface BlobStoreContext extends Closeable, View {
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Generates signed requests for blobs. useful in other tools such as backup utilities.
|
* Generates signed requests for blobs. useful in other tools such as backup utilities.
|
||||||
|
@ -119,8 +119,8 @@ public interface BlobStoreContext extends Closeable, Wrapper {
|
||||||
/**
|
/**
|
||||||
* will be removed in jclouds 1.6
|
* will be removed in jclouds 1.6
|
||||||
*
|
*
|
||||||
* @see Wrapper#getInputType
|
* @see View#getInputType
|
||||||
* @see Wrapper#unwrap
|
* @see View#unwrap
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
<S, A> RestContext<S, A> getProviderSpecificContext();
|
<S, A> RestContext<S, A> getProviderSpecificContext();
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class TransientApiMetadata extends BaseApiMetadata {
|
||||||
.defaultIdentity(System.getProperty("user.name"))
|
.defaultIdentity(System.getProperty("user.name"))
|
||||||
.defaultCredential("bar")
|
.defaultCredential("bar")
|
||||||
.version("1")
|
.version("1")
|
||||||
.wrapper(BlobStoreContext.class)
|
.view(BlobStoreContext.class)
|
||||||
.defaultModule(TransientBlobStoreContextModule.class)
|
.defaultModule(TransientBlobStoreContextModule.class)
|
||||||
.documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide"));
|
.documentation(URI.create("http://www.jclouds.org/documentation/userguide/blobstore-guide"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.jclouds.blobstore.BlobStoreContext;
|
||||||
import org.jclouds.blobstore.InputStreamMap;
|
import org.jclouds.blobstore.InputStreamMap;
|
||||||
import org.jclouds.blobstore.attr.ConsistencyModel;
|
import org.jclouds.blobstore.attr.ConsistencyModel;
|
||||||
import org.jclouds.blobstore.options.ListContainerOptions;
|
import org.jclouds.blobstore.options.ListContainerOptions;
|
||||||
import org.jclouds.internal.BaseWrapper;
|
import org.jclouds.internal.BaseView;
|
||||||
import org.jclouds.location.Provider;
|
import org.jclouds.location.Provider;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
import org.jclouds.rest.Utils;
|
import org.jclouds.rest.Utils;
|
||||||
|
@ -44,7 +44,7 @@ import com.google.common.reflect.TypeToken;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class BlobStoreContextImpl extends BaseWrapper implements BlobStoreContext {
|
public class BlobStoreContextImpl extends BaseView implements BlobStoreContext {
|
||||||
private final BlobMap.Factory blobMapFactory;
|
private final BlobMap.Factory blobMapFactory;
|
||||||
private final InputStreamMap.Factory inputStreamMapFactory;
|
private final InputStreamMap.Factory inputStreamMapFactory;
|
||||||
private final AsyncBlobStore ablobStore;
|
private final AsyncBlobStore ablobStore;
|
||||||
|
@ -54,11 +54,11 @@ public class BlobStoreContextImpl extends BaseWrapper implements BlobStoreContex
|
||||||
private final BlobRequestSigner blobRequestSigner;
|
private final BlobRequestSigner blobRequestSigner;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public BlobStoreContextImpl(@Provider Context wrapped, @Provider TypeToken<? extends Context> wrappedType,
|
public BlobStoreContextImpl(@Provider Context backend, @Provider TypeToken<? extends Context> backendType,
|
||||||
BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel,
|
BlobMap.Factory blobMapFactory, Utils utils, ConsistencyModel consistencyModel,
|
||||||
InputStreamMap.Factory inputStreamMapFactory, AsyncBlobStore ablobStore, BlobStore blobStore,
|
InputStreamMap.Factory inputStreamMapFactory, AsyncBlobStore ablobStore, BlobStore blobStore,
|
||||||
BlobRequestSigner blobRequestSigner) {
|
BlobRequestSigner blobRequestSigner) {
|
||||||
super(wrapped, wrappedType);
|
super(backend, backendType);
|
||||||
this.consistencyModel = checkNotNull(consistencyModel, "consistencyModel");
|
this.consistencyModel = checkNotNull(consistencyModel, "consistencyModel");
|
||||||
this.blobMapFactory = checkNotNull(blobMapFactory, "blobMapFactory");
|
this.blobMapFactory = checkNotNull(blobMapFactory, "blobMapFactory");
|
||||||
this.inputStreamMapFactory = checkNotNull(inputStreamMapFactory, "inputStreamMapFactory");
|
this.inputStreamMapFactory = checkNotNull(inputStreamMapFactory, "inputStreamMapFactory");
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class TransientContainerIntegrationTest extends BaseContainerIntegrationT
|
||||||
String key = "hello";
|
String key = "hello";
|
||||||
// NOTE all metadata in jclouds comes out as lowercase, in an effort to normalize the
|
// NOTE all metadata in jclouds comes out as lowercase, in an effort to normalize the
|
||||||
// providers.
|
// providers.
|
||||||
Blob blob = wrapper.getBlobStore().blobBuilder("hello").userMetadata(ImmutableMap.of("Adrian", "powderpuff"))
|
Blob blob = view.getBlobStore().blobBuilder("hello").userMetadata(ImmutableMap.of("Adrian", "powderpuff"))
|
||||||
.payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).build();
|
.payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).build();
|
||||||
|
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
|
@ -61,7 +61,7 @@ public class TransientContainerIntegrationTest extends BaseContainerIntegrationT
|
||||||
addBlobToContainer(containerName, blob);
|
addBlobToContainer(containerName, blob);
|
||||||
validateContent(containerName, key);
|
validateContent(containerName, key);
|
||||||
|
|
||||||
PageSet<? extends StorageMetadata> container = wrapper.getBlobStore().list(containerName, maxResults(1));
|
PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName, maxResults(1));
|
||||||
|
|
||||||
BlobMetadata metadata = (BlobMetadata) getOnlyElement(container);
|
BlobMetadata metadata = (BlobMetadata) getOnlyElement(container);
|
||||||
// transient container should be lenient and not return metadata on undetailed listing.
|
// transient container should be lenient and not return metadata on undetailed listing.
|
||||||
|
@ -75,7 +75,7 @@ public class TransientContainerIntegrationTest extends BaseContainerIntegrationT
|
||||||
|
|
||||||
@Test(groups = { "integration", "live" })
|
@Test(groups = { "integration", "live" })
|
||||||
public void testDuplicateCreateContainer() {
|
public void testDuplicateCreateContainer() {
|
||||||
BlobStore blobStore = wrapper.getBlobStore();
|
BlobStore blobStore = view.getBlobStore();
|
||||||
Location location = null;
|
Location location = null;
|
||||||
String container = "container";
|
String container = "container";
|
||||||
boolean created;
|
boolean created;
|
||||||
|
|
|
@ -141,15 +141,15 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
@Override
|
@Override
|
||||||
public Void call() throws Exception {
|
public Void call() throws Exception {
|
||||||
String name = blobCount.incrementAndGet() + "";
|
String name = blobCount.incrementAndGet() + "";
|
||||||
Blob blob = wrapper.getBlobStore().blobBuilder(name).payload(testPayload).build();
|
Blob blob = view.getBlobStore().blobBuilder(name).payload(testPayload).build();
|
||||||
wrapper.getBlobStore().putBlob(container, blob);
|
view.getBlobStore().putBlob(container, blob);
|
||||||
assertConsistencyAwareBlobExists(container, name);
|
assertConsistencyAwareBlobExists(container, name);
|
||||||
blob = wrapper.getBlobStore().getBlob(container, name);
|
blob = view.getBlobStore().getBlob(container, name);
|
||||||
|
|
||||||
assert Arrays.equals(CryptoStreams.md5(blob.getPayload()), md5) : String.format(
|
assert Arrays.equals(CryptoStreams.md5(blob.getPayload()), md5) : String.format(
|
||||||
"md5 didn't match on %s/%s", container, name);
|
"md5 didn't match on %s/%s", container, name);
|
||||||
|
|
||||||
wrapper.getBlobStore().removeBlob(container, name);
|
view.getBlobStore().removeBlob(container, name);
|
||||||
assertConsistencyAwareBlobDoesntExist(container, name);
|
assertConsistencyAwareBlobDoesntExist(container, name);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
Map<Integer, Future<?>> responses = Maps.newHashMap();
|
Map<Integer, Future<?>> responses = Maps.newHashMap();
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
|
|
||||||
responses.put(i, Futures.compose(wrapper.getAsyncBlobStore().getBlob(container, name),
|
responses.put(i, Futures.compose(view.getAsyncBlobStore().getBlob(container, name),
|
||||||
new Function<Blob, Void>() {
|
new Function<Blob, Void>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -204,9 +204,9 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void uploadConstitution(String container, String name, String contentDisposition) throws IOException {
|
private void uploadConstitution(String container, String name, String contentDisposition) throws IOException {
|
||||||
wrapper.getBlobStore().putBlob(
|
view.getBlobStore().putBlob(
|
||||||
container,
|
container,
|
||||||
wrapper.getBlobStore().blobBuilder(name).payload(oneHundredOneConstitutions.getInput()).contentType(
|
view.getBlobStore().blobBuilder(name).payload(oneHundredOneConstitutions.getInput()).contentType(
|
||||||
"text/plain").contentMD5(oneHundredOneConstitutionsMD5).contentLength(
|
"text/plain").contentMD5(oneHundredOneConstitutionsMD5).contentLength(
|
||||||
oneHundredOneConstitutionsLength).contentDisposition(contentDisposition).build());
|
oneHundredOneConstitutionsLength).contentDisposition(contentDisposition).build());
|
||||||
}
|
}
|
||||||
|
@ -224,11 +224,11 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
addObjectAndValidateContent(container, name);
|
addObjectAndValidateContent(container, name);
|
||||||
Date after = new Date(System.currentTimeMillis() + 1000);
|
Date after = new Date(System.currentTimeMillis() + 1000);
|
||||||
|
|
||||||
wrapper.getBlobStore().getBlob(container, name, ifModifiedSince(before));
|
view.getBlobStore().getBlob(container, name, ifModifiedSince(before));
|
||||||
validateContent(container, name);
|
validateContent(container, name);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
wrapper.getBlobStore().getBlob(container, name, ifModifiedSince(after));
|
view.getBlobStore().getBlob(container, name, ifModifiedSince(after));
|
||||||
validateContent(container, name);
|
validateContent(container, name);
|
||||||
} catch (HttpResponseException ex) {
|
} catch (HttpResponseException ex) {
|
||||||
assertEquals(ex.getResponse().getStatusCode(), 304);
|
assertEquals(ex.getResponse().getStatusCode(), 304);
|
||||||
|
@ -250,11 +250,11 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
addObjectAndValidateContent(container, name);
|
addObjectAndValidateContent(container, name);
|
||||||
Date after = new Date(System.currentTimeMillis() + 1000);
|
Date after = new Date(System.currentTimeMillis() + 1000);
|
||||||
|
|
||||||
wrapper.getBlobStore().getBlob(container, name, ifUnmodifiedSince(after));
|
view.getBlobStore().getBlob(container, name, ifUnmodifiedSince(after));
|
||||||
validateContent(container, name);
|
validateContent(container, name);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
wrapper.getBlobStore().getBlob(container, name, ifUnmodifiedSince(before));
|
view.getBlobStore().getBlob(container, name, ifUnmodifiedSince(before));
|
||||||
validateContent(container, name);
|
validateContent(container, name);
|
||||||
} catch (HttpResponseException ex) {
|
} catch (HttpResponseException ex) {
|
||||||
assertEquals(ex.getResponse().getStatusCode(), 412);
|
assertEquals(ex.getResponse().getStatusCode(), 412);
|
||||||
|
@ -273,11 +273,11 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
|
|
||||||
String goodETag = addObjectAndValidateContent(container, name);
|
String goodETag = addObjectAndValidateContent(container, name);
|
||||||
|
|
||||||
wrapper.getBlobStore().getBlob(container, name, ifETagMatches(goodETag));
|
view.getBlobStore().getBlob(container, name, ifETagMatches(goodETag));
|
||||||
validateContent(container, name);
|
validateContent(container, name);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
wrapper.getBlobStore().getBlob(container, name, ifETagMatches("powerfrisbee"));
|
view.getBlobStore().getBlob(container, name, ifETagMatches("powerfrisbee"));
|
||||||
validateContent(container, name);
|
validateContent(container, name);
|
||||||
} catch (HttpResponseException ex) {
|
} catch (HttpResponseException ex) {
|
||||||
assertEquals(ex.getResponse().getStatusCode(), 412);
|
assertEquals(ex.getResponse().getStatusCode(), 412);
|
||||||
|
@ -296,11 +296,11 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
|
|
||||||
String goodETag = addObjectAndValidateContent(container, name);
|
String goodETag = addObjectAndValidateContent(container, name);
|
||||||
|
|
||||||
wrapper.getBlobStore().getBlob(container, name, ifETagDoesntMatch("powerfrisbee"));
|
view.getBlobStore().getBlob(container, name, ifETagDoesntMatch("powerfrisbee"));
|
||||||
validateContent(container, name);
|
validateContent(container, name);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
wrapper.getBlobStore().getBlob(container, name, ifETagDoesntMatch(goodETag));
|
view.getBlobStore().getBlob(container, name, ifETagDoesntMatch(goodETag));
|
||||||
} catch (HttpResponseException ex) {
|
} catch (HttpResponseException ex) {
|
||||||
assertEquals(ex.getResponse().getStatusCode(), 304);
|
assertEquals(ex.getResponse().getStatusCode(), 304);
|
||||||
}
|
}
|
||||||
|
@ -317,11 +317,11 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
String name = "apples";
|
String name = "apples";
|
||||||
|
|
||||||
addObjectAndValidateContent(container, name);
|
addObjectAndValidateContent(container, name);
|
||||||
Blob blob1 = wrapper.getBlobStore().getBlob(container, name, range(0, 5));
|
Blob blob1 = view.getBlobStore().getBlob(container, name, range(0, 5));
|
||||||
validateMetadata(blob1.getMetadata(), container, name);
|
validateMetadata(blob1.getMetadata(), container, name);
|
||||||
assertEquals(getContentAsStringOrNullAndClose(blob1), TEST_STRING.substring(0, 6));
|
assertEquals(getContentAsStringOrNullAndClose(blob1), TEST_STRING.substring(0, 6));
|
||||||
|
|
||||||
Blob blob2 = wrapper.getBlobStore().getBlob(container, name, range(6, TEST_STRING.length()));
|
Blob blob2 = view.getBlobStore().getBlob(container, name, range(6, TEST_STRING.length()));
|
||||||
validateMetadata(blob2.getMetadata(), container, name);
|
validateMetadata(blob2.getMetadata(), container, name);
|
||||||
assertEquals(getContentAsStringOrNullAndClose(blob2), TEST_STRING.substring(6, TEST_STRING.length()));
|
assertEquals(getContentAsStringOrNullAndClose(blob2), TEST_STRING.substring(6, TEST_STRING.length()));
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -337,7 +337,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
String name = "apples";
|
String name = "apples";
|
||||||
|
|
||||||
addObjectAndValidateContent(container, name);
|
addObjectAndValidateContent(container, name);
|
||||||
Blob blob = wrapper.getBlobStore().getBlob(container, name, range(0, 5).range(6, TEST_STRING.length()));
|
Blob blob = view.getBlobStore().getBlob(container, name, range(0, 5).range(6, TEST_STRING.length()));
|
||||||
validateMetadata(blob.getMetadata(), container, name);
|
validateMetadata(blob.getMetadata(), container, name);
|
||||||
assertEquals(getContentAsStringOrNullAndClose(blob), TEST_STRING);
|
assertEquals(getContentAsStringOrNullAndClose(blob), TEST_STRING);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -401,7 +401,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
String container = getContainerName();
|
String container = getContainerName();
|
||||||
String name = "test";
|
String name = "test";
|
||||||
try {
|
try {
|
||||||
wrapper.getBlobStore().removeBlob(container, name);
|
view.getBlobStore().removeBlob(container, name);
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(container);
|
returnContainer(container);
|
||||||
}
|
}
|
||||||
|
@ -412,7 +412,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
String container = getContainerName();
|
String container = getContainerName();
|
||||||
String name = "test";
|
String name = "test";
|
||||||
try {
|
try {
|
||||||
assert !wrapper.getBlobStore().blobExists(container, name);
|
assert !view.getBlobStore().blobExists(container, name);
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(container);
|
returnContainer(container);
|
||||||
}
|
}
|
||||||
|
@ -429,7 +429,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
String container = getContainerName();
|
String container = getContainerName();
|
||||||
try {
|
try {
|
||||||
addBlobToContainer(container, name, name, MediaType.TEXT_PLAIN);
|
addBlobToContainer(container, name, name, MediaType.TEXT_PLAIN);
|
||||||
wrapper.getBlobStore().removeBlob(container, name);
|
view.getBlobStore().removeBlob(container, name);
|
||||||
assertContainerEmptyDeleting(container, name);
|
assertContainerEmptyDeleting(container, name);
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(container);
|
returnContainer(container);
|
||||||
|
@ -437,7 +437,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertContainerEmptyDeleting(String container, String name) {
|
private void assertContainerEmptyDeleting(String container, String name) {
|
||||||
Iterable<? extends StorageMetadata> listing = Iterables.filter(wrapper.getBlobStore().list(container),
|
Iterable<? extends StorageMetadata> listing = Iterables.filter(view.getBlobStore().list(container),
|
||||||
new Predicate<StorageMetadata>() {
|
new Predicate<StorageMetadata>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -454,7 +454,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
@Test(groups = { "integration", "live" })
|
@Test(groups = { "integration", "live" })
|
||||||
public void deleteObjectNoContainer() {
|
public void deleteObjectNoContainer() {
|
||||||
try {
|
try {
|
||||||
wrapper.getBlobStore().removeBlob("donb", "test");
|
view.getBlobStore().removeBlob("donb", "test");
|
||||||
} catch (HttpResponseException e) {
|
} catch (HttpResponseException e) {
|
||||||
assertEquals(e.getResponse().getStatusCode(), 404);
|
assertEquals(e.getResponse().getStatusCode(), 404);
|
||||||
} catch (ContainerNotFoundException e) {
|
} catch (ContainerNotFoundException e) {
|
||||||
|
@ -475,7 +475,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
@Test(groups = { "integration", "live" }, dataProvider = "putTests")
|
@Test(groups = { "integration", "live" }, dataProvider = "putTests")
|
||||||
public void testPutObject(String name, String type, Object content, Object realObject) throws InterruptedException,
|
public void testPutObject(String name, String type, Object content, Object realObject) throws InterruptedException,
|
||||||
IOException {
|
IOException {
|
||||||
PayloadBlobBuilder blobBuilder = wrapper.getBlobStore().blobBuilder(name).payload(Payloads.newPayload(content))
|
PayloadBlobBuilder blobBuilder = view.getBlobStore().blobBuilder(name).payload(Payloads.newPayload(content))
|
||||||
.contentType(type);
|
.contentType(type);
|
||||||
addContentMetadata(blobBuilder);
|
addContentMetadata(blobBuilder);
|
||||||
if (content instanceof InputStream) {
|
if (content instanceof InputStream) {
|
||||||
|
@ -484,14 +484,14 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
Blob blob = blobBuilder.build();
|
Blob blob = blobBuilder.build();
|
||||||
String container = getContainerName();
|
String container = getContainerName();
|
||||||
try {
|
try {
|
||||||
assertNotNull(wrapper.getBlobStore().putBlob(container, blob));
|
assertNotNull(view.getBlobStore().putBlob(container, blob));
|
||||||
blob = wrapper.getBlobStore().getBlob(container, blob.getMetadata().getName());
|
blob = view.getBlobStore().getBlob(container, blob.getMetadata().getName());
|
||||||
validateMetadata(blob.getMetadata(), container, name);
|
validateMetadata(blob.getMetadata(), container, name);
|
||||||
checkContentMetadata(blob);
|
checkContentMetadata(blob);
|
||||||
|
|
||||||
String returnedString = getContentAsStringOrNullAndClose(blob);
|
String returnedString = getContentAsStringOrNullAndClose(blob);
|
||||||
assertEquals(returnedString, realObject);
|
assertEquals(returnedString, realObject);
|
||||||
PageSet<? extends StorageMetadata> set = wrapper.getBlobStore().list(container);
|
PageSet<? extends StorageMetadata> set = view.getBlobStore().list(container);
|
||||||
assert set.size() == 1 : set;
|
assert set.size() == 1 : set;
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(container);
|
returnContainer(container);
|
||||||
|
@ -500,7 +500,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
|
|
||||||
@Test(groups = { "integration", "live" })
|
@Test(groups = { "integration", "live" })
|
||||||
public void testPutObjectStream() throws InterruptedException, IOException, ExecutionException {
|
public void testPutObjectStream() throws InterruptedException, IOException, ExecutionException {
|
||||||
PayloadBlobBuilder blobBuilder = wrapper.getBlobStore().blobBuilder("streaming").payload(
|
PayloadBlobBuilder blobBuilder = view.getBlobStore().blobBuilder("streaming").payload(
|
||||||
new StreamingPayload(new WriteTo() {
|
new StreamingPayload(new WriteTo() {
|
||||||
@Override
|
@Override
|
||||||
public void writeTo(OutputStream outstream) throws IOException {
|
public void writeTo(OutputStream outstream) throws IOException {
|
||||||
|
@ -514,14 +514,14 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
String container = getContainerName();
|
String container = getContainerName();
|
||||||
try {
|
try {
|
||||||
|
|
||||||
assertNotNull(wrapper.getBlobStore().putBlob(container, blob));
|
assertNotNull(view.getBlobStore().putBlob(container, blob));
|
||||||
|
|
||||||
blob = wrapper.getBlobStore().getBlob(container, blob.getMetadata().getName());
|
blob = view.getBlobStore().getBlob(container, blob.getMetadata().getName());
|
||||||
String returnedString = getContentAsStringOrNullAndClose(blob);
|
String returnedString = getContentAsStringOrNullAndClose(blob);
|
||||||
assertEquals(returnedString, "foo");
|
assertEquals(returnedString, "foo");
|
||||||
validateMetadata(blob.getMetadata(), container, blob.getMetadata().getName());
|
validateMetadata(blob.getMetadata(), container, blob.getMetadata().getName());
|
||||||
checkContentMetadata(blob);
|
checkContentMetadata(blob);
|
||||||
PageSet<? extends StorageMetadata> set = wrapper.getBlobStore().list(container);
|
PageSet<? extends StorageMetadata> set = view.getBlobStore().list(container);
|
||||||
assert set.size() == 1 : set;
|
assert set.size() == 1 : set;
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(container);
|
returnContainer(container);
|
||||||
|
@ -588,11 +588,11 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
// NOTE all metadata in jclouds comes out as lowercase, in an effort to
|
// NOTE all metadata in jclouds comes out as lowercase, in an effort to
|
||||||
// normalize the
|
// normalize the
|
||||||
// providers.
|
// providers.
|
||||||
Blob blob = wrapper.getBlobStore().blobBuilder(name).userMetadata(ImmutableMap.of("Adrian", "powderpuff"))
|
Blob blob = view.getBlobStore().blobBuilder(name).userMetadata(ImmutableMap.of("Adrian", "powderpuff"))
|
||||||
.payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).calculateMD5().build();
|
.payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).calculateMD5().build();
|
||||||
String container = getContainerName();
|
String container = getContainerName();
|
||||||
try {
|
try {
|
||||||
assertNull(wrapper.getBlobStore().blobMetadata(container, "powderpuff"));
|
assertNull(view.getBlobStore().blobMetadata(container, "powderpuff"));
|
||||||
|
|
||||||
addBlobToContainer(container, blob);
|
addBlobToContainer(container, blob);
|
||||||
Blob newObject = validateContent(container, name);
|
Blob newObject = validateContent(container, name);
|
||||||
|
@ -601,7 +601,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
|
|
||||||
validateMetadata(metadata);
|
validateMetadata(metadata);
|
||||||
validateMetadata(metadata, container, name);
|
validateMetadata(metadata, container, name);
|
||||||
validateMetadata(wrapper.getBlobStore().blobMetadata(container, name));
|
validateMetadata(view.getBlobStore().blobMetadata(container, name));
|
||||||
|
|
||||||
// write 2 items with the same name to ensure that provider doesn't
|
// write 2 items with the same name to ensure that provider doesn't
|
||||||
// accept dupes
|
// accept dupes
|
||||||
|
@ -609,7 +609,7 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
blob.getMetadata().getUserMetadata().put("Adrian", "powderpuff");
|
blob.getMetadata().getUserMetadata().put("Adrian", "powderpuff");
|
||||||
|
|
||||||
addBlobToContainer(container, blob);
|
addBlobToContainer(container, blob);
|
||||||
validateMetadata(wrapper.getBlobStore().blobMetadata(container, name));
|
validateMetadata(view.getBlobStore().blobMetadata(container, name));
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(container);
|
returnContainer(container);
|
||||||
|
|
|
@ -51,18 +51,18 @@ public class BaseBlobLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
|
|
||||||
httpStreamMD5 = checkNotNull(httpStreamMD5 != null ? httpStreamMD5 : sysHttpStreamMD5, "httpStreamMd5");
|
httpStreamMD5 = checkNotNull(httpStreamMD5 != null ? httpStreamMD5 : sysHttpStreamMD5, "httpStreamMd5");
|
||||||
|
|
||||||
HttpResponse response = wrapper.utils().http().invoke(
|
HttpResponse response = view.utils().http().invoke(
|
||||||
HttpRequest.builder().method("GET").endpoint(URI.create(httpStreamUrl)).build());
|
HttpRequest.builder().method("GET").endpoint(URI.create(httpStreamUrl)).build());
|
||||||
long length = response.getPayload().getContentMetadata().getContentLength();
|
long length = response.getPayload().getContentMetadata().getContentLength();
|
||||||
|
|
||||||
String name = "hello";
|
String name = "hello";
|
||||||
byte[] md5 = CryptoStreams.hex(httpStreamMD5);
|
byte[] md5 = CryptoStreams.hex(httpStreamMD5);
|
||||||
|
|
||||||
Blob blob = wrapper.getBlobStore().blobBuilder(name).payload(response.getPayload()).contentLength(length)
|
Blob blob = view.getBlobStore().blobBuilder(name).payload(response.getPayload()).contentLength(length)
|
||||||
.contentMD5(md5).build();
|
.contentMD5(md5).build();
|
||||||
String container = getContainerName();
|
String container = getContainerName();
|
||||||
try {
|
try {
|
||||||
wrapper.getBlobStore().putBlob(container, blob);
|
view.getBlobStore().putBlob(container, blob);
|
||||||
checkMD5(container, name, md5);
|
checkMD5(container, name, md5);
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(container);
|
returnContainer(container);
|
||||||
|
@ -70,7 +70,7 @@ public class BaseBlobLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkMD5(String container, String name, byte[] md5) {
|
protected void checkMD5(String container, String name, byte[] md5) {
|
||||||
assertEquals(wrapper.getBlobStore().blobMetadata(container, name).getContentMetadata().getContentMD5(), md5);
|
assertEquals(view.getBlobStore().blobMetadata(container, name).getContentMetadata().getContentMD5(), md5);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -73,7 +73,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
|
||||||
public void testValues() throws IOException, InterruptedException {
|
public void testValues() throws IOException, InterruptedException {
|
||||||
String bucketName = getContainerName();
|
String bucketName = getContainerName();
|
||||||
try {
|
try {
|
||||||
BlobMap map = createMap(wrapper, bucketName);
|
BlobMap map = createMap(view, bucketName);
|
||||||
|
|
||||||
putFiveStrings(map);
|
putFiveStrings(map);
|
||||||
putFiveStringsUnderPath(map);
|
putFiveStringsUnderPath(map);
|
||||||
|
@ -95,7 +95,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
|
||||||
public void testRemove() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
public void testRemove() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
String bucketName = getContainerName();
|
String bucketName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, Blob> map = createMap(wrapper, bucketName);
|
Map<String, Blob> map = createMap(view, bucketName);
|
||||||
putStringWithMD5(map, "one", "two");
|
putStringWithMD5(map, "one", "two");
|
||||||
assertConsistencyAwareContentEquals(map, "one", "two");
|
assertConsistencyAwareContentEquals(map, "one", "two");
|
||||||
// TODO track how often this occurs and potentially update map implementation
|
// TODO track how often this occurs and potentially update map implementation
|
||||||
|
@ -126,7 +126,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
|
||||||
public void testEntrySet() throws IOException, InterruptedException {
|
public void testEntrySet() throws IOException, InterruptedException {
|
||||||
String bucketName = getContainerName();
|
String bucketName = getContainerName();
|
||||||
try {
|
try {
|
||||||
final BlobMap map = createMap(wrapper, bucketName);
|
final BlobMap map = createMap(view, bucketName);
|
||||||
putFiveStrings(map);
|
putFiveStrings(map);
|
||||||
assertConsistencyAwareMapSize(map, 5);
|
assertConsistencyAwareMapSize(map, 5);
|
||||||
Set<Entry<String, Blob>> entries = map.entrySet();
|
Set<Entry<String, Blob>> entries = map.entrySet();
|
||||||
|
@ -159,9 +159,9 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
|
||||||
public void testContains() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
public void testContains() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
String bucketName = getContainerName();
|
String bucketName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, Blob> map = createMap(wrapper, bucketName);
|
Map<String, Blob> map = createMap(view, bucketName);
|
||||||
putStringWithMD5(map, "one", "apple");
|
putStringWithMD5(map, "one", "apple");
|
||||||
Blob blob = wrapper.getBlobStore().blobBuilder("one").payload("apple").calculateMD5().build();
|
Blob blob = view.getBlobStore().blobBuilder("one").payload("apple").calculateMD5().build();
|
||||||
assertConsistencyAwareContainsValue(map, blob);
|
assertConsistencyAwareContainsValue(map, blob);
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(bucketName);
|
returnContainer(bucketName);
|
||||||
|
@ -185,8 +185,8 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
|
||||||
public void testPut() throws IOException, InterruptedException {
|
public void testPut() throws IOException, InterruptedException {
|
||||||
String bucketName = getContainerName();
|
String bucketName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, Blob> map = createMap(wrapper, bucketName);
|
Map<String, Blob> map = createMap(view, bucketName);
|
||||||
Blob blob = wrapper.getBlobStore().blobBuilder("one").payload(Strings2.toInputStream("apple")).calculateMD5()
|
Blob blob = view.getBlobStore().blobBuilder("one").payload(Strings2.toInputStream("apple")).calculateMD5()
|
||||||
.build();
|
.build();
|
||||||
Blob old = map.put(blob.getMetadata().getName(), blob);
|
Blob old = map.put(blob.getMetadata().getName(), blob);
|
||||||
getOneReturnsAppleAndOldValueIsNull(map, old);
|
getOneReturnsAppleAndOldValueIsNull(map, old);
|
||||||
|
@ -203,12 +203,12 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
|
||||||
public void testPutAll() throws InterruptedException, ExecutionException, TimeoutException {
|
public void testPutAll() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
String bucketName = getContainerName();
|
String bucketName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, Blob> map = createMap(wrapper, bucketName);
|
Map<String, Blob> map = createMap(view, bucketName);
|
||||||
ImmutableMap.Builder<String, Blob> newMap = ImmutableMap.builder();
|
ImmutableMap.Builder<String, Blob> newMap = ImmutableMap.builder();
|
||||||
for (String key : fiveInputs.keySet()) {
|
for (String key : fiveInputs.keySet()) {
|
||||||
newMap.put(
|
newMap.put(
|
||||||
key,
|
key,
|
||||||
wrapper.getBlobStore().blobBuilder(key).payload(fiveInputs.get(key))
|
view.getBlobStore().blobBuilder(key).payload(fiveInputs.get(key))
|
||||||
.contentLength((long) fiveBytes.get(key).length).build());
|
.contentLength((long) fiveBytes.get(key).length).build());
|
||||||
}
|
}
|
||||||
map.putAll(newMap.build());
|
map.putAll(newMap.build());
|
||||||
|
@ -226,7 +226,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
|
||||||
return;
|
return;
|
||||||
String bucketName = getContainerName();
|
String bucketName = getContainerName();
|
||||||
try {
|
try {
|
||||||
BlobMap map = createMap(wrapper, bucketName);
|
BlobMap map = createMap(view, bucketName);
|
||||||
Builder<String> keySet = ImmutableSet.builder();
|
Builder<String> keySet = ImmutableSet.builder();
|
||||||
for (int i = 0; i < maxResultsForTestListings() + 1; i++) {
|
for (int i = 0; i < maxResultsForTestListings() + 1; i++) {
|
||||||
keySet.add(i + "");
|
keySet.add(i + "");
|
||||||
|
@ -250,7 +250,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void putStringWithMD5(Map<String, Blob> map, String key, String text) throws IOException {
|
protected void putStringWithMD5(Map<String, Blob> map, String key, String text) throws IOException {
|
||||||
map.put(key, wrapper.getBlobStore().blobBuilder(key).payload(text).calculateMD5().build());
|
map.put(key, view.getBlobStore().blobBuilder(key).payload(text).calculateMD5().build());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void putFiveStrings(BlobMap map) {
|
protected void putFiveStrings(BlobMap map) {
|
||||||
|
@ -277,7 +277,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addTenObjectsUnderPrefix(String containerName, String prefix) throws InterruptedException {
|
protected void addTenObjectsUnderPrefix(String containerName, String prefix) throws InterruptedException {
|
||||||
BlobMap blobMap = createMap(wrapper, containerName, inDirectory(prefix));
|
BlobMap blobMap = createMap(view, containerName, inDirectory(prefix));
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
blobMap.put(i + "", blobMap.blobBuilder().payload(i + "content").build());
|
blobMap.put(i + "", blobMap.blobBuilder().payload(i + "content").build());
|
||||||
}
|
}
|
||||||
|
@ -285,7 +285,7 @@ public abstract class BaseBlobMapIntegrationTest extends BaseMapIntegrationTest<
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void addTenObjectsUnderRoot(String containerName) throws InterruptedException {
|
protected void addTenObjectsUnderRoot(String containerName) throws InterruptedException {
|
||||||
BlobMap blobMap = createMap(wrapper, containerName, ListContainerOptions.NONE);
|
BlobMap blobMap = createMap(view, containerName, ListContainerOptions.NONE);
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
blobMap.put(i + "", blobMap.blobBuilder().payload(i + "content").build());
|
blobMap.put(i + "", blobMap.blobBuilder().payload(i + "content").build());
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,15 +41,15 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
String name = "hello";
|
String name = "hello";
|
||||||
String text = "fooooooooooooooooooooooo";
|
String text = "fooooooooooooooooooooooo";
|
||||||
|
|
||||||
Blob blob = wrapper.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build();
|
Blob blob = view.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build();
|
||||||
String container = getContainerName();
|
String container = getContainerName();
|
||||||
try {
|
try {
|
||||||
wrapper.getBlobStore().putBlob(container, blob);
|
view.getBlobStore().putBlob(container, blob);
|
||||||
assertConsistencyAwareContainerSize(container, 1);
|
assertConsistencyAwareContainerSize(container, 1);
|
||||||
HttpRequest request = wrapper.getSigner().signRemoveBlob(container, name);
|
HttpRequest request = view.getSigner().signRemoveBlob(container, name);
|
||||||
assertEquals(request.getFilters().size(), 0);
|
assertEquals(request.getFilters().size(), 0);
|
||||||
wrapper.utils().http().invoke(request);
|
view.utils().http().invoke(request);
|
||||||
assert !wrapper.getBlobStore().blobExists(container, name);
|
assert !view.getBlobStore().blobExists(container, name);
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(container);
|
returnContainer(container);
|
||||||
}
|
}
|
||||||
|
@ -60,14 +60,14 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
String name = "hello";
|
String name = "hello";
|
||||||
String text = "fooooooooooooooooooooooo";
|
String text = "fooooooooooooooooooooooo";
|
||||||
|
|
||||||
Blob blob = wrapper.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build();
|
Blob blob = view.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build();
|
||||||
String container = getContainerName();
|
String container = getContainerName();
|
||||||
try {
|
try {
|
||||||
wrapper.getBlobStore().putBlob(container, blob);
|
view.getBlobStore().putBlob(container, blob);
|
||||||
assertConsistencyAwareContainerSize(container, 1);
|
assertConsistencyAwareContainerSize(container, 1);
|
||||||
HttpRequest request = wrapper.getSigner().signGetBlob(container, name);
|
HttpRequest request = view.getSigner().signGetBlob(container, name);
|
||||||
assertEquals(request.getFilters().size(), 0);
|
assertEquals(request.getFilters().size(), 0);
|
||||||
assertEquals(Strings2.toStringAndClose(wrapper.utils().http().invoke(request).getPayload().getInput()), text);
|
assertEquals(Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().getInput()), text);
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(container);
|
returnContainer(container);
|
||||||
}
|
}
|
||||||
|
@ -78,14 +78,14 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
String name = "hello";
|
String name = "hello";
|
||||||
String text = "fooooooooooooooooooooooo";
|
String text = "fooooooooooooooooooooooo";
|
||||||
|
|
||||||
Blob blob = wrapper.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build();
|
Blob blob = view.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build();
|
||||||
String container = getContainerName();
|
String container = getContainerName();
|
||||||
try {
|
try {
|
||||||
wrapper.getBlobStore().putBlob(container, blob);
|
view.getBlobStore().putBlob(container, blob);
|
||||||
assertConsistencyAwareContainerSize(container, 1);
|
assertConsistencyAwareContainerSize(container, 1);
|
||||||
HttpRequest request = wrapper.getSigner().signGetBlob(container, name, range(0, 1));
|
HttpRequest request = view.getSigner().signGetBlob(container, name, range(0, 1));
|
||||||
assertEquals(request.getFilters().size(), 0);
|
assertEquals(request.getFilters().size(), 0);
|
||||||
assertEquals(Strings2.toStringAndClose(wrapper.utils().http().invoke(request).getPayload().getInput()), "fo");
|
assertEquals(Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().getInput()), "fo");
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(container);
|
returnContainer(container);
|
||||||
}
|
}
|
||||||
|
@ -96,12 +96,12 @@ public class BaseBlobSignerLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
String name = "hello";
|
String name = "hello";
|
||||||
String text = "fooooooooooooooooooooooo";
|
String text = "fooooooooooooooooooooooo";
|
||||||
|
|
||||||
Blob blob = wrapper.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build();
|
Blob blob = view.getBlobStore().blobBuilder(name).payload(text).contentType("text/plain").build();
|
||||||
String container = getContainerName();
|
String container = getContainerName();
|
||||||
try {
|
try {
|
||||||
HttpRequest request = wrapper.getSigner().signPutBlob(container, blob);
|
HttpRequest request = view.getSigner().signPutBlob(container, blob);
|
||||||
assertEquals(request.getFilters().size(), 0);
|
assertEquals(request.getFilters().size(), 0);
|
||||||
Strings2.toStringAndClose(wrapper.utils().http().invoke(request).getPayload().getInput());
|
Strings2.toStringAndClose(view.utils().http().invoke(request).getPayload().getInput());
|
||||||
assertConsistencyAwareContainerSize(container, 1);
|
assertConsistencyAwareContainerSize(container, 1);
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(container);
|
returnContainer(container);
|
||||||
|
|
|
@ -36,7 +36,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import org.jclouds.apis.BaseWrapperLiveTest;
|
import org.jclouds.apis.BaseViewLiveTest;
|
||||||
import org.jclouds.blobstore.BlobStoreContext;
|
import org.jclouds.blobstore.BlobStoreContext;
|
||||||
import org.jclouds.blobstore.attr.ConsistencyModel;
|
import org.jclouds.blobstore.attr.ConsistencyModel;
|
||||||
import org.jclouds.blobstore.domain.Blob;
|
import org.jclouds.blobstore.domain.Blob;
|
||||||
|
@ -59,7 +59,7 @@ import com.google.common.collect.Sets;
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.google.inject.Module;
|
import com.google.inject.Module;
|
||||||
|
|
||||||
public class BaseBlobStoreIntegrationTest extends BaseWrapperLiveTest<BlobStoreContext> {
|
public class BaseBlobStoreIntegrationTest extends BaseViewLiveTest<BlobStoreContext> {
|
||||||
protected static final String LOCAL_ENCODING = System.getProperty("file.encoding");
|
protected static final String LOCAL_ENCODING = System.getProperty("file.encoding");
|
||||||
protected static final String XML_STRING_FORMAT = "<apples><apple name=\"%s\"></apple> </apples>";
|
protected static final String XML_STRING_FORMAT = "<apples><apple name=\"%s\"></apple> </apples>";
|
||||||
protected static final String TEST_STRING = String.format(XML_STRING_FORMAT, "apple");
|
protected static final String TEST_STRING = String.format(XML_STRING_FORMAT, "apple");
|
||||||
|
@ -90,9 +90,9 @@ public class BaseBlobStoreIntegrationTest extends BaseWrapperLiveTest<BlobStoreC
|
||||||
@BeforeSuite
|
@BeforeSuite
|
||||||
public void setUpResourcesForAllThreads(ITestContext testContext) throws Exception {
|
public void setUpResourcesForAllThreads(ITestContext testContext) throws Exception {
|
||||||
setupContext();
|
setupContext();
|
||||||
createContainersSharedByAllThreads(wrapper, testContext);
|
createContainersSharedByAllThreads(view, testContext);
|
||||||
wrapper.close();
|
view.close();
|
||||||
wrapper = null;
|
view = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Iterable<Module> setupModules() {
|
protected Iterable<Module> setupModules() {
|
||||||
|
@ -119,7 +119,7 @@ public class BaseBlobStoreIntegrationTest extends BaseWrapperLiveTest<BlobStoreC
|
||||||
if (exec != null) {
|
if (exec != null) {
|
||||||
exec.shutdownNow();
|
exec.shutdownNow();
|
||||||
}
|
}
|
||||||
wrapper.close();
|
view.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static volatile boolean initialized = false;
|
private static volatile boolean initialized = false;
|
||||||
|
@ -224,7 +224,7 @@ public class BaseBlobStoreIntegrationTest extends BaseWrapperLiveTest<BlobStoreC
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void assertConsistencyAware(Runnable assertion) throws InterruptedException {
|
protected void assertConsistencyAware(Runnable assertion) throws InterruptedException {
|
||||||
assertConsistencyAware(wrapper, assertion);
|
assertConsistencyAware(view, assertion);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void createContainerAndEnsureEmpty(BlobStoreContext context, final String containerName)
|
protected static void createContainerAndEnsureEmpty(BlobStoreContext context, final String containerName)
|
||||||
|
@ -236,7 +236,7 @@ public class BaseBlobStoreIntegrationTest extends BaseWrapperLiveTest<BlobStoreC
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void createContainerAndEnsureEmpty(String containerName) throws InterruptedException {
|
protected void createContainerAndEnsureEmpty(String containerName) throws InterruptedException {
|
||||||
createContainerAndEnsureEmpty(wrapper, containerName);
|
createContainerAndEnsureEmpty(view, containerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String addBlobToContainer(String sourceContainer, String key) {
|
protected String addBlobToContainer(String sourceContainer, String key) {
|
||||||
|
@ -244,20 +244,20 @@ public class BaseBlobStoreIntegrationTest extends BaseWrapperLiveTest<BlobStoreC
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String addBlobToContainer(String sourceContainer, String key, String payload, String contentType) {
|
protected String addBlobToContainer(String sourceContainer, String key, String payload, String contentType) {
|
||||||
Blob sourceObject = wrapper.getBlobStore().blobBuilder(key).payload(payload).contentType(contentType).build();
|
Blob sourceObject = view.getBlobStore().blobBuilder(key).payload(payload).contentType(contentType).build();
|
||||||
return addBlobToContainer(sourceContainer, sourceObject);
|
return addBlobToContainer(sourceContainer, sourceObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void add5BlobsUnderPathAnd5UnderRootToContainer(String sourceContainer) {
|
protected void add5BlobsUnderPathAnd5UnderRootToContainer(String sourceContainer) {
|
||||||
for (Entry<String, String> entry : Iterables.concat(fiveStrings.entrySet(), fiveStringsUnderPath.entrySet())) {
|
for (Entry<String, String> entry : Iterables.concat(fiveStrings.entrySet(), fiveStringsUnderPath.entrySet())) {
|
||||||
Blob sourceObject = wrapper.getBlobStore().blobBuilder(entry.getKey()).payload(entry.getValue())
|
Blob sourceObject = view.getBlobStore().blobBuilder(entry.getKey()).payload(entry.getValue())
|
||||||
.contentType("text/xml").build();
|
.contentType("text/xml").build();
|
||||||
addBlobToContainer(sourceContainer, sourceObject);
|
addBlobToContainer(sourceContainer, sourceObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String addBlobToContainer(String sourceContainer, Blob object) {
|
protected String addBlobToContainer(String sourceContainer, Blob object) {
|
||||||
return wrapper.getBlobStore().putBlob(sourceContainer, object);
|
return view.getBlobStore().putBlob(sourceContainer, object);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <T extends BlobMetadata> T validateMetadata(T md, String container, String name) {
|
protected <T extends BlobMetadata> T validateMetadata(T md, String container, String name) {
|
||||||
|
@ -269,7 +269,7 @@ public class BaseBlobStoreIntegrationTest extends BaseWrapperLiveTest<BlobStoreC
|
||||||
|
|
||||||
protected Blob validateContent(String container, String name) throws InterruptedException {
|
protected Blob validateContent(String container, String name) throws InterruptedException {
|
||||||
assertConsistencyAwareContainerSize(container, 1);
|
assertConsistencyAwareContainerSize(container, 1);
|
||||||
Blob newObject = wrapper.getBlobStore().getBlob(container, name);
|
Blob newObject = view.getBlobStore().getBlob(container, name);
|
||||||
assert newObject != null;
|
assert newObject != null;
|
||||||
validateMetadata(newObject.getMetadata(), container, name);
|
validateMetadata(newObject.getMetadata(), container, name);
|
||||||
try {
|
try {
|
||||||
|
@ -285,9 +285,9 @@ public class BaseBlobStoreIntegrationTest extends BaseWrapperLiveTest<BlobStoreC
|
||||||
assertConsistencyAware(new Runnable() {
|
assertConsistencyAware(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
assert wrapper.getBlobStore().countBlobs(containerName) == count : String.format(
|
assert view.getBlobStore().countBlobs(containerName) == count : String.format(
|
||||||
"expected only %d values in %s: %s", count, containerName, ImmutableSet.copyOf(Iterables
|
"expected only %d values in %s: %s", count, containerName, ImmutableSet.copyOf(Iterables
|
||||||
.transform(wrapper.getBlobStore().list(containerName),
|
.transform(view.getBlobStore().list(containerName),
|
||||||
new Function<StorageMetadata, String>() {
|
new Function<StorageMetadata, String>() {
|
||||||
|
|
||||||
public String apply(StorageMetadata from) {
|
public String apply(StorageMetadata from) {
|
||||||
|
@ -307,9 +307,9 @@ public class BaseBlobStoreIntegrationTest extends BaseWrapperLiveTest<BlobStoreC
|
||||||
assertConsistencyAware(new Runnable() {
|
assertConsistencyAware(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
assert wrapper.getBlobStore().blobExists(containerName, name) : String.format(
|
assert view.getBlobStore().blobExists(containerName, name) : String.format(
|
||||||
"could not find %s in %s: %s", name, containerName, ImmutableSet.copyOf(Iterables.transform(
|
"could not find %s in %s: %s", name, containerName, ImmutableSet.copyOf(Iterables.transform(
|
||||||
wrapper.getBlobStore().list(containerName), new Function<StorageMetadata, String>() {
|
view.getBlobStore().list(containerName), new Function<StorageMetadata, String>() {
|
||||||
|
|
||||||
public String apply(StorageMetadata from) {
|
public String apply(StorageMetadata from) {
|
||||||
return from.getName();
|
return from.getName();
|
||||||
|
@ -328,7 +328,7 @@ public class BaseBlobStoreIntegrationTest extends BaseWrapperLiveTest<BlobStoreC
|
||||||
assertConsistencyAware(new Runnable() {
|
assertConsistencyAware(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
assert !wrapper.getBlobStore().blobExists(containerName, name) : String.format("found %s in %s", name,
|
assert !view.getBlobStore().blobExists(containerName, name) : String.format("found %s in %s", name,
|
||||||
containerName);
|
containerName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Throwables.propagateIfPossible(e);
|
Throwables.propagateIfPossible(e);
|
||||||
|
@ -367,7 +367,7 @@ public class BaseBlobStoreIntegrationTest extends BaseWrapperLiveTest<BlobStoreC
|
||||||
* *substantially* slow down tests on a real server over a network.
|
* *substantially* slow down tests on a real server over a network.
|
||||||
*/
|
*/
|
||||||
if (SANITY_CHECK_RETURNED_BUCKET_NAME) {
|
if (SANITY_CHECK_RETURNED_BUCKET_NAME) {
|
||||||
if (!Iterables.any(wrapper.getBlobStore().list(), new Predicate<StorageMetadata>() {
|
if (!Iterables.any(view.getBlobStore().list(), new Predicate<StorageMetadata>() {
|
||||||
public boolean apply(StorageMetadata md) {
|
public boolean apply(StorageMetadata md) {
|
||||||
return containerName.equals(md.getName());
|
return containerName.equals(md.getName());
|
||||||
}
|
}
|
||||||
|
@ -382,7 +382,7 @@ public class BaseBlobStoreIntegrationTest extends BaseWrapperLiveTest<BlobStoreC
|
||||||
assertConsistencyAware(new Runnable() {
|
assertConsistencyAware(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
assert !wrapper.getBlobStore().containerExists(containerName) : "container " + containerName
|
assert !view.getBlobStore().containerExists(containerName) : "container " + containerName
|
||||||
+ " still exists";
|
+ " still exists";
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
propagateIfPossible(e);
|
propagateIfPossible(e);
|
||||||
|
@ -416,7 +416,7 @@ public class BaseBlobStoreIntegrationTest extends BaseWrapperLiveTest<BlobStoreC
|
||||||
private String allocateNewContainerName(final String container) {
|
private String allocateNewContainerName(final String container) {
|
||||||
exec.submit(new Runnable() {
|
exec.submit(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
deleteContainerOrWarnIfUnable(wrapper, container);
|
deleteContainerOrWarnIfUnable(view, container);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
String newScratchContainer = container + containerIndex.incrementAndGet();
|
String newScratchContainer = container + containerIndex.incrementAndGet();
|
||||||
|
@ -429,7 +429,7 @@ public class BaseBlobStoreIntegrationTest extends BaseWrapperLiveTest<BlobStoreC
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeToken<BlobStoreContext> wrapperType() {
|
protected TypeToken<BlobStoreContext> viewType() {
|
||||||
return TypeToken.of(BlobStoreContext.class);
|
return TypeToken.of(BlobStoreContext.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,21 +49,21 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
|
|
||||||
@Test(groups = { "integration", "live" })
|
@Test(groups = { "integration", "live" })
|
||||||
public void containerDoesntExist() {
|
public void containerDoesntExist() {
|
||||||
assert !wrapper.getBlobStore().containerExists("forgetaboutit");
|
assert !view.getBlobStore().containerExists("forgetaboutit");
|
||||||
assert !wrapper.getBlobStore().containerExists("cloudcachestorefunctionalintegrationtest-first");
|
assert !view.getBlobStore().containerExists("cloudcachestorefunctionalintegrationtest-first");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = { "integration", "live" })
|
@Test(groups = { "integration", "live" })
|
||||||
public void testPutTwiceIsOkAndDoesntOverwrite() throws InterruptedException {
|
public void testPutTwiceIsOkAndDoesntOverwrite() throws InterruptedException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
wrapper.getBlobStore().createContainerInLocation(null, containerName);
|
view.getBlobStore().createContainerInLocation(null, containerName);
|
||||||
|
|
||||||
Blob blob = wrapper.getBlobStore().blobBuilder("hello").payload(TEST_STRING).build();
|
Blob blob = view.getBlobStore().blobBuilder("hello").payload(TEST_STRING).build();
|
||||||
wrapper.getBlobStore().putBlob(containerName, blob);
|
view.getBlobStore().putBlob(containerName, blob);
|
||||||
|
|
||||||
wrapper.getBlobStore().createContainerInLocation(null, containerName);
|
view.getBlobStore().createContainerInLocation(null, containerName);
|
||||||
assertEquals(wrapper.getBlobStore().countBlobs(containerName), 1);
|
assertEquals(view.getBlobStore().countBlobs(containerName), 1);
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(containerName);
|
returnContainer(containerName);
|
||||||
}
|
}
|
||||||
|
@ -77,11 +77,11 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
addBlobToContainer(containerName,
|
addBlobToContainer(containerName,
|
||||||
// NOTE all metadata in jclouds comes out as lowercase, in an effort to
|
// NOTE all metadata in jclouds comes out as lowercase, in an effort to
|
||||||
// normalize the providers.
|
// normalize the providers.
|
||||||
wrapper.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("Adrian", "powderpuff"))
|
view.getBlobStore().blobBuilder(key).userMetadata(ImmutableMap.of("Adrian", "powderpuff"))
|
||||||
.payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).calculateMD5().build());
|
.payload(TEST_STRING).contentType(MediaType.TEXT_PLAIN).calculateMD5().build());
|
||||||
validateContent(containerName, key);
|
validateContent(containerName, key);
|
||||||
|
|
||||||
PageSet<? extends StorageMetadata> container = wrapper.getBlobStore().list(containerName,
|
PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName,
|
||||||
maxResults(1).withDetails());
|
maxResults(1).withDetails());
|
||||||
|
|
||||||
BlobMetadata metadata = BlobMetadata.class.cast(get(container, 0));
|
BlobMetadata metadata = BlobMetadata.class.cast(get(container, 0));
|
||||||
|
@ -105,7 +105,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
add5BlobsUnderPathAnd5UnderRootToContainer(containerName);
|
add5BlobsUnderPathAnd5UnderRootToContainer(containerName);
|
||||||
wrapper.getBlobStore().clearContainer(containerName);
|
view.getBlobStore().clearContainer(containerName);
|
||||||
assertConsistencyAwareContainerSize(containerName, 0);
|
assertConsistencyAwareContainerSize(containerName, 0);
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(containerName);
|
returnContainer(containerName);
|
||||||
|
@ -118,13 +118,13 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
try {
|
try {
|
||||||
addAlphabetUnderRoot(containerName);
|
addAlphabetUnderRoot(containerName);
|
||||||
|
|
||||||
PageSet<? extends StorageMetadata> container = wrapper.getBlobStore().list(containerName, maxResults(1));
|
PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName, maxResults(1));
|
||||||
|
|
||||||
assert container.getNextMarker() != null;
|
assert container.getNextMarker() != null;
|
||||||
assertEquals(container.size(), 1);
|
assertEquals(container.size(), 1);
|
||||||
String marker = container.getNextMarker();
|
String marker = container.getNextMarker();
|
||||||
|
|
||||||
container = wrapper.getBlobStore().list(containerName, afterMarker(marker));
|
container = view.getBlobStore().list(containerName, afterMarker(marker));
|
||||||
assertEquals(container.getNextMarker(), null);
|
assertEquals(container.getNextMarker(), null);
|
||||||
assert container.size() == 25 : String.format("size should have been 25, but was %d: %s", container.size(),
|
assert container.size() == 25 : String.format("size should have been 25, but was %d: %s", container.size(),
|
||||||
container);
|
container);
|
||||||
|
@ -142,7 +142,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
String prefix = "rootdelimeter";
|
String prefix = "rootdelimeter";
|
||||||
addTenObjectsUnderPrefix(containerName, prefix);
|
addTenObjectsUnderPrefix(containerName, prefix);
|
||||||
add15UnderRoot(containerName);
|
add15UnderRoot(containerName);
|
||||||
PageSet<? extends StorageMetadata> container = wrapper.getBlobStore().list(containerName);
|
PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName);
|
||||||
assert container.getNextMarker() == null;
|
assert container.getNextMarker() == null;
|
||||||
assertEquals(container.size(), 16);
|
assertEquals(container.size(), 16);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -157,17 +157,17 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
try {
|
try {
|
||||||
String directory = "directory";
|
String directory = "directory";
|
||||||
|
|
||||||
assert !wrapper.getBlobStore().directoryExists(containerName, directory);
|
assert !view.getBlobStore().directoryExists(containerName, directory);
|
||||||
|
|
||||||
wrapper.getBlobStore().createDirectory(containerName, directory);
|
view.getBlobStore().createDirectory(containerName, directory);
|
||||||
|
|
||||||
assert wrapper.getBlobStore().directoryExists(containerName, directory);
|
assert view.getBlobStore().directoryExists(containerName, directory);
|
||||||
PageSet<? extends StorageMetadata> container = wrapper.getBlobStore().list(containerName);
|
PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName);
|
||||||
// we should have only the directory under root
|
// we should have only the directory under root
|
||||||
assert container.getNextMarker() == null;
|
assert container.getNextMarker() == null;
|
||||||
assert container.size() == 1 : container;
|
assert container.size() == 1 : container;
|
||||||
|
|
||||||
container = wrapper.getBlobStore().list(containerName, inDirectory(directory));
|
container = view.getBlobStore().list(containerName, inDirectory(directory));
|
||||||
|
|
||||||
// we should have nothing in the directory
|
// we should have nothing in the directory
|
||||||
assert container.getNextMarker() == null;
|
assert container.getNextMarker() == null;
|
||||||
|
@ -175,50 +175,50 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
|
|
||||||
addTenObjectsUnderPrefix(containerName, directory);
|
addTenObjectsUnderPrefix(containerName, directory);
|
||||||
|
|
||||||
container = wrapper.getBlobStore().list(containerName);
|
container = view.getBlobStore().list(containerName);
|
||||||
// we should still have only the directory under root
|
// we should still have only the directory under root
|
||||||
assert container.getNextMarker() == null;
|
assert container.getNextMarker() == null;
|
||||||
assert container.size() == 1 : container;
|
assert container.size() == 1 : container;
|
||||||
|
|
||||||
container = wrapper.getBlobStore().list(containerName, inDirectory(directory));
|
container = view.getBlobStore().list(containerName, inDirectory(directory));
|
||||||
// we should have only the 10 items under the directory
|
// we should have only the 10 items under the directory
|
||||||
assert container.getNextMarker() == null;
|
assert container.getNextMarker() == null;
|
||||||
assert container.size() == 10 : container;
|
assert container.size() == 10 : container;
|
||||||
|
|
||||||
// try 2 level deep directory
|
// try 2 level deep directory
|
||||||
assert !wrapper.getBlobStore().directoryExists(containerName, directory + "/" + directory);
|
assert !view.getBlobStore().directoryExists(containerName, directory + "/" + directory);
|
||||||
wrapper.getBlobStore().createDirectory(containerName, directory + "/" + directory);
|
view.getBlobStore().createDirectory(containerName, directory + "/" + directory);
|
||||||
assert wrapper.getBlobStore().directoryExists(containerName, directory + "/" + directory);
|
assert view.getBlobStore().directoryExists(containerName, directory + "/" + directory);
|
||||||
|
|
||||||
wrapper.getBlobStore().clearContainer(containerName, inDirectory(directory));
|
view.getBlobStore().clearContainer(containerName, inDirectory(directory));
|
||||||
assert wrapper.getBlobStore().directoryExists(containerName, directory);
|
assert view.getBlobStore().directoryExists(containerName, directory);
|
||||||
assert wrapper.getBlobStore().directoryExists(containerName, directory + "/" + directory);
|
assert view.getBlobStore().directoryExists(containerName, directory + "/" + directory);
|
||||||
|
|
||||||
// should have only the 2 level-deep directory above
|
// should have only the 2 level-deep directory above
|
||||||
container = wrapper.getBlobStore().list(containerName, inDirectory(directory));
|
container = view.getBlobStore().list(containerName, inDirectory(directory));
|
||||||
assert container.getNextMarker() == null;
|
assert container.getNextMarker() == null;
|
||||||
assert container.size() == 1 : container;
|
assert container.size() == 1 : container;
|
||||||
|
|
||||||
wrapper.getBlobStore().createDirectory(containerName, directory + "/" + directory);
|
view.getBlobStore().createDirectory(containerName, directory + "/" + directory);
|
||||||
|
|
||||||
container = wrapper.getBlobStore().list(containerName, inDirectory(directory).recursive());
|
container = view.getBlobStore().list(containerName, inDirectory(directory).recursive());
|
||||||
assert container.getNextMarker() == null;
|
assert container.getNextMarker() == null;
|
||||||
assert container.size() == 1 : container;
|
assert container.size() == 1 : container;
|
||||||
|
|
||||||
wrapper.getBlobStore().clearContainer(containerName, inDirectory(directory).recursive());
|
view.getBlobStore().clearContainer(containerName, inDirectory(directory).recursive());
|
||||||
|
|
||||||
// should no longer have the 2 level-deep directory above
|
// should no longer have the 2 level-deep directory above
|
||||||
container = wrapper.getBlobStore().list(containerName, inDirectory(directory));
|
container = view.getBlobStore().list(containerName, inDirectory(directory));
|
||||||
assert container.getNextMarker() == null;
|
assert container.getNextMarker() == null;
|
||||||
assert container.size() == 0 : container;
|
assert container.size() == 0 : container;
|
||||||
|
|
||||||
container = wrapper.getBlobStore().list(containerName);
|
container = view.getBlobStore().list(containerName);
|
||||||
// should only have the directory
|
// should only have the directory
|
||||||
assert container.getNextMarker() == null;
|
assert container.getNextMarker() == null;
|
||||||
assert container.size() == 1 : container;
|
assert container.size() == 1 : container;
|
||||||
wrapper.getBlobStore().deleteDirectory(containerName, directory);
|
view.getBlobStore().deleteDirectory(containerName, directory);
|
||||||
|
|
||||||
container = wrapper.getBlobStore().list(containerName);
|
container = view.getBlobStore().list(containerName);
|
||||||
// now should be completely empty
|
// now should be completely empty
|
||||||
assert container.getNextMarker() == null;
|
assert container.getNextMarker() == null;
|
||||||
assert container.size() == 0 : container;
|
assert container.size() == 0 : container;
|
||||||
|
@ -236,7 +236,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
addTenObjectsUnderPrefix(containerName, prefix);
|
addTenObjectsUnderPrefix(containerName, prefix);
|
||||||
add15UnderRoot(containerName);
|
add15UnderRoot(containerName);
|
||||||
|
|
||||||
PageSet<? extends StorageMetadata> container = wrapper.getBlobStore().list(containerName, inDirectory(prefix));
|
PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName, inDirectory(prefix));
|
||||||
assert container.getNextMarker() == null;
|
assert container.getNextMarker() == null;
|
||||||
assertEquals(container.size(), 10);
|
assertEquals(container.size(), 10);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -251,7 +251,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
try {
|
try {
|
||||||
addAlphabetUnderRoot(containerName);
|
addAlphabetUnderRoot(containerName);
|
||||||
|
|
||||||
PageSet<? extends StorageMetadata> container = wrapper.getBlobStore().list(containerName, maxResults(5));
|
PageSet<? extends StorageMetadata> container = view.getBlobStore().list(containerName, maxResults(5));
|
||||||
assertEquals(container.size(), 5);
|
assertEquals(container.size(), 5);
|
||||||
assert container.getNextMarker() != null;
|
assert container.getNextMarker() != null;
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -263,7 +263,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
public void containerExists() throws InterruptedException {
|
public void containerExists() throws InterruptedException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
assert wrapper.getBlobStore().containerExists(containerName);
|
assert view.getBlobStore().containerExists(containerName);
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(containerName);
|
returnContainer(containerName);
|
||||||
}
|
}
|
||||||
|
@ -274,7 +274,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
addBlobToContainer(containerName, "test");
|
addBlobToContainer(containerName, "test");
|
||||||
wrapper.getBlobStore().deleteContainer(containerName);
|
view.getBlobStore().deleteContainer(containerName);
|
||||||
assertNotExists(containerName);
|
assertNotExists(containerName);
|
||||||
} finally {
|
} finally {
|
||||||
recycleContainer(containerName);
|
recycleContainer(containerName);
|
||||||
|
@ -285,7 +285,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
public void deleteContainerIfEmpty() throws InterruptedException {
|
public void deleteContainerIfEmpty() throws InterruptedException {
|
||||||
final String containerName = getContainerName();
|
final String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
wrapper.getBlobStore().deleteContainer(containerName);
|
view.getBlobStore().deleteContainer(containerName);
|
||||||
assertNotExists(containerName);
|
assertNotExists(containerName);
|
||||||
} finally {
|
} finally {
|
||||||
// this container is now deleted, so we can't reuse it directly
|
// this container is now deleted, so we can't reuse it directly
|
||||||
|
@ -298,7 +298,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
add15UnderRoot(containerName);
|
add15UnderRoot(containerName);
|
||||||
Set<? extends StorageMetadata> container = wrapper.getBlobStore().list(containerName);
|
Set<? extends StorageMetadata> container = view.getBlobStore().list(containerName);
|
||||||
assertEquals(container.size(), 15);
|
assertEquals(container.size(), 15);
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(containerName);
|
returnContainer(containerName);
|
||||||
|
@ -308,8 +308,8 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
|
|
||||||
protected void addAlphabetUnderRoot(String containerName) throws InterruptedException {
|
protected void addAlphabetUnderRoot(String containerName) throws InterruptedException {
|
||||||
for (char letter = 'a'; letter <= 'z'; letter++) {
|
for (char letter = 'a'; letter <= 'z'; letter++) {
|
||||||
wrapper.getBlobStore().putBlob(containerName,
|
view.getBlobStore().putBlob(containerName,
|
||||||
wrapper.getBlobStore().blobBuilder(letter + "").payload(letter + "content").build());
|
view.getBlobStore().blobBuilder(letter + "").payload(letter + "content").build());
|
||||||
}
|
}
|
||||||
assertContainerSize(containerName, 26);
|
assertContainerSize(containerName, 26);
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
assertConsistencyAware(new Runnable() {
|
assertConsistencyAware(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
assertEquals(wrapper.getBlobStore().countBlobs(containerName), size);
|
assertEquals(view.getBlobStore().countBlobs(containerName), size);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
propagateIfPossible(e);
|
propagateIfPossible(e);
|
||||||
}
|
}
|
||||||
|
@ -329,15 +329,15 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
|
|
||||||
protected void add15UnderRoot(String containerName) throws InterruptedException {
|
protected void add15UnderRoot(String containerName) throws InterruptedException {
|
||||||
for (int i = 0; i < 15; i++) {
|
for (int i = 0; i < 15; i++) {
|
||||||
wrapper.getBlobStore().putBlob(containerName,
|
view.getBlobStore().putBlob(containerName,
|
||||||
wrapper.getBlobStore().blobBuilder(i + "").payload(i + "content").build());
|
view.getBlobStore().blobBuilder(i + "").payload(i + "content").build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addTenObjectsUnderPrefix(String containerName, String prefix) throws InterruptedException {
|
protected void addTenObjectsUnderPrefix(String containerName, String prefix) throws InterruptedException {
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
wrapper.getBlobStore().putBlob(containerName,
|
view.getBlobStore().putBlob(containerName,
|
||||||
wrapper.getBlobStore().blobBuilder(prefix + "/" + i).payload(i + "content").build());
|
view.getBlobStore().blobBuilder(prefix + "/" + i).payload(i + "content").build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -38,18 +38,18 @@ public class BaseContainerLiveTest extends BaseBlobStoreIntegrationTest {
|
||||||
public void testPublicAccess() throws InterruptedException, MalformedURLException, IOException {
|
public void testPublicAccess() throws InterruptedException, MalformedURLException, IOException {
|
||||||
final String containerName = getScratchContainerName();
|
final String containerName = getScratchContainerName();
|
||||||
try {
|
try {
|
||||||
wrapper.getBlobStore().createContainerInLocation(null, containerName, publicRead());
|
view.getBlobStore().createContainerInLocation(null, containerName, publicRead());
|
||||||
assertConsistencyAwareContainerSize(containerName, 0);
|
assertConsistencyAwareContainerSize(containerName, 0);
|
||||||
|
|
||||||
wrapper.getBlobStore().putBlob(containerName,
|
view.getBlobStore().putBlob(containerName,
|
||||||
wrapper.getBlobStore().blobBuilder("hello").payload(TEST_STRING).build());
|
view.getBlobStore().blobBuilder("hello").payload(TEST_STRING).build());
|
||||||
assertConsistencyAwareContainerSize(containerName, 1);
|
assertConsistencyAwareContainerSize(containerName, 1);
|
||||||
|
|
||||||
BlobMetadata metadata = wrapper.getBlobStore().blobMetadata(containerName, "hello");
|
BlobMetadata metadata = view.getBlobStore().blobMetadata(containerName, "hello");
|
||||||
|
|
||||||
assert metadata.getPublicUri() != null : metadata;
|
assert metadata.getPublicUri() != null : metadata;
|
||||||
|
|
||||||
assertEquals(Strings2.toStringAndClose(wrapper.utils().http().get(metadata.getPublicUri())), TEST_STRING);
|
assertEquals(Strings2.toStringAndClose(view.utils().http().get(metadata.getPublicUri())), TEST_STRING);
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
// this container is now public, so we can't reuse it directly
|
// this container is now public, so we can't reuse it directly
|
||||||
|
|
|
@ -53,7 +53,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
public void testValues() throws InterruptedException, IOException {
|
public void testValues() throws InterruptedException, IOException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(wrapper, containerName);
|
Map<String, InputStream> map = createMap(view, containerName);
|
||||||
map.putAll(this.fiveInputs);
|
map.putAll(this.fiveInputs);
|
||||||
// this will cause us to block until the bucket updates.
|
// this will cause us to block until the bucket updates.
|
||||||
assertConsistencyAwareMapSize(map, 5);
|
assertConsistencyAwareMapSize(map, 5);
|
||||||
|
@ -74,7 +74,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
public void testPutMoreThanSingleListing() throws InterruptedException, ExecutionException, TimeoutException {
|
public void testPutMoreThanSingleListing() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
InputStreamMap map = createMap(wrapper, containerName);
|
InputStreamMap map = createMap(view, containerName);
|
||||||
Set<String> keySet = Sets.newLinkedHashSet();
|
Set<String> keySet = Sets.newLinkedHashSet();
|
||||||
for (int i = 0; i < maxResultsForTestListings() + 1; i++) {
|
for (int i = 0; i < maxResultsForTestListings() + 1; i++) {
|
||||||
keySet.add(i + "");
|
keySet.add(i + "");
|
||||||
|
@ -100,7 +100,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
public void testRemove() throws InterruptedException, IOException {
|
public void testRemove() throws InterruptedException, IOException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(wrapper, containerName);
|
Map<String, InputStream> map = createMap(view, containerName);
|
||||||
putStringWithMD5(map, "one", "two");
|
putStringWithMD5(map, "one", "two");
|
||||||
InputStream old = map.remove("one");
|
InputStream old = map.remove("one");
|
||||||
assertEquals(Strings2.toStringAndClose(old), "two");
|
assertEquals(Strings2.toStringAndClose(old), "two");
|
||||||
|
@ -120,7 +120,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
public void testEntrySet() throws InterruptedException, IOException {
|
public void testEntrySet() throws InterruptedException, IOException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(wrapper, containerName);
|
Map<String, InputStream> map = createMap(view, containerName);
|
||||||
((InputStreamMap) map).putAllStrings(this.fiveStrings);
|
((InputStreamMap) map).putAllStrings(this.fiveStrings);
|
||||||
// this will cause us to block until the bucket updates.
|
// this will cause us to block until the bucket updates.
|
||||||
assertConsistencyAwareKeySize(map, 5);
|
assertConsistencyAwareKeySize(map, 5);
|
||||||
|
@ -143,7 +143,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
public void testContainsStringValue() throws InterruptedException, ExecutionException, TimeoutException {
|
public void testContainsStringValue() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(wrapper, containerName);
|
Map<String, InputStream> map = createMap(view, containerName);
|
||||||
((InputStreamMap) map).putString("one", String.format(XML_STRING_FORMAT, "apple"));
|
((InputStreamMap) map).putString("one", String.format(XML_STRING_FORMAT, "apple"));
|
||||||
assertConsistencyAwareContainsValue(map, fiveStrings.get("one"));
|
assertConsistencyAwareContainsValue(map, fiveStrings.get("one"));
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -155,7 +155,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
public void testContainsFileValue() throws InterruptedException, ExecutionException, TimeoutException {
|
public void testContainsFileValue() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(wrapper, containerName);
|
Map<String, InputStream> map = createMap(view, containerName);
|
||||||
((InputStreamMap) map).putString("one", String.format(XML_STRING_FORMAT, "apple"));
|
((InputStreamMap) map).putString("one", String.format(XML_STRING_FORMAT, "apple"));
|
||||||
assertConsistencyAwareContainsValue(map, fiveFiles.get("one"));
|
assertConsistencyAwareContainsValue(map, fiveFiles.get("one"));
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -167,7 +167,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
public void testContainsInputStreamValue() throws InterruptedException, ExecutionException, TimeoutException {
|
public void testContainsInputStreamValue() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(wrapper, containerName);
|
Map<String, InputStream> map = createMap(view, containerName);
|
||||||
((InputStreamMap) map).putString("one", String.format(XML_STRING_FORMAT, "apple"));
|
((InputStreamMap) map).putString("one", String.format(XML_STRING_FORMAT, "apple"));
|
||||||
assertConsistencyAwareContainsValue(map, this.fiveInputs.get("one"));
|
assertConsistencyAwareContainsValue(map, this.fiveInputs.get("one"));
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -179,7 +179,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
public void testContainsBytesValue() throws InterruptedException, ExecutionException, TimeoutException {
|
public void testContainsBytesValue() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(wrapper, containerName);
|
Map<String, InputStream> map = createMap(view, containerName);
|
||||||
((InputStreamMap) map).putString("one", String.format(XML_STRING_FORMAT, "apple"));
|
((InputStreamMap) map).putString("one", String.format(XML_STRING_FORMAT, "apple"));
|
||||||
assertConsistencyAwareContainsValue(map, this.fiveBytes.get("one"));
|
assertConsistencyAwareContainsValue(map, this.fiveBytes.get("one"));
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -192,7 +192,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
public void testPutAll() throws InterruptedException {
|
public void testPutAll() throws InterruptedException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(wrapper, containerName);
|
Map<String, InputStream> map = createMap(view, containerName);
|
||||||
map.putAll(this.fiveInputs);
|
map.putAll(this.fiveInputs);
|
||||||
assertConsistencyAwareMapSize(map, 5);
|
assertConsistencyAwareMapSize(map, 5);
|
||||||
assertConsistencyAwareKeySetEquals(map, new TreeSet<String>(fiveInputs.keySet()));
|
assertConsistencyAwareKeySetEquals(map, new TreeSet<String>(fiveInputs.keySet()));
|
||||||
|
@ -206,7 +206,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
public void testPutAllBytes() throws InterruptedException {
|
public void testPutAllBytes() throws InterruptedException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(wrapper, containerName);
|
Map<String, InputStream> map = createMap(view, containerName);
|
||||||
|
|
||||||
((InputStreamMap) map).putAllBytes(this.fiveBytes);
|
((InputStreamMap) map).putAllBytes(this.fiveBytes);
|
||||||
assertConsistencyAwareMapSize(map, 5);
|
assertConsistencyAwareMapSize(map, 5);
|
||||||
|
@ -221,7 +221,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
public void testPutAllFiles() throws InterruptedException {
|
public void testPutAllFiles() throws InterruptedException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(wrapper, containerName);
|
Map<String, InputStream> map = createMap(view, containerName);
|
||||||
|
|
||||||
((InputStreamMap) map).putAllFiles(this.fiveFiles);
|
((InputStreamMap) map).putAllFiles(this.fiveFiles);
|
||||||
assertConsistencyAwareMapSize(map, 5);
|
assertConsistencyAwareMapSize(map, 5);
|
||||||
|
@ -236,7 +236,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
public void testPutAllStrings() throws InterruptedException {
|
public void testPutAllStrings() throws InterruptedException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(wrapper, containerName);
|
Map<String, InputStream> map = createMap(view, containerName);
|
||||||
|
|
||||||
((InputStreamMap) map).putAllStrings(this.fiveStrings);
|
((InputStreamMap) map).putAllStrings(this.fiveStrings);
|
||||||
assertConsistencyAwareMapSize(map, 5);
|
assertConsistencyAwareMapSize(map, 5);
|
||||||
|
@ -251,7 +251,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
public void testPutString() throws InterruptedException, IOException {
|
public void testPutString() throws InterruptedException, IOException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(wrapper, containerName);
|
Map<String, InputStream> map = createMap(view, containerName);
|
||||||
|
|
||||||
InputStream old = ((InputStreamMap) map).putString("one", fiveStrings.get("one"));
|
InputStream old = ((InputStreamMap) map).putString("one", fiveStrings.get("one"));
|
||||||
getOneReturnsAppleAndOldValueIsNull(map, old);
|
getOneReturnsAppleAndOldValueIsNull(map, old);
|
||||||
|
@ -280,7 +280,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
public void testPutFile() throws IOException, InterruptedException {
|
public void testPutFile() throws IOException, InterruptedException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(wrapper, containerName);
|
Map<String, InputStream> map = createMap(view, containerName);
|
||||||
|
|
||||||
InputStream old = ((InputStreamMap) map).putFile("one", fiveFiles.get("one"));
|
InputStream old = ((InputStreamMap) map).putFile("one", fiveFiles.get("one"));
|
||||||
getOneReturnsAppleAndOldValueIsNull(map, old);
|
getOneReturnsAppleAndOldValueIsNull(map, old);
|
||||||
|
@ -295,7 +295,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
public void testPutBytes() throws InterruptedException, IOException {
|
public void testPutBytes() throws InterruptedException, IOException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(wrapper, containerName);
|
Map<String, InputStream> map = createMap(view, containerName);
|
||||||
|
|
||||||
InputStream old = ((InputStreamMap) map).putBytes("one", fiveBytes.get("one"));
|
InputStream old = ((InputStreamMap) map).putBytes("one", fiveBytes.get("one"));
|
||||||
getOneReturnsAppleAndOldValueIsNull(map, old);
|
getOneReturnsAppleAndOldValueIsNull(map, old);
|
||||||
|
@ -310,7 +310,7 @@ public abstract class BaseInputStreamMapIntegrationTest extends BaseMapIntegrati
|
||||||
public void testPut() throws InterruptedException, IOException {
|
public void testPut() throws InterruptedException, IOException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, InputStream> map = createMap(wrapper, containerName);
|
Map<String, InputStream> map = createMap(view, containerName);
|
||||||
|
|
||||||
InputStream old = map.put("one", fiveInputs.get("one"));
|
InputStream old = map.put("one", fiveInputs.get("one"));
|
||||||
getOneReturnsAppleAndOldValueIsNull(map, old);
|
getOneReturnsAppleAndOldValueIsNull(map, old);
|
||||||
|
|
|
@ -106,7 +106,7 @@ public abstract class BaseMapIntegrationTest<V> extends BaseBlobStoreIntegration
|
||||||
public void testClear() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
public void testClear() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
String containerNameName = getContainerName();
|
String containerNameName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, V> map = createMap(wrapper, containerNameName);
|
Map<String, V> map = createMap(view, containerNameName);
|
||||||
assertConsistencyAwareMapSize(map, 0);
|
assertConsistencyAwareMapSize(map, 0);
|
||||||
putStringWithMD5(map, "one", "apple");
|
putStringWithMD5(map, "one", "apple");
|
||||||
assertConsistencyAwareMapSize(map, 1);
|
assertConsistencyAwareMapSize(map, 1);
|
||||||
|
@ -124,7 +124,7 @@ public abstract class BaseMapIntegrationTest<V> extends BaseBlobStoreIntegration
|
||||||
public void testKeySet() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
public void testKeySet() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
String containerNameName = getContainerName();
|
String containerNameName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, V> map = createMap(wrapper, containerNameName);
|
Map<String, V> map = createMap(view, containerNameName);
|
||||||
assertConsistencyAwareKeySize(map, 0);
|
assertConsistencyAwareKeySize(map, 0);
|
||||||
putStringWithMD5(map, "one", "two");
|
putStringWithMD5(map, "one", "two");
|
||||||
assertConsistencyAwareKeySize(map, 1);
|
assertConsistencyAwareKeySize(map, 1);
|
||||||
|
@ -136,15 +136,15 @@ public abstract class BaseMapIntegrationTest<V> extends BaseBlobStoreIntegration
|
||||||
|
|
||||||
protected void addTenObjectsUnderPrefix(String containerName, String prefix) throws InterruptedException {
|
protected void addTenObjectsUnderPrefix(String containerName, String prefix) throws InterruptedException {
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
wrapper.getBlobStore().putBlob(containerName,
|
view.getBlobStore().putBlob(containerName,
|
||||||
wrapper.getBlobStore().blobBuilder(prefix + "/" + i).payload(i + "content").build());
|
view.getBlobStore().blobBuilder(prefix + "/" + i).payload(i + "content").build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addTenObjectsUnderRoot(String containerName) throws InterruptedException {
|
protected void addTenObjectsUnderRoot(String containerName) throws InterruptedException {
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
wrapper.getBlobStore().putBlob(containerName,
|
view.getBlobStore().putBlob(containerName,
|
||||||
wrapper.getBlobStore().blobBuilder(i + "").payload(i + "content").build());
|
view.getBlobStore().blobBuilder(i + "").payload(i + "content").build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,13 +152,13 @@ public abstract class BaseMapIntegrationTest<V> extends BaseBlobStoreIntegration
|
||||||
public void testDirectory() throws InterruptedException {
|
public void testDirectory() throws InterruptedException {
|
||||||
String containerName = getContainerName();
|
String containerName = getContainerName();
|
||||||
String directory = "apps";
|
String directory = "apps";
|
||||||
Map<String, V> rootMap = createMap(wrapper, containerName);
|
Map<String, V> rootMap = createMap(view, containerName);
|
||||||
Map<String, V> rootRecursiveMap = createMap(wrapper, containerName, recursive());
|
Map<String, V> rootRecursiveMap = createMap(view, containerName, recursive());
|
||||||
Map<String, V> inDirectoryMap = createMap(wrapper, containerName, inDirectory(directory));
|
Map<String, V> inDirectoryMap = createMap(view, containerName, inDirectory(directory));
|
||||||
Map<String, V> inDirectoryRecursiveMap = createMap(wrapper, containerName, inDirectory(directory).recursive());
|
Map<String, V> inDirectoryRecursiveMap = createMap(view, containerName, inDirectory(directory).recursive());
|
||||||
try {
|
try {
|
||||||
|
|
||||||
wrapper.getBlobStore().createDirectory(containerName, directory);
|
view.getBlobStore().createDirectory(containerName, directory);
|
||||||
addTenObjectsUnderRoot(containerName);
|
addTenObjectsUnderRoot(containerName);
|
||||||
assertEquals(rootMap.size(), 10);
|
assertEquals(rootMap.size(), 10);
|
||||||
assertEquals(ImmutableSortedSet.copyOf(rootMap.keySet()),
|
assertEquals(ImmutableSortedSet.copyOf(rootMap.keySet()),
|
||||||
|
@ -184,7 +184,7 @@ public abstract class BaseMapIntegrationTest<V> extends BaseBlobStoreIntegration
|
||||||
assertEquals(ImmutableSortedSet.copyOf(inDirectoryRecursiveMap.keySet()),
|
assertEquals(ImmutableSortedSet.copyOf(inDirectoryRecursiveMap.keySet()),
|
||||||
ImmutableSortedSet.of("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
|
ImmutableSortedSet.of("0", "1", "2", "3", "4", "5", "6", "7", "8", "9"));
|
||||||
|
|
||||||
wrapper.getBlobStore().createDirectory(containerName, directory + "/" + directory);
|
view.getBlobStore().createDirectory(containerName, directory + "/" + directory);
|
||||||
assertEquals(rootMap.size(), 10);
|
assertEquals(rootMap.size(), 10);
|
||||||
assertEquals(rootRecursiveMap.size(), 20);
|
assertEquals(rootRecursiveMap.size(), 20);
|
||||||
assertEquals(inDirectoryMap.size(), 10);
|
assertEquals(inDirectoryMap.size(), 10);
|
||||||
|
@ -252,7 +252,7 @@ public abstract class BaseMapIntegrationTest<V> extends BaseBlobStoreIntegration
|
||||||
public void testContainsKey() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
public void testContainsKey() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
String containerNameName = getContainerName();
|
String containerNameName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, V> map = createMap(wrapper, containerNameName);
|
Map<String, V> map = createMap(view, containerNameName);
|
||||||
assertConsistencyAwareDoesntContainKey(map);
|
assertConsistencyAwareDoesntContainKey(map);
|
||||||
putStringWithMD5(map, "one", "apple");
|
putStringWithMD5(map, "one", "apple");
|
||||||
assertConsistencyAwareContainsKey(map);
|
assertConsistencyAwareContainsKey(map);
|
||||||
|
@ -294,7 +294,7 @@ public abstract class BaseMapIntegrationTest<V> extends BaseBlobStoreIntegration
|
||||||
public void testIsEmpty() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
public void testIsEmpty() throws InterruptedException, ExecutionException, TimeoutException, IOException {
|
||||||
String containerNameName = getContainerName();
|
String containerNameName = getContainerName();
|
||||||
try {
|
try {
|
||||||
Map<String, V> map = createMap(wrapper, containerNameName);
|
Map<String, V> map = createMap(view, containerNameName);
|
||||||
assertConsistencyAwareEmpty(map);
|
assertConsistencyAwareEmpty(map);
|
||||||
putStringWithMD5(map, "one", "apple");
|
putStringWithMD5(map, "one", "apple");
|
||||||
assertConsistencyAwareNotEmpty(map);
|
assertConsistencyAwareNotEmpty(map);
|
||||||
|
@ -343,7 +343,7 @@ public abstract class BaseMapIntegrationTest<V> extends BaseBlobStoreIntegration
|
||||||
public void testListContainer() throws InterruptedException, ExecutionException, TimeoutException {
|
public void testListContainer() throws InterruptedException, ExecutionException, TimeoutException {
|
||||||
String containerNameName = getContainerName();
|
String containerNameName = getContainerName();
|
||||||
try {
|
try {
|
||||||
ListableMap<?, ?> map = (ListableMap<?, ?>) createMap(wrapper, containerNameName);
|
ListableMap<?, ?> map = (ListableMap<?, ?>) createMap(view, containerNameName);
|
||||||
assertConsistencyAwareListContainer(map, containerNameName);
|
assertConsistencyAwareListContainer(map, containerNameName);
|
||||||
} finally {
|
} finally {
|
||||||
returnContainer(containerNameName);
|
returnContainer(containerNameName);
|
||||||
|
|
|
@ -41,24 +41,24 @@ public class BaseServiceIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
|
|
||||||
@Test(groups = { "integration", "live" })
|
@Test(groups = { "integration", "live" })
|
||||||
void containerDoesntExist() {
|
void containerDoesntExist() {
|
||||||
Set<? extends StorageMetadata> list = wrapper.getBlobStore().list();
|
Set<? extends StorageMetadata> list = view.getBlobStore().list();
|
||||||
assert !list.contains(new MutableStorageMetadataImpl());
|
assert !list.contains(new MutableStorageMetadataImpl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = { "integration", "live" })
|
@Test(groups = { "integration", "live" })
|
||||||
public void testAllLocations() throws InterruptedException {
|
public void testAllLocations() throws InterruptedException {
|
||||||
for (final Location location : wrapper.getBlobStore().listAssignableLocations()) {
|
for (final Location location : view.getBlobStore().listAssignableLocations()) {
|
||||||
final String containerName = getScratchContainerName();
|
final String containerName = getScratchContainerName();
|
||||||
try {
|
try {
|
||||||
System.err.printf(" >> creating container in location %s%n", location);
|
System.err.printf(" >> creating container in location %s%n", location);
|
||||||
wrapper.getBlobStore().createContainerInLocation(location, containerName);
|
view.getBlobStore().createContainerInLocation(location, containerName);
|
||||||
System.err.printf(" << call complete.. checking%n");
|
System.err.printf(" << call complete.. checking%n");
|
||||||
|
|
||||||
assertConsistencyAware(new Runnable() {
|
assertConsistencyAware(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PageSet<? extends StorageMetadata> list = wrapper.getBlobStore().list();
|
PageSet<? extends StorageMetadata> list = view.getBlobStore().list();
|
||||||
assert Iterables.any(list, new Predicate<StorageMetadata>() {
|
assert Iterables.any(list, new Predicate<StorageMetadata>() {
|
||||||
public boolean apply(StorageMetadata md) {
|
public boolean apply(StorageMetadata md) {
|
||||||
return containerName.equals(md.getName()) && location.equals(md.getLocation());
|
return containerName.equals(md.getName()) && location.equals(md.getLocation());
|
||||||
|
@ -79,9 +79,9 @@ public class BaseServiceIntegrationTest extends BaseBlobStoreIntegrationTest {
|
||||||
|
|
||||||
@Test(groups = { "integration", "live" })
|
@Test(groups = { "integration", "live" })
|
||||||
public void testGetAssignableLocations() throws Exception {
|
public void testGetAssignableLocations() throws Exception {
|
||||||
if (wrapper.unwrap() instanceof Location)
|
if (view.unwrap() instanceof Location)
|
||||||
assertProvider(Location.class.cast(wrapper.unwrap()));
|
assertProvider(Location.class.cast(view.unwrap()));
|
||||||
for (Location location : wrapper.getBlobStore().listAssignableLocations()) {
|
for (Location location : view.getBlobStore().listAssignableLocations()) {
|
||||||
System.err.printf("location %s%n", location);
|
System.err.printf("location %s%n", location);
|
||||||
assert location.getId() != null : location;
|
assert location.getId() != null : location;
|
||||||
assert location != location.getParent() : location;
|
assert location != location.getParent() : location;
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.blobstore.internal;
|
package org.jclouds.blobstore.internal;
|
||||||
|
|
||||||
import org.jclouds.Wrapper;
|
import org.jclouds.View;
|
||||||
import org.jclouds.apis.ApiMetadata;
|
import org.jclouds.apis.ApiMetadata;
|
||||||
import org.jclouds.apis.internal.BaseApiMetadataTest;
|
import org.jclouds.apis.internal.BaseApiMetadataTest;
|
||||||
import org.jclouds.blobstore.BlobStoreContext;
|
import org.jclouds.blobstore.BlobStoreContext;
|
||||||
|
@ -35,7 +35,7 @@ import com.google.common.reflect.TypeToken;
|
||||||
public abstract class BaseBlobStoreApiMetadataTest extends BaseApiMetadataTest {
|
public abstract class BaseBlobStoreApiMetadataTest extends BaseApiMetadataTest {
|
||||||
|
|
||||||
public BaseBlobStoreApiMetadataTest(ApiMetadata toTest) {
|
public BaseBlobStoreApiMetadataTest(ApiMetadata toTest) {
|
||||||
super(toTest, ImmutableSet.<TypeToken<? extends Wrapper>>of(TypeToken.of(BlobStoreContext.class)));
|
super(toTest, ImmutableSet.<TypeToken<? extends View>>of(TypeToken.of(BlobStoreContext.class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -56,7 +56,7 @@ public abstract class TerremarkVCloudApiMetadata extends BaseRestApiMetadata {
|
||||||
.credentialName("Password")
|
.credentialName("Password")
|
||||||
.version("0.8")
|
.version("0.8")
|
||||||
.defaultProperties(TerremarkVCloudApiMetadata.defaultProperties())
|
.defaultProperties(TerremarkVCloudApiMetadata.defaultProperties())
|
||||||
.wrapper(ComputeServiceContext.class);
|
.view(ComputeServiceContext.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -482,7 +482,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
injector = wrapper.utils().injector();
|
injector = view.utils().injector();
|
||||||
|
|
||||||
sshFactory = injector.getInstance(SshClient.Factory.class);
|
sshFactory = injector.getInstance(SshClient.Factory.class);
|
||||||
socketTester = new RetryablePredicate<IPSocket>(injector.getInstance(SocketOpen.class), 300, 10, TimeUnit.SECONDS);// make
|
socketTester = new RetryablePredicate<IPSocket>(injector.getInstance(SocketOpen.class), 300, 10, TimeUnit.SECONDS);// make
|
||||||
|
@ -492,7 +492,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
// default internet
|
// default internet
|
||||||
// service timeout
|
// service timeout
|
||||||
successTester = new RetryablePredicate<URI>(injector.getInstance(TaskSuccess.class), 650, 10, TimeUnit.SECONDS);
|
successTester = new RetryablePredicate<URI>(injector.getInstance(TaskSuccess.class), 650, 10, TimeUnit.SECONDS);
|
||||||
connection = (S) RestContext.class.cast(wrapper.unwrap()).getApi();
|
connection = (S) RestContext.class.cast(view.unwrap()).getApi();
|
||||||
orgs = listOrgs();
|
orgs = listOrgs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,7 +514,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
for (Org org : orgs) {
|
for (Org org : orgs) {
|
||||||
RestContext<S, A> newContext = null;
|
RestContext<S, A> newContext = null;
|
||||||
try {
|
try {
|
||||||
newContext = createWrapper(
|
newContext = createView(
|
||||||
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName())),
|
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName())),
|
||||||
setupModules()).unwrap();
|
setupModules()).unwrap();
|
||||||
assertEquals(newContext.getApi().findOrgNamed(null), org);
|
assertEquals(newContext.getApi().findOrgNamed(null), org);
|
||||||
|
@ -549,7 +549,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
for (ReferenceType cat : org.getCatalogs().values()) {
|
for (ReferenceType cat : org.getCatalogs().values()) {
|
||||||
RestContext<S, A> newContext = null;
|
RestContext<S, A> newContext = null;
|
||||||
try {
|
try {
|
||||||
newContext = createWrapper(
|
newContext = createView(
|
||||||
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
|
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
|
||||||
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_CATALOG, cat.getName())), setupModules())
|
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_CATALOG, cat.getName())), setupModules())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -592,7 +592,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
for (ReferenceType net : response.getAvailableNetworks().values()) {
|
for (ReferenceType net : response.getAvailableNetworks().values()) {
|
||||||
RestContext<S, A> newContext = null;
|
RestContext<S, A> newContext = null;
|
||||||
try {
|
try {
|
||||||
newContext = createWrapper(
|
newContext = createView(
|
||||||
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
|
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
|
||||||
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName(),
|
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName(),
|
||||||
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK, net.getName())), setupModules())
|
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK, net.getName())), setupModules())
|
||||||
|
@ -671,7 +671,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
for (ReferenceType vdc : org.getVDCs().values()) {
|
for (ReferenceType vdc : org.getVDCs().values()) {
|
||||||
RestContext<S, A> newContext = null;
|
RestContext<S, A> newContext = null;
|
||||||
try {
|
try {
|
||||||
newContext = createWrapper(
|
newContext = createView(
|
||||||
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
|
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
|
||||||
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName())), setupModules())
|
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName())), setupModules())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -703,7 +703,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
for (ReferenceType tasksList : org.getTasksLists().values()) {
|
for (ReferenceType tasksList : org.getTasksLists().values()) {
|
||||||
RestContext<S, A> newContext = null;
|
RestContext<S, A> newContext = null;
|
||||||
try {
|
try {
|
||||||
newContext = createWrapper(
|
newContext = createView(
|
||||||
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
|
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
|
||||||
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_TASKSLIST, tasksList.getName())), setupModules())
|
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_TASKSLIST, tasksList.getName())), setupModules())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
@ -737,7 +737,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
|
||||||
|
|
||||||
@AfterGroups(groups = { "live" })
|
@AfterGroups(groups = { "live" })
|
||||||
public void teardownClient() {
|
public void teardownClient() {
|
||||||
wrapper.close();
|
view.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Iterable<Org> listOrgs() {
|
protected Iterable<Org> listOrgs() {
|
||||||
|
|
|
@ -54,7 +54,7 @@ extends BaseComputeServiceContextLiveTest {
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
Injector injector = wrapper.utils().injector();
|
Injector injector = view.utils().injector();
|
||||||
|
|
||||||
tmClient = injector.getInstance(TerremarkVCloudClient.class);
|
tmClient = injector.getInstance(TerremarkVCloudClient.class);
|
||||||
allCatalogItemsInOrg = injector.getInstance(AllCatalogItemsInOrg.class);
|
allCatalogItemsInOrg = injector.getInstance(AllCatalogItemsInOrg.class);
|
||||||
|
|
|
@ -60,10 +60,10 @@ public abstract class BaseTerremarkClientLiveTest<S extends TerremarkVCloudClien
|
||||||
@BeforeClass(groups = { "integration", "live" })
|
@BeforeClass(groups = { "integration", "live" })
|
||||||
public void setupContext() {
|
public void setupContext() {
|
||||||
super.setupContext();
|
super.setupContext();
|
||||||
Injector injector = wrapper.utils().injector();
|
Injector injector = view.utils().injector();
|
||||||
socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), 300, 1, TimeUnit.SECONDS);
|
socketTester = new RetryablePredicate<IPSocket>(new InetSocketAddressConnect(), 300, 1, TimeUnit.SECONDS);
|
||||||
sshFactory = injector.getInstance(Factory.class);
|
sshFactory = injector.getInstance(Factory.class);
|
||||||
connection = (S) RestContext.class.cast(wrapper.unwrap()).getApi();
|
connection = (S) RestContext.class.cast(view.unwrap()).getApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Module getSshModule() {
|
protected Module getSshModule() {
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.jclouds.compute;
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.jclouds.Wrapper;
|
import org.jclouds.View;
|
||||||
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
import org.jclouds.compute.internal.ComputeServiceContextImpl;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
|
@ -37,7 +37,7 @@ import com.google.inject.ImplementedBy;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ImplementedBy(ComputeServiceContextImpl.class)
|
@ImplementedBy(ComputeServiceContextImpl.class)
|
||||||
public interface ComputeServiceContext extends Closeable, Wrapper {
|
public interface ComputeServiceContext extends Closeable, View {
|
||||||
|
|
||||||
ComputeService getComputeService();
|
ComputeService getComputeService();
|
||||||
|
|
||||||
|
@ -69,8 +69,8 @@ public interface ComputeServiceContext extends Closeable, Wrapper {
|
||||||
/**
|
/**
|
||||||
* will be removed in jclouds 1.6
|
* will be removed in jclouds 1.6
|
||||||
*
|
*
|
||||||
* @see Wrapper#getInputType
|
* @see View#getInputType
|
||||||
* @see Wrapper#unwrap
|
* @see View#unwrap
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
<S, A> RestContext<S, A> getProviderSpecificContext();
|
<S, A> RestContext<S, A> getProviderSpecificContext();
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.jclouds.compute.ComputeService;
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.compute.Utils;
|
import org.jclouds.compute.Utils;
|
||||||
import org.jclouds.domain.Credentials;
|
import org.jclouds.domain.Credentials;
|
||||||
import org.jclouds.internal.BaseWrapper;
|
import org.jclouds.internal.BaseView;
|
||||||
import org.jclouds.location.Provider;
|
import org.jclouds.location.Provider;
|
||||||
import org.jclouds.rest.RestContext;
|
import org.jclouds.rest.RestContext;
|
||||||
|
|
||||||
|
@ -40,14 +40,14 @@ import com.google.common.reflect.TypeToken;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ComputeServiceContextImpl extends BaseWrapper implements ComputeServiceContext {
|
public class ComputeServiceContextImpl extends BaseView implements ComputeServiceContext {
|
||||||
private final ComputeService computeService;
|
private final ComputeService computeService;
|
||||||
private final Utils utils;
|
private final Utils utils;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ComputeServiceContextImpl(@Provider Context wrapped, @Provider TypeToken<? extends Context> wrappedType,
|
public ComputeServiceContextImpl(@Provider Context backend, @Provider TypeToken<? extends Context> backendType,
|
||||||
ComputeService computeService, Utils utils) {
|
ComputeService computeService, Utils utils) {
|
||||||
super(wrapped, wrappedType);
|
super(backend, backendType);
|
||||||
this.computeService = checkNotNull(computeService, "computeService");
|
this.computeService = checkNotNull(computeService, "computeService");
|
||||||
this.utils = checkNotNull(utils, "utils");
|
this.utils = checkNotNull(utils, "utils");
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ public class StubApiMetadata extends BaseApiMetadata {
|
||||||
.defaultCredential("stub")
|
.defaultCredential("stub")
|
||||||
.defaultEndpoint("stub")
|
.defaultEndpoint("stub")
|
||||||
.documentation(URI.create("http://www.jclouds.org/documentation/userguide/compute"))
|
.documentation(URI.create("http://www.jclouds.org/documentation/userguide/compute"))
|
||||||
.wrapper(ComputeServiceContext.class)
|
.view(ComputeServiceContext.class)
|
||||||
.defaultModule(StubComputeServiceContextModule.class);
|
.defaultModule(StubComputeServiceContextModule.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package org.jclouds.compute.internal;
|
package org.jclouds.compute.internal;
|
||||||
|
|
||||||
import org.jclouds.Wrapper;
|
import org.jclouds.View;
|
||||||
import org.jclouds.apis.ApiMetadata;
|
import org.jclouds.apis.ApiMetadata;
|
||||||
import org.jclouds.apis.internal.BaseApiMetadataTest;
|
import org.jclouds.apis.internal.BaseApiMetadataTest;
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
|
@ -17,7 +17,7 @@ import com.google.common.reflect.TypeToken;
|
||||||
public abstract class BaseComputeServiceApiMetadataTest extends BaseApiMetadataTest {
|
public abstract class BaseComputeServiceApiMetadataTest extends BaseApiMetadataTest {
|
||||||
|
|
||||||
public BaseComputeServiceApiMetadataTest(ApiMetadata toTest) {
|
public BaseComputeServiceApiMetadataTest(ApiMetadata toTest) {
|
||||||
super(toTest, ImmutableSet.<TypeToken<? extends Wrapper>>of(TypeToken.of(ComputeServiceContext.class)));
|
super(toTest, ImmutableSet.<TypeToken<? extends View>>of(TypeToken.of(ComputeServiceContext.class)));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -28,7 +28,7 @@ import com.google.common.reflect.TypeToken;
|
||||||
public abstract class BaseComputeServiceContextLiveTest extends BaseGenericComputeServiceContextLiveTest<ComputeServiceContext> {
|
public abstract class BaseComputeServiceContextLiveTest extends BaseGenericComputeServiceContextLiveTest<ComputeServiceContext> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected TypeToken<ComputeServiceContext> wrapperType() {
|
protected TypeToken<ComputeServiceContext> viewType() {
|
||||||
return TypeToken.of(ComputeServiceContext.class);
|
return TypeToken.of(ComputeServiceContext.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,7 +150,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
|
|
||||||
|
|
||||||
protected void buildSocketTester() {
|
protected void buildSocketTester() {
|
||||||
SocketOpen socketOpen = wrapper.utils().injector().getInstance(SocketOpen.class);
|
SocketOpen socketOpen = view.utils().injector().getInstance(SocketOpen.class);
|
||||||
socketTester = new RetryablePredicate<IPSocket>(socketOpen, 60, 1, TimeUnit.SECONDS);
|
socketTester = new RetryablePredicate<IPSocket>(socketOpen, 60, 1, TimeUnit.SECONDS);
|
||||||
// wait a maximum of 60 seconds for port 8080 to open.
|
// wait a maximum of 60 seconds for port 8080 to open.
|
||||||
long maxWait = TimeUnit.SECONDS.toMillis(60);
|
long maxWait = TimeUnit.SECONDS.toMillis(60);
|
||||||
|
@ -162,7 +162,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
@Override
|
@Override
|
||||||
protected void initializeContext() {
|
protected void initializeContext() {
|
||||||
super.initializeContext();
|
super.initializeContext();
|
||||||
client = wrapper.getComputeService();
|
client = view.getComputeService();
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait up to 5 seconds for an auth exception
|
// wait up to 5 seconds for an auth exception
|
||||||
|
@ -320,7 +320,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkHttpGet(NodeMetadata node) {
|
protected void checkHttpGet(NodeMetadata node) {
|
||||||
ComputeTestUtils.checkHttpGet(wrapper.utils().http(), node, 8080);
|
ComputeTestUtils.checkHttpGet(view.utils().http(), node, 8080);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(enabled = true, dependsOnMethods = "testCompareSizes")
|
@Test(enabled = true, dependsOnMethods = "testCompareSizes")
|
||||||
|
@ -416,7 +416,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
public void testCredentialsCache() throws Exception {
|
public void testCredentialsCache() throws Exception {
|
||||||
initializeContext();
|
initializeContext();
|
||||||
for (NodeMetadata node : nodes)
|
for (NodeMetadata node : nodes)
|
||||||
assert (wrapper.utils().credentialStore().get("node#" + node.getId()) != null) : "credentials for " + node.getId();
|
assert (view.utils().credentialStore().get("node#" + node.getId()) != null) : "credentials for " + node.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<? extends NodeMetadata, ExecResponse> runScriptWithCreds(final String group, OperatingSystem os,
|
protected Map<? extends NodeMetadata, ExecResponse> runScriptWithCreds(final String group, OperatingSystem os,
|
||||||
|
@ -431,7 +431,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
assertNotNull(node.getGroup());
|
assertNotNull(node.getGroup());
|
||||||
assertEquals(node.getGroup(), group);
|
assertEquals(node.getGroup(), group);
|
||||||
assertEquals(node.getState(), NodeState.RUNNING);
|
assertEquals(node.getState(), NodeState.RUNNING);
|
||||||
Credentials fromStore = wrapper.utils().credentialStore().get("node#" + node.getId());
|
Credentials fromStore = view.utils().credentialStore().get("node#" + node.getId());
|
||||||
assertEquals(fromStore, node.getCredentials());
|
assertEquals(fromStore, node.getCredentials());
|
||||||
assert node.getPublicAddresses().size() >= 1 || node.getPrivateAddresses().size() >= 1 : "no ips in" + node;
|
assert node.getPublicAddresses().size() >= 1 || node.getPrivateAddresses().size() >= 1 : "no ips in" + node;
|
||||||
assertNotNull(node.getCredentials());
|
assertNotNull(node.getCredentials());
|
||||||
|
@ -548,7 +548,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
assertEquals(toDestroy, destroyed.size());
|
assertEquals(toDestroy, destroyed.size());
|
||||||
for (NodeMetadata node : filter(client.listNodesDetailsMatching(all()), inGroup(group))) {
|
for (NodeMetadata node : filter(client.listNodesDetailsMatching(all()), inGroup(group))) {
|
||||||
assert node.getState() == NodeState.TERMINATED : node;
|
assert node.getState() == NodeState.TERMINATED : node;
|
||||||
assert wrapper.utils().credentialStore().get("node#" + node.getId()) == null : "credential should have been null for "
|
assert view.utils().credentialStore().get("node#" + node.getId()) == null : "credential should have been null for "
|
||||||
+ "node#" + node.getId();
|
+ "node#" + node.getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -650,7 +650,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
format("ls %s/bundles/org/jboss/as/osgi/configadmin/main|sed -e 's/.*-//g' -e 's/.jar//g'",
|
format("ls %s/bundles/org/jboss/as/osgi/configadmin/main|sed -e 's/.*-//g' -e 's/.jar//g'",
|
||||||
JBOSS_HOME)), configureSeconds));
|
JBOSS_HOME)), configureSeconds));
|
||||||
|
|
||||||
trackAvailabilityOfProcessOnNode(wrapper.utils().userExecutor().submit(new Callable<ExecResponse>() {
|
trackAvailabilityOfProcessOnNode(view.utils().userExecutor().submit(new Callable<ExecResponse>() {
|
||||||
@Override
|
@Override
|
||||||
public ExecResponse call() {
|
public ExecResponse call() {
|
||||||
return client.runScriptOnNode(nodeId, startJBoss(configuration), runAsRoot(false).blockOnComplete(false)
|
return client.runScriptOnNode(nodeId, startJBoss(configuration), runAsRoot(false).blockOnComplete(false)
|
||||||
|
@ -666,7 +666,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
|
|
||||||
client.runScriptOnNode(nodeId, "/tmp/init-jboss stop", runAsRoot(false).wrapInInitScript(false));
|
client.runScriptOnNode(nodeId, "/tmp/init-jboss stop", runAsRoot(false).wrapInInitScript(false));
|
||||||
|
|
||||||
trackAvailabilityOfProcessOnNode(wrapper.utils().userExecutor().submit(new Callable<ExecResponse>() {
|
trackAvailabilityOfProcessOnNode(view.utils().userExecutor().submit(new Callable<ExecResponse>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExecResponse call() {
|
public ExecResponse call() {
|
||||||
|
@ -814,7 +814,7 @@ public abstract class BaseComputeServiceLiveTest extends BaseComputeServiceConte
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void doCheckJavaIsInstalledViaSsh(NodeMetadata node, String taskName) throws IOException {
|
protected void doCheckJavaIsInstalledViaSsh(NodeMetadata node, String taskName) throws IOException {
|
||||||
SshClient ssh = wrapper.utils().sshForNode().apply(node);
|
SshClient ssh = view.utils().sshForNode().apply(node);
|
||||||
try {
|
try {
|
||||||
ssh.connect();
|
ssh.connect();
|
||||||
ExecResponse hello = ssh.exec("echo hello");
|
ExecResponse hello = ssh.exec("echo hello");
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
import org.jclouds.apis.BaseWrapperLiveTest;
|
import org.jclouds.apis.BaseViewLiveTest;
|
||||||
import org.jclouds.compute.ComputeServiceContext;
|
import org.jclouds.compute.ComputeServiceContext;
|
||||||
import org.jclouds.domain.LoginCredentials;
|
import org.jclouds.domain.LoginCredentials;
|
||||||
import org.jclouds.domain.LoginCredentials.Builder;
|
import org.jclouds.domain.LoginCredentials.Builder;
|
||||||
|
@ -39,7 +39,7 @@ import com.google.inject.util.Modules;
|
||||||
/**
|
/**
|
||||||
* @author Jason King, Adrian Cole
|
* @author Jason King, Adrian Cole
|
||||||
*/
|
*/
|
||||||
public abstract class BaseGenericComputeServiceContextLiveTest<W extends ComputeServiceContext> extends BaseWrapperLiveTest<W> {
|
public abstract class BaseGenericComputeServiceContextLiveTest<W extends ComputeServiceContext> extends BaseViewLiveTest<W> {
|
||||||
|
|
||||||
protected String imageId;
|
protected String imageId;
|
||||||
protected String loginUser;
|
protected String loginUser;
|
||||||
|
|
|
@ -53,13 +53,13 @@ public abstract class BaseImageExtensionLiveTest extends BaseComputeServiceConte
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Template getNodeTemplate() {
|
public Template getNodeTemplate() {
|
||||||
return wrapper.getComputeService().templateBuilder().any().build();
|
return view.getComputeService().templateBuilder().any().build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(groups = { "integration", "live" }, singleThreaded = true)
|
@Test(groups = { "integration", "live" }, singleThreaded = true)
|
||||||
public void testCreateImage() throws RunNodesException, InterruptedException {
|
public void testCreateImage() throws RunNodesException, InterruptedException {
|
||||||
|
|
||||||
ComputeService computeService = wrapper.getComputeService();
|
ComputeService computeService = view.getComputeService();
|
||||||
|
|
||||||
Optional<ImageExtension> imageExtension = computeService.getImageExtension();
|
Optional<ImageExtension> imageExtension = computeService.getImageExtension();
|
||||||
assertTrue("image extension was not present", imageExtension.isPresent());
|
assertTrue("image extension was not present", imageExtension.isPresent());
|
||||||
|
@ -87,20 +87,20 @@ public abstract class BaseImageExtensionLiveTest extends BaseComputeServiceConte
|
||||||
@Test(groups = { "integration", "live" }, singleThreaded = true, dependsOnMethods = "testCreateImage")
|
@Test(groups = { "integration", "live" }, singleThreaded = true, dependsOnMethods = "testCreateImage")
|
||||||
public void testSpawnNodeFromImage() throws RunNodesException {
|
public void testSpawnNodeFromImage() throws RunNodesException {
|
||||||
|
|
||||||
ComputeService computeService = wrapper.getComputeService();
|
ComputeService computeService = view.getComputeService();
|
||||||
|
|
||||||
Template template = computeService.templateBuilder().fromImage(getImage().get()).build();
|
Template template = computeService.templateBuilder().fromImage(getImage().get()).build();
|
||||||
|
|
||||||
NodeMetadata node = Iterables.getOnlyElement(computeService.createNodesInGroup("test-create-image", 1, template));
|
NodeMetadata node = Iterables.getOnlyElement(computeService.createNodesInGroup("test-create-image", 1, template));
|
||||||
|
|
||||||
SshClient client = wrapper.utils().sshForNode().apply(node);
|
SshClient client = view.utils().sshForNode().apply(node);
|
||||||
client.connect();
|
client.connect();
|
||||||
|
|
||||||
ExecResponse hello = client.exec("echo hello");
|
ExecResponse hello = client.exec("echo hello");
|
||||||
|
|
||||||
assertEquals(hello.getOutput().trim(), "hello");
|
assertEquals(hello.getOutput().trim(), "hello");
|
||||||
|
|
||||||
wrapper.getComputeService().destroyNode(node.getId());
|
view.getComputeService().destroyNode(node.getId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ public abstract class BaseImageExtensionLiveTest extends BaseComputeServiceConte
|
||||||
"testSpawnNodeFromImage" })
|
"testSpawnNodeFromImage" })
|
||||||
public void testDeleteImage() {
|
public void testDeleteImage() {
|
||||||
|
|
||||||
ComputeService computeService = wrapper.getComputeService();
|
ComputeService computeService = view.getComputeService();
|
||||||
|
|
||||||
Optional<ImageExtension> imageExtension = computeService.getImageExtension();
|
Optional<ImageExtension> imageExtension = computeService.getImageExtension();
|
||||||
assertTrue("image extension was not present", imageExtension.isPresent());
|
assertTrue("image extension was not present", imageExtension.isPresent());
|
||||||
|
@ -123,7 +123,7 @@ public abstract class BaseImageExtensionLiveTest extends BaseComputeServiceConte
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<? extends Image> getImage() {
|
private Optional<? extends Image> getImage() {
|
||||||
return Iterables.tryFind(wrapper.getComputeService().listImages(), new Predicate<Image>() {
|
return Iterables.tryFind(view.getComputeService().listImages(), new Predicate<Image>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Image input) {
|
public boolean apply(Image input) {
|
||||||
return input.getId().contains("test-create-image");
|
return input.getId().contains("test-create-image");
|
||||||
|
|
|
@ -66,11 +66,11 @@ import com.google.inject.Module;
|
||||||
public abstract class BaseTemplateBuilderLiveTest extends BaseComputeServiceContextLiveTest {
|
public abstract class BaseTemplateBuilderLiveTest extends BaseComputeServiceContextLiveTest {
|
||||||
|
|
||||||
public void testCompareSizes() throws Exception {
|
public void testCompareSizes() throws Exception {
|
||||||
Hardware defaultSize = wrapper.getComputeService().templateBuilder().build().getHardware();
|
Hardware defaultSize = view.getComputeService().templateBuilder().build().getHardware();
|
||||||
|
|
||||||
Hardware smallest = wrapper.getComputeService().templateBuilder().smallest().build().getHardware();
|
Hardware smallest = view.getComputeService().templateBuilder().smallest().build().getHardware();
|
||||||
Hardware fastest = wrapper.getComputeService().templateBuilder().fastest().build().getHardware();
|
Hardware fastest = view.getComputeService().templateBuilder().fastest().build().getHardware();
|
||||||
Hardware biggest = wrapper.getComputeService().templateBuilder().biggest().build().getHardware();
|
Hardware biggest = view.getComputeService().templateBuilder().biggest().build().getHardware();
|
||||||
|
|
||||||
System.out.printf("smallest %s%n", smallest);
|
System.out.printf("smallest %s%n", smallest);
|
||||||
System.out.printf("fastest %s%n", fastest);
|
System.out.printf("fastest %s%n", fastest);
|
||||||
|
@ -89,8 +89,8 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseComputeServiceCont
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFromTemplate() {
|
public void testFromTemplate() {
|
||||||
Template defaultTemplate = wrapper.getComputeService().templateBuilder().build();
|
Template defaultTemplate = view.getComputeService().templateBuilder().build();
|
||||||
assertEquals(wrapper.getComputeService().templateBuilder().fromTemplate(defaultTemplate).build().toString(),
|
assertEquals(view.getComputeService().templateBuilder().fromTemplate(defaultTemplate).build().toString(),
|
||||||
defaultTemplate.toString());
|
defaultTemplate.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseComputeServiceCont
|
||||||
|
|
||||||
@Test(dataProvider = "osSupported")
|
@Test(dataProvider = "osSupported")
|
||||||
public void testTemplateBuilderCanFind(OsFamilyVersion64Bit matrix) throws InterruptedException {
|
public void testTemplateBuilderCanFind(OsFamilyVersion64Bit matrix) throws InterruptedException {
|
||||||
TemplateBuilder builder = wrapper.getComputeService().templateBuilder().osFamily(matrix.family)
|
TemplateBuilder builder = view.getComputeService().templateBuilder().osFamily(matrix.family)
|
||||||
.os64Bit(matrix.is64Bit);
|
.os64Bit(matrix.is64Bit);
|
||||||
if (!matrix.version.equals(""))
|
if (!matrix.version.equals(""))
|
||||||
builder.osVersionMatches("^" + matrix.version + "$");
|
builder.osVersionMatches("^" + matrix.version + "$");
|
||||||
|
@ -147,7 +147,7 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseComputeServiceCont
|
||||||
|
|
||||||
@Test(dataProvider = "osNotSupported", expectedExceptions = NoSuchElementException.class)
|
@Test(dataProvider = "osNotSupported", expectedExceptions = NoSuchElementException.class)
|
||||||
public void testTemplateBuilderCannotFind(OsFamilyVersion64Bit matrix) throws InterruptedException {
|
public void testTemplateBuilderCannotFind(OsFamilyVersion64Bit matrix) throws InterruptedException {
|
||||||
TemplateBuilder builder = wrapper.getComputeService().templateBuilder().osFamily(matrix.family)
|
TemplateBuilder builder = view.getComputeService().templateBuilder().osFamily(matrix.family)
|
||||||
.os64Bit(matrix.is64Bit);
|
.os64Bit(matrix.is64Bit);
|
||||||
if (!matrix.version.equals(""))
|
if (!matrix.version.equals(""))
|
||||||
builder.osVersionMatches("^" + matrix.version + "$");
|
builder.osVersionMatches("^" + matrix.version + "$");
|
||||||
|
@ -156,18 +156,18 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseComputeServiceCont
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTemplateBuilderCanUseImageId() throws Exception {
|
public void testTemplateBuilderCanUseImageId() throws Exception {
|
||||||
Template defaultTemplate = wrapper.getComputeService().templateBuilder().build();
|
Template defaultTemplate = view.getComputeService().templateBuilder().build();
|
||||||
wrapper.close();
|
view.close();
|
||||||
setupContext();
|
setupContext();
|
||||||
|
|
||||||
Template template = wrapper.getComputeService().templateBuilder().imageId(defaultTemplate.getImage().getId())
|
Template template = view.getComputeService().templateBuilder().imageId(defaultTemplate.getImage().getId())
|
||||||
.locationId(defaultTemplate.getLocation().getId()).build();
|
.locationId(defaultTemplate.getLocation().getId()).build();
|
||||||
assertEquals(template.getImage(), defaultTemplate.getImage());
|
assertEquals(template.getImage(), defaultTemplate.getImage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDefaultTemplateBuilder() throws IOException {
|
public void testDefaultTemplateBuilder() throws IOException {
|
||||||
Template defaultTemplate = wrapper.getComputeService().templateBuilder().build();
|
Template defaultTemplate = view.getComputeService().templateBuilder().build();
|
||||||
assert defaultTemplate.getImage().getOperatingSystem().getVersion().matches("1[012].[10][04]") : defaultTemplate
|
assert defaultTemplate.getImage().getOperatingSystem().getVersion().matches("1[012].[10][04]") : defaultTemplate
|
||||||
.getImage().getOperatingSystem().getVersion();
|
.getImage().getOperatingSystem().getVersion();
|
||||||
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true);
|
||||||
|
@ -179,8 +179,8 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseComputeServiceCont
|
||||||
|
|
||||||
@Test(groups = { "integration", "live" })
|
@Test(groups = { "integration", "live" })
|
||||||
public void testGetAssignableLocations() throws Exception {
|
public void testGetAssignableLocations() throws Exception {
|
||||||
assertProvider(wrapper.unwrap());
|
assertProvider(view.unwrap());
|
||||||
for (Location location : wrapper.getComputeService().listAssignableLocations()) {
|
for (Location location : view.getComputeService().listAssignableLocations()) {
|
||||||
System.err.printf("location %s%n", location);
|
System.err.printf("location %s%n", location);
|
||||||
assert location.getId() != null : location;
|
assert location.getId() != null : location;
|
||||||
assert location != location.getParent() : location;
|
assert location != location.getParent() : location;
|
||||||
|
@ -218,14 +218,14 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseComputeServiceCont
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTemplateBuilderWithImageIdSpecified() throws IOException {
|
public void testTemplateBuilderWithImageIdSpecified() throws IOException {
|
||||||
Template defaultTemplate = wrapper.getComputeService().templateBuilder().build();
|
Template defaultTemplate = view.getComputeService().templateBuilder().build();
|
||||||
|
|
||||||
ComputeServiceContext context = null;
|
ComputeServiceContext context = null;
|
||||||
try {
|
try {
|
||||||
Properties overrides = setupProperties();
|
Properties overrides = setupProperties();
|
||||||
overrides.setProperty("jclouds.image-id", defaultTemplate.getImage().getId());
|
overrides.setProperty("jclouds.image-id", defaultTemplate.getImage().getId());
|
||||||
|
|
||||||
context = createWrapper(overrides, setupModules());
|
context = createView(overrides, setupModules());
|
||||||
|
|
||||||
assertEquals(context.getComputeService().templateBuilder().build().toString(), defaultTemplate.toString());
|
assertEquals(context.getComputeService().templateBuilder().build().toString(), defaultTemplate.toString());
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -238,7 +238,7 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseComputeServiceCont
|
||||||
Properties overrides = setupProperties();
|
Properties overrides = setupProperties();
|
||||||
overrides.setProperty(provider + ".image-id", defaultTemplate.getImage().getId());
|
overrides.setProperty(provider + ".image-id", defaultTemplate.getImage().getId());
|
||||||
|
|
||||||
context = createWrapper(overrides, setupModules());
|
context = createView(overrides, setupModules());
|
||||||
|
|
||||||
assertEquals(context.getComputeService().templateBuilder().build().toString(), defaultTemplate.toString());
|
assertEquals(context.getComputeService().templateBuilder().build().toString(), defaultTemplate.toString());
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -266,7 +266,7 @@ public abstract class BaseTemplateBuilderLiveTest extends BaseComputeServiceCont
|
||||||
boolean auth = authenticateSudo != null ? Boolean.valueOf(authenticateSudo) : true;
|
boolean auth = authenticateSudo != null ? Boolean.valueOf(authenticateSudo) : true;
|
||||||
overrides.setProperty(propertyKey + ".image.authenticate-sudo", auth + "");
|
overrides.setProperty(propertyKey + ".image.authenticate-sudo", auth + "");
|
||||||
|
|
||||||
context = createWrapper(overrides, ImmutableSet.<Module>of(credentialStoreModule));
|
context = createView(overrides, ImmutableSet.<Module>of(credentialStoreModule));
|
||||||
|
|
||||||
Iterable<String> userPass = Splitter.on(':').split(login);
|
Iterable<String> userPass = Splitter.on(':').split(login);
|
||||||
String user = Iterables.get(userPass, 0);
|
String user = Iterables.get(userPass, 0);
|
||||||
|
|
|
@ -486,37 +486,37 @@ public class ContextBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #buildAndWrapWith(Class)
|
* @see #buildView(Class)
|
||||||
*/
|
*/
|
||||||
public <W extends Wrapper> W build(Class<W> wrapperType) {
|
public <V extends View> V build(Class<V> viewType) {
|
||||||
return buildAndWrapWith(checkNotNull(wrapperType, "wrapperType"));
|
return buildView(checkNotNull(viewType, "viewType"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see #buildAndWrapWith(TypeToken)
|
* @see #buildView(TypeToken)
|
||||||
*/
|
*/
|
||||||
public <W extends Wrapper> W buildAndWrapWith(Class<W> wrapperType) {
|
public <V extends View> V buildView(Class<V> viewType) {
|
||||||
return buildAndWrapWith(TypeToken.of(checkNotNull(wrapperType, "wrapperType")));
|
return buildView(TypeToken.of(checkNotNull(viewType, "viewType")));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this will build any {@link ApiMetadata#getWrappers() wrapper} supported by the ApiMetadata.
|
* this will build any {@link ApiMetadata#getViews() view} supported by the ApiMetadata.
|
||||||
*
|
*
|
||||||
* ex. {@code builder.build(BlobStoreContext.class) } will work, if {@code TypeToken<BlobStore>}
|
* ex. {@code builder.build(BlobStoreContext.class) } will work, if {@code TypeToken<BlobStore>}
|
||||||
* is a configured {@link ApiMetadata#getWrappers() wrapper} of this api.
|
* is a configured {@link ApiMetadata#getViews() view} of this api.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <W extends Wrapper> W buildAndWrapWith(TypeToken<W> wrapperType) {
|
public <V extends View> V buildView(TypeToken<V> viewType) {
|
||||||
TypeToken<W> returnType;
|
TypeToken<V> returnType;
|
||||||
try {
|
try {
|
||||||
returnType = (TypeToken<W>) Apis.findWrapper(apiMetadata, checkNotNull(wrapperType, "wrapperType"));
|
returnType = (TypeToken<V>) Apis.findView(apiMetadata, checkNotNull(viewType, "viewType"));
|
||||||
} catch (NoSuchElementException e) {
|
} catch (NoSuchElementException e) {
|
||||||
throw new IllegalArgumentException(String.format(
|
throw new IllegalArgumentException(String.format(
|
||||||
"api %s not wrappable as %s; context: %s, wrappers: %s", apiMetadata,
|
"api %s not wrappable as %s; context: %s, views: %s", apiMetadata,
|
||||||
wrapperType, apiMetadata.getContext(), apiMetadata.getWrappers()));
|
viewType, apiMetadata.getContext(), apiMetadata.getViews()));
|
||||||
}
|
}
|
||||||
return (W) buildInjector().getInstance(Key.get(TypeLiteral.get(returnType.getType())));
|
return (V) buildInjector().getInstance(Key.get(TypeLiteral.get(returnType.getType())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,10 +22,10 @@ import com.google.common.annotations.Beta;
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link Wrapper} allows access to the provider-specific, or library-driven api
|
* {@link View} allows access to the provider-specific, or library-driven api
|
||||||
* behind an abstraction. One wrapped context can support multiple wrappers.
|
* behind an abstraction. One backend context can support multiple views.
|
||||||
* <p/>
|
* <p/>
|
||||||
* For example, the {@code CloudStackContext} can be wrapped by both
|
* For example, the {@code CloudStackContext} can be backend by both
|
||||||
* {@code ComputeServiceContext} and {@code LoadBalancerServiceContext}, as the
|
* {@code ComputeServiceContext} and {@code LoadBalancerServiceContext}, as the
|
||||||
* api covers these features.
|
* api covers these features.
|
||||||
*
|
*
|
||||||
|
@ -33,27 +33,27 @@ import com.google.common.reflect.TypeToken;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Beta
|
@Beta
|
||||||
public interface Wrapper {
|
public interface View {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return type of the context powering the current one.
|
* @return type of the context powering the current one.
|
||||||
*/
|
*/
|
||||||
TypeToken<?> getWrappedType();
|
TypeToken<?> getBackendType();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an object of the specified type to allow access to the wrapped
|
* Return an object of the specified type to allow access to the backend
|
||||||
* context. If the wrapped context is not assignable from the supplied type,
|
* context. If the backend context is not assignable from the supplied type,
|
||||||
* an {@link IllegalArgumentException} is thrown.
|
* an {@link IllegalArgumentException} is thrown.
|
||||||
*
|
*
|
||||||
* @param type
|
* @param type
|
||||||
* the type of the context to be returned. The wrapped context must
|
* the type of the context to be returned. The backend context must
|
||||||
* be assignable from this type.
|
* be assignable from this type.
|
||||||
* @return an instance of the specified type
|
* @return an instance of the specified type
|
||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
* if the wrapped context is not assignable from the specified
|
* if the backend context is not assignable from the specified
|
||||||
* class.
|
* class.
|
||||||
* @see #getWrappedType()
|
* @see #getBackendType()
|
||||||
*/
|
*/
|
||||||
<C extends Context> C unwrap(TypeToken<C> type) throws IllegalArgumentException;
|
<C extends Context> C unwrap(TypeToken<C> type) throws IllegalArgumentException;
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public interface Wrapper {
|
||||||
*
|
*
|
||||||
* @throws ClassCastException
|
* @throws ClassCastException
|
||||||
* if the user supplied {@code C} param is not assignableFrom
|
* if the user supplied {@code C} param is not assignableFrom
|
||||||
* {@link #getWrappedType()}
|
* {@link #getBackendType()}
|
||||||
*/
|
*/
|
||||||
<C extends Context> C unwrap() throws ClassCastException;
|
<C extends Context> C unwrap() throws ClassCastException;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue