mirror of https://github.com/apache/jclouds.git
refactored to use consistent setup*Properties methods like expect tt tests
This commit is contained in:
parent
93a5bae746
commit
f93c495c43
|
@ -18,22 +18,11 @@
|
|||
*/
|
||||
package org.jclouds.cloudloadbalancers;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.cloudloadbalancers.reference.RackspaceConstants.PROPERTY_ACCOUNT_ID;
|
||||
import static org.jclouds.cloudloadbalancers.reference.Region.DFW;
|
||||
import static org.jclouds.location.reference.LocationConstants.ENDPOINT;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGION;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import org.jclouds.cloudloadbalancers.features.BaseCloudLoadBalancersAsyncClientTest;
|
||||
import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersAsyncClientTest;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.rest.RestContextSpec;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -79,23 +68,4 @@ public class CloudLoadBalancersAsyncClientTest extends BaseCloudLoadBalancersAsy
|
|||
|
||||
}
|
||||
|
||||
protected String provider = "cloudloadbalancers";
|
||||
|
||||
@Override
|
||||
public RestContextSpec<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient> createContextSpec() {
|
||||
return new RestContextFactory(getProperties()).createContextSpec(provider, "user", "password", new Properties());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
Properties overrides = new Properties();
|
||||
overrides.setProperty(PROPERTY_ENDPOINT, "https://auth.api.rackspacecloud.com");
|
||||
overrides.setProperty(PROPERTY_API_VERSION, "1");
|
||||
overrides.setProperty(PROPERTY_REGIONS, "DFW");
|
||||
overrides.setProperty(PROPERTY_REGION + "." + DFW + "." + ENDPOINT, String
|
||||
.format("https://dfw.loadbalancers.api.rackspacecloud.com/v{%s}/{%s}", PROPERTY_API_VERSION,
|
||||
PROPERTY_ACCOUNT_ID));
|
||||
overrides.setProperty(provider + ".contextbuilder", CloudLoadBalancersContextBuilder.class.getName());
|
||||
return overrides;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,26 +18,18 @@
|
|||
*/
|
||||
package org.jclouds.cloudloadbalancers.features;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
|
||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
|
||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersContextBuilder;
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes;
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest;
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes.Builder;
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest;
|
||||
import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type;
|
||||
import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancer;
|
||||
import org.jclouds.cloudloadbalancers.functions.UnwrapLoadBalancers;
|
||||
import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersAsyncClientTest;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.rest.RestContextSpec;
|
||||
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
|
@ -61,7 +53,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudLoadBalancersAsyncClie
|
|||
HttpRequest httpRequest = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/1234/loadbalancers HTTP/1.1");
|
||||
"GET https://lon.loadbalancers.api.rackspacecloud.com/v1.0/10001786/loadbalancers HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -78,7 +70,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudLoadBalancersAsyncClie
|
|||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/1234/loadbalancers/5 HTTP/1.1");
|
||||
"GET https://lon.loadbalancers.api.rackspacecloud.com/v1.0/10001786/loadbalancers/5 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -96,7 +88,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudLoadBalancersAsyncClie
|
|||
"HTTP").port(80).virtualIPType(Type.PUBLIC).build());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"POST https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/1234/loadbalancers HTTP/1.1");
|
||||
"POST https://lon.loadbalancers.api.rackspacecloud.com/v1.0/10001786/loadbalancers HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
assertPayloadEquals(
|
||||
httpRequest,
|
||||
|
@ -117,7 +109,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudLoadBalancersAsyncClie
|
|||
"HTTP").port(80).virtualIPId(4).build());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"POST https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/1234/loadbalancers HTTP/1.1");
|
||||
"POST https://lon.loadbalancers.api.rackspacecloud.com/v1.0/10001786/loadbalancers HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
assertPayloadEquals(
|
||||
httpRequest,
|
||||
|
@ -138,7 +130,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudLoadBalancersAsyncClie
|
|||
HttpRequest httpRequest = processor.createRequest(method, 2, Builder.name("foo"));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"PUT https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/1234/loadbalancers/2 HTTP/1.1");
|
||||
"PUT https://lon.loadbalancers.api.rackspacecloud.com/v1.0/10001786/loadbalancers/2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
assertPayloadEquals(httpRequest, "{\"loadBalancer\":{\"name\":\"foo\"}}", "application/json", false);
|
||||
|
||||
|
@ -155,7 +147,7 @@ public class LoadBalancerAsyncClientTest extends BaseCloudLoadBalancersAsyncClie
|
|||
HttpRequest httpRequest = processor.createRequest(method, 5);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"DELETE https://dfw.loadbalancers.api.rackspacecloud.com/v1.0/1234/loadbalancers/5 HTTP/1.1");
|
||||
"DELETE https://lon.loadbalancers.api.rackspacecloud.com/v1.0/10001786/loadbalancers/5 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: */*\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
|
@ -173,20 +165,4 @@ public class LoadBalancerAsyncClientTest extends BaseCloudLoadBalancersAsyncClie
|
|||
};
|
||||
}
|
||||
|
||||
protected String provider = "cloudloadbalancers";
|
||||
|
||||
@Override
|
||||
public RestContextSpec<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient> createContextSpec() {
|
||||
return new RestContextFactory(getProperties()).createContextSpec(provider, "user", "password", new Properties());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
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", CloudLoadBalancersContextBuilder.class.getName());
|
||||
return overrides;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.jclouds.cloudloadbalancers.domain.LoadBalancerAttributes;
|
|||
import org.jclouds.cloudloadbalancers.domain.LoadBalancerRequest;
|
||||
import org.jclouds.cloudloadbalancers.domain.NodeRequest;
|
||||
import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type;
|
||||
import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersClientLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
|
|
@ -18,27 +18,19 @@
|
|||
*/
|
||||
package org.jclouds.cloudloadbalancers.features;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
|
||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
|
||||
import org.jclouds.cloudloadbalancers.CloudLoadBalancersContextBuilder;
|
||||
import org.jclouds.cloudloadbalancers.domain.NodeAttributes;
|
||||
import org.jclouds.cloudloadbalancers.domain.NodeAttributes.Builder;
|
||||
import org.jclouds.cloudloadbalancers.domain.NodeRequest;
|
||||
import org.jclouds.cloudloadbalancers.domain.internal.BaseNode.Condition;
|
||||
import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersAsyncClientTest;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||
import org.jclouds.http.functions.ReleasePayloadAndReturn;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.rest.RestContextSpec;
|
||||
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
||||
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
|
@ -153,20 +145,4 @@ public class NodeAsyncClientTest extends BaseCloudLoadBalancersAsyncClientTest<N
|
|||
};
|
||||
}
|
||||
|
||||
protected String provider = "cloudloadbalancers";
|
||||
|
||||
@Override
|
||||
public RestContextSpec<CloudLoadBalancersClient, CloudLoadBalancersAsyncClient> createContextSpec() {
|
||||
return new RestContextFactory(getProperties()).createContextSpec(provider, "user", "password", new Properties());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
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", CloudLoadBalancersContextBuilder.class.getName());
|
||||
return overrides;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.jclouds.cloudloadbalancers.domain.NodeAttributes;
|
|||
import org.jclouds.cloudloadbalancers.domain.NodeRequest;
|
||||
import org.jclouds.cloudloadbalancers.domain.LoadBalancer.Status;
|
||||
import org.jclouds.cloudloadbalancers.domain.VirtualIP.Type;
|
||||
import org.jclouds.cloudloadbalancers.internal.BaseCloudLoadBalancersClientLiveTest;
|
||||
import org.testng.annotations.AfterGroups;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import java.net.UnknownHostException;
|
|||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
|
||||
|
@ -43,20 +44,23 @@ import org.jclouds.cloudservers.domain.BackupSchedule;
|
|||
import org.jclouds.cloudservers.domain.DailyBackup;
|
||||
import org.jclouds.cloudservers.domain.RebootType;
|
||||
import org.jclouds.cloudservers.domain.WeeklyBackup;
|
||||
import org.jclouds.cloudservers.internal.BaseCloudServersRestClientExpectTest.TestAuthenticationServiceModule;
|
||||
import org.jclouds.cloudservers.options.CreateServerOptions;
|
||||
import org.jclouds.cloudservers.options.CreateSharedIpGroupOptions;
|
||||
import org.jclouds.cloudservers.options.ListOptions;
|
||||
import org.jclouds.cloudservers.options.RebuildServerOptions;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
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.OpenStackAuthAsyncClient.AuthenticationResponse;
|
||||
import org.jclouds.openstack.TestOpenStackAuthenticationModule;
|
||||
import org.jclouds.openstack.filters.AddTimestampQuery;
|
||||
import org.jclouds.openstack.filters.AuthenticateRequest;
|
||||
import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule.GetAuth;
|
||||
import org.jclouds.openstack.keystone.v1_1.domain.Auth;
|
||||
import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.RestClientTest;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
|
@ -71,6 +75,7 @@ import org.testng.annotations.Test;
|
|||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
|
@ -78,8 +83,9 @@ import com.google.inject.TypeLiteral;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", singleThreaded=true, testName = "CloudServersAsyncClientTest")
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during
|
||||
// surefire
|
||||
@Test(groups = "unit", singleThreaded = true, testName = "CloudServersAsyncClientTest")
|
||||
public class CloudServersAsyncClientTest extends RestClientTest<CloudServersAsyncClient> {
|
||||
private static final Class<? extends ListOptions[]> listOptionsVarargsClass = new ListOptions[] {}.getClass();
|
||||
private static final Class<? extends CreateServerOptions[]> createServerOptionsVarargsClass = new CreateServerOptions[] {}
|
||||
|
@ -890,11 +896,22 @@ public class CloudServersAsyncClientTest extends RestClientTest<CloudServersAsyn
|
|||
@RequiresHttp
|
||||
protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule {
|
||||
private TestCloudServersRestClientModule() {
|
||||
super(new TestOpenStackAuthenticationModule());
|
||||
super(new TestAuthenticationServiceModule());
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
GetAuth provideGetAuth() {
|
||||
return new GetAuth(null) {
|
||||
@Override
|
||||
public Auth apply(Credentials in) {
|
||||
return new ParseAuthTest().expected();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected URI provideServerUrl(AuthenticationResponse response) {
|
||||
protected URI provideServerUrl(Auth response) {
|
||||
return URI.create("http://serverManagementUrl");
|
||||
}
|
||||
|
||||
|
@ -904,16 +921,15 @@ public class CloudServersAsyncClientTest extends RestClientTest<CloudServersAsyn
|
|||
|
||||
@Override
|
||||
public RestContextSpec<?, ?> createContextSpec() {
|
||||
return new RestContextFactory(getProperties()).createContextSpec(provider, "user", "password", new Properties());
|
||||
return new RestContextFactory(setupRestProperties()).createContextSpec(provider, "user", "password", setupProperties());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
protected Properties setupProperties() {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,46 +34,21 @@ import com.google.common.collect.ImmutableMultimap;
|
|||
@Test(groups = "unit", testName = "CloudServersExpectTest")
|
||||
public class CloudServersExpectTest extends BaseCloudServersRestClientExpectTest {
|
||||
|
||||
HttpRequest initialAuth = HttpRequest.builder().method("GET").endpoint(URI.create("https://auth/v1.0"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("X-Auth-User", "identity")
|
||||
.put("X-Auth-Key", "credential")
|
||||
.put("Accept", "*/*").build()).build();
|
||||
|
||||
String authToken = "d6245d35-22a0-47c0-9770-2c5097da25fc";
|
||||
|
||||
HttpResponse responseWithUrls = HttpResponse.builder().statusCode(204).message("HTTP/1.1 204 No Content")
|
||||
.headers(ImmutableMultimap.<String,String>builder()
|
||||
.put("Server", "Apache/2.2.3 (Red Hat)")
|
||||
.put("vary", "X-Auth-Token,X-Auth-Key,X-Storage-User,X-Storage-Pass")
|
||||
.put("X-Storage-Url", "https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_dc1f419c-5059-4c87-a389-3f2e33a77b22")
|
||||
.put("Cache-Control", "s-maxage=86399")
|
||||
.put("Content-Type", "text/xml")
|
||||
.put("Date", "Tue, 10 Jan 2012 22:08:47 GMT")
|
||||
.put("X-Auth-Token", authToken)
|
||||
.put("X-Server-Management-Url","https://servers.api.rackspacecloud.com/v1.0/413274")
|
||||
.put("X-Storage-Token", authToken)
|
||||
.put("Connection", "Keep-Alive")
|
||||
.put("X-CDN-Management-Url", "https://cdn1.clouddrive.com/v1/MossoCloudFS_dc1f419c-5059-4c87-a389-3f2e33a77b22")
|
||||
.put("Content-Length", "0")
|
||||
.build()).build();
|
||||
|
||||
public void deleteImageReturnsTrueOn200AndFalseOn404() {
|
||||
|
||||
HttpRequest deleteImage11 = HttpRequest.builder().method("DELETE").endpoint(
|
||||
URI.create("https://servers.api.rackspacecloud.com/v1.0/413274/images/11?now=1257695648897")).headers(
|
||||
URI.create("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/11?now=1257695648897")).headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse imageDeleted = HttpResponse.builder().statusCode(204).message("HTTP/1.1 204 No Content").build();
|
||||
|
||||
CloudServersClient clientWhenImageExists = requestsSendResponses(initialAuth, responseWithUrls, deleteImage11, imageDeleted);
|
||||
CloudServersClient clientWhenImageExists = requestsSendResponses(initialAuth, responseWithAuth, deleteImage11, imageDeleted);
|
||||
assert clientWhenImageExists.deleteImage(11);
|
||||
|
||||
HttpResponse imageNotFound = HttpResponse.builder().statusCode(404).message("HTTP/1.1 404 Not Found").build();
|
||||
|
||||
CloudServersClient clientWhenImageDoesntExist = requestsSendResponses(initialAuth, responseWithUrls, deleteImage11, imageNotFound);
|
||||
CloudServersClient clientWhenImageDoesntExist = requestsSendResponses(initialAuth, responseWithAuth, deleteImage11, imageNotFound);
|
||||
assert !clientWhenImageDoesntExist.deleteImage(11);
|
||||
|
||||
}
|
||||
|
|
|
@ -40,137 +40,79 @@ public class RetryOnRenewExpectTest extends BaseCloudServersRestClientExpectTest
|
|||
|
||||
@Test
|
||||
public void testShouldReauthenticateOn401() {
|
||||
String authToken = "d6245d35-22a0-47c0-9770-2c5097da25fc";
|
||||
String authToken2 = "12345678-9012-47c0-9770-2c5097da25fc";
|
||||
|
||||
HttpRequest initialAuth = HttpRequest.builder().method("GET").endpoint(URI.create("https://auth/v1.0"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("X-Auth-User", "identity")
|
||||
.put("X-Auth-Key", "credential")
|
||||
.put("Accept", "*/*").build()).build();
|
||||
|
||||
|
||||
HttpResponse responseWithUrls = HttpResponse.builder().statusCode(204).message("HTTP/1.1 204 No Content")
|
||||
.headers(ImmutableMultimap.<String,String>builder()
|
||||
.put("Server", "Apache/2.2.3 (Red Hat)")
|
||||
.put("vary", "X-Auth-Token,X-Auth-Key,X-Storage-User,X-Storage-Pass")
|
||||
.put("X-Storage-Url", "https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_dc1f419c-5059-4c87-a389-3f2e33a77b22")
|
||||
.put("Cache-Control", "s-maxage=86399")
|
||||
.put("Content-Type", "text/xml")
|
||||
.put("Date", "Tue, 10 Jan 2012 22:08:47 GMT")
|
||||
.put("X-Auth-Token", authToken)
|
||||
.put("X-Server-Management-Url","https://servers.api.rackspacecloud.com/v1.0/413274")
|
||||
.put("X-Storage-Token", authToken)
|
||||
.put("Connection", "Keep-Alive")
|
||||
.put("X-CDN-Management-Url", "https://cdn1.clouddrive.com/v1/MossoCloudFS_dc1f419c-5059-4c87-a389-3f2e33a77b22")
|
||||
.put("Content-Length", "0")
|
||||
.build()).build();
|
||||
|
||||
HttpRequest deleteImage = HttpRequest.builder().method("DELETE").endpoint(
|
||||
URI.create("https://servers.api.rackspacecloud.com/v1.0/413274/images/11?now=1257695648897")).headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse pleaseRenew = HttpResponse.builder().statusCode(401)
|
||||
.message("HTTP/1.1 401 Unauthorized")
|
||||
.payload(Payloads.newStringPayload("[{\"unauthorized\":{\"message\":\"Invalid authentication token. Please renew.\",\"code\":401}}]"))
|
||||
.build();
|
||||
|
||||
HttpRequest deleteImage = HttpRequest.builder().method("DELETE")
|
||||
.endpoint(URI.create("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/11?now=1257695648897"))
|
||||
.headers(ImmutableMultimap.<String, String> builder().put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse pleaseRenew = HttpResponse
|
||||
.builder()
|
||||
.statusCode(401)
|
||||
.message("HTTP/1.1 401 Unauthorized")
|
||||
.payload(
|
||||
Payloads
|
||||
.newStringPayload("[{\"unauthorized\":{\"message\":\"Invalid authentication token. Please renew.\",\"code\":401}}]"))
|
||||
.build();
|
||||
|
||||
// second auth uses same creds as initial one
|
||||
HttpRequest redoAuth = initialAuth;
|
||||
|
||||
HttpResponse responseWithUrls2 = HttpResponse.builder().statusCode(204).message("HTTP/1.1 204 No Content")
|
||||
.headers(ImmutableMultimap.<String,String>builder()
|
||||
.put("Server", "Apache/2.2.3 (Red Hat)")
|
||||
.put("vary", "X-Auth-Token,X-Auth-Key,X-Storage-User,X-Storage-Pass")
|
||||
.put("X-Storage-Url", "https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_dc1f419c-5059-4c87-a389-3f2e33a77b22")
|
||||
.put("Cache-Control", "s-maxage=86399")
|
||||
.put("Content-Type", "text/xml")
|
||||
.put("Date", "Tue, 10 Jan 2012 22:08:47 GMT")
|
||||
.put("X-Auth-Token", authToken2)
|
||||
.put("X-Server-Management-Url","https://servers.api.rackspacecloud.com/v1.0/413274")
|
||||
.put("X-Storage-Token", authToken2)
|
||||
.put("Connection", "Keep-Alive")
|
||||
.put("X-CDN-Management-Url", "https://cdn1.clouddrive.com/v1/MossoCloudFS_dc1f419c-5059-4c87-a389-3f2e33a77b22")
|
||||
.put("Content-Length", "0")
|
||||
.build()).build();
|
||||
|
||||
HttpRequest deleteImage2 = HttpRequest.builder().method("DELETE").endpoint(
|
||||
URI.create("https://servers.api.rackspacecloud.com/v1.0/413274/images/11?now=1257695648897")).headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("X-Auth-Token", authToken2).build()).build();
|
||||
String authToken2 = "12345678-9012-47c0-9770-2c5097da25fc";
|
||||
|
||||
HttpResponse responseWithUrls2 = HttpResponse
|
||||
.Builder.from(responseWithAuth)
|
||||
.payload(
|
||||
Payloads.newPayload(responseWithAuth.getPayload().getRawContent().toString()
|
||||
.replace(authToken, authToken2))).build();
|
||||
|
||||
HttpRequest deleteImage2 = HttpRequest.builder().method("DELETE")
|
||||
.endpoint(URI.create("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/11?now=1257695648897"))
|
||||
.headers(ImmutableMultimap.<String, String> builder().put("X-Auth-Token", authToken2).build()).build();
|
||||
|
||||
HttpResponse imageDeleted = HttpResponse.builder().statusCode(204).message("HTTP/1.1 204 No Content").build();
|
||||
|
||||
CloudServersClient clientWhenImageExists = orderedRequestsSendResponses(initialAuth, responseWithUrls,
|
||||
deleteImage, pleaseRenew, redoAuth, responseWithUrls2, deleteImage2, imageDeleted);
|
||||
|
||||
CloudServersClient clientWhenImageExists = orderedRequestsSendResponses(initialAuth, responseWithAuth,
|
||||
deleteImage, pleaseRenew, redoAuth, responseWithUrls2, deleteImage2, imageDeleted);
|
||||
|
||||
assert clientWhenImageExists.deleteImage(11);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions=AuthorizationException.class)
|
||||
@Test(expectedExceptions = AuthorizationException.class)
|
||||
public void testDoesNotReauthenticateOnFatal401() {
|
||||
String authToken = "d6245d35-22a0-47c0-9770-2c5097da25fc";
|
||||
|
||||
HttpRequest initialAuth = HttpRequest.builder().method("GET").endpoint(URI.create("https://auth/v1.0"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("X-Auth-User", "identity")
|
||||
.put("X-Auth-Key", "credential")
|
||||
.put("Accept", "*/*").build()).build();
|
||||
|
||||
|
||||
HttpResponse responseWithUrls = HttpResponse.builder().statusCode(204).message("HTTP/1.1 204 No Content")
|
||||
.headers(ImmutableMultimap.<String,String>builder()
|
||||
.put("Server", "Apache/2.2.3 (Red Hat)")
|
||||
.put("vary", "X-Auth-Token,X-Auth-Key,X-Storage-User,X-Storage-Pass")
|
||||
.put("X-Storage-Url", "https://storage101.dfw1.clouddrive.com/v1/MossoCloudFS_dc1f419c-5059-4c87-a389-3f2e33a77b22")
|
||||
.put("Cache-Control", "s-maxage=86399")
|
||||
.put("Content-Type", "text/xml")
|
||||
.put("Date", "Tue, 10 Jan 2012 22:08:47 GMT")
|
||||
.put("X-Auth-Token", authToken)
|
||||
.put("X-Server-Management-Url","https://servers.api.rackspacecloud.com/v1.0/413274")
|
||||
.put("X-Storage-Token", authToken)
|
||||
.put("Connection", "Keep-Alive")
|
||||
.put("X-CDN-Management-Url", "https://cdn1.clouddrive.com/v1/MossoCloudFS_dc1f419c-5059-4c87-a389-3f2e33a77b22")
|
||||
.put("Content-Length", "0")
|
||||
.build()).build();
|
||||
|
||||
HttpRequest deleteImage = HttpRequest.builder().method("DELETE").endpoint(
|
||||
URI.create("https://servers.api.rackspacecloud.com/v1.0/413274/images/11?now=1257695648897")).headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("X-Auth-Token", authToken).build()).build();
|
||||
HttpRequest deleteImage = HttpRequest.builder().method("DELETE")
|
||||
.endpoint(URI.create("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/11?now=1257695648897"))
|
||||
.headers(ImmutableMultimap.<String, String> builder().put("X-Auth-Token", authToken).build()).build();
|
||||
|
||||
HttpResponse unauthResponse = HttpResponse.builder().statusCode(401)
|
||||
.message("HTTP/1.1 401 Unauthorized")
|
||||
.payload(Payloads.newStringPayload("[{\"unauthorized\":{\"message\":\"Fatal unauthorized.\",\"code\":401}}]"))
|
||||
.build();
|
||||
HttpResponse unauthResponse = HttpResponse
|
||||
.builder()
|
||||
.statusCode(401)
|
||||
.message("HTTP/1.1 401 Unauthorized")
|
||||
.payload(
|
||||
Payloads.newStringPayload("[{\"unauthorized\":{\"message\":\"Fatal unauthorized.\",\"code\":401}}]"))
|
||||
.build();
|
||||
|
||||
CloudServersClient client = orderedRequestsSendResponses(initialAuth, responseWithAuth, deleteImage,
|
||||
unauthResponse);
|
||||
|
||||
CloudServersClient client = orderedRequestsSendResponses(initialAuth, responseWithUrls,
|
||||
deleteImage, unauthResponse);
|
||||
|
||||
client.deleteImage(11);
|
||||
}
|
||||
|
||||
// FIXME stack trace shows the AuthorizationException, but it's buried inside a guice TestException
|
||||
@Test(expectedExceptions=AuthorizationException.class)
|
||||
// FIXME stack trace shows the AuthorizationException, but it's buried inside
|
||||
// a guice TestException
|
||||
@Test(expectedExceptions = AuthorizationException.class)
|
||||
public void testDoesNotReauthenticateOnAuthentication401() {
|
||||
HttpRequest initialAuth = HttpRequest.builder().method("GET").endpoint(URI.create("https://auth/v1.0"))
|
||||
.headers(
|
||||
ImmutableMultimap.<String, String> builder()
|
||||
.put("X-Auth-User", "identity")
|
||||
.put("X-Auth-Key", "credential")
|
||||
.put("Accept", "*/*").build()).build();
|
||||
|
||||
|
||||
HttpResponse unauthResponse = HttpResponse.builder().statusCode(401)
|
||||
.message("HTTP/1.1 401 Unauthorized")
|
||||
.payload(Payloads.newStringPayload("[{\"unauthorized\":{\"message\":\"A different message implying fatal.\",\"code\":401}}]"))
|
||||
.build();
|
||||
|
||||
HttpResponse unauthResponse = HttpResponse
|
||||
.builder()
|
||||
.statusCode(401)
|
||||
.message("HTTP/1.1 401 Unauthorized")
|
||||
.payload(
|
||||
Payloads
|
||||
.newStringPayload("[{\"unauthorized\":{\"message\":\"A different message implying fatal.\",\"code\":401}}]"))
|
||||
.build();
|
||||
|
||||
CloudServersClient client = requestSendsResponse(initialAuth, unauthResponse);
|
||||
|
||||
|
||||
client.deleteImage(11);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,9 +29,9 @@ import org.jclouds.cloudservers.CloudServersPropertiesBuilder;
|
|||
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.http.RequiresHttp;
|
||||
import org.jclouds.openstack.config.OpenStackAuthenticationModule;
|
||||
import org.jclouds.openstack.filters.AddTimestampQuery;
|
||||
import org.jclouds.rest.BaseRestClientExpectTest;
|
||||
import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule;
|
||||
import org.jclouds.openstack.keystone.v1_1.internal.BaseKeyStoneRestClientExpectTest;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
|
@ -42,7 +42,7 @@ import com.google.inject.Module;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class BaseCloudServersRestClientExpectTest extends BaseRestClientExpectTest<CloudServersClient> {
|
||||
public class BaseCloudServersRestClientExpectTest extends BaseKeyStoneRestClientExpectTest<CloudServersClient> {
|
||||
|
||||
public BaseCloudServersRestClientExpectTest() {
|
||||
provider = "cloudservers";
|
||||
|
@ -52,7 +52,7 @@ public class BaseCloudServersRestClientExpectTest extends BaseRestClientExpectTe
|
|||
protected Properties setupRestProperties() {
|
||||
Properties overrides = new Properties();
|
||||
overrides.setProperty(PROPERTY_REGIONS, "US");
|
||||
overrides.setProperty(provider + ".endpoint", "https://auth");
|
||||
overrides.setProperty(provider + ".endpoint", endpoint);
|
||||
overrides.setProperty(provider + ".contextbuilder", CloudServersContextBuilder.class.getName());
|
||||
overrides.setProperty(provider + ".propertiesbuilder", CloudServersPropertiesBuilder.class.getName());
|
||||
return overrides;
|
||||
|
@ -61,23 +61,14 @@ public class BaseCloudServersRestClientExpectTest extends BaseRestClientExpectTe
|
|||
protected static final String CONSTANT_DATE = "2009-11-08T15:54:08.897Z";
|
||||
|
||||
/**
|
||||
* override so that we can control the timestamp used in {@link AddTimestampQuery}
|
||||
* override so that we can control the timestamp used in
|
||||
* {@link AddTimestampQuery}
|
||||
*/
|
||||
static class TestOpenStackAuthenticationModule extends OpenStackAuthenticationModule {
|
||||
public static class TestAuthenticationServiceModule extends AuthenticationServiceModule {
|
||||
@Override
|
||||
protected void configure() {
|
||||
super.configure();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Supplier<Date> provideCacheBusterDate() {
|
||||
return new Supplier<Date>() {
|
||||
public Date get() {
|
||||
return new SimpleDateFormatDateService().iso8601DateParse(CONSTANT_DATE);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -89,8 +80,16 @@ public class BaseCloudServersRestClientExpectTest extends BaseRestClientExpectTe
|
|||
@RequiresHttp
|
||||
protected static class TestCloudServersRestClientModule extends CloudServersRestClientModule {
|
||||
private TestCloudServersRestClientModule() {
|
||||
super(new TestOpenStackAuthenticationModule());
|
||||
super(new TestAuthenticationServiceModule());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Supplier<Date> provideCacheBusterDate() {
|
||||
return new Supplier<Date>() {
|
||||
public Date get() {
|
||||
return new SimpleDateFormatDateService().iso8601DateParse(CONSTANT_DATE);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
|
@ -46,10 +45,11 @@ import org.jclouds.rest.RestContextSpec;
|
|||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
|
@ -135,19 +135,14 @@ 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* this is only here as "ec2" is not in rest.properties
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public RestContextSpec<?, ?> createContextSpec() {
|
||||
return new RestContextFactory(getProperties()).createContextSpec(provider, "identity", "credential",
|
||||
new Properties());
|
||||
return RestContextFactory.<EC2Client, EC2AsyncClient> contextSpec(provider, "https://ec2.us-east-1.amazonaws.com",
|
||||
EC2AsyncClient.VERSION, "", "", "identity", "credential", EC2Client.class, EC2AsyncClient.class,
|
||||
(Class) EC2PropertiesBuilder.class, (Class) EC2ContextBuilder.class, ImmutableSet.<Module> of());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -788,15 +788,14 @@ public class NovaAsyncClientTest extends RestClientTest<NovaAsyncClient> {
|
|||
|
||||
@Override
|
||||
public RestContextSpec<?, ?> createContextSpec() {
|
||||
return new RestContextFactory(getProperties()).createContextSpec(provider, "user", "password", new Properties());
|
||||
return new RestContextFactory(setupRestProperties()).createContextSpec(provider, "user", "password", setupProperties());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
protected Properties setupProperties() {
|
||||
Properties overrides = new Properties();
|
||||
overrides.setProperty(PROPERTY_API_VERSION, "api-version");
|
||||
overrides.setProperty(provider + ".endpoint", "http://endpoint");
|
||||
overrides.setProperty(provider + ".contextbuilder", NovaContextBuilder.class.getName());
|
||||
return overrides;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,8 +56,8 @@ public class BindAsHostPrefixIfConfiguredNoPathTest extends BaseS3AsyncClientTes
|
|||
|
||||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
Properties properties = super.getProperties();
|
||||
protected Properties setupProperties() {
|
||||
Properties properties = super.setupProperties();
|
||||
properties.setProperty(PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "false");
|
||||
return properties;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,9 @@ import com.google.inject.TypeLiteral;
|
|||
@Test(groups = "unit", testName = "BindAsHostPrefixIfConfiguredTest")
|
||||
public class BindAsHostPrefixIfConfiguredTest extends BaseS3AsyncClientTest<S3AsyncClient> {
|
||||
|
||||
public BindAsHostPrefixIfConfiguredTest(){
|
||||
endpoint = "http://euc/services/Walrus";
|
||||
}
|
||||
@Override
|
||||
protected TypeLiteral<RestAnnotationProcessor<S3AsyncClient>> createTypeLiteral() {
|
||||
return new TypeLiteral<RestAnnotationProcessor<S3AsyncClient>>() {
|
||||
|
@ -93,9 +96,8 @@ public class BindAsHostPrefixIfConfiguredTest extends BaseS3AsyncClientTest<S3As
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
Properties properties = super.getProperties();
|
||||
properties.setProperty("s3.endpoint", "http://euc/services/Walrus");
|
||||
protected Properties setupProperties() {
|
||||
Properties properties = super.setupProperties();
|
||||
properties.setProperty(PROPERTY_S3_SERVICE_PATH, "/services/Walrus");
|
||||
properties.setProperty(PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "false");
|
||||
return properties;
|
||||
|
|
|
@ -154,8 +154,9 @@ public class RequestAuthorizeSignatureTest extends BaseS3AsyncClientTest<S3Async
|
|||
assertEquals(request.getEndpoint().getHost(), "bucket.s3.amazonaws.com");
|
||||
}
|
||||
|
||||
protected Properties getProperties() {
|
||||
Properties overrides = super.getProperties();
|
||||
@Override
|
||||
protected Properties setupProperties() {
|
||||
Properties overrides = super.setupProperties();
|
||||
overrides.setProperty(PROPERTY_SESSION_INTERVAL, 1 + "");
|
||||
return overrides;
|
||||
}
|
||||
|
|
|
@ -21,13 +21,13 @@ package org.jclouds.s3.internal;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.rest.RestClientTest;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.rest.RestContextSpec;
|
||||
import org.jclouds.s3.S3AsyncClient;
|
||||
import org.jclouds.s3.S3Client;
|
||||
import org.jclouds.s3.S3ContextBuilder;
|
||||
import org.jclouds.s3.S3PropertiesBuilder;
|
||||
import org.jclouds.s3.blobstore.functions.BlobToObject;
|
||||
|
@ -35,6 +35,9 @@ import org.jclouds.s3.filters.RequestAuthorizeSignature;
|
|||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
|
@ -65,20 +68,17 @@ public abstract class BaseS3AsyncClientTest<T extends S3AsyncClient> extends Res
|
|||
}
|
||||
|
||||
protected String provider = "s3";
|
||||
protected String endpoint = "https://s3.amazonaws.com";
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
/**
|
||||
* this is only here as "s3" is not in rest.properties
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
@Override
|
||||
public RestContextSpec<?, ?> createContextSpec() {
|
||||
return new RestContextFactory(getProperties()).createContextSpec(provider, "identity", "credential",
|
||||
new Properties());
|
||||
return RestContextFactory.<S3Client, S3AsyncClient> contextSpec(provider, endpoint,
|
||||
S3AsyncClient.VERSION, "", "", "identity", "credential", S3Client.class, S3AsyncClient.class,
|
||||
(Class) S3PropertiesBuilder.class, (Class) S3ContextBuilder.class, ImmutableSet.<Module> of());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,11 +77,11 @@ public abstract class CommonSwiftClientTest<A extends CommonSwiftAsyncClient> ex
|
|||
|
||||
@Override
|
||||
public RestContextSpec<CommonSwiftClient, CommonSwiftAsyncClient> createContextSpec() {
|
||||
return new RestContextFactory().createContextSpec(provider, "user", "password", new Properties());
|
||||
return new RestContextFactory(setupRestProperties()).createContextSpec(provider, "user", "password", setupProperties());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
protected Properties setupProperties() {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty(PROPERTY_REGIONS, "US");
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://auth");
|
||||
|
|
|
@ -18,11 +18,10 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.easymock.classextension.EasyMock.verify;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
@ -32,14 +31,14 @@ import java.util.Properties;
|
|||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.vcloud.VCloudPropertiesBuilder;
|
||||
import org.jclouds.vcloud.options.CatalogItemOptions;
|
||||
import org.nnsoft.guice.rocoto.Rocoto;
|
||||
import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code BindCatalogItemToXmlPayload}
|
||||
|
@ -48,14 +47,13 @@ import com.google.inject.name.Names;
|
|||
*/
|
||||
@Test(groups = "unit")
|
||||
public class BindCatalogItemToXmlPayloadTest {
|
||||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
Injector injector = Guice.createInjector(Rocoto.expandVariables(new ConfigurationModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
Properties props = new Properties();
|
||||
Names.bindProperties(binder(), checkNotNull(new VCloudPropertiesBuilder(props).build(), "properties"));
|
||||
protected void bindConfigurations() {
|
||||
bindProperties(new VCloudPropertiesBuilder(new Properties()).build());
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
public void testDefault() throws IOException {
|
||||
String expected = "<CatalogItem xmlns=\"http://www.vmware.com/vcloud/v1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" name=\"myname\" xsi:schemaLocation=\"http://www.vmware.com/vcloud/v1 http://vcloud.safesecureweb.com/ns/vcloud.xsd\"><Description>mydescription</Description><Entity href=\"http://fooentity\"/><Property key=\"foo\">bar</Property></CatalogItem>";
|
||||
|
|
|
@ -18,11 +18,10 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.easymock.classextension.EasyMock.verify;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
@ -31,13 +30,13 @@ import java.util.Properties;
|
|||
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.vcloud.VCloudPropertiesBuilder;
|
||||
import org.nnsoft.guice.rocoto.Rocoto;
|
||||
import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code BindDeployVAppParamsToXmlPayload}
|
||||
|
@ -46,14 +45,13 @@ import com.google.inject.name.Names;
|
|||
*/
|
||||
@Test(groups = "unit")
|
||||
public class BindDeployVAppParamsToXmlPayloadTest {
|
||||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
Injector injector = Guice.createInjector(Rocoto.expandVariables(new ConfigurationModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
Properties props = new Properties();
|
||||
Names.bindProperties(binder(), checkNotNull(new VCloudPropertiesBuilder(props).build(), "properties"));
|
||||
protected void bindConfigurations() {
|
||||
bindProperties(new VCloudPropertiesBuilder(new Properties()).build());
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
public void testPowerOnTrue() throws IOException {
|
||||
String expected = "<DeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\" powerOn=\"true\"/>";
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
|
@ -44,6 +43,8 @@ import org.jclouds.vcloud.domain.network.FenceMode;
|
|||
import org.jclouds.vcloud.domain.network.NetworkConfig;
|
||||
import org.jclouds.vcloud.endpoints.Network;
|
||||
import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
|
||||
import org.nnsoft.guice.rocoto.Rocoto;
|
||||
import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
@ -54,11 +55,9 @@ import com.google.common.cache.LoadingCache;
|
|||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code BindInstantiateVAppTemplateParamsToXmlPayload}
|
||||
|
@ -69,7 +68,7 @@ import com.google.inject.name.Names;
|
|||
public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
||||
Injector createInjector(final URI vAppTemplate, final VAppTemplate value) {
|
||||
|
||||
return Guice.createInjector(new AbstractModule() {
|
||||
return Guice.createInjector(Rocoto.expandVariables(new ConfigurationModule() {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
|
@ -88,9 +87,8 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
Properties props = new Properties();
|
||||
Names.bindProperties(binder(), checkNotNull(new VCloudPropertiesBuilder(props).build(), "properties"));
|
||||
protected void bindConfigurations() {
|
||||
bindProperties(new VCloudPropertiesBuilder(new Properties()).build());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
@ -108,7 +106,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
|||
return new ReferenceTypeImpl(null, null, URI
|
||||
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1990"));
|
||||
}
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
public void testDefault() throws IOException {
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -30,13 +29,13 @@ import org.jclouds.vcloud.VCloudPropertiesBuilder;
|
|||
import org.jclouds.vcloud.domain.NetworkConnection;
|
||||
import org.jclouds.vcloud.domain.NetworkConnectionSection;
|
||||
import org.jclouds.vcloud.domain.network.IpAddressAllocationMode;
|
||||
import org.nnsoft.guice.rocoto.Rocoto;
|
||||
import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code BindNetworkConnectionSectionToXmlPayload}
|
||||
|
@ -45,14 +44,13 @@ import com.google.inject.name.Names;
|
|||
*/
|
||||
@Test(groups = "unit")
|
||||
public class BindNetworkConnectionSectionToXmlPayloadTest {
|
||||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
Injector injector = Guice.createInjector(Rocoto.expandVariables(new ConfigurationModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
Properties props = new Properties();
|
||||
Names.bindProperties(binder(), checkNotNull(new VCloudPropertiesBuilder(props).build(), "properties"));
|
||||
protected void bindConfigurations() {
|
||||
bindProperties(new VCloudPropertiesBuilder(new Properties()).build());
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
public void testWithIpAllocationModeNONE() throws IOException {
|
||||
|
||||
|
|
|
@ -18,11 +18,10 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.easymock.classextension.EasyMock.verify;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
@ -31,13 +30,13 @@ import java.util.Properties;
|
|||
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.vcloud.VCloudPropertiesBuilder;
|
||||
import org.nnsoft.guice.rocoto.Rocoto;
|
||||
import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code BindUndeployVAppParamsToXmlPayload}
|
||||
|
@ -46,15 +45,14 @@ import com.google.inject.name.Names;
|
|||
*/
|
||||
@Test(groups = "unit")
|
||||
public class BindUndeployVAppParamsToXmlPayloadTest {
|
||||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
Injector injector = Guice.createInjector(Rocoto.expandVariables(new ConfigurationModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
Properties props = new Properties();
|
||||
Names.bindProperties(binder(), checkNotNull(new VCloudPropertiesBuilder(props).build(), "properties"));
|
||||
protected void bindConfigurations() {
|
||||
bindProperties(new VCloudPropertiesBuilder(new Properties()).build());
|
||||
}
|
||||
});
|
||||
|
||||
}));
|
||||
|
||||
public void testSaveStateTrue() throws IOException {
|
||||
String expected = "<UndeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\" saveState=\"true\"/>";
|
||||
|
||||
|
|
|
@ -18,10 +18,9 @@
|
|||
*/
|
||||
package org.jclouds.trmk.vcloud_0_8.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
@ -38,6 +37,8 @@ import org.jclouds.trmk.vcloud_0_8.endpoints.Network;
|
|||
import org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions;
|
||||
import org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions.NetworkConfig;
|
||||
import org.jclouds.util.Strings2;
|
||||
import org.nnsoft.guice.rocoto.Rocoto;
|
||||
import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
|
@ -45,11 +46,9 @@ import com.google.common.collect.ImmutableList;
|
|||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.Multimaps;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code BindInstantiateVAppTemplateParamsToXmlPayload}
|
||||
|
@ -58,12 +57,11 @@ import com.google.inject.name.Names;
|
|||
*/
|
||||
@Test(groups = "unit")
|
||||
public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
||||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
Injector injector = Guice.createInjector(Rocoto.expandVariables(new ConfigurationModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
Properties props = new Properties();
|
||||
Names.bindProperties(binder(), checkNotNull(new TerremarkVCloudPropertiesBuilder(props).build(), "properties"));
|
||||
protected void bindConfigurations() {
|
||||
bindProperties(new TerremarkVCloudPropertiesBuilder(new Properties()).build());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
@ -73,7 +71,7 @@ public class BindInstantiateVAppTemplateParamsToXmlPayloadTest {
|
|||
ReferenceType provideNetwork() {
|
||||
return new ReferenceTypeImpl(null, null, URI.create("https://vcloud.safesecureweb.com/network/1990"));
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
public void testAllOptions() throws IOException {
|
||||
|
||||
|
|
|
@ -18,11 +18,10 @@
|
|||
*/
|
||||
package org.jclouds.trmk.vcloud_0_8.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.easymock.classextension.EasyMock.verify;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
import static org.jclouds.Constants.PROPERTY_API_VERSION;
|
||||
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
|
||||
import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NAME;
|
||||
|
@ -35,14 +34,13 @@ import java.util.Properties;
|
|||
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudPropertiesBuilder;
|
||||
import org.jclouds.trmk.vcloud_0_8.binders.BindNodeConfigurationToXmlPayload;
|
||||
import org.nnsoft.guice.rocoto.Rocoto;
|
||||
import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code BindNodeConfigurationToXmlPayload}
|
||||
|
@ -51,19 +49,19 @@ import com.google.inject.name.Names;
|
|||
*/
|
||||
@Test(groups = "unit")
|
||||
public class BindNodeConfigurationToXmlPayloadTest {
|
||||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
Injector injector = Guice.createInjector(Rocoto.expandVariables(new ConfigurationModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
protected void bindConfigurations() {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty(PROPERTY_API_VERSION, "0.8a-ext1.6");
|
||||
properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NAME, "vCloudExpressExtensions");
|
||||
properties.setProperty(PROPERTY_TERREMARK_EXTENSION_VERSION, "1.6");
|
||||
properties.setProperty(PROPERTY_ENDPOINT, "https://services.vcloudexpress.terremark.com/api");
|
||||
Names.bindProperties(binder(), checkNotNull(new TerremarkVCloudPropertiesBuilder(properties).build(),
|
||||
"properties"));
|
||||
bindProperties(properties);
|
||||
bindProperties(new TerremarkVCloudPropertiesBuilder(properties).build());
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
public void testChangeDescription() throws IOException {
|
||||
String expectedPayload = "<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Name>willie</Name><Enabled>true</Enabled><Description>description</Description></NodeService>";
|
||||
|
|
|
@ -18,11 +18,10 @@
|
|||
*/
|
||||
package org.jclouds.trmk.vcloud_0_8.binders;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.easymock.classextension.EasyMock.verify;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
import static org.jclouds.trmk.vcloud_0_8.domain.VAppConfiguration.Builder.changeNameTo;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -34,21 +33,20 @@ import org.jclouds.cim.ResourceAllocationSettingData;
|
|||
import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudPropertiesBuilder;
|
||||
import org.jclouds.trmk.vcloud_0_8.binders.BindVAppConfigurationToXmlPayload;
|
||||
import org.jclouds.trmk.vcloud_0_8.domain.Status;
|
||||
import org.jclouds.trmk.vcloud_0_8.domain.VAppConfiguration;
|
||||
import org.jclouds.trmk.vcloud_0_8.domain.internal.VAppImpl;
|
||||
import org.jclouds.util.Strings2;
|
||||
import org.nnsoft.guice.rocoto.Rocoto;
|
||||
import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableListMultimap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code BindVAppConfigurationToXmlPayload}
|
||||
|
@ -57,16 +55,13 @@ import com.google.inject.name.Names;
|
|||
*/
|
||||
@Test(groups = "unit")
|
||||
public class BindVAppConfigurationToXmlPayloadTest {
|
||||
Injector injector = Guice.createInjector(new AbstractModule() {
|
||||
Injector injector = Guice.createInjector(Rocoto.expandVariables(new ConfigurationModule() {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
Properties props = new Properties();
|
||||
Names
|
||||
.bindProperties(binder(), checkNotNull(new TerremarkVCloudPropertiesBuilder(props).build(),
|
||||
"properties"));
|
||||
protected void bindConfigurations() {
|
||||
bindProperties(new TerremarkVCloudPropertiesBuilder(new Properties()).build());
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
public void testChangeName() throws IOException {
|
||||
VAppImpl vApp = new VAppImpl("MyAppServer6", URI
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Properties;
|
|||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.BaseRestClientExpectTest.RegisterContext;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -67,13 +68,24 @@ public abstract class RestClientTest<T> extends BaseRestClientTest {
|
|||
RestContextSpec<?, ?> contextSpec = createContextSpec();
|
||||
|
||||
injector = createContextBuilder(contextSpec,
|
||||
ImmutableSet.of(new MockModule(), new NullLoggingModule(), createModule()), getProperties())
|
||||
ImmutableSet.of(new MockModule(), new NullLoggingModule(), createModule()), setupProperties())
|
||||
.buildInjector();
|
||||
parserFactory = injector.getInstance(ParseSax.Factory.class);
|
||||
processor = injector.getInstance(Key.get(createTypeLiteral()));
|
||||
}
|
||||
|
||||
protected Properties getProperties() {
|
||||
/**
|
||||
* override this when the provider or api is not located in rest.properties and you are not using
|
||||
* the {@link RegisterContext} annotation on your tests.
|
||||
*/
|
||||
protected Properties setupRestProperties() {
|
||||
return RestContextFactory.getPropertiesFromResource("/rest.properties");
|
||||
}
|
||||
|
||||
/**
|
||||
* override this to supply context-specific parameters during tests.
|
||||
*/
|
||||
protected Properties setupProperties() {
|
||||
return new Properties();
|
||||
}
|
||||
}
|
|
@ -40,6 +40,7 @@ import org.jclouds.io.Payload;
|
|||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.RestContextFactory;
|
||||
import org.jclouds.rest.RestContextSpec;
|
||||
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
|
@ -89,8 +90,8 @@ public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest<AWSS3
|
|||
public void testPutObject() throws ArrayIndexOutOfBoundsException, SecurityException, IllegalArgumentException,
|
||||
NoSuchMethodException, IOException {
|
||||
|
||||
Method method = AWSS3AsyncClient.class
|
||||
.getMethod("putObject", String.class, S3Object.class, PutObjectOptions[].class);
|
||||
Method method = AWSS3AsyncClient.class.getMethod("putObject", String.class, S3Object.class,
|
||||
PutObjectOptions[].class);
|
||||
HttpRequest request = processor.createRequest(method, "bucket",
|
||||
blobToS3Object.apply(BindBlobToMultipartFormTest.TEST_BLOB));
|
||||
|
||||
|
@ -153,11 +154,6 @@ public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest<AWSS3
|
|||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Properties getProperties() {
|
||||
return RestContextFactory.getPropertiesFromResource("/rest.properties");
|
||||
}
|
||||
|
||||
public void testInitiateMultipartUpload() throws SecurityException, NegativeArraySizeException,
|
||||
NoSuchMethodException {
|
||||
Method method = AWSS3AsyncClient.class.getMethod("initiateMultipartUpload", String.class, ObjectMetadata.class,
|
||||
|
@ -293,4 +289,9 @@ public class AWSS3AsyncClientTest extends org.jclouds.s3.S3AsyncClientTest<AWSS3
|
|||
return new TestAWSS3RestClientModule();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RestContextSpec<?, ?> createContextSpec() {
|
||||
Properties props = new Properties();
|
||||
return new RestContextFactory().createContextSpec(provider, "identity", "credential", props);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue