mirror of https://github.com/apache/jclouds.git
Issue 475: removed builtin providers for ec2, s3, cloudservers, cloudfiles, and vcloudexpress
This commit is contained in:
parent
1fec99e379
commit
f38c8d5e56
14
README.txt
14
README.txt
|
@ -29,29 +29,27 @@ data.
|
|||
our current version is 1.0-beta-9a
|
||||
our dev version is 1.0-SNAPSHOT
|
||||
|
||||
our compute api supports: aws-ec2, gogrid, cloudservers (generic), cloudservers-us,
|
||||
our compute api supports: aws-ec2, gogrid, cloudservers-us, stub (in-memory),
|
||||
cloudservers-uk, vcloud (generic), ec2 (generic), byon,
|
||||
trmk-ecloud, trmk-vcloudexpress, eucalyptus (generic),
|
||||
cloudsigma-zrh, elasticstack(generic), bluelock-vclouddirector,
|
||||
slicehost, eucalyptus-partnercloud-ec2, elastichosts-lon-p (Peer 1),
|
||||
elastichosts-sat-p (Peer 1), elastichosts-lon-b (BlueSquare),
|
||||
openhosting-east1, serverlove-z1-man, skalicloud-sdg-my,
|
||||
vcloudexpress (generic), stub (in-memory)
|
||||
openhosting-east1, serverlove-z1-man, skalicloud-sdg-my
|
||||
|
||||
* note * the pom dependency org.jclouds/jclouds-allcompute gives you access to
|
||||
to all of these providers
|
||||
|
||||
our blobstore api supports: aws-s3, cloudfiles (generic), cloudfiles-us, cloudfiles-uk,
|
||||
our blobstore api supports: aws-s3, cloudfiles-us, cloudfiles-uk, filesystem,
|
||||
azureblob, atmos (generic), synaptic-storage, scaleup-storage,
|
||||
cloudonestorage, s3 (generic), walrus(generic), googlestorage,
|
||||
eucalyptus-partnercloud-s3, swift (generic), transient (in-mem),
|
||||
filesystem (on-disk)
|
||||
cloudonestorage, walrus(generic), googlestorage,
|
||||
eucalyptus-partnercloud-s3, swift (generic), transient (in-mem)
|
||||
|
||||
* note * the pom dependency org.jclouds/jclouds-allblobstore gives you access to
|
||||
to all of these providers
|
||||
|
||||
we also have support for: ibmdev, mezeo, nirvanix, boxdotnet, rimuhosting, openstack nova,
|
||||
azurequeue, simpledb, scaleup-storage as well as a async-http-client
|
||||
azurequeue, simpledb, cloudstack as well as a async-http-client
|
||||
driver in the sandbox
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package org.jclouds.cloudservers;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withFile;
|
||||
import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withMetadata;
|
||||
import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withSharedIpGroup;
|
||||
|
@ -55,8 +54,8 @@ import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
|||
import org.jclouds.http.functions.ReturnFalseOn404;
|
||||
import org.jclouds.http.functions.ReturnTrueIf2xx;
|
||||
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
|
||||
import org.jclouds.openstack.TestOpenStackAuthenticationModule;
|
||||
import org.jclouds.openstack.OpenStackAuthAsyncClient.AuthenticationResponse;
|
||||
import org.jclouds.openstack.TestOpenStackAuthenticationModule;
|
||||
import org.jclouds.openstack.filters.AddTimestampQuery;
|
||||
import org.jclouds.openstack.filters.AuthenticateRequest;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
|
@ -890,16 +889,17 @@ public class CloudServersAsyncClientTest extends RestClientTest<CloudServersAsyn
|
|||
protected String provider = "cloudservers";
|
||||
|
||||
@Override
|
||||
public RestContextSpec<CloudServersClient, CloudServersAsyncClient> createContextSpec() {
|
||||
return new RestContextFactory().createContextSpec(provider, "user", "password", new Properties());
|
||||
public RestContextSpec<?, ?> createContextSpec() {
|
||||
return new RestContextFactory(getProperties()).createContextSpec(provider, "user", "password", new Properties());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty(PROPERTY_REGIONS, "US");
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://auth");
|
||||
properties.setProperty(PROPERTY_API_VERSION, "1");
|
||||
return properties;
|
||||
Properties overrides = new Properties();
|
||||
overrides.setProperty(PROPERTY_REGIONS, "US");
|
||||
overrides.setProperty(PROPERTY_API_VERSION, "1");
|
||||
overrides.setProperty(provider + ".endpoint", "https://auth");
|
||||
overrides.setProperty(provider + ".contextbuilder", CloudServersContextBuilder.class.getName());
|
||||
return overrides;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package org.jclouds.ec2;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
|
||||
import static org.jclouds.ec2.reference.EC2Constants.PROPERTY_EC2_AMI_OWNERS;
|
||||
|
@ -40,7 +39,6 @@ public class EC2PropertiesBuilder extends PropertiesBuilder {
|
|||
Properties properties = super.defaultProperties();
|
||||
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
|
||||
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://ec2.us-east-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_API_VERSION, EC2AsyncClient.VERSION);
|
||||
properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "*");
|
||||
return properties;
|
||||
|
|
|
@ -31,6 +31,8 @@ import org.jclouds.aws.filters.FormSigner;
|
|||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.ec2.EC2AsyncClient;
|
||||
import org.jclouds.ec2.EC2Client;
|
||||
import org.jclouds.ec2.EC2ContextBuilder;
|
||||
import org.jclouds.ec2.EC2PropertiesBuilder;
|
||||
import org.jclouds.ec2.config.EC2RestClientModule;
|
||||
import org.jclouds.ec2.domain.AvailabilityZone;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
@ -114,9 +116,19 @@ public abstract class BaseEC2AsyncClientTest<T> extends RestClientTest<T> {
|
|||
|
||||
protected String provider = "ec2";
|
||||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
Properties overrides = new Properties();
|
||||
overrides.setProperty(provider + ".endpoint", "https://ec2.us-east-1.amazonaws.com");
|
||||
overrides.setProperty(provider + ".propertiesbuilder", EC2PropertiesBuilder.class.getName());
|
||||
overrides.setProperty(provider + ".contextbuilder", EC2ContextBuilder.class.getName());
|
||||
return overrides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestContextSpec<?, ?> createContextSpec() {
|
||||
return new RestContextFactory().createContextSpec(provider, "identity", "credential", new Properties());
|
||||
return new RestContextFactory(getProperties()).createContextSpec(provider, "identity", "credential",
|
||||
new Properties());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
package org.jclouds.s3;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
|
||||
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
|
||||
|
@ -49,7 +48,6 @@ public class S3PropertiesBuilder extends PropertiesBuilder {
|
|||
properties.setProperty(PROPERTY_S3_SERVICE_PATH, "/");
|
||||
properties.setProperty(PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "true");
|
||||
properties.setProperty(PROPERTY_RELAX_HOSTNAME, "true");
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://s3.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_BLOBSTORE_DIRECTORY_SUFFIX, DIRECTORY_SUFFIX_FOLDER);
|
||||
return properties;
|
||||
}
|
||||
|
|
|
@ -72,9 +72,19 @@ public abstract class BaseS3AsyncClientTest extends RestClientTest<S3AsyncClient
|
|||
|
||||
protected String provider = "s3";
|
||||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
Properties overrides = new Properties();
|
||||
overrides.setProperty(provider + ".endpoint", "https://s3.amazonaws.com");
|
||||
overrides.setProperty(provider + ".propertiesbuilder", S3PropertiesBuilder.class.getName());
|
||||
overrides.setProperty(provider + ".contextbuilder", S3ContextBuilder.class.getName());
|
||||
return overrides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestContextSpec<?, ?> createContextSpec() {
|
||||
return new RestContextFactory().createContextSpec(provider, "identity", "credential", new Properties());
|
||||
return new RestContextFactory(getProperties()).createContextSpec(provider, "identity", "credential",
|
||||
new Properties());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.s3;
|
||||
|
||||
import org.jclouds.blobstore.util.BlobStoreUtils;
|
||||
import org.jclouds.rest.Providers;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ProvidersInPropertiesTest {
|
||||
|
||||
@Test
|
||||
public void testSupportedProviders() {
|
||||
Iterable<String> providers = Providers.getSupportedProviders();
|
||||
assert Iterables.contains(providers, "s3") : providers;;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSupportedBlobStoreProviders() {
|
||||
Iterable<String> providers = BlobStoreUtils.getSupportedProviders();
|
||||
assert Iterables.contains(providers, "s3") : providers;
|
||||
}
|
||||
|
||||
}
|
|
@ -70,7 +70,7 @@ public class BindAsHostPrefixIfConfiguredTest extends BaseS3AsyncClientTest {
|
|||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
Properties properties = new Properties();
|
||||
Properties properties = super.getProperties();
|
||||
properties.setProperty(PROPERTY_S3_SERVICE_PATH, "/services/Walrus");
|
||||
properties.setProperty(PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "false");
|
||||
return properties;
|
||||
|
|
|
@ -22,7 +22,6 @@ package org.jclouds.s3.blobstore;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.blobstore.BlobRequestSigner;
|
||||
import org.jclouds.blobstore.domain.Blob;
|
||||
|
@ -32,10 +31,7 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.io.payloads.PhantomPayload;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.RestClientTest;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.rest.RestContextSpec;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.s3.BaseS3AsyncClientTest;
|
||||
import org.jclouds.s3.S3AsyncClient;
|
||||
import org.jclouds.s3.S3Client;
|
||||
import org.jclouds.s3.config.S3RestClientModule;
|
||||
|
@ -44,7 +40,6 @@ import org.testng.annotations.Test;
|
|||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code S3BlobRequestSigner}
|
||||
|
@ -53,39 +48,39 @@ import com.google.inject.TypeLiteral;
|
|||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", testName = "S3BlobRequestSignerTest")
|
||||
public class S3BlobRequestSignerTest extends RestClientTest<S3AsyncClient> {
|
||||
public class S3BlobRequestSignerTest extends BaseS3AsyncClientTest {
|
||||
|
||||
private BlobRequestSigner signer;
|
||||
private Factory blobFactory;
|
||||
|
||||
public void testSignGetBlob() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException,
|
||||
NoSuchMethodException, IOException {
|
||||
NoSuchMethodException, IOException {
|
||||
HttpRequest request = signer.signGetBlob("container", "name");
|
||||
|
||||
assertRequestLineEquals(request, "GET https://container.s3.amazonaws.com/name HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(
|
||||
request,
|
||||
"Authorization: AWS identity:0uvBv1wEskuhFHYJF/L6kEV9A7o=\nDate: Thu, 05 Jun 2008 16:38:19 GMT\nHost: container.s3.amazonaws.com\n");
|
||||
request,
|
||||
"Authorization: AWS identity:0uvBv1wEskuhFHYJF/L6kEV9A7o=\nDate: Thu, 05 Jun 2008 16:38:19 GMT\nHost: container.s3.amazonaws.com\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertEquals(request.getFilters().size(), 0);
|
||||
}
|
||||
|
||||
public void testSignRemoveBlob() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException,
|
||||
NoSuchMethodException, IOException {
|
||||
NoSuchMethodException, IOException {
|
||||
HttpRequest request = signer.signRemoveBlob("container", "name");
|
||||
|
||||
assertRequestLineEquals(request, "DELETE https://container.s3.amazonaws.com/name HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(
|
||||
request,
|
||||
"Authorization: AWS identity:4FnyjdX/ULdDMRbVlLNjZfEo9RQ=\nDate: Thu, 05 Jun 2008 16:38:19 GMT\nHost: container.s3.amazonaws.com\n");
|
||||
request,
|
||||
"Authorization: AWS identity:4FnyjdX/ULdDMRbVlLNjZfEo9RQ=\nDate: Thu, 05 Jun 2008 16:38:19 GMT\nHost: container.s3.amazonaws.com\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
assertEquals(request.getFilters().size(), 0);
|
||||
}
|
||||
|
||||
public void testSignPutBlob() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException,
|
||||
NoSuchMethodException, IOException {
|
||||
NoSuchMethodException, IOException {
|
||||
Blob blob = blobFactory.create(null);
|
||||
blob.getMetadata().setName("name");
|
||||
blob.setPayload(new PhantomPayload());
|
||||
|
@ -97,8 +92,8 @@ public class S3BlobRequestSignerTest extends RestClientTest<S3AsyncClient> {
|
|||
|
||||
assertRequestLineEquals(request, "PUT https://container.s3.amazonaws.com/name HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(
|
||||
request,
|
||||
"Authorization: AWS identity:j9Dy/lmmvlCKjA4lkqZenLxMkR4=\nDate: Thu, 05 Jun 2008 16:38:19 GMT\nHost: container.s3.amazonaws.com\n");
|
||||
request,
|
||||
"Authorization: AWS identity:j9Dy/lmmvlCKjA4lkqZenLxMkR4=\nDate: Thu, 05 Jun 2008 16:38:19 GMT\nHost: container.s3.amazonaws.com\n");
|
||||
|
||||
assertContentHeadersEqual(request, "text/plain", null, null, null, (long) 2l, new byte[] { 0, 2, 4, 8 });
|
||||
|
||||
|
@ -112,16 +107,6 @@ public class S3BlobRequestSignerTest extends RestClientTest<S3AsyncClient> {
|
|||
this.signer = injector.getInstance(BlobRequestSigner.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkFilters(HttpRequest request) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TypeLiteral<RestAnnotationProcessor<S3AsyncClient>> createTypeLiteral() {
|
||||
return new TypeLiteral<RestAnnotationProcessor<S3AsyncClient>>() {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Module createModule() {
|
||||
return new TestS3RestClientModule();
|
||||
|
@ -141,9 +126,4 @@ public class S3BlobRequestSignerTest extends RestClientTest<S3AsyncClient> {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestContextSpec<?, ?> createContextSpec() {
|
||||
return new RestContextFactory().createContextSpec("s3", "identity", "credential", new Properties());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
package org.jclouds.s3.config;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.aws.handlers.AWSClientErrorRetryHandler;
|
||||
import org.jclouds.aws.handlers.AWSRedirectionRetryHandler;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.handlers.DelegatingErrorHandler;
|
||||
import org.jclouds.http.handlers.DelegatingRetryHandler;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.BaseRestClientTest.MockModule;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.s3.S3AsyncClient;
|
||||
import org.jclouds.s3.S3Client;
|
||||
import org.jclouds.s3.handlers.ParseS3ErrorFromXmlContent;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class S3RestClientModuleTest {
|
||||
|
||||
Injector createInjector() throws IOException {
|
||||
return new RestContextFactory().createContextBuilder("s3", "foo", "bar",
|
||||
ImmutableSet.of(new MockModule(), new NullLoggingModule()), new Properties())
|
||||
.buildInjector();
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdatesOnlyOncePerSecond() throws NoSuchMethodException, InterruptedException {
|
||||
S3RestClientModule<S3Client, S3AsyncClient> module = S3RestClientModule.create();
|
||||
|
||||
Supplier<String> map = module.provideTimeStampCache(1, new SimpleDateFormatDateService());
|
||||
String timeStamp = map.get();
|
||||
for (int i = 0; i < 10; i++)
|
||||
map.get();
|
||||
assertEquals(timeStamp, map.get());
|
||||
Thread.sleep(1001);
|
||||
assertFalse(timeStamp.equals(map.get()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testServerErrorHandler() throws IOException {
|
||||
DelegatingErrorHandler handler = createInjector().getInstance(DelegatingErrorHandler.class);
|
||||
assertEquals(handler.getServerErrorHandler().getClass(), ParseS3ErrorFromXmlContent.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClientErrorHandler() throws IOException {
|
||||
DelegatingErrorHandler handler = createInjector().getInstance(DelegatingErrorHandler.class);
|
||||
assertEquals(handler.getClientErrorHandler().getClass(), ParseS3ErrorFromXmlContent.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClientRetryHandler() throws IOException {
|
||||
DelegatingRetryHandler handler = createInjector().getInstance(DelegatingRetryHandler.class);
|
||||
assertEquals(handler.getClientErrorRetryHandler().getClass(),
|
||||
AWSClientErrorRetryHandler.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRedirectionRetryHandler() throws IOException {
|
||||
DelegatingRetryHandler handler = createInjector().getInstance(DelegatingRetryHandler.class);
|
||||
assertEquals(handler.getRedirectionRetryHandler().getClass(),
|
||||
AWSRedirectionRetryHandler.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -69,21 +69,21 @@ public class RequestAuthorizeSignatureTest extends BaseS3AsyncClientTest {
|
|||
date = request.getFirstHeaderOrNull(HttpHeaders.DATE);
|
||||
filter.filter(request);
|
||||
if (request.getFirstHeaderOrNull(HttpHeaders.DATE).equals(date))
|
||||
assert signature.equals(request.getFirstHeaderOrNull(HttpHeaders.AUTHORIZATION)) : String
|
||||
.format("sig: %s != %s on attempt %s", signature, request
|
||||
.getFirstHeaderOrNull(HttpHeaders.AUTHORIZATION), iterations);
|
||||
assert signature.equals(request.getFirstHeaderOrNull(HttpHeaders.AUTHORIZATION)) : String.format(
|
||||
"sig: %s != %s on attempt %s", signature, request.getFirstHeaderOrNull(HttpHeaders.AUTHORIZATION),
|
||||
iterations);
|
||||
else
|
||||
iterations++;
|
||||
|
||||
}
|
||||
System.out.printf("%s: %d iterations before the timestamp updated %n", Thread.currentThread()
|
||||
.getName(), iterations);
|
||||
System.out.printf("%s: %d iterations before the timestamp updated %n", Thread.currentThread().getName(),
|
||||
iterations);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAppendBucketNameHostHeader() throws SecurityException, NoSuchMethodException {
|
||||
HttpRequest request = processor.createRequest(S3AsyncClient.class.getMethod(
|
||||
"getBucketLocation", String.class), "bucket");
|
||||
HttpRequest request = processor.createRequest(S3AsyncClient.class.getMethod("getBucketLocation", String.class),
|
||||
"bucket");
|
||||
StringBuilder builder = new StringBuilder();
|
||||
filter.appendBucketName(request, builder);
|
||||
assertEquals(builder.toString(), "/bucket");
|
||||
|
@ -98,9 +98,9 @@ public class RequestAuthorizeSignatureTest extends BaseS3AsyncClientTest {
|
|||
}
|
||||
|
||||
private GeneratedHttpRequest<S3AsyncClient> putBucketAcl() throws NoSuchMethodException {
|
||||
return processor.createRequest(S3AsyncClient.class.getMethod("putBucketACL", String.class,
|
||||
AccessControlList.class), "bucket", AccessControlList.fromCannedAccessPolicy(
|
||||
CannedAccessPolicy.PRIVATE, "1234"));
|
||||
return processor.createRequest(
|
||||
S3AsyncClient.class.getMethod("putBucketACL", String.class, AccessControlList.class), "bucket",
|
||||
AccessControlList.fromCannedAccessPolicy(CannedAccessPolicy.PRIVATE, "1234"));
|
||||
}
|
||||
|
||||
// "?acl", "?location", "?logging", or "?torrent"
|
||||
|
@ -129,20 +129,21 @@ public class RequestAuthorizeSignatureTest extends BaseS3AsyncClientTest {
|
|||
S3Object object = blobToS3Object.apply(BindBlobToMultipartFormTest.TEST_BLOB);
|
||||
|
||||
object.getMetadata().getUserMetadata().put("x-amz-Adrian", "foo");
|
||||
HttpRequest request = processor.createRequest(S3AsyncClient.class.getMethod("putObject",
|
||||
String.class, S3Object.class, PutObjectOptions[].class), "bucket", object);
|
||||
HttpRequest request = processor.createRequest(
|
||||
S3AsyncClient.class.getMethod("putObject", String.class, S3Object.class, PutObjectOptions[].class),
|
||||
"bucket", object);
|
||||
return request;
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAppendBucketNameURIHost() throws SecurityException, NoSuchMethodException {
|
||||
HttpRequest request = processor.createRequest(S3AsyncClient.class.getMethod(
|
||||
"getBucketLocation", String.class), "bucket");
|
||||
HttpRequest request = processor.createRequest(S3AsyncClient.class.getMethod("getBucketLocation", String.class),
|
||||
"bucket");
|
||||
assertEquals(request.getEndpoint().getHost(), "bucket.s3.amazonaws.com");
|
||||
}
|
||||
|
||||
|
||||
protected Properties getProperties() {
|
||||
Properties overrides= new Properties();
|
||||
Properties overrides = super.getProperties();
|
||||
overrides.setProperty(PROPERTY_SESSION_INTERVAL, 1 + "");
|
||||
return overrides;
|
||||
}
|
||||
|
|
|
@ -82,7 +82,6 @@ import com.google.inject.Injector;
|
|||
import com.google.inject.Module;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code VCloudExpressAsyncClient}
|
||||
*
|
||||
|
@ -94,17 +93,16 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testInstantiateVAppTemplateInVDCURI() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
|
||||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3"), "my-vapp");
|
||||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"),
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3"), "my-vapp");
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
||||
assertPayloadEquals(request, Strings2.toStringAndClose(getClass()
|
||||
.getResourceAsStream("/newvapp-hosting.xml")),
|
||||
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
||||
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/newvapp-hosting.xml")),
|
||||
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, VCloudExpressVAppHandler.class);
|
||||
|
@ -114,22 +112,27 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
}
|
||||
|
||||
public void testInstantiateVAppTemplateInVDCURIOptions() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
|
||||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3"), "my-vapp", processorCount(1)
|
||||
.memory(512).disk(1024).addNetworkConfig(
|
||||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
HttpRequest request = processor.createRequest(
|
||||
method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"),
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/3"),
|
||||
"my-vapp",
|
||||
processorCount(1)
|
||||
.memory(512)
|
||||
.disk(1024)
|
||||
.addNetworkConfig(
|
||||
new NetworkConfig(null, URI.create("https://vcloud.safesecureweb.com/network/1990"),
|
||||
FenceMode.BRIDGED)));
|
||||
FenceMode.BRIDGED)));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
||||
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/newvapp-hostingcpumemdisk.xml")),
|
||||
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
||||
assertPayloadEquals(request,
|
||||
Strings2.toStringAndClose(getClass().getResourceAsStream("/newvapp-hostingcpumemdisk.xml")),
|
||||
"application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, VCloudExpressVAppHandler.class);
|
||||
|
@ -140,27 +143,33 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testInstantiateVAppTemplateInOrgOptionsIllegalName() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("instantiateVAppTemplateInVDC", URI.class, URI.class,
|
||||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
processor.createRequest(method, URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), "CentOS 01", processorCount(1).memory(512)
|
||||
.disk(1024).addNetworkConfig(
|
||||
String.class, InstantiateVAppTemplateOptions[].class);
|
||||
processor.createRequest(
|
||||
method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"),
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"),
|
||||
"CentOS 01",
|
||||
processorCount(1)
|
||||
.memory(512)
|
||||
.disk(1024)
|
||||
.addNetworkConfig(
|
||||
new NetworkConfig("aloha", URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1990"), null)));
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1990"), null)));
|
||||
}
|
||||
|
||||
public void testCloneVAppInVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.class,
|
||||
CloneVAppOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/4181"), "my-vapp");
|
||||
CloneVAppOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"),
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/4181"), "my-vapp");
|
||||
|
||||
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/cloneVApp HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
|
||||
"/cloneVApp-default.xml")), "application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
|
||||
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/cloneVApp-default.xml")),
|
||||
"application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
||||
|
@ -171,16 +180,16 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testCloneVAppInVDCOptions() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("cloneVAppInVDC", URI.class, URI.class, String.class,
|
||||
CloneVAppOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/201"), "new-linux-server",
|
||||
new CloneVAppOptions().deploy().powerOn().withDescription("The description of the new vApp"));
|
||||
CloneVAppOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"),
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vapp/201"), "new-linux-server",
|
||||
new CloneVAppOptions().deploy().powerOn().withDescription("The description of the new vApp"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/vdc/1/action/cloneVApp HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/cloneVApp.xml")),
|
||||
"application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
|
||||
"application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ParseSax.class);
|
||||
assertSaxResponseParserClassEquals(method, TaskHandler.class);
|
||||
|
@ -191,8 +200,8 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testOrg() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("getOrg", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/org/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.org+xml\n");
|
||||
|
@ -222,8 +231,8 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testCatalog() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("getCatalog", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalog/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalog+xml\n");
|
||||
|
@ -253,8 +262,8 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("getNetwork", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/network/2"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/network/2"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/network/2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.network+xml\n");
|
||||
|
@ -269,8 +278,8 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testCatalogItemURI() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("getCatalogItem", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.catalogItem+xml\n");
|
||||
|
@ -285,7 +294,7 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testFindCatalogItemInOrgCatalogNamed() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("findCatalogItemInOrgCatalogNamed", String.class,
|
||||
String.class, String.class);
|
||||
String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, "org", "catalog", "item");
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1 HTTP/1.1");
|
||||
|
@ -301,7 +310,7 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testFindVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("findVAppTemplateInOrgCatalogNamed", String.class,
|
||||
String.class, String.class);
|
||||
String.class, String.class);
|
||||
HttpRequest request = processor.createRequest(method, "org", "catalog", "template");
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2 HTTP/1.1");
|
||||
|
@ -317,8 +326,8 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testVAppTemplateURI() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("getVAppTemplate", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
|
||||
|
@ -390,8 +399,8 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("getVDC", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vdc/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
|
||||
|
@ -406,8 +415,8 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testGetTasksList() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("getTasksList", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/tasksList/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.tasksList+xml\n");
|
||||
|
@ -437,8 +446,8 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("deployVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/action/deploy HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
|
@ -453,8 +462,8 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testGet() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("getVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/vApp/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
|
||||
|
@ -469,8 +478,8 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testUndeployVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("undeployVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/action/undeploy HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
|
@ -485,8 +494,8 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testDelete() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("deleteVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
|
||||
|
||||
assertRequestLineEquals(request, "DELETE https://vcloud.safesecureweb.com/api/v0.8/vApp/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -501,11 +510,11 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testPowerOnVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("powerOnVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/powerOn HTTP/1.1");
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/powerOn HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
|
@ -518,11 +527,11 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testPowerOffVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("powerOffVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/powerOff HTTP/1.1");
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/powerOff HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
|
@ -535,11 +544,11 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testResetVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("resetVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/reset HTTP/1.1");
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/reset HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
|
@ -552,11 +561,11 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testSuspendVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("suspendVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/suspend HTTP/1.1");
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/suspend HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
|
@ -569,11 +578,11 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testShutdownVApp() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("shutdownVApp", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/1"));
|
||||
|
||||
assertRequestLineEquals(request,
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/shutdown HTTP/1.1");
|
||||
"POST https://vcloud.safesecureweb.com/api/v0.8/vApp/1/power/action/shutdown HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
assertPayloadEquals(request, null, null, false);
|
||||
|
||||
|
@ -586,8 +595,8 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testGetTask() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("getTask", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/task/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/1"));
|
||||
|
||||
assertRequestLineEquals(request, "GET https://vcloud.safesecureweb.com/api/v0.8/task/1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
|
||||
|
@ -602,8 +611,8 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
public void testCancelTask() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = VCloudExpressAsyncClient.class.getMethod("cancelTask", URI.class);
|
||||
HttpRequest request = processor.createRequest(method, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/task/1"));
|
||||
HttpRequest request = processor.createRequest(method,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/1"));
|
||||
|
||||
assertRequestLineEquals(request, "POST https://vcloud.safesecureweb.com/api/v0.8/task/1/action/cancel HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "");
|
||||
|
@ -633,11 +642,21 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
return new VCloudRestClientModuleExtension();
|
||||
}
|
||||
|
||||
protected String provider = "vcloudexpress";
|
||||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
Properties overrides = new Properties();
|
||||
overrides.setProperty(provider + ".endpoint", "https://vcloud.safesecureweb.com/api/v0.8");
|
||||
overrides.setProperty(provider + ".propertiesbuilder", VCloudExpressPropertiesBuilder.class.getName());
|
||||
overrides.setProperty(provider + ".contextbuilder", VCloudExpressContextBuilder.class.getName());
|
||||
return overrides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestContextSpec<?, ?> createContextSpec() {
|
||||
Properties overrides = new Properties();
|
||||
overrides.setProperty("vcloudexpress.endpoint", "https://vcloud.safesecureweb.com/api/v0.8");
|
||||
return new RestContextFactory().createContextSpec("vcloudexpress", "identity", "credential", overrides);
|
||||
return new RestContextFactory(getProperties()).createContextSpec(provider, "identity", "credential",
|
||||
new Properties());
|
||||
}
|
||||
|
||||
@RequiresHttp
|
||||
|
@ -645,7 +664,7 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
public static class VCloudRestClientModuleExtension extends VCloudExpressRestClientModule {
|
||||
@Override
|
||||
protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService,
|
||||
@Named(PROPERTY_API_VERSION) String version) {
|
||||
@Named(PROPERTY_API_VERSION) String version) {
|
||||
return URI.create("https://vcloud.safesecureweb.com/api/v0.8/login");
|
||||
}
|
||||
|
||||
|
@ -688,7 +707,7 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
@Override
|
||||
protected String provideDefaultVDCName(
|
||||
@org.jclouds.vcloud.endpoints.VDC Supplier<Map<String, String>> vDCtoOrgSupplier) {
|
||||
@org.jclouds.vcloud.endpoints.VDC Supplier<Map<String, String>> vDCtoOrgSupplier) {
|
||||
return "vdc";
|
||||
}
|
||||
|
||||
|
@ -699,13 +718,13 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
@Override
|
||||
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
|
||||
final VCloudExpressLoginAsyncClient login) {
|
||||
final VCloudExpressLoginAsyncClient login) {
|
||||
return Suppliers.<VCloudSession> ofInstance(new VCloudSession() {
|
||||
|
||||
@Override
|
||||
public Map<String, ReferenceType> getOrgs() {
|
||||
return ImmutableMap.<String, ReferenceType> of("org", new ReferenceTypeImpl("org",
|
||||
VCloudExpressMediaType.ORG_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1")));
|
||||
VCloudExpressMediaType.ORG_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1")));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -726,20 +745,22 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
}
|
||||
|
||||
protected Supplier<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> provideOrgVDCSupplierCache(
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) {
|
||||
@Named(PROPERTY_SESSION_INTERVAL) long seconds, final OrgVDCSupplier supplier) {
|
||||
|
||||
return Suppliers.<Map<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>>> ofInstance(ImmutableMap
|
||||
.<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> of("org",
|
||||
.<String, Map<String, ? extends org.jclouds.vcloud.domain.VDC>> of("org",
|
||||
|
||||
ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of("vdc", new VDCImpl("vdc", null, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), null, null, "description", null,
|
||||
null, null, null, null, ImmutableMap.<String, ReferenceType> of("vapp",
|
||||
new ReferenceTypeImpl("vapp", "application/vnd.vmware.vcloud.vApp+xml", URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1")),
|
||||
"network", new ReferenceTypeImpl("network",
|
||||
"application/vnd.vmware.vcloud.vAppTemplate+xml", URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))),
|
||||
null, 0, 0, 0, false))));
|
||||
ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of(
|
||||
"vdc",
|
||||
new VDCImpl("vdc", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"), null,
|
||||
null, "description", null, null, null, null, null, ImmutableMap.<String, ReferenceType> of(
|
||||
"vapp",
|
||||
new ReferenceTypeImpl("vapp", "application/vnd.vmware.vcloud.vApp+xml", URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vApp/188849-1")),
|
||||
"network",
|
||||
new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdcItem/2"))), null, 0, 0, 0,
|
||||
false))));
|
||||
|
||||
}
|
||||
|
||||
|
@ -752,17 +773,21 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
@Override
|
||||
public Map<String, Org> get() {
|
||||
return ImmutableMap.<String, Org> of("org", new OrgImpl("org", null, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), "org", null, ImmutableMap
|
||||
.<String, ReferenceType> of("catalog", new ReferenceTypeImpl("catalog",
|
||||
VCloudExpressMediaType.CATALOG_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap
|
||||
.<String, ReferenceType> of("vdc", new ReferenceTypeImpl("vdc", VCloudExpressMediaType.VDC_XML,
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap
|
||||
.<String, ReferenceType> of(), new ReferenceTypeImpl("tasksList",
|
||||
VCloudExpressMediaType.TASKSLIST_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")), ImmutableList
|
||||
.<Task> of()));
|
||||
return ImmutableMap.<String, Org> of(
|
||||
"org",
|
||||
new OrgImpl("org", null, URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), "org", null,
|
||||
ImmutableMap.<String, ReferenceType> of(
|
||||
"catalog",
|
||||
new ReferenceTypeImpl("catalog", VCloudExpressMediaType.CATALOG_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap
|
||||
.<String, ReferenceType> of(
|
||||
"vdc",
|
||||
new ReferenceTypeImpl("vdc", VCloudExpressMediaType.VDC_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), ImmutableMap
|
||||
.<String, ReferenceType> of(), new ReferenceTypeImpl("tasksList",
|
||||
VCloudExpressMediaType.TASKSLIST_XML, URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")), ImmutableList
|
||||
.<Task> of()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -777,14 +802,17 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
|
||||
return ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> of("org",
|
||||
|
||||
ImmutableMap.<String, org.jclouds.vcloud.domain.Catalog> of("catalog", new CatalogImpl("catalog", "type",
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"), null, "description",
|
||||
ImmutableMap.<String, ReferenceType> of("item", new ReferenceTypeImpl("item",
|
||||
"application/vnd.vmware.vcloud.catalogItem+xml", URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1")), "template",
|
||||
ImmutableMap.<String, org.jclouds.vcloud.domain.Catalog> of(
|
||||
"catalog",
|
||||
new CatalogImpl("catalog", "type", URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"),
|
||||
null, "description", ImmutableMap.<String, ReferenceType> of(
|
||||
"item",
|
||||
new ReferenceTypeImpl("item", "application/vnd.vmware.vcloud.catalogItem+xml", URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1")),
|
||||
"template",
|
||||
new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"))),
|
||||
ImmutableList.<Task> of(), true)));
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"))), ImmutableList
|
||||
.<Task> of(), true)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -796,26 +824,15 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
|
|||
|
||||
@Override
|
||||
public Map<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> get() {
|
||||
return ImmutableMap
|
||||
.<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> of(
|
||||
"org",
|
||||
ImmutableMap
|
||||
.<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>> of(
|
||||
"catalog",
|
||||
ImmutableMap
|
||||
.<String, org.jclouds.vcloud.domain.CatalogItem> of(
|
||||
"template",
|
||||
new CatalogItemImpl(
|
||||
"template",
|
||||
URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"),
|
||||
"description",
|
||||
new ReferenceTypeImpl(
|
||||
"template",
|
||||
"application/vnd.vmware.vcloud.vAppTemplate+xml",
|
||||
URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2")),
|
||||
ImmutableMap.<String, String> of()))));
|
||||
return ImmutableMap.<String, Map<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>>> of(
|
||||
"org", ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.CatalogItem>> of(
|
||||
"catalog", ImmutableMap.<String, org.jclouds.vcloud.domain.CatalogItem> of(
|
||||
"template",
|
||||
new CatalogItemImpl("template", URI
|
||||
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"), "description",
|
||||
new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml",
|
||||
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2")),
|
||||
ImmutableMap.<String, String> of()))));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
"A clojure binding for the jclouds BlobStore.
|
||||
|
||||
Current supported services are:
|
||||
[transient, filesystem, s3, azureblob, atmos, cloudfiles, walrus, scaleup-storage,
|
||||
[transient, filesystem, azureblob, atmos, walrus, scaleup-storage,
|
||||
googlestorage, synaptic, peer1-storage, aws-s3, eucalyptus-partnercloud-s3,
|
||||
cloudfiles-us, cloudfiles-uk, swift]
|
||||
|
||||
|
|
|
@ -21,12 +21,11 @@
|
|||
"A clojure binding to the jclouds ComputeService.
|
||||
|
||||
Current supported providers are:
|
||||
[ec2, aws-ec2, eucualyptus-partnercloud-ec2, cloudservers,
|
||||
cloudservers-uk, cloudservers-us, byon,
|
||||
[aws-ec2, eucualyptus-partnercloud-ec2, elastichosts-lon-b,
|
||||
cloudservers-uk, cloudservers-us, byon, cloudsigma-zrh, stub,
|
||||
trmk-ecloud, trmk-vcloudexpress, vcloud, bluelock, eucalyptus,
|
||||
slicehost, elastichosts-lon-p, elastichosts-sat-p, elastichosts,
|
||||
openhosting-east1, serverlove-z1-man, skalicloud-sdg-my,
|
||||
elastichosts-lon-b, cloudsigma-zrh, vcloudexpress, stub]
|
||||
openhosting-east1, serverlove-z1-man, skalicloud-sdg-my]
|
||||
|
||||
Here's an example of getting some compute configuration from rackspace:
|
||||
|
||||
|
|
|
@ -72,24 +72,24 @@ import com.google.inject.Module;
|
|||
public class RestContextFactory {
|
||||
|
||||
public static <S, A> RestContextSpec<S, A> contextSpec(String provider, String endpoint, String apiVersion,
|
||||
String iso3166Codes, String identity, String credential, Class<S> sync, Class<A> async,
|
||||
Class<PropertiesBuilder> propertiesBuilderClass, Class<RestContextBuilder<S, A>> contextBuilderClass,
|
||||
Iterable<Module> modules) {
|
||||
String iso3166Codes, String identity, String credential, Class<S> sync, Class<A> async,
|
||||
Class<PropertiesBuilder> propertiesBuilderClass, Class<RestContextBuilder<S, A>> contextBuilderClass,
|
||||
Iterable<Module> modules) {
|
||||
return new RestContextSpec<S, A>(provider, endpoint, apiVersion, iso3166Codes, identity, credential, sync, async,
|
||||
propertiesBuilderClass, contextBuilderClass, modules);
|
||||
propertiesBuilderClass, contextBuilderClass, modules);
|
||||
}
|
||||
|
||||
public static <S, A> RestContextSpec<S, A> contextSpec(String provider, String endpoint, String apiVersion,
|
||||
String iso3166Codes, String identity, String credential, Class<S> sync, Class<A> async) {
|
||||
String iso3166Codes, String identity, String credential, Class<S> sync, Class<A> async) {
|
||||
return new RestContextSpec<S, A>(provider, endpoint, apiVersion, iso3166Codes, identity, credential, sync, async);
|
||||
}
|
||||
|
||||
@SuppressWarnings( { "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public static <S, A> RestContextSpec<S, A> contextSpec(String provider, String endpoint, String apiVersion,
|
||||
String iso3166Codes, String identity, String credential, Class<S> sync, Class<A> async,
|
||||
Iterable<Module> modules) {
|
||||
String iso3166Codes, String identity, String credential, Class<S> sync, Class<A> async,
|
||||
Iterable<Module> modules) {
|
||||
return new RestContextSpec<S, A>(provider, endpoint, apiVersion, iso3166Codes, identity, credential, sync, async,
|
||||
PropertiesBuilder.class, (Class) RestContextBuilder.class, modules);
|
||||
PropertiesBuilder.class, (Class) RestContextBuilder.class, modules);
|
||||
}
|
||||
|
||||
private final static Properties NO_PROPERTIES = new Properties();
|
||||
|
@ -180,9 +180,9 @@ public class RestContextFactory {
|
|||
|
||||
/**
|
||||
*
|
||||
* Identity will be found by searching {@code jclouds.identity} failing that {@code
|
||||
* provider.identity} where provider corresponds to the parameter. Same pattern is used for
|
||||
* credential ({@code jclouds.credential} failing that {@code provider.credential}).
|
||||
* Identity will be found by searching {@code jclouds.identity} failing that
|
||||
* {@code provider.identity} where provider corresponds to the parameter. Same pattern is used
|
||||
* for credential ({@code jclouds.credential} failing that {@code provider.credential}).
|
||||
*
|
||||
* @param <S>
|
||||
* Type of the provider specific client
|
||||
|
@ -198,18 +198,18 @@ public class RestContextFactory {
|
|||
* properties to pass to the context.
|
||||
*/
|
||||
public <S, A> RestContextBuilder<S, A> createContextBuilder(String provider, Iterable<? extends Module> wiring,
|
||||
Properties overrides) {
|
||||
Properties overrides) {
|
||||
return createContextBuilder(provider, null, null, wiring, overrides);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <S, A> RestContextBuilder<S, A> createContextBuilder(String provider, @Nullable String identity,
|
||||
@Nullable String credential, Properties properties) {
|
||||
@Nullable String credential, Properties properties) {
|
||||
return createContextBuilder(provider, identity, credential, EMPTY_LIST, properties);
|
||||
}
|
||||
|
||||
public <S, A> RestContextBuilder<S, A> createContextBuilder(String provider, @Nullable String identity,
|
||||
@Nullable String credential, Iterable<? extends Module> wiring) {
|
||||
@Nullable String credential, Iterable<? extends Module> wiring) {
|
||||
return createContextBuilder(provider, identity, credential, wiring, NO_PROPERTIES);
|
||||
}
|
||||
|
||||
|
@ -229,7 +229,7 @@ public class RestContextFactory {
|
|||
* @return initialized context ready for use
|
||||
*/
|
||||
public <S, A> RestContextBuilder<S, A> createContextBuilder(String providerName, @Nullable String identity,
|
||||
@Nullable String credential, Iterable<? extends Module> wiring, Properties _overrides) {
|
||||
@Nullable String credential, Iterable<? extends Module> wiring, Properties _overrides) {
|
||||
checkNotNull(wiring, "wiring");
|
||||
RestContextSpec<S, A> contextSpec = createContextSpec(providerName, identity, credential, wiring, _overrides);
|
||||
return createContextBuilder(contextSpec, _overrides);
|
||||
|
@ -249,37 +249,37 @@ public class RestContextFactory {
|
|||
if (contextSpec.sync != null) {
|
||||
props.setProperty(contextSpec.provider + ".sync", contextSpec.sync.getName());
|
||||
props.setProperty(contextSpec.provider + ".async", checkNotNull(contextSpec.async, "contextSpec.async")
|
||||
.getName());
|
||||
.getName());
|
||||
} else {
|
||||
props.setProperty(contextSpec.provider + ".contextbuilder", checkNotNull(contextSpec.contextBuilderClass,
|
||||
"contextSpec.contextBuilderClass").getName());
|
||||
props.setProperty(contextSpec.provider + ".contextbuilder",
|
||||
checkNotNull(contextSpec.contextBuilderClass, "contextSpec.contextBuilderClass").getName());
|
||||
|
||||
props.setProperty(contextSpec.provider + ".propertiesbuilder", checkNotNull(
|
||||
contextSpec.propertiesBuilderClass, "contextSpec.propertiesBuilderClass").getName());
|
||||
props.setProperty(contextSpec.provider + ".propertiesbuilder",
|
||||
checkNotNull(contextSpec.propertiesBuilderClass, "contextSpec.propertiesBuilderClass").getName());
|
||||
}
|
||||
if (size(contextSpec.modules) > 0) {
|
||||
props.setProperty(contextSpec.provider + ".modules", Joiner.on(',').join(
|
||||
transform(contextSpec.modules, new Function<Module, String>() {
|
||||
props.setProperty(contextSpec.provider + ".modules",
|
||||
Joiner.on(',').join(transform(contextSpec.modules, new Function<Module, String>() {
|
||||
|
||||
@Override
|
||||
public String apply(Module from) {
|
||||
return from.getClass().getName();
|
||||
}
|
||||
@Override
|
||||
public String apply(Module from) {
|
||||
return from.getClass().getName();
|
||||
}
|
||||
|
||||
})));
|
||||
})));
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <S, A> RestContextSpec<S, A> createContextSpec(String providerName, String identity, String credential,
|
||||
Properties _overrides) {
|
||||
Properties _overrides) {
|
||||
return createContextSpec(providerName, identity, credential, EMPTY_LIST, _overrides);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <S, A> RestContextSpec<S, A> createContextSpec(String providerName, String identity, String credential,
|
||||
Iterable<? extends Module> wiring, Properties _overrides) {
|
||||
Iterable<? extends Module> wiring, Properties _overrides) {
|
||||
checkNotNull(providerName, "providerName");
|
||||
checkNotNull(_overrides, "overrides");
|
||||
|
||||
|
@ -291,8 +291,8 @@ public class RestContextFactory {
|
|||
String iso3166Codes = props.getProperty(providerName + "." + LocationConstants.ISO3166_CODES, null);
|
||||
String apiVersion = props.getProperty(providerName + ".apiversion", null);
|
||||
identity = props.getProperty(providerName + ".identity", props.getProperty("jclouds.identity", identity));
|
||||
credential = loadCredentialOrDefault(props, providerName + ".credential", loadCredentialOrDefault(props,
|
||||
"jclouds.credential", credential));
|
||||
credential = loadCredentialOrDefault(props, providerName + ".credential",
|
||||
loadCredentialOrDefault(props, "jclouds.credential", credential));
|
||||
String syncClassName = props.getProperty(providerName + ".sync", null);
|
||||
String asyncClassName = props.getProperty(providerName + ".async", null);
|
||||
Iterable<Module> modules = concat(Modules2.modulesForProviderInProperties(providerName, props), wiring);
|
||||
|
@ -306,13 +306,18 @@ public class RestContextFactory {
|
|||
propertiesBuilderClass = Providers.resolvePropertiesBuilderClass(providerName, props);
|
||||
sync = (Class<S>) (syncClassName != null ? Class.forName(syncClassName) : null);
|
||||
async = (Class<A>) (syncClassName != null ? Class.forName(asyncClassName) : null);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"provider %s not configured or supported. consider one of the following, as the provider name may have changed:%n%s%nIf you are sure that provider name is correct, check that the maven dependency org.jclouds.provider/%s is loaded.",
|
||||
providerName, Providers.getSupportedProviders(), providerName), e);
|
||||
} catch (Exception e) {
|
||||
propagate(e);
|
||||
assert false : "exception should have propogated " + e;
|
||||
return null;
|
||||
}
|
||||
RestContextSpec<S, A> contextSpec = new RestContextSpec<S, A>(providerName, endpoint, apiVersion, iso3166Codes,
|
||||
identity, credential, sync, async, propertiesBuilderClass, contextBuilderClass, modules);
|
||||
identity, credential, sync, async, propertiesBuilderClass, contextBuilderClass, modules);
|
||||
return contextSpec;
|
||||
}
|
||||
|
||||
|
@ -322,7 +327,7 @@ public class RestContextFactory {
|
|||
else if (properties.containsKey(property + ".resource"))
|
||||
try {
|
||||
return Strings2.toStringAndClose(RestContextFactory.class.getResourceAsStream(properties
|
||||
.getProperty(property + ".resource")));
|
||||
.getProperty(property + ".resource")));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("error reading resource: " + properties.getProperty(property + ".resource"));
|
||||
}
|
||||
|
@ -342,20 +347,20 @@ public class RestContextFactory {
|
|||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <S, A> RestContextBuilder<S, A> createContextBuilder(RestContextSpec<S, A> contextSpec,
|
||||
Properties overrides) {
|
||||
Properties overrides) {
|
||||
return createContextBuilder(contextSpec, EMPTY_LIST, overrides);
|
||||
}
|
||||
|
||||
public static <S, A> RestContextBuilder<S, A> createContextBuilder(RestContextSpec<S, A> contextSpec,
|
||||
Iterable<Module> modules) {
|
||||
Iterable<Module> modules) {
|
||||
return createContextBuilder(contextSpec, modules, NO_PROPERTIES);
|
||||
}
|
||||
|
||||
public static <S, A> RestContextBuilder<S, A> createContextBuilder(RestContextSpec<S, A> contextSpec,
|
||||
Iterable<Module> modules, Properties overrides) {
|
||||
Iterable<Module> modules, Properties overrides) {
|
||||
try {
|
||||
PropertiesBuilder builder = contextSpec.propertiesBuilderClass.getConstructor(Properties.class).newInstance(
|
||||
overrides);
|
||||
overrides);
|
||||
|
||||
builder.provider(contextSpec.provider);
|
||||
if (contextSpec.apiVersion != null)
|
||||
|
@ -368,7 +373,7 @@ public class RestContextFactory {
|
|||
builder.endpoint(contextSpec.endpoint);
|
||||
|
||||
RestContextBuilder<S, A> contextBuilder = Providers.initContextBuilder(contextSpec.contextBuilderClass,
|
||||
contextSpec.sync, contextSpec.async, builder.build());
|
||||
contextSpec.sync, contextSpec.async, builder.build());
|
||||
|
||||
contextBuilder.withModules(concat(modules, contextSpec.modules));
|
||||
|
||||
|
@ -406,7 +411,7 @@ public class RestContextFactory {
|
|||
* @see RestContextFactory#createContextBuilder(String, Iterable)
|
||||
*/
|
||||
public <S, A> RestContext<S, A> createContext(String provider, Iterable<? extends Module> wiring,
|
||||
Properties overrides) {
|
||||
Properties overrides) {
|
||||
RestContextBuilder<S, A> builder = createContextBuilder(provider, wiring, overrides);
|
||||
return buildContextUnwrappingExceptions(builder);
|
||||
}
|
||||
|
@ -415,7 +420,7 @@ public class RestContextFactory {
|
|||
* @see RestContextFactory#createContextBuilder(String, String,String, Properties)
|
||||
*/
|
||||
public <S, A> RestContext<S, A> createContext(String provider, @Nullable String identity,
|
||||
@Nullable String credential, Properties properties) {
|
||||
@Nullable String credential, Properties properties) {
|
||||
RestContextBuilder<S, A> builder = createContextBuilder(provider, identity, credential, properties);
|
||||
return buildContextUnwrappingExceptions(builder);
|
||||
}
|
||||
|
@ -424,7 +429,7 @@ public class RestContextFactory {
|
|||
* @see RestContextFactory#createContextBuilder(String, String,String, Iterable)
|
||||
*/
|
||||
public <S, A> RestContext<S, A> createContext(String provider, @Nullable String identity,
|
||||
@Nullable String credential, Iterable<? extends Module> wiring) {
|
||||
@Nullable String credential, Iterable<? extends Module> wiring) {
|
||||
RestContextBuilder<S, A> builder = createContextBuilder(provider, identity, credential, wiring);
|
||||
return buildContextUnwrappingExceptions(builder);
|
||||
}
|
||||
|
@ -433,7 +438,7 @@ public class RestContextFactory {
|
|||
* @see RestContextFactory#createContextBuilder(String, String,String, Iterable, Properties)
|
||||
*/
|
||||
public <S, A> RestContext<S, A> createContext(String provider, @Nullable String identity,
|
||||
@Nullable String credential, Iterable<? extends Module> wiring, Properties overrides) {
|
||||
@Nullable String credential, Iterable<? extends Module> wiring, Properties overrides) {
|
||||
RestContextBuilder<S, A> builder = createContextBuilder(provider, identity, credential, wiring, overrides);
|
||||
return buildContextUnwrappingExceptions(builder);
|
||||
}
|
||||
|
@ -466,7 +471,7 @@ public class RestContextFactory {
|
|||
* @see RestContextFactory#createContextBuilder(RestContextSpec, Iterable, Properties)
|
||||
*/
|
||||
public static <S, A> RestContext<S, A> createContext(RestContextSpec<S, A> contextSpec, Iterable<Module> modules,
|
||||
Properties overrides) {
|
||||
Properties overrides) {
|
||||
RestContextBuilder<S, A> builder = createContextBuilder(contextSpec, modules, overrides);
|
||||
return buildContextUnwrappingExceptions(builder);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
package org.jclouds.aws.ec2;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.Constants.PROPERTY_ISO3166_CODES;
|
||||
import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1;
|
||||
import static org.jclouds.aws.domain.Region.EU_WEST_1;
|
||||
|
@ -62,7 +63,8 @@ public class AWSEC2PropertiesBuilder extends org.jclouds.ec2.EC2PropertiesBuilde
|
|||
// authorized key executes after ssh has started
|
||||
properties.setProperty("jclouds.ssh.max_retries", "7");
|
||||
properties.setProperty("jclouds.ssh.retryable_messages",
|
||||
"Auth fail,invalid data,End of IO Stream Read,Connection reset,socket is not established");
|
||||
"Auth fail,invalid data,End of IO Stream Read,Connection reset,socket is not established");
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://ec2.us-east-1.amazonaws.com");
|
||||
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_REGIONS));
|
||||
// amazon, alestic, canonical, and rightscale
|
||||
properties.setProperty(PROPERTY_EC2_AMI_OWNERS, "137112412989,063491364108,099720109477,411009282317");
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.google.inject.Module;
|
|||
*/
|
||||
@Test(groups = "unit")
|
||||
public abstract class BaseAWSEC2AsyncClientTest<T> extends RestClientTest<T> {
|
||||
|
||||
@RequiresHttp
|
||||
@ConfiguresRestClient
|
||||
protected static class StubAWSEC2RestClientModule extends AWSEC2RestClientModule {
|
||||
|
@ -46,8 +47,8 @@ public abstract class BaseAWSEC2AsyncClientTest<T> extends RestClientTest<T> {
|
|||
@Override
|
||||
public Map<String, URI> get() {
|
||||
return ImmutableMap.<String, URI> of(Region.EU_WEST_1, URI.create("https://ec2.eu-west-1.amazonaws.com"),
|
||||
Region.US_EAST_1, URI.create("https://ec2.us-east-1.amazonaws.com"), Region.US_WEST_1, URI
|
||||
.create("https://ec2.us-west-1.amazonaws.com"));
|
||||
Region.US_EAST_1, URI.create("https://ec2.us-east-1.amazonaws.com"), Region.US_WEST_1,
|
||||
URI.create("https://ec2.us-west-1.amazonaws.com"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,11 @@ package org.jclouds.aws.s3;
|
|||
import java.io.IOException;
|
||||
import java.lang.reflect.Array;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ReturnTrueIf2xx;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.s3.S3AsyncClient;
|
||||
import org.jclouds.s3.functions.ReturnFalseIfBucketAlreadyOwnedByYouOrIllegalState;
|
||||
import org.jclouds.s3.options.PutBucketOptions;
|
||||
|
@ -41,17 +43,22 @@ public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest {
|
|||
this.provider = "aws-s3";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
return RestContextFactory.getPropertiesFromResource("/rest.properties");
|
||||
}
|
||||
|
||||
public void testPutBucketEu() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException,
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class, Array.newInstance(
|
||||
PutBucketOptions.class, 0).getClass());
|
||||
NoSuchMethodException, IOException {
|
||||
Method method = S3AsyncClient.class.getMethod("putBucketInRegion", String.class, String.class,
|
||||
Array.newInstance(PutBucketOptions.class, 0).getClass());
|
||||
HttpRequest request = processor.createRequest(method, "EU", "bucket");
|
||||
|
||||
assertRequestLineEquals(request, "PUT https://bucket." + url + "/ HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(request, "Host: bucket." + url + "\n");
|
||||
assertPayloadEquals(request,
|
||||
"<CreateBucketConfiguration><LocationConstraint>EU</LocationConstraint></CreateBucketConfiguration>",
|
||||
"text/xml", false);
|
||||
"<CreateBucketConfiguration><LocationConstraint>EU</LocationConstraint></CreateBucketConfiguration>",
|
||||
"text/xml", false);
|
||||
|
||||
assertResponseParserClassEquals(method, request, ReturnTrueIf2xx.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
|
|
Loading…
Reference in New Issue