moved all code off use of RestContext except CloudStackContext, which will use it until 1.7

This commit is contained in:
adriancole 2013-04-08 23:38:02 -07:00
parent bf0a0aa781
commit 39f3dba5ef
131 changed files with 1211 additions and 1361 deletions

View File

@ -47,7 +47,6 @@ import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.predicates.SocketOpen;
import org.jclouds.rest.RestContext;
import org.jclouds.ssh.SshClient;
import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.annotations.AfterGroups;
@ -78,7 +77,6 @@ public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest
protected int maxDriveImageTime = 300;
protected String vncPassword = "Il0veVNC";
protected CloudSigmaClient client;
protected RestContext<CloudSigmaClient, CloudSigmaAsyncClient> cloudSigmaContext;
protected Predicate<HostAndPort> socketTester;
protected Predicate<DriveInfo> driveNotClaimed;
@ -88,9 +86,8 @@ public class CloudSigmaClientLiveTest extends BaseComputeServiceContextLiveTest
@Override
public void setupContext() {
super.setupContext();
cloudSigmaContext = view.unwrap();
client = cloudSigmaContext.getApi();
client = view.utils().injector().getInstance(CloudSigmaClient.class);
driveNotClaimed = retry(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, 1, SECONDS);
SocketOpen socketOpten = context.utils().injector().getInstance(SocketOpen.class);
socketTester = retry(socketOpten, maxDriveImageTime, 1, SECONDS);

View File

@ -20,7 +20,6 @@ package org.jclouds.cloudstack;
import org.jclouds.cloudstack.internal.CloudStackContextImpl;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.rest.RestContext;
import com.google.inject.ImplementedBy;
@ -33,8 +32,24 @@ import com.google.inject.ImplementedBy;
@ImplementedBy(CloudStackContextImpl.class)
public interface CloudStackContext extends ComputeServiceContext {
RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> getDomainContext();
CloudStackClient getApi();
RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> getGlobalContext();
/**
* @deprecated please use {@link #getDomainApi()} as
* async interface will be removed in jclouds 1.7.
*/
@Deprecated
org.jclouds.rest.RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> getDomainContext();
CloudStackDomainClient getDomainApi();
/**
* @deprecated please use {@link #getGlobalApi()} as
* async interface will be removed in jclouds 1.7.
*/
@Deprecated
org.jclouds.rest.RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> getGlobalContext();
CloudStackGlobalClient getGlobalApi();
}

View File

@ -22,6 +22,7 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.Context;
import org.jclouds.cloudstack.CloudStackClient;
import org.jclouds.cloudstack.CloudStackContext;
import org.jclouds.cloudstack.CloudStackDomainAsyncClient;
import org.jclouds.cloudstack.CloudStackDomainClient;
@ -31,7 +32,6 @@ import org.jclouds.compute.ComputeService;
import org.jclouds.compute.Utils;
import org.jclouds.compute.internal.ComputeServiceContextImpl;
import org.jclouds.location.Provider;
import org.jclouds.rest.RestContext;
import com.google.common.reflect.TypeToken;
@ -40,26 +40,43 @@ import com.google.common.reflect.TypeToken;
*/
@Singleton
public class CloudStackContextImpl extends ComputeServiceContextImpl implements CloudStackContext {
private final RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext;
private final RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext;
private final CloudStackClient client;
private final org.jclouds.rest.RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext;
private final org.jclouds.rest.RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext;
@Inject
public CloudStackContextImpl(@Provider Context backend, @Provider TypeToken<? extends Context> backendType,
ComputeService computeService, Utils utils,
RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext,
RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext) {
CloudStackContextImpl(@Provider Context backend, @Provider TypeToken<? extends Context> backendType,
ComputeService computeService, Utils utils, CloudStackClient client,
org.jclouds.rest.RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainContext,
org.jclouds.rest.RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalContext) {
super(backend, backendType, computeService, utils);
this.client = client;
this.domainContext = domainContext;
this.globalContext = globalContext;
}
@Override
public RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> getDomainContext() {
public CloudStackClient getApi() {
return client;
}
@Override
public CloudStackDomainClient getDomainApi() {
return domainContext.getApi();
}
@Override
public CloudStackGlobalClient getGlobalApi() {
return globalContext.getApi();
}
@Override
public org.jclouds.rest.RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> getDomainContext() {
return domainContext;
}
@Override
public RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> getGlobalContext() {
public org.jclouds.rest.RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> getGlobalContext() {
return globalContext;
}
}

View File

@ -109,7 +109,7 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien
}).annotatedWith(Memoized.class).to(NetworksForCurrentUser.class).in(Scopes.SINGLETON);
bind(new TypeLiteral<Map<String, Credentials>>() {
}).toInstance(credentialStore);
bind(CloudStackClient.class).toInstance(cloudStackContext.getApi());
bind(CloudStackClient.class).toInstance(client);
bind(new TypeLiteral<Map<NetworkType, ? extends OptionsConverter>>() {}).
toInstance(new CloudStackComputeServiceContextModule().optionsConverters());
bind(String.class).annotatedWith(Names.named(PROPERTY_SESSION_INTERVAL)).toInstance("60");

View File

@ -51,7 +51,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
}
protected void deleteNetworksInZoneWithVlanId(String zoneId, String vlanId) {
Set<Network> networks = domainAdminContext.getApi().getNetworkClient().listNetworks(
Set<Network> networks = domainAdminClient.getNetworkClient().listNetworks(
ListNetworksOptions.Builder
.isDefault(false)
.isSystem(false)
@ -63,7 +63,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
URI broadcastUri = URI.create("vlan://" + vlanId);
for (Network net : networks) {
if (broadcastUri.equals(net.getBroadcastURI())) {
String jobId = domainAdminContext.getApi().getNetworkClient().deleteNetwork(net.getId());
String jobId = domainAdminClient.getNetworkClient().deleteNetwork(net.getId());
adminJobComplete.apply(jobId);
}
}
@ -96,7 +96,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
cloudStackContext.getApi().getOfferingClient().listNetworkOfferings(specifyVLAN(true).zoneId(zoneId)), 0).getId();
// create an arbitrary network
network = domainAdminContext.getApi()
network = domainAdminClient
.getNetworkClient()
// startIP/endIP/netmask/gateway must be specified together
.createNetworkInZone(zoneId, offeringId, group, group,
@ -117,7 +117,7 @@ public class CloudStackExperimentLiveTest extends BaseCloudStackClientLiveTest {
if (nodes != null)
view.getComputeService().destroyNodesMatching(NodePredicates.inGroup(group));
if (network != null)
domainAdminContext.getApi().getNetworkClient().deleteNetwork(network.getId());
domainAdminClient.getNetworkClient().deleteNetwork(network.getId());
}
}

View File

@ -155,6 +155,6 @@ public class DomainDomainClientExpectTest extends BaseCloudStackExpectTest<Domai
@Override
protected DomainDomainClient clientFrom(CloudStackContext context) {
return context.getDomainContext().getApi().getDomainClient();
return context.getDomainApi().getDomainClient();
}
}

View File

@ -114,7 +114,7 @@ public class NetworkClientLiveTest extends BaseCloudStackClientLiveTest {
Network network = null;
try {
network = domainAdminContext.getApi()
network = domainAdminClient
.getNetworkClient()
// startIP/endIP/netmask/gateway must be specified together
.createNetworkInZone(zone.getId(), offering.getId(), name, name,

View File

@ -67,8 +67,7 @@ public class OfferingClientLiveTest extends BaseCloudStackClientLiveTest {
} catch (NoSuchElementException e) {
// This bug is present both in 2.2.8 and 2.2.12
assertTrue(Predicates.in(ImmutableSet.of("2.2.8", "2.2.12")).apply(
cloudStackContext.getProviderMetadata().getApiMetadata().getVersion()));
assertTrue(Predicates.in(ImmutableSet.of("2.2.8", "2.2.12")).apply(apiVersion));
}
}
}

View File

@ -49,7 +49,6 @@ public class SessionClientLiveTest extends BaseCloudStackClientLiveTest {
public void testCreateContextUsingUserAndPasswordAuthentication() {
skipIfNotGlobalAdmin();
String endpoint = cloudStackContext.getProviderMetadata().getEndpoint();
Account testAccount = null;
User testUser = null;
@ -79,7 +78,6 @@ public class SessionClientLiveTest extends BaseCloudStackClientLiveTest {
@Test(expectedExceptions = AuthorizationException.class)
public void testTryToGetApiKeypairWithWrongCredentials() {
String endpoint = cloudStackContext.getProviderMetadata().getEndpoint();
ApiKeyPairs.loginToEndpointAsUsernameInDomainWithPasswordAndReturnApiKeyPair(
URI.create(endpoint), "dummy-missing-user", "with-a-wrong-password", "");
}

View File

@ -21,6 +21,9 @@ package org.jclouds.cloudstack.internal;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.get;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.jclouds.cloudstack.domain.Account.Type.ADMIN;
import static org.jclouds.cloudstack.domain.Account.Type.DOMAIN_ADMIN;
import static org.jclouds.cloudstack.domain.Account.Type.USER;
import static org.jclouds.reflect.Reflection2.typeToken;
import static org.jclouds.util.Predicates2.retry;
import static org.testng.Assert.assertEquals;
@ -30,17 +33,15 @@ import java.util.Properties;
import java.util.Set;
import java.util.logging.Logger;
import org.jclouds.cloudstack.CloudStackAsyncClient;
import org.jclouds.cloudstack.CloudStackClient;
import org.jclouds.cloudstack.CloudStackContext;
import org.jclouds.cloudstack.CloudStackDomainAsyncClient;
import org.jclouds.cloudstack.CloudStackDomainClient;
import org.jclouds.cloudstack.CloudStackGlobalAsyncClient;
import org.jclouds.cloudstack.CloudStackGlobalClient;
import org.jclouds.cloudstack.domain.Account;
import org.jclouds.cloudstack.domain.Template;
import org.jclouds.cloudstack.domain.User;
import org.jclouds.cloudstack.domain.VirtualMachine;
import org.jclouds.cloudstack.features.AccountClient;
import org.jclouds.cloudstack.functions.ReuseOrAssociateNewPublicIPAddress;
import org.jclouds.cloudstack.options.ListTemplatesOptions;
import org.jclouds.cloudstack.predicates.CorrectHypervisorForZone;
@ -55,7 +56,6 @@ import org.jclouds.compute.ComputeService;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.internal.BaseGenericComputeServiceContextLiveTest;
import org.jclouds.predicates.SocketOpen;
import org.jclouds.rest.RestContext;
import org.jclouds.ssh.SshClient;
import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.SkipException;
@ -151,7 +151,7 @@ public class BaseCloudStackClientLiveTest extends BaseGenericComputeServiceConte
protected String prefix = System.getProperty("user.name");
protected ComputeService computeClient;
protected RestContext<CloudStackClient, CloudStackAsyncClient> cloudStackContext;
protected CloudStackContext cloudStackContext;
protected CloudStackClient client;
protected CloudStackClient adminClient;
protected User user;
@ -171,13 +171,11 @@ public class BaseCloudStackClientLiveTest extends BaseGenericComputeServiceConte
protected boolean domainAdminEnabled;
protected CloudStackContext domainAdminComputeContext;
protected RestContext<CloudStackDomainClient, CloudStackDomainAsyncClient> domainAdminContext;
protected CloudStackDomainClient domainAdminClient;
protected User domainAdminUser;
protected boolean globalAdminEnabled;
protected CloudStackContext globalAdminComputeContext;
protected RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient> globalAdminContext;
protected CloudStackGlobalClient globalAdminClient;
protected User globalAdminUser;
@ -200,26 +198,25 @@ public class BaseCloudStackClientLiveTest extends BaseGenericComputeServiceConte
public void setupContext() {
super.setupContext();
computeClient = view.getComputeService();
cloudStackContext = view.unwrap();
cloudStackContext = CloudStackContext.class.cast(view);
client = cloudStackContext.getApi();
user = verifyCurrentUserIsOfType(cloudStackContext, Account.Type.USER);
user = verifyCurrentUserIsOfType(identity, client.getAccountClient(), USER);
domainAdminEnabled = setupDomainAdminProperties() != null;
if (domainAdminEnabled) {
domainAdminComputeContext = createView(setupDomainAdminProperties(), setupModules());
domainAdminContext = domainAdminComputeContext.getDomainContext();
domainAdminClient = domainAdminContext.getApi();
domainAdminUser = verifyCurrentUserIsOfType(domainAdminContext, Account.Type.DOMAIN_ADMIN);
adminClient = domainAdminContext.getApi();
domainAdminClient = domainAdminComputeContext.getDomainApi();
domainAdminUser = verifyCurrentUserIsOfType(domainAdminIdentity, domainAdminClient.getAccountClient(),
DOMAIN_ADMIN);
adminClient = domainAdminClient;
}
globalAdminEnabled = setupGlobalAdminProperties() != null;
if (globalAdminEnabled) {
globalAdminComputeContext = createView(setupGlobalAdminProperties(), setupModules());
globalAdminContext = globalAdminComputeContext.getGlobalContext();
globalAdminClient = globalAdminContext.getApi();
globalAdminUser = verifyCurrentUserIsOfType(globalAdminContext, Account.Type.ADMIN);
adminClient = globalAdminContext.getApi();
globalAdminClient = globalAdminComputeContext.getGlobalApi();
globalAdminUser = verifyCurrentUserIsOfType(globalAdminIdentity, globalAdminClient.getAccountClient(), ADMIN);
adminClient = globalAdminClient;
}
injector = cloudStackContext.utils().injector();
@ -250,10 +247,9 @@ public class BaseCloudStackClientLiveTest extends BaseGenericComputeServiceConte
return new SshjSshClientModule();
}
protected static User verifyCurrentUserIsOfType(
RestContext<? extends CloudStackClient, ? extends CloudStackAsyncClient> context, Account.Type type) {
Iterable<User> users = Iterables.concat(context.getApi().getAccountClient().listAccounts());
Predicate<User> apiKeyMatches = UserPredicates.apiKeyEquals(context.getIdentity());
private static User verifyCurrentUserIsOfType(String identity, AccountClient accountClient, Account.Type type) {
Iterable<User> users = Iterables.concat(accountClient.listAccounts());
Predicate<User> apiKeyMatches = UserPredicates.apiKeyEquals(identity);
User currentUser;
try {
currentUser = Iterables.find(users, apiKeyMatches);

View File

@ -25,46 +25,29 @@ import static org.jclouds.util.Predicates2.retry;
import java.util.Date;
import java.util.Set;
import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.apis.BaseApiLiveTest;
import org.jclouds.cloudwatch.domain.Dimension;
import org.jclouds.cloudwatch.domain.MetricDatum;
import org.jclouds.cloudwatch.domain.Unit;
import org.jclouds.cloudwatch.options.ListMetricsOptions;
import org.jclouds.rest.RestContext;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.google.common.reflect.TypeToken;
/**
* Tests behavior of {@code CloudWatch}.
*
* @author Jeremy Whitlock
*/
public class CloudWatchLiveTest extends BaseContextLiveTest<RestContext<CloudWatchApi, CloudWatchAsyncApi>> {
public class CloudWatchLiveTest extends BaseApiLiveTest<CloudWatchApi> {
public CloudWatchLiveTest() {
provider = "cloudwatch";
}
private CloudWatchApi api;
@Override
@BeforeClass(groups = { "integration", "live" })
public void setupContext() {
super.setupContext();
api = context.getApi();
}
@Override
protected TypeToken<RestContext<CloudWatchApi, CloudWatchAsyncApi>> contextType() {
return CloudWatchApiMetadata.CONTEXT_TOKEN;
}
@Test
protected void testCloudWatchListMetrics() {
// Just make sure there is at least one metric returned (Much better if the account you use has more than 500)

View File

@ -303,6 +303,6 @@ public class MetricApiLiveTest extends BaseCloudWatchApiLiveTest {
}
protected MetricApi api() {
return context.getApi().getMetricApiForRegion(null);
return api.getMetricApiForRegion(null);
}
}

View File

@ -18,29 +18,17 @@
*/
package org.jclouds.cloudwatch.internal;
import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.cloudwatch.CloudWatchApiMetadata;
import org.jclouds.cloudwatch.CloudWatchAsyncApi;
import org.jclouds.apis.BaseApiLiveTest;
import org.jclouds.cloudwatch.CloudWatchApi;
import org.jclouds.rest.RestContext;
import org.testng.annotations.Test;
import com.google.common.reflect.TypeToken;
/**
*
* @author Adrian Cole
*/
@Test(groups = "live")
public class BaseCloudWatchApiLiveTest extends BaseContextLiveTest<RestContext<CloudWatchApi, CloudWatchAsyncApi>> {
public class BaseCloudWatchApiLiveTest extends BaseApiLiveTest<CloudWatchApi> {
public BaseCloudWatchApiLiveTest() {
provider = "cloudwatch";
}
@Override
protected TypeToken<RestContext<CloudWatchApi, CloudWatchAsyncApi>> contextType() {
return CloudWatchApiMetadata.CONTEXT_TOKEN;
}
}

View File

@ -77,7 +77,7 @@ public class SubnetApiLiveTest extends BaseEC2ApiLiveTest {
}
private SubnetApi api() {
Optional<? extends SubnetApi> subnetOption = context.getApi().getSubnetApi();
Optional<? extends SubnetApi> subnetOption = api.getSubnetApi();
if (!subnetOption.isPresent())
throw new SkipException("subnet api not present");
return subnetOption.get();

View File

@ -31,7 +31,7 @@ import com.google.common.base.Optional;
public class WindowsApiLiveTest extends BaseEC2ApiLiveTest {
protected WindowsApi api() {
Optional<? extends WindowsApi> windowsOption = context.getApi().getWindowsApi();
Optional<? extends WindowsApi> windowsOption = api.getWindowsApi();
if (!windowsOption.isPresent())
throw new SkipException("windows api not present");
return windowsOption.get();

View File

@ -119,8 +119,8 @@ public abstract class BaseTagApiLiveTest extends BaseEC2ApiLiveTest {
@Override
@BeforeClass(groups = "live")
public void setupContext() {
super.setupContext();
public void setup() {
super.setup();
resource = checkNotNull(createResourceForTagging(System.getProperty("user.name") + "-tag"), "resource");
}
@ -146,16 +146,16 @@ public abstract class BaseTagApiLiveTest extends BaseEC2ApiLiveTest {
protected abstract void cleanupResource(Resource resource);
protected TagApi api() {
Optional<? extends TagApi> tagOption = context.getApi().getTagApi();
Optional<? extends TagApi> tagOption = api.getTagApi();
if (!tagOption.isPresent())
throw new SkipException("tag api not present");
return tagOption.get();
}
@AfterClass(groups = "live")
protected void tearDownContext() {
protected void tearDown() {
if (resource != null)
cleanupResource(resource);
super.tearDownContext();
super.tearDown();
}
}

View File

@ -1,26 +1,14 @@
package org.jclouds.ec2.internal;
import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.apis.BaseApiLiveTest;
import org.jclouds.ec2.EC2Api;
import org.jclouds.ec2.EC2AsyncApi;
import org.jclouds.rest.RestContext;
import com.google.common.reflect.TypeToken;
/**
*
* @author Adrian Cole
*/
public class BaseEC2ApiLiveTest extends BaseContextLiveTest<RestContext<? extends EC2Api, ? extends EC2AsyncApi>> {
public class BaseEC2ApiLiveTest extends BaseApiLiveTest<EC2Api> {
public BaseEC2ApiLiveTest() {
provider = "ec2";
}
@Override
protected TypeToken<RestContext<? extends EC2Api, ? extends EC2AsyncApi>> contextType() {
return new TypeToken<RestContext<? extends EC2Api, ? extends EC2AsyncApi>>() {
};
}
}

View File

@ -1,26 +0,0 @@
package org.jclouds.ec2.internal;
import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.ec2.EC2ApiMetadata;
import org.jclouds.ec2.EC2AsyncClient;
import org.jclouds.ec2.EC2Client;
import org.jclouds.rest.RestContext;
import com.google.common.reflect.TypeToken;
/**
*
* @author Adrian Cole
*/
public class BaseEC2ClientLiveTest extends BaseContextLiveTest<RestContext<? extends EC2Client, ? extends EC2AsyncClient>> {
public BaseEC2ClientLiveTest() {
provider = "ec2";
}
@Override
protected TypeToken<RestContext<? extends EC2Client, ? extends EC2AsyncClient>> contextType() {
return EC2ApiMetadata.CONTEXT_TOKEN;
}
}

View File

@ -44,7 +44,6 @@ import org.jclouds.elasticstack.predicates.DriveClaimed;
import org.jclouds.elasticstack.util.Servers;
import org.jclouds.io.Payloads;
import org.jclouds.predicates.SocketOpen;
import org.jclouds.rest.RestContext;
import org.jclouds.ssh.SshClient;
import org.jclouds.sshj.config.SshjSshClientModule;
import org.jclouds.util.Strings2;
@ -76,7 +75,6 @@ public class ElasticStackClientLiveTest extends BaseComputeServiceContextLiveTes
protected int maxDriveImageTime = 360;
protected String vncPassword = "Il0veVNC";
protected ElasticStackClient client;
protected RestContext<ElasticStackClient, ElasticStackAsyncClient> cloudStackContext;
protected Predicate<HostAndPort> socketTester;
protected Predicate<DriveInfo> driveNotClaimed;
protected String imageId;
@ -87,7 +85,7 @@ public class ElasticStackClientLiveTest extends BaseComputeServiceContextLiveTes
super.setupContext();
imageId = view.getComputeService().templateBuilder().build().getImage().getId();
client = view.unwrap(ElasticStackApiMetadata.CONTEXT_TOKEN).getApi();
client = view.utils().injector().getInstance(ElasticStackClient.class);
driveNotClaimed = retry(Predicates.not(new DriveClaimed(client)), maxDriveImageTime, 1, SECONDS);
SocketOpen socketOpen = context.utils().injector().getInstance(SocketOpen.class);
socketTester = retry(socketOpen, maxDriveImageTime, 1, SECONDS);

View File

@ -57,16 +57,16 @@ public class VolumeAndSnapshotApiLiveTest extends BaseCinderApiLiveTest {
@BeforeClass(groups = {"integration", "live"})
@Override
public void setupContext() {
super.setupContext();
zone = Iterables.getLast(cinder.getApi().getConfiguredZones(), "nova");
volumeApi = cinder.getApi().getVolumeApiForZone(zone);
snapshotApi = cinder.getApi().getSnapshotApiForZone(zone);
public void setup() {
super.setup();
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
volumeApi = api.getVolumeApiForZone(zone);
snapshotApi = api.getSnapshotApiForZone(zone);
}
@AfterClass(groups = { "integration", "live" })
@Override
protected void tearDownContext() {
protected void tearDown() {
if (testSnapshot != null) {
assertTrue(snapshotApi.delete(testSnapshot.getId()));
assertTrue(SnapshotPredicates.awaitDeleted(snapshotApi).apply(testSnapshot));
@ -77,7 +77,7 @@ public class VolumeAndSnapshotApiLiveTest extends BaseCinderApiLiveTest {
assertTrue(VolumePredicates.awaitDeleted(volumeApi).apply(testVolume));
}
super.tearDownContext();
super.tearDown();
}
public void testCreateVolume() {

View File

@ -42,16 +42,16 @@ public class VolumeTypeApiLiveTest extends BaseCinderApiLiveTest {
@BeforeGroups(groups = {"integration", "live"})
@Override
public void setupContext() {
super.setupContext();
zone = Iterables.getLast(cinder.getApi().getConfiguredZones(), "nova");
volumeTypeApi = cinder.getApi().getVolumeTypeApiForZone(zone);
public void setup() {
super.setup();
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
volumeTypeApi = api.getVolumeTypeApiForZone(zone);
}
@AfterClass(groups = { "integration", "live" })
@Override
protected void tearDownContext() {
super.tearDownContext();
protected void tearDown() {
super.tearDown();
}
public void testListAndGetVolumeTypes() {

View File

@ -20,46 +20,25 @@ package org.jclouds.openstack.cinder.v1.internal;
import java.util.Properties;
import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.apis.BaseApiLiveTest;
import org.jclouds.openstack.cinder.v1.CinderApi;
import org.jclouds.openstack.cinder.v1.CinderApiMetadata;
import org.jclouds.openstack.cinder.v1.CinderAsyncApi;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
import org.jclouds.rest.RestContext;
import org.testng.annotations.BeforeGroups;
import com.google.common.reflect.TypeToken;
/**
* Tests behavior of CinderApi
*
* @author Everett Toews
*/
public class BaseCinderApiLiveTest extends BaseContextLiveTest<RestContext<CinderApi, CinderAsyncApi>> {
public class BaseCinderApiLiveTest extends BaseApiLiveTest<CinderApi> {
public BaseCinderApiLiveTest() {
provider = "openstack-cinder";
}
protected RestContext<CinderApi, CinderAsyncApi> cinder;
@BeforeGroups(groups = { "integration", "live" })
@Override
public void setupContext() {
super.setupContext();
cinder = context;
}
@Override
protected Properties setupProperties() {
Properties props = super.setupProperties();
setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
return props;
}
@Override
protected TypeToken<RestContext<CinderApi, CinderAsyncApi>> contextType() {
return CinderApiMetadata.CONTEXT_TOKEN;
}
}

View File

@ -33,7 +33,7 @@ import org.testng.annotations.Test;
public class KeystoneApiLiveTest extends BaseKeystoneApiLiveTest {
public void testGetApiMetaData() {
ApiMetadata result = keystoneContext.getApi().getApiMetadata();
ApiMetadata result = api.getApiMetadata();
assertNotNull(result);
assertNotNull(result.getId());
assertNotNull(result.getStatus());

View File

@ -36,7 +36,7 @@ import org.testng.annotations.Test;
public class ServiceApiLiveTest extends BaseKeystoneApiLiveTest {
public void testTenants() {
ServiceApi api = keystoneContext.getApi().getServiceApi();
ServiceApi api = this.api.getServiceApi();
Set<? extends Tenant> result = api.listTenants();
assertNotNull(result);
assertFalse(result.isEmpty());

View File

@ -37,7 +37,7 @@ import org.testng.annotations.Test;
public class TenantApiLiveTest extends BaseKeystoneApiLiveTest {
public void testTenants() {
TenantApi api = keystoneContext.getApi().getTenantApi().get();
TenantApi api = this.api.getTenantApi().get();
Set<? extends Tenant> result = api.list().concat().toSet();
assertNotNull(result);
assertFalse(result.isEmpty());
@ -54,7 +54,7 @@ public class TenantApiLiveTest extends BaseKeystoneApiLiveTest {
public void testTenantsByName() {
TenantApi api = keystoneContext.getApi().getTenantApi().get();
TenantApi api = this.api.getTenantApi().get();
for (Tenant tenant : api.list().concat()) {
Tenant aTenant = api.getByName(tenant.getName());

View File

@ -24,18 +24,21 @@ import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.AssertJUnit.assertTrue;
import java.util.Properties;
import java.util.Set;
import org.jclouds.http.HttpRequest;
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
import org.jclouds.openstack.keystone.v2_0.domain.Endpoint;
import org.jclouds.openstack.keystone.v2_0.domain.Token;
import org.jclouds.openstack.keystone.v2_0.domain.User;
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
import org.jclouds.openstack.keystone.v2_0.internal.BaseKeystoneApiLiveTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
import com.google.inject.Injector;
import com.google.inject.Module;
/**
* Tests TokenApi
@ -47,17 +50,22 @@ public class TokenApiLiveTest extends BaseKeystoneApiLiveTest {
protected String token;
@Override
protected KeystoneApi create(Properties props, Iterable<Module> modules) {
Injector injector = newBuilder().modules(modules).overrides(props).buildInjector();
grabToken(injector.getInstance(AuthenticateRequest.class));
return injector.getInstance(KeystoneApi.class);
}
// Get the token currently in use (there's currently no listTokens())
@BeforeMethod
public void grabToken() {
AuthenticateRequest ar = keystoneContext.getUtils().getInjector().getInstance(AuthenticateRequest.class);
HttpRequest test = ar.filter(HttpRequest.builder().method("GET").endpoint(context.getProviderMetadata().getEndpoint()).build());
private void grabToken(AuthenticateRequest ar) {
HttpRequest test = ar.filter(HttpRequest.builder().method("GET").endpoint(endpoint).build());
token = Iterables.getOnlyElement(test.getHeaders().get("X-Auth-Token"));
}
public void testToken() {
TokenApi api = keystoneContext.getApi().getTokenApi().get();
TokenApi api = this.api.getTokenApi().get();
assertTrue(api.isValid(token));
Token result = api.get(token);
assertNotNull(result);
@ -73,7 +81,7 @@ public class TokenApiLiveTest extends BaseKeystoneApiLiveTest {
public void testInvalidToken() {
TokenApi api = keystoneContext.getApi().getTokenApi().get();
TokenApi api = this.api.getTokenApi().get();
assertFalse(api.isValid("thisisnotarealtoken!"));
assertNull(api.get("thisisnotarealtoken!"));
@ -81,7 +89,7 @@ public class TokenApiLiveTest extends BaseKeystoneApiLiveTest {
public void testTokenEndpoints() {
TokenApi api = keystoneContext.getApi().getTokenApi().get();
TokenApi api = this.api.getTokenApi().get();
Set<? extends Endpoint> endpoints = api.listEndpointsForToken(token);
assertNotNull(endpoints);
assertFalse(endpoints.isEmpty());
@ -90,7 +98,7 @@ public class TokenApiLiveTest extends BaseKeystoneApiLiveTest {
public void testInvalidTokenEndpoints() {
TokenApi api = keystoneContext.getApi().getTokenApi().get();
TokenApi api = this.api.getTokenApi().get();
assertTrue(api.listEndpointsForToken("thisisnotarealtoken!").isEmpty());
}

View File

@ -40,7 +40,7 @@ public class UserApiLiveTest extends BaseKeystoneApiLiveTest {
public void testUsers() {
UserApi api = keystoneContext.getApi().getUserApi().get();
UserApi api = this.api.getUserApi().get();
Set<? extends User> users = api.list().concat().toSet();
assertNotNull(users);
assertFalse(users.isEmpty());
@ -53,8 +53,8 @@ public class UserApiLiveTest extends BaseKeystoneApiLiveTest {
public void testUserRolesOnTenant() {
UserApi api = keystoneContext.getApi().getUserApi().get();
Set<? extends Tenant> tenants = keystoneContext.getApi().getTenantApi().get().list().concat().toSet();
UserApi api = this.api.getUserApi().get();
Set<? extends Tenant> tenants = this.api.getTenantApi().get().list().concat().toSet();
for (User user : api.list().concat()) {
for (Tenant tenant : tenants) {
@ -69,7 +69,7 @@ public class UserApiLiveTest extends BaseKeystoneApiLiveTest {
public void testListRolesOfUser() {
UserApi api = keystoneContext.getApi().getUserApi().get();
UserApi api = this.api.getUserApi().get();
for (User user : api.list().concat()) {
Set<? extends Role> roles = api.listRolesOfUser(user.getId());
for (Role role : roles) {
@ -81,7 +81,7 @@ public class UserApiLiveTest extends BaseKeystoneApiLiveTest {
public void testUsersByName() {
UserApi api = keystoneContext.getApi().getUserApi().get();
UserApi api = this.api.getUserApi().get();
for (User user : api.list().concat()) {
User aUser = api.getByName(user.getName());
assertEquals(aUser, user);

View File

@ -20,48 +20,27 @@ package org.jclouds.openstack.keystone.v2_0.internal;
import java.util.Properties;
import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.apis.BaseApiLiveTest;
import org.jclouds.openstack.keystone.v2_0.KeystoneApi;
import org.jclouds.openstack.keystone.v2_0.KeystoneApiMetadata;
import org.jclouds.openstack.keystone.v2_0.KeystoneAsyncApi;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
import org.jclouds.rest.RestContext;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
import com.google.common.reflect.TypeToken;
/**
* Tests behavior of {@code KeystoneApi}
*
* @author Adam Lowe
*/
@Test(groups = "live")
public class BaseKeystoneApiLiveTest extends BaseContextLiveTest<RestContext<? extends KeystoneApi,? extends KeystoneAsyncApi>> {
public class BaseKeystoneApiLiveTest extends BaseApiLiveTest<KeystoneApi> {
public BaseKeystoneApiLiveTest() {
provider = "openstack-keystone";
}
protected RestContext<? extends KeystoneApi,? extends KeystoneAsyncApi> keystoneContext;
@BeforeGroups(groups = { "integration", "live" })
@Override
public void setupContext() {
super.setupContext();
keystoneContext = context;
}
@Override
protected Properties setupProperties() {
Properties props = super.setupProperties();
setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
return props;
}
@Override
protected TypeToken<RestContext<? extends KeystoneApi,? extends KeystoneAsyncApi>> contextType() {
return KeystoneApiMetadata.CONTEXT_TOKEN;
}
}

View File

@ -62,13 +62,13 @@ public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest {
@BeforeClass(groups = {"integration", "live"})
@Override
public void setupContext() {
super.setupContext();
zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
serverApi = novaContext.getApi().getServerApiForZone(zone);
extensionApi = novaContext.getApi().getExtensionApiForZone(zone);
imageApi = novaContext.getApi().getImageApiForZone(zone);
apiOption = novaContext.getApi().getServerAdminExtensionForZone(zone);
public void setup() {
super.setup();
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
serverApi = api.getServerApiForZone(zone);
extensionApi = api.getExtensionApiForZone(zone);
imageApi = api.getImageApiForZone(zone);
apiOption = api.getServerAdminExtensionForZone(zone);
if (apiOption.isPresent()) {
testServerId = createServerInZone(zone).getId();
}
@ -76,16 +76,16 @@ public class AdminActionsApiLiveTest extends BaseNovaApiLiveTest {
@AfterClass(groups = { "integration", "live" })
@Override
protected void tearDownContext() {
protected void tearDown() {
if (apiOption.isPresent()) {
if (testServerId != null) {
assertTrue(novaContext.getApi().getServerApiForZone(zone).delete(testServerId));
assertTrue(api.getServerApiForZone(zone).delete(testServerId));
}
if (backupImageId != null) {
imageApi.delete(backupImageId);
}
}
super.tearDownContext();
super.tearDown();
}
protected void skipOnAdminExtensionAbsent() {

View File

@ -52,22 +52,22 @@ public class FlavorExtraSpecsApiLiveTest extends BaseNovaApiLiveTest {
@BeforeClass(groups = {"integration", "live"})
@Override
public void setupContext() {
super.setupContext();
zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
flavorApi = novaContext.getApi().getFlavorApiForZone(zone);
apiOption = novaContext.getApi().getFlavorExtraSpecsExtensionForZone(zone);
public void setup() {
super.setup();
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
flavorApi = api.getFlavorApiForZone(zone);
apiOption = api.getFlavorExtraSpecsExtensionForZone(zone);
}
@AfterClass(groups = { "integration", "live" })
@Override
protected void tearDownContext() {
protected void tearDown() {
if (apiOption.isPresent() && testFlavor != null) {
for(String key : testSpecs.keySet()) {
assertTrue(apiOption.get().deleteMetadataKey(testFlavor.getId(), key));
}
}
super.tearDownContext();
super.tearDown();
}
public void testCreateExtraSpecs() {

View File

@ -47,8 +47,8 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest {
@Test
public void testListFloatingIPs() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
Optional<? extends FloatingIPApi> apiOption = novaContext.getApi().getFloatingIPExtensionForZone(zoneId);
for (String zoneId : api.getConfiguredZones()) {
Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPExtensionForZone(zoneId);
if (!apiOption.isPresent())
continue;
FloatingIPApi api = apiOption.get();
@ -69,8 +69,8 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest {
@Test
public void testAllocateAndDecreateFloatingIPs() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
Optional<? extends FloatingIPApi> apiOption = novaContext.getApi().getFloatingIPExtensionForZone(zoneId);
for (String zoneId : api.getConfiguredZones()) {
Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPExtensionForZone(zoneId);
if (!apiOption.isPresent())
continue;
FloatingIPApi api = apiOption.get();
@ -100,12 +100,12 @@ public class FloatingIPApiLiveTest extends BaseNovaApiLiveTest {
@Test
public void testAddAndRemoveFloatingIp() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
Optional<? extends FloatingIPApi> apiOption = novaContext.getApi().getFloatingIPExtensionForZone(zoneId);
for (String zoneId : api.getConfiguredZones()) {
Optional<? extends FloatingIPApi> apiOption = api.getFloatingIPExtensionForZone(zoneId);
if (!apiOption.isPresent())
continue;
FloatingIPApi api = apiOption.get();
ServerApi serverApi = novaContext.getApi().getServerApiForZone(zoneId);
ServerApi serverApi = this.api.getServerApiForZone(zoneId);
Server server = createServerInZone(zoneId);
FloatingIP floatingIP = api.create();
assertNotNull(floatingIP);

View File

@ -53,12 +53,12 @@ public class HostAdministrationApiLiveTest extends BaseNovaApiLiveTest {
@BeforeGroups(groups = {"integration", "live"})
@Override
public void setupContext() {
super.setupContext();
public void setup() {
super.setup();
if (identity.endsWith(":admin")) {
String zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
optApi = novaContext.getApi().getHostAdministrationExtensionForZone(zone);
String zone = Iterables.getLast(api.getConfiguredZones(), "nova");
optApi = api.getHostAdministrationExtensionForZone(zone);
}
}

View File

@ -51,20 +51,20 @@ public class HostAggregateApiLiveTest extends BaseNovaApiLiveTest {
@BeforeClass(groups = {"integration", "live"})
@Override
public void setupContext() {
super.setupContext();
String zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
apiOption = novaContext.getApi().getHostAggregateExtensionForZone(zone);
hostAdminOption = novaContext.getApi().getHostAdministrationExtensionForZone(zone);
public void setup() {
super.setup();
String zone = Iterables.getLast(api.getConfiguredZones(), "nova");
apiOption = api.getHostAggregateExtensionForZone(zone);
hostAdminOption = api.getHostAdministrationExtensionForZone(zone);
}
@AfterClass(groups = { "integration", "live" })
@Override
protected void tearDownContext() {
protected void tearDown() {
if (testAggregate != null) {
assertTrue(apiOption.get().delete(testAggregate.getId()));
}
super.tearDownContext();
super.tearDown();
}
public void testCreateAggregate() {

View File

@ -35,8 +35,8 @@ import com.google.common.collect.FluentIterable;
public class KeyPairApiLiveTest extends BaseNovaApiLiveTest {
public void testListKeyPairs() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
KeyPairApi api = novaContext.getApi().getKeyPairExtensionForZone(zoneId).get();
for (String zoneId : api.getConfiguredZones()) {
KeyPairApi api = this.api.getKeyPairExtensionForZone(zoneId).get();
FluentIterable<? extends KeyPair> keyPairsList = api.list();
assertNotNull(keyPairsList);
}
@ -44,8 +44,8 @@ public class KeyPairApiLiveTest extends BaseNovaApiLiveTest {
public void testCreateAndDeleteKeyPair() throws Exception {
final String KEYPAIR_NAME = "testkp";
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
KeyPairApi api = novaContext.getApi().getKeyPairExtensionForZone(zoneId).get();
for (String zoneId : api.getConfiguredZones()) {
KeyPairApi api = this.api.getKeyPairExtensionForZone(zoneId).get();
KeyPair keyPair = null;
try {
keyPair = api.create(KEYPAIR_NAME);
@ -62,8 +62,8 @@ public class KeyPairApiLiveTest extends BaseNovaApiLiveTest {
final String KEYPAIR_NAME = "testkp";
final String PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCrrBREFxz3002l1HuXz0+UOdJQ/mOYD5DiJwwB/TOybwIKQJPOxJWA9gBoo4k9dthTKBTaEYbzrll7iZcp59E80S6mNiAr3mUgi+x5Y8uyXeJ2Ws+h6peVyFVUu9epkwpcTd1GVfdcVWsTajwDz9+lxCDhl0RZKDFoT0scTxbj/w== nova@nv-aw2az2-api0002";
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
KeyPairApi api = novaContext.getApi().getKeyPairExtensionForZone(zoneId).get();
for (String zoneId : api.getConfiguredZones()) {
KeyPairApi api = this.api.getKeyPairExtensionForZone(zoneId).get();
KeyPair keyPair = null;
try {
keyPair = api.createWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY);

View File

@ -41,11 +41,11 @@ public class QuotaApiLiveTest extends BaseNovaApiLiveTest {
@BeforeClass(groups = {"integration", "live"})
@Override
public void setupContext() {
super.setupContext();
public void setup() {
super.setup();
tenant = identity.split(":")[0];
String zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
apiOption = novaContext.getApi().getQuotaExtensionForZone(zone);
String zone = Iterables.getLast(api.getConfiguredZones(), "nova");
apiOption = api.getQuotaExtensionForZone(zone);
}
public void testGetQuotasForCurrentTenant() {

View File

@ -41,10 +41,10 @@ public class QuotaClassApiLiveTest extends BaseNovaApiLiveTest {
@BeforeClass(groups = {"integration", "live"})
@Override
public void setupContext() {
super.setupContext();
zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
apiOption = novaContext.getApi().getQuotaClassExtensionForZone(zone);
public void setup() {
super.setup();
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
apiOption = api.getQuotaClassExtensionForZone(zone);
}
public void testUpdateAndGetQuotaClass() {

View File

@ -42,16 +42,16 @@ public class SecurityGroupApiLiveTest extends BaseNovaApiLiveTest {
public static final String SECURITY_GROUP_NAME = "testsg";
public void list() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
SecurityGroupApi api = novaContext.getApi().getSecurityGroupExtensionForZone(zoneId).get();
for (String zoneId : api.getConfiguredZones()) {
SecurityGroupApi api = this.api.getSecurityGroupExtensionForZone(zoneId).get();
Set<? extends SecurityGroup> securityGroupsList = api.list().toSet();
assertNotNull(securityGroupsList);
}
}
public void createGetAndDeleteSecurityGroup() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
SecurityGroupApi api = novaContext.getApi().getSecurityGroupExtensionForZone(zoneId).get();
for (String zoneId : api.getConfiguredZones()) {
SecurityGroupApi api = this.api.getSecurityGroupExtensionForZone(zoneId).get();
SecurityGroup securityGroup = null;
String id;
try {
@ -70,8 +70,8 @@ public class SecurityGroupApiLiveTest extends BaseNovaApiLiveTest {
}
public void createAndDeleteSecurityGroupRule() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
SecurityGroupApi api = novaContext.getApi().getSecurityGroupExtensionForZone(zoneId).get();
for (String zoneId : api.getConfiguredZones()) {
SecurityGroupApi api = this.api.getSecurityGroupExtensionForZone(zoneId).get();
SecurityGroup securityGroup = null;
try {

View File

@ -46,11 +46,11 @@ public class ServerWithSecurityGroupsApiLiveTest extends BaseNovaApiLiveTest {
@BeforeGroups(groups = {"integration", "live"})
@Override
public void setupContext() {
super.setupContext();
zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
serverApi = novaContext.getApi().getServerApiForZone(zone);
apiOption = novaContext.getApi().getServerWithSecurityGroupsExtensionForZone(zone);
public void setup() {
super.setup();
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
serverApi = api.getServerApiForZone(zone);
apiOption = api.getServerWithSecurityGroupsExtensionForZone(zone);
}
public void testGetServer() {

View File

@ -37,8 +37,8 @@ import com.google.common.base.Optional;
public class SimpleTenantUsageApiLiveTest extends BaseNovaApiLiveTest {
public void testList() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
Optional<? extends SimpleTenantUsageApi> optApi = novaContext.getApi().getSimpleTenantUsageExtensionForZone(zoneId);
for (String zoneId : api.getConfiguredZones()) {
Optional<? extends SimpleTenantUsageApi> optApi = api.getSimpleTenantUsageExtensionForZone(zoneId);
if (optApi.isPresent() && identity.endsWith(":admin")) {
SimpleTenantUsageApi api = optApi.get();
Set<? extends SimpleTenantUsage> usages = api.list().toSet();

View File

@ -44,10 +44,10 @@ public class VirtualInterfaceApiLiveTest extends BaseNovaApiLiveTest {
@BeforeClass(groups = {"integration", "live"})
@Override
public void setupContext() {
super.setupContext();
zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
apiOption = novaContext.getApi().getVirtualInterfaceExtensionForZone(zone);
public void setup() {
super.setup();
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
apiOption = api.getVirtualInterfaceExtensionForZone(zone);
}
public void testListVirtualInterfaces() {
@ -62,7 +62,7 @@ public class VirtualInterfaceApiLiveTest extends BaseNovaApiLiveTest {
}
} finally {
if (testServer != null) {
novaContext.getApi().getServerApiForZone(zone).delete(testServer.getId());
api.getServerApiForZone(zone).delete(testServer.getId());
}
}
}

View File

@ -56,15 +56,15 @@ public class VolumeApiLiveTest extends BaseNovaApiLiveTest {
@BeforeClass(groups = {"integration", "live"})
@Override
public void setupContext() {
super.setupContext();
zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
volumeOption = novaContext.getApi().getVolumeExtensionForZone(zone);
public void setup() {
super.setup();
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
volumeOption = api.getVolumeExtensionForZone(zone);
}
@AfterClass(groups = { "integration", "live" })
@Override
protected void tearDownContext() {
protected void tearDown() {
if (volumeOption.isPresent()) {
if (testSnapshot != null) {
final String snapshotId = testSnapshot.getId();
@ -85,7 +85,7 @@ public class VolumeApiLiveTest extends BaseNovaApiLiveTest {
}, 180 * 1000L).apply(volumeOption.get()));
}
}
super.tearDownContext();
super.tearDown();
}
public void testCreateVolume() {
@ -268,7 +268,7 @@ public class VolumeApiLiveTest extends BaseNovaApiLiveTest {
} finally {
if (server_id != null)
novaContext.getApi().getServerApiForZone(zone).delete(server_id);
api.getServerApiForZone(zone).delete(server_id);
}
}

View File

@ -54,16 +54,16 @@ public class VolumeAttachmentApiLiveTest extends BaseNovaApiLiveTest {
@BeforeClass(groups = {"integration", "live"})
@Override
public void setupContext() {
super.setupContext();
zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
volumeApi = novaContext.getApi().getVolumeExtensionForZone(zone);
volumeAttachmentApi = novaContext.getApi().getVolumeAttachmentExtensionForZone(zone);
public void setup() {
super.setup();
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
volumeApi = api.getVolumeExtensionForZone(zone);
volumeAttachmentApi = api.getVolumeAttachmentExtensionForZone(zone);
}
@AfterClass(groups = { "integration", "live" })
@Override
protected void tearDownContext() {
protected void tearDown() {
if (volumeApi.isPresent()) {
if (testVolume != null) {
final String volumeId = testVolume.getId();
@ -76,7 +76,7 @@ public class VolumeAttachmentApiLiveTest extends BaseNovaApiLiveTest {
}
}
super.tearDownContext();
super.tearDown();
}
public void testCreateVolume() {
@ -150,7 +150,7 @@ public class VolumeAttachmentApiLiveTest extends BaseNovaApiLiveTest {
} finally {
if (server_id != null)
novaContext.getApi().getServerApiForZone(zone).delete(server_id);
api.getServerApiForZone(zone).delete(server_id);
}
}

View File

@ -53,16 +53,16 @@ public class VolumeTypeApiLiveTest extends BaseNovaApiLiveTest {
@BeforeGroups(groups = {"integration", "live"})
@Override
public void setupContext() {
super.setupContext();
zone = Iterables.getLast(novaContext.getApi().getConfiguredZones(), "nova");
volumeTypeOption = novaContext.getApi().getVolumeTypeExtensionForZone(zone);
public void setup() {
super.setup();
zone = Iterables.getLast(api.getConfiguredZones(), "nova");
volumeTypeOption = api.getVolumeTypeExtensionForZone(zone);
}
@AfterClass(groups = { "integration", "live" })
@Override
protected void tearDownContext() {
protected void tearDown() {
if (volumeTypeOption.isPresent()) {
if (testVolumeType != null) {
final String id = testVolumeType.getId();
@ -74,7 +74,7 @@ public class VolumeTypeApiLiveTest extends BaseNovaApiLiveTest {
}, 5 * 1000L).apply(volumeTypeOption.get()));
}
}
super.tearDownContext();
super.tearDown();
}
public void testCreateVolumeType() {

View File

@ -45,7 +45,7 @@ public class ExtensionApiLiveTest extends BaseNovaApiLiveTest {
@Test(description = "GET /v${apiVersion}/{tenantId}/extensions")
public void testListExtensions() throws Exception {
for (String zoneId : zones) {
ExtensionApi api = novaContext.getApi().getExtensionApiForZone(zoneId);
ExtensionApi api = this.api.getExtensionApiForZone(zoneId);
Set<? extends Extension> response = api.list();
assertNotNull(response);
assertFalse(response.isEmpty());
@ -68,7 +68,7 @@ public class ExtensionApiLiveTest extends BaseNovaApiLiveTest {
@Test(description = "GET /v${apiVersion}/{tenantId}/extensions/{alias}", dependsOnMethods = { "testListExtensions" })
public void testGetExtensionByAlias() throws Exception {
for (String zoneId : zones) {
ExtensionApi api = novaContext.getApi().getExtensionApiForZone(zoneId);
ExtensionApi api = this.api.getExtensionApiForZone(zoneId);
Set<? extends Extension> response = api.list();
for (Extension extension : response) {
Extension details = api.get(extension.getId());

View File

@ -46,7 +46,7 @@ public class FlavorApiLiveTest extends BaseNovaApiLiveTest {
@Test(description = "GET /v${apiVersion}/{tenantId}/flavors")
public void testListFlavors() throws Exception {
for (String zoneId : zones) {
FlavorApi api = novaContext.getApi().getFlavorApiForZone(zoneId);
FlavorApi api = this.api.getFlavorApiForZone(zoneId);
Set<? extends Resource> response = api.list().concat().toSet();
assertNotNull(response);
assertFalse(response.isEmpty());
@ -66,7 +66,7 @@ public class FlavorApiLiveTest extends BaseNovaApiLiveTest {
@Test(description = "GET /v${apiVersion}/{tenantId}/flavors/detail")
public void testListFlavorsInDetail() throws Exception {
for (String zoneId : zones) {
FlavorApi api = novaContext.getApi().getFlavorApiForZone(zoneId);
FlavorApi api = this.api.getFlavorApiForZone(zoneId);
Set<? extends Flavor> response = api.listInDetail().concat().toSet();
assertNotNull(response);
assertFalse(response.isEmpty());
@ -89,7 +89,7 @@ public class FlavorApiLiveTest extends BaseNovaApiLiveTest {
@Test(description = "GET /v${apiVersion}/{tenantId}/flavors/{id}", dependsOnMethods = { "testListFlavorsInDetail" })
public void testGetFlavorById() throws Exception {
for (String zoneId : zones) {
FlavorApi api = novaContext.getApi().getFlavorApiForZone(zoneId);
FlavorApi api = this.api.getFlavorApiForZone(zoneId);
Set<? extends Flavor> response = api.listInDetail().concat().toSet();
for (Flavor flavor : response) {
Flavor details = api.get(flavor.getId());

View File

@ -41,7 +41,7 @@ public class ImageApiLiveTest extends BaseNovaApiLiveTest {
@Test(description = "GET /v${apiVersion}/{tenantId}/images")
public void testListImages() throws Exception {
for (String zoneId : zones) {
ImageApi api = novaContext.getApi().getImageApiForZone(zoneId);
ImageApi api = this.api.getImageApiForZone(zoneId);
Set<? extends Resource> response = api.list().concat().toSet();
assertNotNull(response);
assertFalse(response.isEmpty());
@ -55,8 +55,8 @@ public class ImageApiLiveTest extends BaseNovaApiLiveTest {
@Test(description = "GET /v${apiVersion}/{tenantId}/images/detail")
public void testListImagesInDetail() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
ImageApi api = novaContext.getApi().getImageApiForZone(zoneId);
for (String zoneId : api.getConfiguredZones()) {
ImageApi api = this.api.getImageApiForZone(zoneId);
Set<? extends Image> response = api.listInDetail().concat().toSet();
assertNotNull(response);
assertFalse(response.isEmpty());
@ -79,8 +79,8 @@ public class ImageApiLiveTest extends BaseNovaApiLiveTest {
@Test(description = "GET /v${apiVersion}/{tenantId}/images/{id}", dependsOnMethods = { "testListImagesInDetail" })
public void testGetImageById() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
ImageApi api = novaContext.getApi().getImageApiForZone(zoneId);
for (String zoneId : api.getConfiguredZones()) {
ImageApi api = this.api.getImageApiForZone(zoneId);
Set<? extends Image> response = api.listInDetail().concat().toSet();
for (Image image : response) {
Image details = api.get(image.getId());

View File

@ -43,7 +43,7 @@ public class ServerApiLiveTest extends BaseNovaApiLiveTest {
@Test(description = "GET /v${apiVersion}/{tenantId}/servers")
public void testListServers() throws Exception {
for (String zoneId : zones) {
ServerApi api = novaContext.getApi().getServerApiForZone(zoneId);
ServerApi api = this.api.getServerApiForZone(zoneId);
for (Resource server : api.list().concat()) {
checkResource(server);
}
@ -53,7 +53,7 @@ public class ServerApiLiveTest extends BaseNovaApiLiveTest {
@Test(description = "GET /v${apiVersion}/{tenantId}/servers/detail")
public void testListServersInDetail() throws Exception {
for (String zoneId : zones) {
ServerApi api = novaContext.getApi().getServerApiForZone(zoneId);
ServerApi api = this.api.getServerApiForZone(zoneId);
for (Server server : api.listInDetail().concat()) {
checkServer(server);
}
@ -63,7 +63,7 @@ public class ServerApiLiveTest extends BaseNovaApiLiveTest {
@Test(description = "GET /v${apiVersion}/{tenantId}/servers/{id}", dependsOnMethods = { "testListServersInDetail" })
public void testGetServerById() throws Exception {
for (String zoneId : zones) {
ServerApi api = novaContext.getApi().getServerApiForZone(zoneId);
ServerApi api = this.api.getServerApiForZone(zoneId);
for (Resource server : api.list().concat()) {
Server details = api.get(server.getId());
assertEquals(details.getId(), server.getId());

View File

@ -21,10 +21,9 @@ package org.jclouds.openstack.nova.v2_0.internal;
import java.util.Properties;
import java.util.Set;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.apis.BaseApiLiveTest;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
import org.jclouds.openstack.nova.v2_0.NovaApi;
import org.jclouds.openstack.nova.v2_0.NovaAsyncApi;
import org.jclouds.openstack.nova.v2_0.config.NovaProperties;
import org.jclouds.openstack.nova.v2_0.domain.Flavor;
import org.jclouds.openstack.nova.v2_0.domain.Server;
@ -34,7 +33,6 @@ import org.jclouds.openstack.nova.v2_0.features.FlavorApi;
import org.jclouds.openstack.nova.v2_0.features.ImageApi;
import org.jclouds.openstack.nova.v2_0.features.ServerApi;
import org.jclouds.openstack.v2_0.domain.Resource;
import org.jclouds.rest.RestContext;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@ -49,7 +47,7 @@ import com.google.common.collect.Ordering;
* @author Adrian Cole
*/
@Test(groups = "live")
public class BaseNovaApiLiveTest extends BaseComputeServiceContextLiveTest {
public class BaseNovaApiLiveTest extends BaseApiLiveTest<NovaApi> {
protected String hostName = System.getProperty("user.name").replace('.','-').toLowerCase();
public BaseNovaApiLiveTest() {
@ -57,16 +55,14 @@ public class BaseNovaApiLiveTest extends BaseComputeServiceContextLiveTest {
}
protected Set<String> zones;
protected RestContext<NovaApi, NovaAsyncApi> novaContext;
@BeforeClass(groups = { "integration", "live" })
@Override
public void setupContext() {
super.setupContext();
novaContext = view.unwrap();
zones = novaContext.getApi().getConfiguredZones();
public void setup() {
super.setup();
zones = api.getConfiguredZones();
for (String zone : zones){
ServerApi api = novaContext.getApi().getServerApiForZone(zone);
ServerApi api = this.api.getServerApiForZone(zone);
for (Resource server : api.list().concat()){
if (server.getName().equals(hostName))
api.delete(server.getId());
@ -83,7 +79,7 @@ public class BaseNovaApiLiveTest extends BaseComputeServiceContextLiveTest {
}
protected Server createServerInZone(String zoneId) {
ServerApi serverApi = novaContext.getApi().getServerApiForZone(zoneId);
ServerApi serverApi = api.getServerApiForZone(zoneId);
ServerCreated server = serverApi.create(hostName, imageIdForZone(zoneId), flavorRefForZone(zoneId));
blockUntilServerInState(server.getId(), serverApi, Status.ACTIVE);
return serverApi.get(server.getId());
@ -108,12 +104,12 @@ public class BaseNovaApiLiveTest extends BaseComputeServiceContextLiveTest {
}
protected String imageIdForZone(String zoneId) {
ImageApi imageApi = novaContext.getApi().getImageApiForZone(zoneId);
ImageApi imageApi = api.getImageApiForZone(zoneId);
return Iterables.getLast(imageApi.list().concat()).getId();
}
protected String flavorRefForZone(String zoneId) {
FlavorApi flavorApi = novaContext.getApi().getFlavorApiForZone(zoneId);
FlavorApi flavorApi = api.getFlavorApiForZone(zoneId);
return DEFAULT_FLAVOR_ORDERING.min(flavorApi.listInDetail().concat()).getId();
}

View File

@ -56,8 +56,8 @@ public class AccessRuleApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
@Override
@BeforeGroups(groups = { "live" })
public void setupContext() {
super.setupContext();
public void setup() {
super.setup();
accessRule1 = AccessRule.deny("206.160.163.21");
accessRule2 = AccessRule.deny("206.160.165.11");
@ -76,57 +76,57 @@ public class AccessRuleApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
zone = "ORD";//Iterables.getFirst(clbApi.getConfiguredZones(), null);
lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
zone = "ORD";//Iterables.getFirst(api.getConfiguredZones(), null);
lb = api.getLoadBalancerApiForZone(zone).create(createLB);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
}
@Test(dependsOnMethods = "testCreateLoadBalancer")
public void testCreateAccessList() throws Exception {
clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).create(accessRules.values());
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
api.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).create(accessRules.values());
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
assertExpectedAccessRules(accessRules);
}
@Test(dependsOnMethods = "testCreateAccessList")
public void testRemoveSingleAccessRule() throws Exception {
Iterable<AccessRuleWithId> actualAccessList = clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).list();
Iterable<AccessRuleWithId> actualAccessList = api.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).list();
AccessRuleWithId removedAccessRule = Iterables.getFirst(actualAccessList, null);
accessRules.remove(removedAccessRule.getAddress());
assertTrue(clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).delete(removedAccessRule.getId()));
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(api.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).delete(removedAccessRule.getId()));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
assertExpectedAccessRules(accessRules);
}
@Test(dependsOnMethods = "testRemoveSingleAccessRule")
public void testRemoveManyAccessRules() throws Exception {
Iterable<AccessRuleWithId> actualAccessList = clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).list();
Iterable<AccessRuleWithId> actualAccessList = api.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).list();
AccessRuleWithId removedAccessRule1 = Iterables.getFirst(actualAccessList, null);
AccessRuleWithId removedAccessRule2 = Iterables.getLast(actualAccessList);
List<Integer> removedAccessRuleIds = ImmutableList.<Integer> of(removedAccessRule1.getId(), removedAccessRule2.getId());
accessRules.remove(removedAccessRule1.getAddress());
accessRules.remove(removedAccessRule2.getAddress());
assertTrue(clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).delete(removedAccessRuleIds));
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(api.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).delete(removedAccessRuleIds));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
assertExpectedAccessRules(accessRules);
}
@Test(dependsOnMethods = "testRemoveManyAccessRules")
public void testRemoveAllAccessRules() throws Exception {
assertTrue(clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).deleteAll());
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(api.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).deleteAll());
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
assertExpectedAccessRules(new HashMap<String, AccessRule>());
}
private void assertExpectedAccessRules(Map<String, AccessRule> expectedAccessList) {
Iterable<AccessRuleWithId> actualAccessList = clbApi.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).list();
Iterable<AccessRuleWithId> actualAccessList = api.getAccessRuleApiForZoneAndLoadBalancer(zone, lb.getId()).list();
for (AccessRule actualAccessRule: actualAccessList) {
assertEquals(expectedAccessList.containsKey(actualAccessRule.getAddress()), true,
@ -136,10 +136,10 @@ public class AccessRuleApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
@Override
@AfterGroups(groups = "live")
protected void tearDownContext() {
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
clbApi.getLoadBalancerApiForZone(zone).delete(lb.getId());
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
super.tearDownContext();
protected void tearDown() {
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
api.getLoadBalancerApiForZone(zone).delete(lb.getId());
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(zone)).apply(lb));
super.tearDown();
}
}

View File

@ -49,63 +49,63 @@ public class ConnectionApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
zone = Iterables.getFirst(api.getConfiguredZones(), null);
lb = api.getLoadBalancerApiForZone(zone).create(createLB);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
}
@Test(dependsOnMethods = "testCreateLoadBalancer")
public void testCreateAndGetConnectionThrottling() throws Exception {
clbApi.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).createOrUpdateConnectionThrottle(
api.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).createOrUpdateConnectionThrottle(
ConnectionApiExpectTest.getConnectionThrottle());
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
ConnectionThrottle connectionThrottle =
clbApi.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).getConnectionThrottle();
api.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).getConnectionThrottle();
assertEquals(connectionThrottle, ConnectionApiExpectTest.getConnectionThrottle());
}
@Test(dependsOnMethods = "testCreateAndGetConnectionThrottling")
public void testRemoveAndGetConnectionThrottle() throws Exception {
assertTrue(clbApi.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).deleteConnectionThrottle());
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(api.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).deleteConnectionThrottle());
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
ConnectionThrottle connectionThrottle =
clbApi.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).getConnectionThrottle();
api.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).getConnectionThrottle();
assertNull(connectionThrottle);
}
@Test(dependsOnMethods = "testRemoveAndGetConnectionThrottle")
public void testEnableAndIsConnectionLogging() throws Exception {
clbApi.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).enableConnectionLogging();
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
api.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).enableConnectionLogging();
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
boolean isConnectionLogging =
clbApi.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).isConnectionLogging();
api.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).isConnectionLogging();
assertTrue(isConnectionLogging);
}
@Test(dependsOnMethods = "testEnableAndIsConnectionLogging")
public void testDisableAndIsConnectionLogging() throws Exception {
clbApi.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).disableConnectionLogging();
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
api.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).disableConnectionLogging();
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
boolean isConnectionLogging =
clbApi.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).isConnectionLogging();
api.getConnectionApiForZoneAndLoadBalancer(zone, lb.getId()).isConnectionLogging();
assertFalse(isConnectionLogging);
}
@Override
@AfterGroups(groups = "live")
protected void tearDownContext() {
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
clbApi.getLoadBalancerApiForZone(zone).delete(lb.getId());
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
super.tearDownContext();
protected void tearDown() {
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
api.getLoadBalancerApiForZone(zone).delete(lb.getId());
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(zone)).apply(lb));
super.tearDown();
}
}

View File

@ -46,40 +46,40 @@ public class ContentCachingApiLiveTest extends BaseCloudLoadBalancersApiLiveTest
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
zone = Iterables.getFirst(api.getConfiguredZones(), null);
lb = api.getLoadBalancerApiForZone(zone).create(createLB);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
}
@Test(dependsOnMethods = "testCreateLoadBalancer")
public void testEnableAndIsContentCaching() throws Exception {
clbApi.getContentCachingApiForZoneAndLoadBalancer(zone, lb.getId()).enable();
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
api.getContentCachingApiForZoneAndLoadBalancer(zone, lb.getId()).enable();
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
boolean isContentCaching =
clbApi.getContentCachingApiForZoneAndLoadBalancer(zone, lb.getId()).isContentCaching();
api.getContentCachingApiForZoneAndLoadBalancer(zone, lb.getId()).isContentCaching();
assertTrue(isContentCaching);
}
@Test(dependsOnMethods = "testEnableAndIsContentCaching")
public void testDisableAndIsContentCaching() throws Exception {
clbApi.getContentCachingApiForZoneAndLoadBalancer(zone, lb.getId()).disable();
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
api.getContentCachingApiForZoneAndLoadBalancer(zone, lb.getId()).disable();
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
boolean isContentCaching =
clbApi.getContentCachingApiForZoneAndLoadBalancer(zone, lb.getId()).isContentCaching();
api.getContentCachingApiForZoneAndLoadBalancer(zone, lb.getId()).isContentCaching();
assertFalse(isContentCaching);
}
@Override
@AfterGroups(groups = "live")
protected void tearDownContext() {
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
clbApi.getLoadBalancerApiForZone(zone).delete(lb.getId());
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
super.tearDownContext();
protected void tearDown() {
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
api.getLoadBalancerApiForZone(zone).delete(lb.getId());
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(zone)).apply(lb));
super.tearDown();
}
}

View File

@ -46,8 +46,8 @@ public class ErrorPageApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
@Override
@BeforeGroups(groups = { "live" })
public void setupContext() {
super.setupContext();
public void setup() {
super.setup();
contentExpected = ErrorPageApiExpectTest.getContentExpected();
contentEscaped = ErrorPageApiExpectTest.getContentEscaped();
@ -58,38 +58,38 @@ public class ErrorPageApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
zone = Iterables.getFirst(api.getConfiguredZones(), null);
lb = api.getLoadBalancerApiForZone(zone).create(createLB);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
}
@Test(dependsOnMethods = "testCreateLoadBalancer")
public void testCreateAndGetErrorPage() throws Exception {
clbApi.getErrorPageApiForZoneAndLoadBalancer(zone, lb.getId()).create(contentEscaped);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
api.getErrorPageApiForZoneAndLoadBalancer(zone, lb.getId()).create(contentEscaped);
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
String content = clbApi.getErrorPageApiForZoneAndLoadBalancer(zone, lb.getId()).get();
String content = api.getErrorPageApiForZoneAndLoadBalancer(zone, lb.getId()).get();
assertEquals(content, contentExpected);
}
@Test(dependsOnMethods = "testCreateAndGetErrorPage")
public void testRemoveAndGetErrorPage() throws Exception {
assertTrue(clbApi.getErrorPageApiForZoneAndLoadBalancer(zone, lb.getId()).delete());
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(api.getErrorPageApiForZoneAndLoadBalancer(zone, lb.getId()).delete());
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
String content = clbApi.getErrorPageApiForZoneAndLoadBalancer(zone, lb.getId()).get();
String content = api.getErrorPageApiForZoneAndLoadBalancer(zone, lb.getId()).get();
assertTrue(content.contains("Service Unavailable"));
}
@Override
@AfterGroups(groups = "live")
protected void tearDownContext() {
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
clbApi.getLoadBalancerApiForZone(zone).delete(lb.getId());
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
super.tearDownContext();
protected void tearDown() {
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
api.getLoadBalancerApiForZone(zone).delete(lb.getId());
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(zone)).apply(lb));
super.tearDown();
}
}

View File

@ -48,41 +48,41 @@ public class HealthMonitorApiLiveTest extends BaseCloudLoadBalancersApiLiveTest
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
zone = Iterables.getFirst(api.getConfiguredZones(), null);
lb = api.getLoadBalancerApiForZone(zone).create(createLB);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
}
@Test(dependsOnMethods = "testCreateLoadBalancer")
public void testCreateAndGetHealthMonitor() throws Exception {
clbApi.getHealthMonitorApiForZoneAndLoadBalancer(zone, lb.getId()).createOrUpdate(
api.getHealthMonitorApiForZoneAndLoadBalancer(zone, lb.getId()).createOrUpdate(
HealthMonitorApiExpectTest.getConnectHealthMonitor());
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
HealthMonitor healthMonitor =
clbApi.getHealthMonitorApiForZoneAndLoadBalancer(zone, lb.getId()).get();
api.getHealthMonitorApiForZoneAndLoadBalancer(zone, lb.getId()).get();
assertEquals(healthMonitor, HealthMonitorApiExpectTest.getConnectHealthMonitor());
}
@Test(dependsOnMethods = "testCreateAndGetHealthMonitor")
public void testRemoveAndGetHealthMonitor() throws Exception {
assertTrue(clbApi.getHealthMonitorApiForZoneAndLoadBalancer(zone, lb.getId()).delete());
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(api.getHealthMonitorApiForZoneAndLoadBalancer(zone, lb.getId()).delete());
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
HealthMonitor healthMonitor =
clbApi.getHealthMonitorApiForZoneAndLoadBalancer(zone, lb.getId()).get();
api.getHealthMonitorApiForZoneAndLoadBalancer(zone, lb.getId()).get();
assertNull(healthMonitor);
}
@Override
@AfterGroups(groups = "live")
protected void tearDownContext() {
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
clbApi.getLoadBalancerApiForZone(zone).delete(lb.getId());
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
super.tearDownContext();
protected void tearDown() {
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
api.getLoadBalancerApiForZone(zone).delete(lb.getId());
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(zone)).apply(lb));
super.tearDown();
}
}

View File

@ -53,20 +53,20 @@ public class LoadBalancerApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
@Override
@AfterGroups(groups = "live")
protected void tearDownContext() {
protected void tearDown() {
for (LoadBalancer lb: lbs) {
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
clbApi.getLoadBalancerApiForZone(lb.getRegion()).delete(lb.getId());
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
api.getLoadBalancerApiForZone(lb.getRegion()).delete(lb.getId());
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
}
super.tearDownContext();
super.tearDown();
}
public void testCreateLoadBalancer() throws Exception {
for (String zone: clbApi.getConfiguredZones()) {
for (String zone: api.getConfiguredZones()) {
Logger.getAnonymousLogger().info("starting lb in region " + zone);
LoadBalancer lb = clbApi.getLoadBalancerApiForZone(zone).create(
LoadBalancer lb = api.getLoadBalancerApiForZone(zone).create(
CreateLoadBalancer.builder()
.name(prefix + "-" + zone)
.protocol("HTTP")
@ -83,9 +83,9 @@ public class LoadBalancerApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
lbs.add(lb);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
LoadBalancer newLb = clbApi.getLoadBalancerApiForZone(zone).get(lb.getId());
LoadBalancer newLb = api.getLoadBalancerApiForZone(zone).get(lb.getId());
checkLBInRegion(zone, newLb, prefix + "-" + zone);
assertEquals(newLb.getStatus(), LoadBalancer.Status.ACTIVE);
@ -95,12 +95,12 @@ public class LoadBalancerApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
@Test(dependsOnMethods = "testCreateLoadBalancer")
public void testUpdateLoadBalancer() throws Exception {
for (LoadBalancer lb: lbs) {
clbApi.getLoadBalancerApiForZone(lb.getRegion()).update(lb.getId(),
api.getLoadBalancerApiForZone(lb.getRegion()).update(lb.getId(),
UpdateLoadBalancer.builder().name("foo" + "-" + lb.getRegion()).build());
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
LoadBalancer newLb = clbApi.getLoadBalancerApiForZone(lb.getRegion()).get(lb.getId());
LoadBalancer newLb = api.getLoadBalancerApiForZone(lb.getRegion()).get(lb.getId());
checkLBInRegion(newLb.getRegion(), newLb, "foo" + "-" + lb.getRegion());
assertEquals(newLb.getStatus(), LoadBalancer.Status.ACTIVE);
@ -109,9 +109,9 @@ public class LoadBalancerApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
@Test(dependsOnMethods = "testUpdateLoadBalancer")
public void testListLoadBalancers() throws Exception {
for (String zone: clbApi.getConfiguredZones()) {
for (String zone: api.getConfiguredZones()) {
Set<LoadBalancer> response = clbApi.getLoadBalancerApiForZone(zone).list().concat().toSet();
Set<LoadBalancer> response = api.getLoadBalancerApiForZone(zone).list().concat().toSet();
assertNotNull(response);
assertTrue(response.size() >= 0);
@ -131,7 +131,7 @@ public class LoadBalancerApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
// node info not available during list;
assert lb.getNodes().size() == 0 : lb;
LoadBalancer getDetails = clbApi.getLoadBalancerApiForZone(zone).get(lb.getId());
LoadBalancer getDetails = api.getLoadBalancerApiForZone(zone).get(lb.getId());
try {
assertEquals(getDetails.getRegion(), lb.getRegion());
@ -160,27 +160,27 @@ public class LoadBalancerApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
"key2", "value2",
"key3", "value3");
Metadata metadata = clbApi.getLoadBalancerApiForZone(lb.getRegion()).createMetadata(lb.getId(), metadataMap);
Metadata metadata = api.getLoadBalancerApiForZone(lb.getRegion()).createMetadata(lb.getId(), metadataMap);
assertEquals(metadata, getExpectedMetadata());
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
metadata = clbApi.getLoadBalancerApiForZone(lb.getRegion()).getMetadata(lb.getId());
metadata = api.getLoadBalancerApiForZone(lb.getRegion()).getMetadata(lb.getId());
assertEquals(metadata, getExpectedMetadata());
assertTrue(clbApi.getLoadBalancerApiForZone(lb.getRegion()).updateMetadatum(lb.getId(), metadata.getId("key1"), "key1-updated"));
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
metadata = clbApi.getLoadBalancerApiForZone(lb.getRegion()).getMetadata(lb.getId());
assertTrue(api.getLoadBalancerApiForZone(lb.getRegion()).updateMetadatum(lb.getId(), metadata.getId("key1"), "key1-updated"));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
metadata = api.getLoadBalancerApiForZone(lb.getRegion()).getMetadata(lb.getId());
assertEquals(metadata.get("key1"), "key1-updated");
assertTrue(clbApi.getLoadBalancerApiForZone(lb.getRegion()).deleteMetadatum(lb.getId(), metadata.getId("key1")));
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
metadata = clbApi.getLoadBalancerApiForZone(lb.getRegion()).getMetadata(lb.getId());
assertTrue(api.getLoadBalancerApiForZone(lb.getRegion()).deleteMetadatum(lb.getId(), metadata.getId("key1")));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
metadata = api.getLoadBalancerApiForZone(lb.getRegion()).getMetadata(lb.getId());
assertNull(metadata.get("key1"));
assertTrue(clbApi.getLoadBalancerApiForZone(lb.getRegion()).deleteMetadata(lb.getId(),
assertTrue(api.getLoadBalancerApiForZone(lb.getRegion()).deleteMetadata(lb.getId(),
ImmutableList.<Integer> of(metadata.getId("key2"), metadata.getId("key3"))));
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
metadata = clbApi.getLoadBalancerApiForZone(lb.getRegion()).getMetadata(lb.getId());
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
metadata = api.getLoadBalancerApiForZone(lb.getRegion()).getMetadata(lb.getId());
assertEquals(metadata.size(), 0);
}
}

View File

@ -57,16 +57,16 @@ public class NodeApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
private Map<LoadBalancer, Set<Node>> nodes = Maps.newHashMap();
public void testCreateLoadBalancers() {
assertTrue(clbApi.getConfiguredZones().size() > 0, "Need to have some zones!");
Logger.getAnonymousLogger().info("running against zones " + clbApi.getConfiguredZones());
for (String zone : clbApi.getConfiguredZones()) {
assertTrue(api.getConfiguredZones().size() > 0, "Need to have some zones!");
Logger.getAnonymousLogger().info("running against zones " + api.getConfiguredZones());
for (String zone : api.getConfiguredZones()) {
Logger.getAnonymousLogger().info("starting lb in zone " + zone);
LoadBalancer lb = clbApi.getLoadBalancerApiForZone(zone).create(
LoadBalancer lb = api.getLoadBalancerApiForZone(zone).create(
CreateLoadBalancer.builder().name(prefix + "-" + zone).protocol("HTTP").port(80).virtualIPType(
Type.PUBLIC).node(AddNode.builder().address("192.168.1.1").port(8080).build()).build());
nodes.put(lb, new HashSet<Node>());
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
}
}
@ -77,17 +77,17 @@ public class NodeApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
Set<Node> nodeSet = entry.getValue();
String region = lb.getRegion();
Logger.getAnonymousLogger().info("starting node on loadbalancer " + lb.getId() + " in region " + region);
Set<Node> newNodes = clbApi.getNodeApiForZoneAndLoadBalancer(region, lb.getId()).add(
Set<Node> newNodes = api.getNodeApiForZoneAndLoadBalancer(region, lb.getId()).add(
ImmutableSet.<AddNode> of(AddNode.builder().address("192.168.1.2").port(8080).build()));
for (Node n : newNodes) {
assertEquals(n.getStatus(), Node.Status.ONLINE);
nodeSet.add(n);
assertEquals(clbApi.getNodeApiForZoneAndLoadBalancer(region, lb.getId()).get(n.getId()).getStatus(),
assertEquals(api.getNodeApiForZoneAndLoadBalancer(region, lb.getId()).get(n.getId()).getStatus(),
Node.Status.ONLINE);
}
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
}
}
@ -96,12 +96,12 @@ public class NodeApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
for (Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) {
for (Node n : entry.getValue()) {
String region = entry.getKey().getRegion();
clbApi.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).update(n.getId(),
api.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).update(n.getId(),
UpdateNode.builder().weight(23).build());
assertEquals(clbApi.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).get(n.getId())
assertEquals(api.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).get(n.getId())
.getStatus(), Node.Status.ONLINE);
Node newNode = clbApi.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).get(n.getId());
Node newNode = api.getNodeApiForZoneAndLoadBalancer(region, entry.getKey().getId()).get(n.getId());
assertEquals(newNode.getStatus(), Node.Status.ONLINE);
assertEquals(newNode.getWeight(), (Integer) 23);
}
@ -111,7 +111,7 @@ public class NodeApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
@Test(dependsOnMethods = "testModifyNode")
public void testListNodes() throws Exception {
for (LoadBalancer lb : nodes.keySet()) {
Set<Node> response = clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).list().concat().toSet();
Set<Node> response = api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).list().concat().toSet();
assert null != response;
assertTrue(response.size() >= 0);
for (Node n : response) {
@ -123,7 +123,7 @@ public class NodeApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
assert !Arrays.asList(LoadBalancer.WEIGHTED_ALGORITHMS).contains(lb.getAlgorithm())
|| n.getWeight() != null : n;
Node getDetails = clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).get(n.getId());
Node getDetails = api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).get(n.getId());
try {
assertEquals(getDetails.getId(), n.getId());
@ -151,45 +151,45 @@ public class NodeApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
"key2", "value2",
"key3", "value3");
Metadata metadata = clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).createMetadata(node.getId(), metadataMap);
Metadata metadata = api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).createMetadata(node.getId(), metadataMap);
assertEquals(metadata, getExpectedMetadata());
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
metadata = clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).getMetadata(node.getId());
metadata = api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).getMetadata(node.getId());
assertEquals(metadata, getExpectedMetadata());
assertTrue(clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).updateMetadatum(node.getId(), metadata.getId("key1"), "key1-updated"));
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
metadata = clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).getMetadata(node.getId());
assertTrue(api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).updateMetadatum(node.getId(), metadata.getId("key1"), "key1-updated"));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
metadata = api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).getMetadata(node.getId());
assertEquals(metadata.get("key1"), "key1-updated");
assertTrue(clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).deleteMetadatum(node.getId(), metadata.getId("key1")));
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
metadata = clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).getMetadata(node.getId());
assertTrue(api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).deleteMetadatum(node.getId(), metadata.getId("key1")));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
metadata = api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).getMetadata(node.getId());
assertNull(metadata.get("key1"));
assertTrue(clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).deleteMetadata(node.getId(),
assertTrue(api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).deleteMetadata(node.getId(),
ImmutableList.<Integer> of(metadata.getId("key2"), metadata.getId("key3"))));
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
metadata = clbApi.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).getMetadata(node.getId());
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
metadata = api.getNodeApiForZoneAndLoadBalancer(lb.getRegion(), lb.getId()).getMetadata(node.getId());
assertEquals(metadata.size(), 0);
}
}
@Override
@AfterGroups(groups = "live")
protected void tearDownContext() {
protected void tearDown() {
for (Entry<LoadBalancer, Set<Node>> entry : nodes.entrySet()) {
LoadBalancer lb = entry.getKey();
LoadBalancerApi lbClient = clbApi.getLoadBalancerApiForZone(lb.getRegion());
LoadBalancerApi lbClient = api.getLoadBalancerApiForZone(lb.getRegion());
if (lbClient.get(lb.getId()).getStatus() != Status.DELETED) {
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
lbClient.delete(lb.getId());
}
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(lb.getRegion())).apply(lb));
}
super.tearDownContext();
super.tearDown();
}
private Metadata getExpectedMetadata() {

View File

@ -56,10 +56,10 @@ public class ReportApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
zone = Iterables.getFirst(api.getConfiguredZones(), null);
lb = api.getLoadBalancerApiForZone(zone).create(createLB);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
}
@Test(dependsOnMethods = "testCreateLoadBalancer")
@ -69,20 +69,20 @@ public class ReportApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
Date yesterday = calendar.getTime();
Date today = new Date();
FluentIterable<LoadBalancer> loadBalancers = clbApi.getReportApiForZone(zone).listBillableLoadBalancers(yesterday, today).concat();
FluentIterable<LoadBalancer> loadBalancers = api.getReportApiForZone(zone).listBillableLoadBalancers(yesterday, today).concat();
assertNotNull(loadBalancers);
HistoricalUsage historicalUsage = clbApi.getReportApiForZone(zone).getHistoricalUsage(yesterday, today);
HistoricalUsage historicalUsage = api.getReportApiForZone(zone).getHistoricalUsage(yesterday, today);
assertNotEquals(historicalUsage.getAccountId(), 0);
FluentIterable<LoadBalancerUsage> loadBalancerUsages = clbApi.getReportApiForZone(zone).listLoadBalancerUsage(lb.getId(), yesterday, today).concat();
FluentIterable<LoadBalancerUsage> loadBalancerUsages = api.getReportApiForZone(zone).listLoadBalancerUsage(lb.getId(), yesterday, today).concat();
assertNotNull(loadBalancerUsages);
loadBalancerUsages = clbApi.getReportApiForZone(zone).listCurrentLoadBalancerUsage(lb.getId()).concat();
loadBalancerUsages = api.getReportApiForZone(zone).listCurrentLoadBalancerUsage(lb.getId()).concat();
assertNotNull(loadBalancerUsages);
try {
LoadBalancerStats loadBalancerStats = clbApi.getReportApiForZone(zone).getLoadBalancerStats(lb.getId());
LoadBalancerStats loadBalancerStats = api.getReportApiForZone(zone).getLoadBalancerStats(lb.getId());
assertNotNull(loadBalancerStats);
}
catch (HttpResponseException e) {
@ -92,19 +92,19 @@ public class ReportApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
}
}
Iterable<Protocol> protocols = clbApi.getReportApiForZone(zone).listProtocols();
Iterable<Protocol> protocols = api.getReportApiForZone(zone).listProtocols();
assertTrue(!Iterables.isEmpty(protocols));
Iterable<String> algorithms = clbApi.getReportApiForZone(zone).listAlgorithms();
Iterable<String> algorithms = api.getReportApiForZone(zone).listAlgorithms();
assertTrue(!Iterables.isEmpty(algorithms));
}
@Override
@AfterGroups(groups = "live")
protected void tearDownContext() {
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
clbApi.getLoadBalancerApiForZone(zone).delete(lb.getId());
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
super.tearDownContext();
protected void tearDown() {
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
api.getLoadBalancerApiForZone(zone).delete(lb.getId());
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(zone)).apply(lb));
super.tearDown();
}
}

View File

@ -48,41 +48,41 @@ public class SSLTerminationApiLiveTest extends BaseCloudLoadBalancersApiLiveTest
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
zone = Iterables.getFirst(api.getConfiguredZones(), null);
lb = api.getLoadBalancerApiForZone(zone).create(createLB);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
}
@Test(dependsOnMethods = "testCreateLoadBalancer")
public void testCreateAndGetSSLTermination() throws Exception {
clbApi.getSSLTerminationApiForZoneAndLoadBalancer(zone, lb.getId()).createOrUpdate(
api.getSSLTerminationApiForZoneAndLoadBalancer(zone, lb.getId()).createOrUpdate(
SSLTerminationApiExpectTest.getSSLTermination());
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
SSLTermination sslTermination =
clbApi.getSSLTerminationApiForZoneAndLoadBalancer(zone, lb.getId()).get();
api.getSSLTerminationApiForZoneAndLoadBalancer(zone, lb.getId()).get();
assertEquals(sslTermination, SSLTerminationApiExpectTest.getSSLTermination());
}
@Test(dependsOnMethods = "testCreateAndGetSSLTermination")
public void testRemoveAndGetSSLTermination() throws Exception {
assertTrue(clbApi.getSSLTerminationApiForZoneAndLoadBalancer(zone, lb.getId()).delete());
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(api.getSSLTerminationApiForZoneAndLoadBalancer(zone, lb.getId()).delete());
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
SSLTermination sslTermination =
clbApi.getSSLTerminationApiForZoneAndLoadBalancer(zone, lb.getId()).get();
api.getSSLTerminationApiForZoneAndLoadBalancer(zone, lb.getId()).get();
assertNull(sslTermination);
}
@Override
@AfterGroups(groups = "live")
protected void tearDownContext() {
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
clbApi.getLoadBalancerApiForZone(zone).delete(lb.getId());
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
super.tearDownContext();
protected void tearDown() {
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
api.getLoadBalancerApiForZone(zone).delete(lb.getId());
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(zone)).apply(lb));
super.tearDown();
}
}

View File

@ -48,40 +48,40 @@ public class SessionPersistenceApiLiveTest extends BaseCloudLoadBalancersApiLive
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
zone = Iterables.getFirst(api.getConfiguredZones(), null);
lb = api.getLoadBalancerApiForZone(zone).create(createLB);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
}
@Test(dependsOnMethods = "testCreateLoadBalancer")
public void testCreateAndGetSessionPersistence() throws Exception {
clbApi.getSessionPersistenceApiForZoneAndLoadBalancer(zone, lb.getId()).create(SessionPersistence.HTTP_COOKIE);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
api.getSessionPersistenceApiForZoneAndLoadBalancer(zone, lb.getId()).create(SessionPersistence.HTTP_COOKIE);
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
SessionPersistence sessionPersistence =
clbApi.getSessionPersistenceApiForZoneAndLoadBalancer(zone, lb.getId()).get();
api.getSessionPersistenceApiForZoneAndLoadBalancer(zone, lb.getId()).get();
assertEquals(sessionPersistence, SessionPersistence.HTTP_COOKIE);
}
@Test(dependsOnMethods = "testCreateAndGetSessionPersistence")
public void testRemoveAndGetSessionPersistence() throws Exception {
clbApi.getSessionPersistenceApiForZoneAndLoadBalancer(zone, lb.getId()).delete();
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
api.getSessionPersistenceApiForZoneAndLoadBalancer(zone, lb.getId()).delete();
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
SessionPersistence sessionPersistence =
clbApi.getSessionPersistenceApiForZoneAndLoadBalancer(zone, lb.getId()).get();
api.getSessionPersistenceApiForZoneAndLoadBalancer(zone, lb.getId()).get();
assertNull(sessionPersistence);
}
@Override
@AfterGroups(groups = "live")
protected void tearDownContext() {
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
clbApi.getLoadBalancerApiForZone(zone).delete(lb.getId());
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
super.tearDownContext();
protected void tearDown() {
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
api.getLoadBalancerApiForZone(zone).delete(lb.getId());
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(zone)).apply(lb));
super.tearDown();
}
}

View File

@ -52,60 +52,60 @@ public class VirtualIPApiLiveTest extends BaseCloudLoadBalancersApiLiveTest {
CreateLoadBalancer createLB = CreateLoadBalancer.builder()
.name(prefix+"-jclouds").protocol("HTTP").port(80).virtualIPType(Type.PUBLIC).node(addNode).build();
zone = Iterables.getFirst(clbApi.getConfiguredZones(), null);
lb = clbApi.getLoadBalancerApiForZone(zone).create(createLB);
zone = Iterables.getFirst(api.getConfiguredZones(), null);
lb = api.getLoadBalancerApiForZone(zone).create(createLB);
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
}
@Test(dependsOnMethods = "testCreateLoadBalancer")
public void testCreateVirtualIPs() throws Exception {
clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).create(VirtualIP.publicIPv6());
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).create(VirtualIP.publicIPv6());
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).create(VirtualIP.publicIPv6());
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).create(VirtualIP.publicIPv6());
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).create(VirtualIP.publicIPv6());
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).create(VirtualIP.publicIPv6());
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
Iterable<VirtualIPWithId> actualVirtualIPs = clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
Iterable<VirtualIPWithId> actualVirtualIPs = api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
assertEquals(Iterators.size(actualVirtualIPs.iterator()), 5);
}
@Test(dependsOnMethods = "testCreateVirtualIPs")
public void testRemoveSingleVirtualIP() throws Exception {
Iterable<VirtualIPWithId> actualVirtualIPs = clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
Iterable<VirtualIPWithId> actualVirtualIPs = api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
VirtualIPWithId removedVirtualIP = Iterables.getFirst(actualVirtualIPs, null);
assertTrue(clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).delete(removedVirtualIP.getId()));
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).delete(removedVirtualIP.getId()));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
actualVirtualIPs = clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
actualVirtualIPs = api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
assertEquals(Iterators.size(actualVirtualIPs.iterator()), 4);
}
@Test(dependsOnMethods = "testRemoveSingleVirtualIP")
public void testRemoveManyVirtualIPs() throws Exception {
Iterable<VirtualIPWithId> actualVirtualIPs = clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
Iterable<VirtualIPWithId> actualVirtualIPs = api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
VirtualIPWithId removedVirtualIP1 = Iterables.getFirst(actualVirtualIPs, null);
VirtualIPWithId removedVirtualIP2 = Iterables.getLast(actualVirtualIPs);
List<Integer> removedVirtualIPIds = ImmutableList.<Integer> of(removedVirtualIP1.getId(), removedVirtualIP2.getId());
assertTrue(clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).delete(removedVirtualIPIds));
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
assertTrue(api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).delete(removedVirtualIPIds));
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
actualVirtualIPs = clbApi.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
actualVirtualIPs = api.getVirtualIPApiForZoneAndLoadBalancer(zone, lb.getId()).list();
assertEquals(Iterators.size(actualVirtualIPs.iterator()), 2);
}
@Override
@AfterGroups(groups = "live")
protected void tearDownContext() {
assertTrue(awaitAvailable(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
clbApi.getLoadBalancerApiForZone(zone).delete(lb.getId());
assertTrue(awaitDeleted(clbApi.getLoadBalancerApiForZone(zone)).apply(lb));
super.tearDownContext();
protected void tearDown() {
assertTrue(awaitAvailable(api.getLoadBalancerApiForZone(zone)).apply(lb));
api.getLoadBalancerApiForZone(zone).delete(lb.getId());
assertTrue(awaitDeleted(api.getLoadBalancerApiForZone(zone)).apply(lb));
super.tearDown();
}
}

View File

@ -21,22 +21,16 @@ package org.jclouds.rackspace.cloudloadbalancers.v1.internal;
import java.util.Properties;
import java.util.logging.Logger;
import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.apis.BaseApiLiveTest;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApi;
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersApiMetadata;
import org.jclouds.rackspace.cloudloadbalancers.v1.CloudLoadBalancersAsyncApi;
import org.jclouds.rest.RestContext;
import org.testng.annotations.BeforeGroups;
import com.google.common.reflect.TypeToken;
/**
*
* @author Adrian Cole
*/
public class BaseCloudLoadBalancersApiLiveTest extends BaseContextLiveTest<RestContext<CloudLoadBalancersApi, CloudLoadBalancersAsyncApi>> {
protected CloudLoadBalancersApi clbApi;
public class BaseCloudLoadBalancersApiLiveTest extends BaseApiLiveTest<CloudLoadBalancersApi> {
public BaseCloudLoadBalancersApiLiveTest() {
provider = "rackspace-cloudloadbalancers";
@ -44,12 +38,9 @@ public class BaseCloudLoadBalancersApiLiveTest extends BaseContextLiveTest<RestC
@BeforeGroups(groups = { "integration", "live" })
@Override
public void setupContext() {
super.setupContext();
clbApi = context.getApi();
Logger.getAnonymousLogger().info("running against zones " + clbApi.getConfiguredZones());
public void setup() {
super.setup();
Logger.getAnonymousLogger().info("running against zones " + api.getConfiguredZones());
}
@Override
@ -58,9 +49,4 @@ public class BaseCloudLoadBalancersApiLiveTest extends BaseContextLiveTest<RestC
setIfTestSystemPropertyPresent(props, KeystoneProperties.CREDENTIAL_TYPE);
return props;
}
@Override
protected TypeToken<RestContext<CloudLoadBalancersApi, CloudLoadBalancersAsyncApi>> contextType() {
return CloudLoadBalancersApiMetadata.CONTEXT_TOKEN;
}
}

View File

@ -31,10 +31,6 @@ public class Route53ApiLiveTest extends BaseRoute53ApiLiveTest {
@Test
protected void testGetChangeReturnsNullOnNotFound() {
assertNull(api().getChange("FOOOBAR"));
}
protected Route53Api api() {
return context.getApi();
assertNull(api.getChange("FOOOBAR"));
}
}

View File

@ -95,6 +95,6 @@ public class HostedZoneApiLiveTest extends BaseRoute53ApiLiveTest {
}
protected HostedZoneApi api() {
return context.getApi().getHostedZoneApi();
return api.getHostedZoneApi();
}
}

View File

@ -94,7 +94,7 @@ public class ResourceRecordSetApiLiveTest extends BaseRoute53ApiLiveTest {
}
private void checkAllRRs(String zoneId) {
HostedZone zone = context.getApi().getHostedZoneApi().get(zoneId).getZone();
HostedZone zone = api.getHostedZoneApi().get(zoneId).getZone();
List<ResourceRecordSet> records = api(zone.getId()).list().concat().toList();
assertEquals(zone.getResourceRecordSetCount(), records.size());
@ -171,7 +171,7 @@ public class ResourceRecordSetApiLiveTest extends BaseRoute53ApiLiveTest {
clearAndDeleteHostedZonesNamed(name);
String nonce = name + " @ " + new Date();
String comment = name + " for " + JcloudsVersion.get();
NewHostedZone newHostedZone = context.getApi().getHostedZoneApi()
NewHostedZone newHostedZone = api.getHostedZoneApi()
.createWithReferenceAndComment(name, nonce, comment);
getAnonymousLogger().info("created zone: " + newHostedZone);
assertTrue(inSync.apply(newHostedZone.getChange()), "zone didn't sync " + newHostedZone);
@ -191,12 +191,12 @@ public class ResourceRecordSetApiLiveTest extends BaseRoute53ApiLiveTest {
}
private void clearAndDeleteHostedZonesNamed(String name) {
for (HostedZone zone : context.getApi().getHostedZoneApi().list().concat().filter(nameEquals(name))) {
for (HostedZone zone : api.getHostedZoneApi().list().concat().filter(nameEquals(name))) {
getAnonymousLogger().info("clearing and deleting zone: " + zone);
Set<ResourceRecordSet> remaining = refresh(zone.getId()).concat().filter(not(requiredRRTypes)).toSet();
if (!remaining.isEmpty())
sync(api(zone.getId()).apply(deleteAll(remaining)));
sync(context.getApi().getHostedZoneApi().delete(zone.getId()));
sync(api.getHostedZoneApi().delete(zone.getId()));
}
}
@ -209,13 +209,13 @@ public class ResourceRecordSetApiLiveTest extends BaseRoute53ApiLiveTest {
}
private PagedIterable<HostedZone> zones() {
PagedIterable<HostedZone> zones = context.getApi().getHostedZoneApi().list();
PagedIterable<HostedZone> zones = api.getHostedZoneApi().list();
if (zones.get(0).isEmpty())
throw new SkipException("no zones in context: " + context);
throw new SkipException("no zones in context: " + identity);
return zones;
}
private ResourceRecordSetApi api(String zoneId) {
return context.getApi().getResourceRecordSetApiForHostedZone(zoneId);
return api.getResourceRecordSetApiForHostedZone(zoneId);
}
}

View File

@ -22,25 +22,20 @@ import static java.util.concurrent.TimeUnit.SECONDS;
import static org.jclouds.route53.domain.Change.Status.INSYNC;
import static org.jclouds.util.Predicates2.retry;
import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.route53.Route53ApiMetadata;
import org.jclouds.route53.Route53AsyncApi;
import org.jclouds.apis.BaseApiLiveTest;
import org.jclouds.route53.Route53Api;
import org.jclouds.route53.domain.Change;
import org.jclouds.rest.RestContext;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Predicate;
import com.google.common.reflect.TypeToken;
/**
*
* @author Adrian Cole
*/
@Test(groups = "live")
public class BaseRoute53ApiLiveTest extends
BaseContextLiveTest<RestContext<? extends Route53Api, ? extends Route53AsyncApi>> {
public class BaseRoute53ApiLiveTest extends BaseApiLiveTest<Route53Api> {
public BaseRoute53ApiLiveTest() {
provider = "route53";
@ -50,17 +45,12 @@ public class BaseRoute53ApiLiveTest extends
@BeforeClass(groups = "live")
@Override
public void setupContext() {
super.setupContext();
public void setup() {
super.setup();
inSync = retry(new Predicate<Change>() {
public boolean apply(Change input) {
return context.getApi().getChange(input.getId()).getStatus() == INSYNC;
return api.getChange(input.getId()).getStatus() == INSYNC;
}
}, 600, 1, 5, SECONDS);
}
@Override
protected TypeToken<RestContext<? extends Route53Api, ? extends Route53AsyncApi>> contextType() {
return Route53ApiMetadata.CONTEXT_TOKEN;
}
}

View File

@ -34,7 +34,6 @@ import java.util.Set;
import org.jclouds.ContextBuilder;
import org.jclouds.concurrent.config.ExecutorServiceModule;
import org.jclouds.rest.RestContext;
import org.jclouds.s3.domain.S3Object;
import org.testng.annotations.Test;
@ -55,7 +54,7 @@ public class S3ClientMockTest {
private static final Set<Module> modules = ImmutableSet.<Module> of(
new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor()));
static RestContext<? extends S3Client,? extends S3AsyncClient> getContext(URL server) {
static S3Client getS3Client(URL server) {
Properties overrides = new Properties();
overrides.setProperty(PROPERTY_S3_VIRTUAL_HOST_BUCKETS, "false");
// prevent expect-100 bug http://code.google.com/p/mockwebserver/issues/detail?id=6
@ -66,7 +65,7 @@ public class S3ClientMockTest {
.endpoint(server.toString())
.modules(modules)
.overrides(overrides)
.build(S3ApiMetadata.CONTEXT_TOKEN);
.buildApi(S3Client.class);
}
public void testZeroLengthPutHasContentLengthHeader() throws IOException, InterruptedException {
@ -74,7 +73,7 @@ public class S3ClientMockTest {
server.enqueue(new MockResponse().setBody("").addHeader(ETAG, "ABCDEF"));
server.play();
S3Client client = getContext(server.getUrl("/")).getApi();
S3Client client = getS3Client(server.getUrl("/"));
S3Object nada = client.newS3Object();
nada.getMetadata().setKey("object");
nada.setPayload(new byte[] {});
@ -94,7 +93,7 @@ public class S3ClientMockTest {
server.enqueue(new MockResponse().setBody("").addHeader(ETAG, "ABCDEF"));
server.play();
S3Client client = getContext(server.getUrl("/")).getApi();
S3Client client = getS3Client(server.getUrl("/"));
S3Object fileInDir = client.newS3Object();
fileInDir.getMetadata().setKey("someDir/fileName");
fileInDir.setPayload(new byte[] { 1, 2, 3, 4 });

View File

@ -63,14 +63,14 @@ public class BulkMessageApiLiveTest extends BaseSQSApiLiveTest {
@BeforeClass(groups = { "integration", "live" })
@Override
public void setupContext() {
super.setupContext();
public void setup() {
super.setup();
recreateQueueInRegion(prefix, null);
}
public void testSendMessages() {
for (URI queue : queues) {
BatchResult<? extends MessageIdAndMD5> acks = api().getMessageApiForQueue(queue).send(idPayload);
BatchResult<? extends MessageIdAndMD5> acks = api.getMessageApiForQueue(queue).send(idPayload);
assertEquals(acks.size(), idPayload.size(), "error sending " + acks);
assertEquals(acks.keySet(), idPayload.keySet());
@ -87,7 +87,7 @@ public class BulkMessageApiLiveTest extends BaseSQSApiLiveTest {
@Test(dependsOnMethods = "testSendMessages")
public void testChangeMessageVisibility() {
for (URI queue : queues) {
MessageApi api = api().getMessageApiForQueue(queue);
MessageApi api = this.api.getMessageApiForQueue(queue);
Set<Message> messages = collectMessages(api);
@ -117,7 +117,7 @@ public class BulkMessageApiLiveTest extends BaseSQSApiLiveTest {
@Test(dependsOnMethods = "testChangeMessageVisibility")
public void testDeleteMessage() throws InterruptedException {
for (URI queue : queues) {
BatchResult<String> acks = api().getMessageApiForQueue(queue).delete(receiptHandles);
BatchResult<String> acks = api.getMessageApiForQueue(queue).delete(receiptHandles);
assertEquals(acks.size(), Iterables.size(receiptHandles), "error deleting messages " + acks);
assertNoMessages(queue);
}

View File

@ -45,8 +45,8 @@ public class MessageApiLiveTest extends BaseSQSApiLiveTest {
@BeforeClass(groups = { "integration", "live" })
@Override
public void setupContext() {
super.setupContext();
public void setup() {
super.setup();
recreateQueueInRegion(prefix, null);
}
@ -55,14 +55,14 @@ public class MessageApiLiveTest extends BaseSQSApiLiveTest {
public void testSendMessage() {
for (URI queue : queues) {
assertEquals(api().getMessageApiForQueue(queue).send(message).getMD5(), md5);
assertEquals(api.getMessageApiForQueue(queue).send(message).getMD5(), md5);
}
}
@Test(dependsOnMethods = "testSendMessage")
public void testReceiveMessageWithoutHidingMessage() {
for (URI queue : queues) {
assertEquals(api().getMessageApiForQueue(queue).receive(attribute("All").visibilityTimeout(0)).getMD5(), md5);
assertEquals(api.getMessageApiForQueue(queue).receive(attribute("All").visibilityTimeout(0)).getMD5(), md5);
}
}
@ -71,7 +71,7 @@ public class MessageApiLiveTest extends BaseSQSApiLiveTest {
@Test(dependsOnMethods = "testReceiveMessageWithoutHidingMessage")
public void testChangeMessageVisibility() {
for (URI queue : queues) {
MessageApi api = api().getMessageApiForQueue(queue);
MessageApi api = this.api.getMessageApiForQueue(queue);
// start hiding it at 5 seconds
receiptHandle = api.receive(attribute("None").visibilityTimeout(5)).getReceiptHandle();
// hidden message, so we can't see it
@ -86,7 +86,7 @@ public class MessageApiLiveTest extends BaseSQSApiLiveTest {
@Test(dependsOnMethods = "testChangeMessageVisibility")
public void testDeleteMessage() throws InterruptedException {
for (URI queue : queues) {
api().getMessageApiForQueue(queue).delete(receiptHandle);
api.getMessageApiForQueue(queue).delete(receiptHandle);
assertNoMessages(queue);
}
}

View File

@ -58,8 +58,8 @@ public class PermissionApiLiveTest extends BaseSQSApiLiveTest {
@BeforeClass(groups = { "integration", "live" })
@Override
public void setupContext() {
super.setupContext();
public void setup() {
super.setup();
recreateQueueInRegion(prefix, null);
}
@ -77,17 +77,17 @@ public class PermissionApiLiveTest extends BaseSQSApiLiveTest {
public void testAddAnonymousPermission() throws InterruptedException {
for (URI queue : queues) {
QueueAttributes attributes = api().getQueueApi().getAttributes(queue);
QueueAttributes attributes = api.getQueueApi().getAttributes(queue);
assertNoPermissions(queue);
String accountToAuthorize = getOwner(queue);
api().getPermissionApiForQueue(queue).addPermissionToAccount("fubar", Action.GET_QUEUE_ATTRIBUTES,
api.getPermissionApiForQueue(queue).addPermissionToAccount("fubar", Action.GET_QUEUE_ATTRIBUTES,
accountToAuthorize);
String policyForAuthorizationByAccount = assertPolicyPresent(queue);
String policyForAnonymous = policyForAuthorizationByAccount.replace("\"" + accountToAuthorize + "\"", "\"*\"");
api().getQueueApi().setAttribute(queue, "Policy", policyForAnonymous);
api.getQueueApi().setAttribute(queue, "Policy", policyForAnonymous);
assertEquals(getAnonymousAttributesApi(queue).getQueueArn(), attributes.getQueueArn());
}
@ -96,18 +96,17 @@ public class PermissionApiLiveTest extends BaseSQSApiLiveTest {
@Test(dependsOnMethods = "testAddAnonymousPermission")
public void testRemovePermission() throws InterruptedException {
for (URI queue : queues) {
api().getPermissionApiForQueue(queue).remove("fubar");
api.getPermissionApiForQueue(queue).remove("fubar");
assertNoPermissions(queue);
}
}
private AnonymousAttributesApi getAnonymousAttributesApi(URI queue) {
return ContextBuilder
.newBuilder(
return ContextBuilder.newBuilder(
forClientMappedToAsyncClientOnEndpoint(AnonymousAttributesApi.class,
AnonymousAttributesAsyncApi.class, queue.toASCIIString()))
.modules(ImmutableSet.<Module> of(new ExecutorServiceModule(sameThreadExecutor(), sameThreadExecutor())))
.buildInjector().getInstance(AnonymousAttributesApi.class);
.buildApi(AnonymousAttributesApi.class);
}
}

View File

@ -50,7 +50,7 @@ public class QueueApiLiveTest extends BaseSQSApiLiveTest {
}
protected void listQueuesInRegion(String region) throws InterruptedException {
FluentIterable<URI> allResults = api().getQueueApiForRegion(region).list();
FluentIterable<URI> allResults = api.getQueueApiForRegion(region).list();
assertNotNull(allResults);
if (allResults.size() >= 1) {
URI queue = getLast(allResults);
@ -60,7 +60,7 @@ public class QueueApiLiveTest extends BaseSQSApiLiveTest {
@Test
public void testGracefulNoQueue() throws InterruptedException {
assertNull(api().getQueueApi().get(UUID.randomUUID().toString()));
assertNull(api.getQueueApi().get(UUID.randomUUID().toString()));
}
@Test
@ -72,37 +72,37 @@ public class QueueApiLiveTest extends BaseSQSApiLiveTest {
@Test(dependsOnMethods = "testCanRecreateQueueGracefully")
public void testCreateQueueWhenAlreadyExistsReturnsURI() {
for (URI queue : queues) {
assertEquals(api().getQueueApi().create(prefix), queue);
assertEquals(api.getQueueApi().create(prefix), queue);
}
}
@Test(dependsOnMethods = "testCanRecreateQueueGracefully")
public void testGet() {
for (URI queue : queues) {
assertEquals(api().getQueueApi().get(prefix), queue);
assertEquals(api.getQueueApi().get(prefix), queue);
}
}
@Test(dependsOnMethods = "testCanRecreateQueueGracefully")
public void testGetInAccount() {
for (URI queue : queues) {
assertEquals(api().getQueueApi().getInAccount(prefix, getOwner(queue)), queue);
assertEquals(api.getQueueApi().getInAccount(prefix, getOwner(queue)), queue);
}
}
@Test(dependsOnMethods = "testCanRecreateQueueGracefully")
public void testGetQueueAttributes() {
for (URI queue : queues) {
Map<String, String> attributes = api().getQueueApi().getAttributes(queue, ImmutableSet.of("All"));
assertEquals(api().getQueueApi().getAttributes(queue, attributes.keySet()), attributes);
Map<String, String> attributes = api.getQueueApi().getAttributes(queue, ImmutableSet.of("All"));
assertEquals(api.getQueueApi().getAttributes(queue, attributes.keySet()), attributes);
}
}
@Test(dependsOnMethods = "testGetQueueAttributes")
public void testSetQueueAttribute() {
for (URI queue : queues) {
api().getQueueApi().setAttribute(queue, "MaximumMessageSize", "1024");
assertEquals(api().getQueueApi().getAttributes(queue).getMaximumMessageSize(), 1024);
api.getQueueApi().setAttribute(queue, "MaximumMessageSize", "1024");
assertEquals(api.getQueueApi().getAttributes(queue).getMaximumMessageSize(), 1024);
}
}
}

View File

@ -28,11 +28,8 @@ import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.rest.RestContext;
import org.jclouds.apis.BaseApiLiveTest;
import org.jclouds.sqs.SQSApi;
import org.jclouds.sqs.SQSApiMetadata;
import org.jclouds.sqs.SQSAsyncApi;
import org.jclouds.sqs.domain.Message;
import org.jclouds.sqs.features.QueueApi;
import org.testng.annotations.AfterClass;
@ -41,7 +38,6 @@ import org.testng.annotations.Test;
import com.google.common.base.Splitter;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Sets;
import com.google.common.reflect.TypeToken;
import com.google.common.util.concurrent.Atomics;
import com.google.common.util.concurrent.Uninterruptibles;
@ -50,7 +46,7 @@ import com.google.common.util.concurrent.Uninterruptibles;
* @author Adrian Cole
*/
@Test(groups = "live")
public class BaseSQSApiLiveTest extends BaseContextLiveTest<RestContext<SQSApi, SQSAsyncApi>> {
public class BaseSQSApiLiveTest extends BaseApiLiveTest<SQSApi> {
protected String prefix = System.getProperty("user.name") + "-sqs";
@ -65,7 +61,7 @@ public class BaseSQSApiLiveTest extends BaseContextLiveTest<RestContext<SQSApi,
}
protected String recreateQueueInRegion(String queueName, String region) {
QueueApi api = api().getQueueApiForRegion(region);
QueueApi api = this.api.getQueueApiForRegion(region);
URI result = api.get(queueName);
if (result != null) {
api.delete(result);
@ -76,16 +72,11 @@ public class BaseSQSApiLiveTest extends BaseContextLiveTest<RestContext<SQSApi,
return queueName;
}
@Override
protected TypeToken<RestContext<SQSApi, SQSAsyncApi>> contextType() {
return SQSApiMetadata.CONTEXT_TOKEN;
}
protected String assertPolicyPresent(final URI queue) {
final AtomicReference<String> policy = Atomics.newReference();
assertEventually(new Runnable() {
public void run() {
String policyForAuthorizationByAccount = api().getQueueApi().getAttribute(queue, "Policy");
String policyForAuthorizationByAccount = api.getQueueApi().getAttribute(queue, "Policy");
assertNotNull(policyForAuthorizationByAccount);
policy.set(policyForAuthorizationByAccount);
@ -97,7 +88,7 @@ public class BaseSQSApiLiveTest extends BaseContextLiveTest<RestContext<SQSApi,
protected void assertNoPermissions(final URI queue) {
assertEventually(new Runnable() {
public void run() {
String policy = api().getQueueApi().getAttribute(queue, "Policy");
String policy = api.getQueueApi().getAttribute(queue, "Policy");
assertTrue(policy == null || policy.indexOf("\"Statement\":[]") != -1, policy);
}
});
@ -106,7 +97,7 @@ public class BaseSQSApiLiveTest extends BaseContextLiveTest<RestContext<SQSApi,
protected void assertNoMessages(final URI queue) {
assertEventually(new Runnable() {
public void run() {
Message message = api().getMessageApiForQueue(queue).receive();
Message message = api.getMessageApiForQueue(queue).receive();
assertNull(message, "message: " + message + " left in queue " + queue);
}
});
@ -116,7 +107,7 @@ public class BaseSQSApiLiveTest extends BaseContextLiveTest<RestContext<SQSApi,
final URI finalQ = queue;
assertEventually(new Runnable() {
public void run() {
FluentIterable<URI> result = api().getQueueApiForRegion(region).list();
FluentIterable<URI> result = api.getQueueApiForRegion(region).list();
assertNotNull(result);
assert result.size() >= 1 : result;
assertTrue(result.contains(finalQ), finalQ + " not in " + result);
@ -152,15 +143,10 @@ public class BaseSQSApiLiveTest extends BaseContextLiveTest<RestContext<SQSApi,
@Override
@AfterClass(groups = "live")
protected void tearDownContext() {
protected void tearDown() {
for (URI queue : queues) {
api().getQueueApi().delete(queue);
api.getQueueApi().delete(queue);
}
super.tearDownContext();
super.tearDown();
}
protected SQSApi api() {
return context.getApi();
}
}

View File

@ -39,7 +39,7 @@ public class STSApiLiveTest extends BaseSTSApiLiveTest {
@Test
protected void testCreateTemporaryCredentials() {
SessionCredentials creds = api().createTemporaryCredentials(
SessionCredentials creds = api.createTemporaryCredentials(
new SessionCredentialsOptions().durationSeconds(MINUTES.toSeconds(15)));
checkTemporaryCredentials(creds);
// TODO: actually login to some service
@ -53,7 +53,7 @@ public class STSApiLiveTest extends BaseSTSApiLiveTest {
@Test
protected void testCreateFederatedUser() {
UserAndSessionCredentials user = api().createFederatedUser("Bob", new FederatedUserOptions().durationSeconds(MINUTES.toSeconds(15)));
UserAndSessionCredentials user = api.createFederatedUser("Bob", new FederatedUserOptions().durationSeconds(MINUTES.toSeconds(15)));
checkTemporaryCredentials(user.getCredentials());
assertTrue(user.getUser().getId().contains("Bob"), user + " id incorrect");
assertTrue(user.getUser().getArn().contains("Bob"), user + " arn incorrect");
@ -63,7 +63,7 @@ public class STSApiLiveTest extends BaseSTSApiLiveTest {
@Test
protected void testAssumeRole() {
String arnToAssume = getTestArn();
UserAndSessionCredentials role = api().assumeRole(arnToAssume, "session",
UserAndSessionCredentials role = api.assumeRole(arnToAssume, "session",
new AssumeRoleOptions().durationSeconds(MINUTES.toSeconds(15)));
checkTemporaryCredentials(role.getCredentials());
assertTrue(role.getUser().getId().contains("session"), role + " id incorrect");
@ -81,8 +81,4 @@ public class STSApiLiveTest extends BaseSTSApiLiveTest {
checkNotNull(creds.getSessionToken(), "SessionToken cannot be null for TemporaryCredentials.");
checkNotNull(creds.getExpiration(), "Expiration cannot be null for TemporaryCredentials.");
}
protected STSApi api() {
return context.getApi();
}
}

View File

@ -18,30 +18,17 @@
*/
package org.jclouds.sts.internal;
import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.sts.STSApiMetadata;
import org.jclouds.sts.STSAsyncApi;
import org.jclouds.apis.BaseApiLiveTest;
import org.jclouds.sts.STSApi;
import org.jclouds.rest.RestContext;
import org.testng.annotations.Test;
import com.google.common.reflect.TypeToken;
/**
*
* @author Adrian Cole
*/
@Test(groups = "live")
public class BaseSTSApiLiveTest extends
BaseContextLiveTest<RestContext<? extends STSApi, ? extends STSAsyncApi>> {
public class BaseSTSApiLiveTest extends BaseApiLiveTest<STSApi> {
public BaseSTSApiLiveTest() {
provider = "sts";
}
@Override
protected TypeToken<RestContext<? extends STSApi, ? extends STSAsyncApi>> contextType() {
return STSApiMetadata.CONTEXT_TOKEN;
}
}

View File

@ -23,14 +23,11 @@ import static org.testng.Assert.assertTrue;
import java.util.Properties;
import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneProperties;
import org.jclouds.openstack.swift.CommonSwiftAsyncClient;
import org.jclouds.openstack.swift.CommonSwiftClient;
import org.jclouds.openstack.swift.domain.ContainerMetadata;
import org.jclouds.openstack.swift.options.CreateContainerOptions;
import org.jclouds.rest.RestContext;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableList;
@ -56,19 +53,19 @@ public class SwiftContainerIntegrationLiveTest extends BaseContainerIntegrationT
@Test(groups = "live")
public void testSetGetContainerMetadata() throws InterruptedException {
BlobStore blobStore = view.getBlobStore();
RestContext<CommonSwiftClient, CommonSwiftAsyncClient> swift = blobStore.getContext().unwrap();
CommonSwiftClient swift = view.utils().injector().getInstance(CommonSwiftClient.class);
String containerName = getContainerName();
assertTrue(swift.getApi().createContainer(containerName));
assertTrue(swift.createContainer(containerName));
ImmutableMap<String, String> metadata = ImmutableMap.<String, String> of(
"key1", "value1",
"key2", "value2");
assertTrue(swift.getApi().setContainerMetadata(containerName, metadata));
assertTrue(swift.setContainerMetadata(containerName, metadata));
ContainerMetadata containerMetadata = swift.getApi().getContainerMetadata(containerName);
ContainerMetadata containerMetadata = swift.getContainerMetadata(containerName);
assertEquals(containerMetadata.getMetadata().get("key1"), "value1");
assertEquals(containerMetadata.getMetadata().get("key2"), "value2");
@ -76,8 +73,8 @@ public class SwiftContainerIntegrationLiveTest extends BaseContainerIntegrationT
@Test(groups = "live")
public void testCreateDeleteContainerMetadata() throws InterruptedException {
BlobStore blobStore = view.getBlobStore();
RestContext<CommonSwiftClient, CommonSwiftAsyncClient> swift = blobStore.getContext().unwrap();
CommonSwiftClient swift = view.utils().injector().getInstance(CommonSwiftClient.class);
String containerName = getContainerName();
CreateContainerOptions options = CreateContainerOptions.Builder
.withPublicAccess()
@ -86,18 +83,18 @@ public class SwiftContainerIntegrationLiveTest extends BaseContainerIntegrationT
"key2", "value2",
"key3", "value3"));
assertTrue(swift.getApi().createContainer(containerName, options));
assertTrue(swift.createContainer(containerName, options));
ContainerMetadata containerMetadata = swift.getApi().getContainerMetadata(containerName);
ContainerMetadata containerMetadata = swift.getContainerMetadata(containerName);
assertEquals(containerMetadata.getMetadata().size(), 3);
assertEquals(containerMetadata.getMetadata().get("key1"), "value1");
assertEquals(containerMetadata.getMetadata().get("key2"), "value2");
assertEquals(containerMetadata.getMetadata().get("key3"), "value3");
assertTrue(swift.getApi().deleteContainerMetadata(containerName, ImmutableList.<String> of("key2","key3")));
assertTrue(swift.deleteContainerMetadata(containerName, ImmutableList.<String> of("key2","key3")));
containerMetadata = swift.getApi().getContainerMetadata(containerName);
containerMetadata = swift.getContainerMetadata(containerName);
assertEquals(containerMetadata.getMetadata().size(), 1);
assertEquals(containerMetadata.getMetadata().get("key1"), "value1");

View File

@ -22,11 +22,11 @@ import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.find;
import static com.google.common.collect.Iterables.size;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.jclouds.util.Predicates2.retry;
import static org.jclouds.trmk.vcloud_0_8.domain.VAppConfiguration.Builder.changeNameTo;
import static org.jclouds.trmk.vcloud_0_8.domain.VAppConfiguration.Builder.deleteDiskWithAddressOnParent;
import static org.jclouds.trmk.vcloud_0_8.options.CloneVAppOptions.Builder.deploy;
import static org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions.Builder.processorCount;
import static org.jclouds.util.Predicates2.retry;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.fail;
@ -41,13 +41,12 @@ import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException;
import org.jclouds.apis.BaseApiLiveTest;
import org.jclouds.cim.CIMPredicates;
import org.jclouds.cim.ResourceAllocationSettingData;
import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.predicates.SocketOpen;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.RestContext;
import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.SshClient.Factory;
import org.jclouds.ssh.SshException;
@ -74,12 +73,12 @@ import org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions;
import org.jclouds.trmk.vcloud_0_8.predicates.TaskSuccess;
import org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.net.HostAndPort;
@ -87,7 +86,7 @@ import com.google.inject.Injector;
import com.google.inject.Module;
@Test(groups = "live", singleThreaded = true)
public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A extends TerremarkVCloudAsyncClient> extends BaseComputeServiceContextLiveTest {
public abstract class TerremarkClientLiveTest extends BaseApiLiveTest<TerremarkVCloudClient> {
protected String expectedOs = "Ubuntu Linux (64-bit)";
protected String itemName = "Ubuntu JeOS 9.10 (64-bit)";
@ -105,7 +104,6 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
protected VDC vdc;
protected String serverName;
protected KeyPair key;
protected S connection;
public static final String PREFIX = System.getProperty("user.name") + "-terremark";
@ -120,7 +118,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
@Test
public void testKeysList() throws Exception {
for (Org org : orgs) {
TerremarkVCloudClient vCloudExpressClient = TerremarkVCloudClient.class.cast(connection);
TerremarkVCloudClient vCloudExpressClient = TerremarkVCloudClient.class.cast(api);
Set<KeyPair> response = vCloudExpressClient.listKeyPairsInOrg(org.getHref());
assertNotNull(response);
}
@ -130,8 +128,8 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
public void testGetAllInternetServices() throws Exception {
for (Org org : orgs) {
for (ReferenceType vdc : org.getVDCs().values()) {
for (InternetService service : connection.getAllInternetServicesInVDC(vdc.getHref())) {
assertNotNull(connection.getNodes(service.getId()));
for (InternetService service : api.getAllInternetServicesInVDC(vdc.getHref())) {
assertNotNull(api.getNodes(service.getId()));
}
}
}
@ -141,11 +139,11 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
public void testCreateInternetServiceMonitorDisabled() throws Exception {
for (Org org : orgs) {
for (ReferenceType vdc : org.getVDCs().values()) {
Set<PublicIpAddress> publicIpAddresses = connection.getPublicIpsAssociatedWithVDC(vdc.getHref());
Set<PublicIpAddress> publicIpAddresses = api.getPublicIpsAssociatedWithVDC(vdc.getHref());
PublicIpAddress publicIp = publicIpAddresses.iterator().next();
InternetService service = connection.addInternetServiceToExistingIp(publicIp.getId(), PREFIX
InternetService service = api.addInternetServiceToExistingIp(publicIp.getId(), PREFIX
+ "-no-monitoring", Protocol.TCP, 1234, AddInternetServiceOptions.Builder.monitorDisabled());
connection.deleteInternetService(service.getId());
api.deleteInternetService(service.getId());
}
}
}
@ -154,9 +152,9 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
public void testGetPublicIpsAssociatedWithVDC() throws Exception {
for (Org org : orgs) {
for (ReferenceType vdc : org.getVDCs().values()) {
for (PublicIpAddress ip : connection.getPublicIpsAssociatedWithVDC(vdc.getHref())) {
assertNotNull(connection.getInternetServicesOnPublicIp(ip.getId()));
assertNotNull(connection.getPublicIp(ip.getId()));
for (PublicIpAddress ip : api.getPublicIpsAssociatedWithVDC(vdc.getHref())) {
assertNotNull(api.getInternetServicesOnPublicIp(ip.getId()));
assertNotNull(api.getPublicIp(ip.getId()));
}
}
}
@ -166,12 +164,12 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
public void testGetConfigCustomizationOptions() throws Exception {
for (Org org : orgs) {
for (ReferenceType catalog : org.getCatalogs().values()) {
Catalog response = connection.getCatalog(catalog.getHref());
Catalog response = api.getCatalog(catalog.getHref());
for (ReferenceType resource : response.values()) {
if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
CatalogItem item = connection.findCatalogItemInOrgCatalogNamed(org.getName(), catalog.getName(),
CatalogItem item = api.findCatalogItemInOrgCatalogNamed(org.getName(), catalog.getName(),
resource.getName());
assert connection.getCustomizationOptions(item.getCustomizationOptions().getHref()) != null;
assert api.getCustomizationOptions(item.getCustomizationOptions().getHref()) != null;
}
}
}
@ -190,30 +188,30 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
// String expectedOs = "Red Hat Enterprise Linux 5 (64-bit)";
// lookup the datacenter you are deploying into
vdc = connection.findVDCInOrgNamed(null, null);
vdc = api.findVDCInOrgNamed(null, null);
// create an options object to collect the configuration we want.
InstantiateVAppTemplateOptions instantiateOptions = createInstantiateOptions().sshKeyFingerprint(
key.getFingerPrint());
CatalogItem item = connection.findCatalogItemInOrgCatalogNamed(null, null, itemName);
CatalogItem item = api.findCatalogItemInOrgCatalogNamed(null, null, itemName);
assert item != null;
// if this template supports setting the root password, let's add it to
// our options
CustomizationParameters customizationOptions = connection.getCustomizationOptions(item.getCustomizationOptions()
CustomizationParameters customizationOptions = api.getCustomizationOptions(item.getCustomizationOptions()
.getHref());
if (customizationOptions.canCustomizePassword())
instantiateOptions.withPassword("robotsarefun");
VAppTemplate vAppTemplate = connection.getVAppTemplate(item.getEntity().getHref());
VAppTemplate vAppTemplate = api.getVAppTemplate(item.getEntity().getHref());
assert vAppTemplate != null;
// instantiate, noting vApp returned has minimal details
vApp = connection.instantiateVAppTemplateInVDC(vdc.getHref(), vAppTemplate.getHref(), serverName,
vApp = api.instantiateVAppTemplateInVDC(vdc.getHref(), vAppTemplate.getHref(), serverName,
instantiateOptions);
assertEquals(vApp.getStatus(), Status.RESOLVED);
@ -221,27 +219,27 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
// in terremark, this should be a no-op, as it should simply return the
// above task, which is
// already deploying
Task deployTask = connection.deployVApp(vApp.getHref());
Task deployTask = api.deployVApp(vApp.getHref());
// check to see the result of calling deploy twice
deployTask = connection.deployVApp(vApp.getHref());
deployTask = api.deployVApp(vApp.getHref());
assertEquals(deployTask.getHref(), deployTask.getHref());
vApp = connection.getVApp(vApp.getHref());
vApp = api.getVApp(vApp.getHref());
assertEquals(vApp.getStatus(), Status.RESOLVED);
try {// per docs, this is not supported
connection.cancelTask(deployTask.getHref());
api.cancelTask(deployTask.getHref());
} catch (UnsupportedOperationException e) {
}
assert successTester.apply(deployTask.getHref());
System.out.printf("%d: done deploying vApp%n", System.currentTimeMillis());
vApp = connection.getVApp(vApp.getHref());
vApp = api.getVApp(vApp.getHref());
ReferenceType vAppResource = connection.findVDCInOrgNamed(null, null).getResourceEntities().get(serverName);
ReferenceType vAppResource = api.findVDCInOrgNamed(null, null).getResourceEntities().get(serverName);
assertEquals(vAppResource.getHref(), vApp.getHref());
int processorCount = 1;
@ -249,10 +247,10 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
verifyConfigurationOfVApp(vApp, serverName, expectedOs, processorCount, memory, hardDisk);
assertEquals(vApp.getStatus(), Status.OFF);
assert successTester.apply(connection.powerOnVApp(vApp.getHref()).getHref());
assert successTester.apply(api.powerOnVApp(vApp.getHref()).getHref());
System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis());
vApp = connection.getVApp(vApp.getHref());
vApp = api.getVApp(vApp.getHref());
assertEquals(vApp.getStatus(), Status.ON);
}
@ -261,20 +259,20 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
}
protected void prepare() {
Org org = connection.findOrgNamed(null);
Org org = api.findOrgNamed(null);
try {
key = connection.generateKeyPairInOrg(org.getHref(), "livetest", false);
key = api.generateKeyPairInOrg(org.getHref(), "livetest", false);
} catch (IllegalStateException e) {
key = connection.findKeyPairInOrg(org.getHref(), "livetest");
connection.deleteKeyPair(key.getId());
key = connection.generateKeyPairInOrg(org.getHref(), "livetest", false);
key = api.findKeyPairInOrg(org.getHref(), "livetest");
api.deleteKeyPair(key.getId());
key = api.generateKeyPairInOrg(org.getHref(), "livetest", false);
}
assertNotNull(key);
assertEquals(key.getName(), "livetest");
assertNotNull(key.getPrivateKey());
assertNotNull(key.getFingerPrint());
assertEquals(key.isDefault(), false);
assertEquals(key.getFingerPrint(), connection.findKeyPairInOrg(org.getHref(), key.getName()).getFingerPrint());
assertEquals(key.getFingerPrint(), api.findKeyPairInOrg(org.getHref(), key.getName()).getFingerPrint());
}
protected abstract Entry<InternetService, PublicIpAddress> getNewInternetServiceAndIpForSSH(VApp vApp);
@ -288,7 +286,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
@Test(enabled = true, dependsOnMethods = "testInstantiateAndPowerOn")
public void testCloneVApp() throws IOException {
assert successTester.apply(connection.powerOffVApp(vApp.getHref()).getHref());
assert successTester.apply(api.powerOffVApp(vApp.getHref()).getHref());
System.out.printf("%d: done powering off vApp%n", System.currentTimeMillis());
StringBuilder name = new StringBuilder();
@ -299,19 +297,19 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
CloneVAppOptions options = deploy().powerOn().withDescription("The description of " + newName);
System.out.printf("%d: cloning vApp%n", System.currentTimeMillis());
Task task = connection.cloneVAppInVDC(vdc.getHref(), vApp.getHref(), newName, options);
Task task = api.cloneVAppInVDC(vdc.getHref(), vApp.getHref(), newName, options);
// wait for the task to complete
assert successTester.apply(task.getHref());
System.out.printf("%d: done cloning vApp%n", System.currentTimeMillis());
assert successTester.apply(connection.powerOnVApp(vApp.getHref()).getHref());
assert successTester.apply(api.powerOnVApp(vApp.getHref()).getHref());
System.out.printf("%d: done powering on vApp%n", System.currentTimeMillis());
// refresh task to get the new vApp location
task = connection.getTask(task.getHref());
task = api.getTask(task.getHref());
clone = connection.getVApp(task.getOwner().getHref());
clone = api.getVApp(task.getOwner().getHref());
assertEquals(clone.getStatus(), Status.ON);
assertEquals(clone.getName(), newName);
@ -320,7 +318,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
@Test(enabled = true, dependsOnMethods = { "testInstantiateAndPowerOn", "testAddInternetService" })
public void testPublicIp() throws InterruptedException, ExecutionException, TimeoutException, IOException {
node = connection.addNode(is.getId(), Iterables.getLast(vApp.getNetworkToAddresses().values()), vApp.getName()
node = api.addNode(is.getId(), Iterables.getLast(vApp.getNetworkToAddresses().values()), vApp.getName()
+ "-SSH", 22);
loopAndCheckPass();
}
@ -342,53 +340,53 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
@Test(enabled = true, dependsOnMethods = "testPublicIp")
public void testConfigureNode() throws InterruptedException, ExecutionException, TimeoutException, IOException {
connection.configureNode(node.getId(), node.getName(), node.isEnabled(), "holy cow");
api.configureNode(node.getId(), node.getName(), node.isEnabled(), "holy cow");
}
@Test(enabled = true, dependsOnMethods = "testPublicIp")
public void testLifeCycle() throws InterruptedException, ExecutionException, TimeoutException, IOException {
try {// per docs, this is not supported
connection.undeployVApp(vApp.getHref());
api.undeployVApp(vApp.getHref());
fail("Expected UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
}
try {// per docs, this is not supported
connection.suspendVApp(vApp.getHref());
api.suspendVApp(vApp.getHref());
fail("Expected UnsupportedOperationException");
} catch (UnsupportedOperationException e) {
}
assert successTester.apply(connection.resetVApp(vApp.getHref()).getHref());
assert successTester.apply(api.resetVApp(vApp.getHref()).getHref());
vApp = connection.getVApp(vApp.getHref());
vApp = api.getVApp(vApp.getHref());
assertEquals(vApp.getStatus(), Status.ON);
// TODO we need to determine whether shutdown is supported before invoking
// it.
// connection.shutdownVApp(vApp.getId());
// vApp = connection.getVApp(vApp.getId());
// api.shutdownVApp(vApp.getId());
// vApp = api.getVApp(vApp.getId());
// assertEquals(vApp.getStatus(), VAppStatus.ON);
assert successTester.apply(connection.powerOffVApp(vApp.getHref()).getHref());
assert successTester.apply(api.powerOffVApp(vApp.getHref()).getHref());
vApp = connection.getVApp(vApp.getHref());
vApp = api.getVApp(vApp.getHref());
assertEquals(vApp.getStatus(), Status.OFF);
}
@Test(enabled = true, dependsOnMethods = "testLifeCycle")
public void testConfigure() throws InterruptedException, ExecutionException, TimeoutException, IOException {
vApp = connection.getVApp(vApp.getHref());
vApp = api.getVApp(vApp.getHref());
Task task = connection.configureVApp(vApp, changeNameTo("eduardo").changeMemoryTo(1536).changeProcessorCountTo(1)
Task task = api.configureVApp(vApp, changeNameTo("eduardo").changeMemoryTo(1536).changeProcessorCountTo(1)
.addDisk(25 * 1048576).addDisk(25 * 1048576));
assert successTester.apply(task.getHref());
vApp = connection.getVApp(vApp.getHref());
vApp = api.getVApp(vApp.getHref());
assertEquals(vApp.getName(), "eduardo");
assertEquals(find(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.PROCESSOR))
.getVirtualQuantity().longValue(), 1);
@ -397,23 +395,23 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
assertEquals(size(filter(vApp.getResourceAllocations(), CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE))),
3);
assert successTester.apply(connection.powerOnVApp(vApp.getHref()).getHref());
assert successTester.apply(api.powerOnVApp(vApp.getHref()).getHref());
loopAndCheckPass();
assert successTester.apply(connection.powerOffVApp(vApp.getHref()).getHref());
assert successTester.apply(api.powerOffVApp(vApp.getHref()).getHref());
// extract the disks on the vApp sorted by addressOnParent
List<ResourceAllocationSettingData> disks = Lists.newArrayList(filter(vApp.getResourceAllocations(),
CIMPredicates.resourceTypeIn(ResourceType.DISK_DRIVE)));
// delete the second disk
task = connection.configureVApp(vApp,
task = api.configureVApp(vApp,
deleteDiskWithAddressOnParent(Integer.parseInt(disks.get(1).getAddressOnParent())));
assert successTester.apply(task.getHref());
assert successTester.apply(connection.powerOnVApp(vApp.getHref()).getHref());
assert successTester.apply(api.powerOnVApp(vApp.getHref()).getHref());
loopAndCheckPass();
}
@ -457,47 +455,42 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
@AfterGroups(groups = { "live" })
void cleanup() throws InterruptedException, ExecutionException, TimeoutException {
if (node != null)
connection.deleteNode(node.getId());
api.deleteNode(node.getId());
if (is != null)
connection.deleteInternetService(is.getId());
api.deleteInternetService(is.getId());
if (key != null)
connection.deleteKeyPair(key.getId());
api.deleteKeyPair(key.getId());
if (vApp != null) {
try {
successTester.apply(connection.powerOffVApp(vApp.getHref()).getHref());
successTester.apply(api.powerOffVApp(vApp.getHref()).getHref());
} catch (Exception e) {
}
connection.deleteVApp(vApp.getHref());
api.deleteVApp(vApp.getHref());
}
if (clone != null) {
try {
successTester.apply(connection.powerOffVApp(clone.getHref()).getHref());
successTester.apply(api.powerOffVApp(clone.getHref()).getHref());
} catch (Exception e) {
}
connection.deleteVApp(clone.getHref());
api.deleteVApp(clone.getHref());
}
}
}
@SuppressWarnings("unchecked")
@Override
@BeforeClass(groups = { "integration", "live" })
public void setupContext() {
super.setupContext();
injector = view.utils().injector();
protected TerremarkVCloudClient create(Properties props, Iterable<Module> modules) {
Injector injector = newBuilder().modules(modules).overrides(props).buildInjector();
sshFactory = injector.getInstance(SshClient.Factory.class);
// longer than default internet service timeout
socketTester = retry(injector.getInstance(SocketOpen.class), 300, 10, SECONDS);
successTester = retry(injector.getInstance(TaskSuccess.class), 650, 10, SECONDS);
connection = (S) RestContext.class.cast(view.unwrap()).getApi();
api = injector.getInstance(TerremarkVCloudClient.class);
orgs = listOrgs();
return api;
}
@Test
public void testOrg() throws Exception {
for (Org org : orgs) {
@ -506,21 +499,21 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
assert org.getCatalogs().size() >= 1;
assert org.getTasksLists().size() >= 1;
assert org.getVDCs().size() >= 1;
assertEquals(connection.findOrgNamed(org.getName()), org);
assertEquals(api.findOrgNamed(org.getName()), org);
}
}
@Test
public void testPropertiesCanOverrideDefaultOrg() throws Exception {
for (Org org : orgs) {
RestContext<S, A> newContext = null;
TerremarkVCloudClient newApi = null;
try {
newContext = createView(
newApi = create(
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName())),
setupModules()).unwrap();
assertEquals(newContext.getApi().findOrgNamed(null), org);
setupModules());
assertEquals(newApi.findOrgNamed(null), org);
} finally {
newContext.close();
newApi.close();
}
}
}
@ -535,11 +528,11 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
public void testCatalog() throws Exception {
for (Org org : orgs) {
for (ReferenceType cat : org.getCatalogs().values()) {
Catalog response = connection.getCatalog(cat.getHref());
Catalog response = api.getCatalog(cat.getHref());
assertNotNull(response);
assertNotNull(response.getName());
assertNotNull(response.getHref());
assertEquals(connection.findCatalogInOrgNamed(org.getName(), response.getName()), response);
assertEquals(api.findCatalogInOrgNamed(org.getName(), response.getName()), response);
}
}
}
@ -548,15 +541,14 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
public void testPropertiesCanOverrideDefaultCatalog() throws Exception {
for (Org org : orgs) {
for (ReferenceType cat : org.getCatalogs().values()) {
RestContext<S, A> newContext = null;
TerremarkVCloudClient newApi = null;
try {
newContext = createView(
newApi = create(
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_CATALOG, cat.getName())), setupModules())
.unwrap();
assertEquals(newContext.getApi().findCatalogInOrgNamed(null, null), connection.getCatalog(cat.getHref()));
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_CATALOG, cat.getName())), setupModules());
assertEquals(newApi.findCatalogInOrgNamed(null, null), api.getCatalog(cat.getHref()));
} finally {
newContext.close();
newApi.close();
}
}
}
@ -566,16 +558,16 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
public void testGetVDCNetwork() throws Exception {
for (Org org : orgs) {
for (ReferenceType vdc : org.getVDCs().values()) {
VDC response = connection.getVDC(vdc.getHref());
VDC response = api.getVDC(vdc.getHref());
for (ReferenceType resource : response.getAvailableNetworks().values()) {
if (resource.getType().equals(TerremarkVCloudMediaType.NETWORK_XML)) {
try {
Network net = connection.getNetwork(resource.getHref());
Network net = api.getNetwork(resource.getHref());
assertNotNull(net);
assertNotNull(net.getName());
assertNotNull(net.getHref());
assertEquals(
connection.findNetworkInOrgVDCNamed(org.getName(), response.getName(), net.getName()), net);
api.findNetworkInOrgVDCNamed(org.getName(), response.getName(), net.getName()), net);
} catch (AuthorizationException e) {
}
@ -589,19 +581,18 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
public void testPropertiesCanOverrideDefaultNetwork() throws Exception {
for (Org org : orgs) {
for (ReferenceType vdc : org.getVDCs().values()) {
VDC response = connection.getVDC(vdc.getHref());
VDC response = api.getVDC(vdc.getHref());
for (ReferenceType net : response.getAvailableNetworks().values()) {
RestContext<S, A> newContext = null;
TerremarkVCloudClient newApi = null;
try {
newContext = createView(
newApi = create(
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName(),
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK, net.getName())), setupModules())
.unwrap();
assertEquals(newContext.getApi().findNetworkInOrgVDCNamed(null, null, net.getName()),
connection.getNetwork(net.getHref()));
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_NETWORK, net.getName())), setupModules());
assertEquals(newApi.findNetworkInOrgVDCNamed(null, null, net.getName()),
api.getNetwork(net.getHref()));
} finally {
newContext.close();
newApi.close();
}
}
}
@ -612,10 +603,10 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
public void testGetCatalogItem() throws Exception {
for (Org org : orgs) {
for (ReferenceType cat : org.getCatalogs().values()) {
Catalog response = connection.getCatalog(cat.getHref());
Catalog response = api.getCatalog(cat.getHref());
for (ReferenceType resource : response.values()) {
if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
CatalogItem item = connection.getCatalogItem(resource.getHref());
CatalogItem item = api.getCatalogItem(resource.getHref());
verifyCatalogItem(item);
}
}
@ -636,10 +627,10 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
public void testFindCatalogItem() throws Exception {
for (Org org : orgs) {
for (ReferenceType cat : org.getCatalogs().values()) {
Catalog response = connection.getCatalog(cat.getHref());
Catalog response = api.getCatalog(cat.getHref());
for (ReferenceType resource : response.values()) {
if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
CatalogItem item = connection.findCatalogItemInOrgCatalogNamed(org.getName(), response.getName(),
CatalogItem item = api.findCatalogItemInOrgCatalogNamed(org.getName(), response.getName(),
resource.getName());
verifyCatalogItem(item);
}
@ -652,7 +643,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
public void testDefaultVDC() throws Exception {
for (Org org : orgs) {
for (ReferenceType vdc : org.getVDCs().values()) {
VDC response = connection.getVDC(vdc.getHref());
VDC response = api.getVDC(vdc.getHref());
assertNotNull(response);
assertNotNull(response.getName());
assertNotNull(response.getHref());
@ -661,7 +652,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
assertNotNull(response.getCatalog());
assertNotNull(response.getInternetServices());
assertNotNull(response.getPublicIps());
assertEquals(connection.getVDC(response.getHref()), response);
assertEquals(api.getVDC(response.getHref()), response);
}
}
}
@ -670,15 +661,14 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
public void testPropertiesCanOverrideDefaultVDC() throws Exception {
for (Org org : orgs) {
for (ReferenceType vdc : org.getVDCs().values()) {
RestContext<S, A> newContext = null;
TerremarkVCloudClient newApi = null;
try {
newContext = createView(
newApi = create(
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName())), setupModules())
.unwrap();
assertEquals(newContext.getApi().findVDCInOrgNamed(null, null), connection.getVDC(vdc.getHref()));
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_VDC, vdc.getName())), setupModules());
assertEquals(newApi.findVDCInOrgNamed(null, null), api.getVDC(vdc.getHref()));
} finally {
newContext.close();
newApi.close();
}
}
}
@ -688,12 +678,12 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
public void testDefaultTasksList() throws Exception {
for (Org org : orgs) {
for (ReferenceType tasksList : org.getTasksLists().values()) {
org.jclouds.trmk.vcloud_0_8.domain.TasksList response = connection.findTasksListInOrgNamed(org.getName(),
org.jclouds.trmk.vcloud_0_8.domain.TasksList response = api.findTasksListInOrgNamed(org.getName(),
tasksList.getName());
assertNotNull(response);
assertNotNull(response.getLocation());
assertNotNull(response.getTasks());
assertEquals(connection.getTasksList(response.getLocation()).getLocation(), response.getLocation());
assertEquals(api.getTasksList(response.getLocation()).getLocation(), response.getLocation());
}
}
}
@ -702,16 +692,15 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
public void testPropertiesCanOverrideDefaultTasksList() throws Exception {
for (Org org : orgs) {
for (ReferenceType tasksList : org.getTasksLists().values()) {
RestContext<S, A> newContext = null;
TerremarkVCloudClient newApi = null;
try {
newContext = createView(
newApi = create(
overrideDefaults(ImmutableMap.of(VCloudConstants.PROPERTY_VCLOUD_DEFAULT_ORG, org.getName(),
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_TASKSLIST, tasksList.getName())), setupModules())
.unwrap();
assertEquals(newContext.getApi().findTasksListInOrgNamed(null, null),
connection.getTasksList(tasksList.getHref()));
VCloudConstants.PROPERTY_VCLOUD_DEFAULT_TASKSLIST, tasksList.getName())), setupModules());
assertEquals(newApi.findTasksListInOrgNamed(null, null),
api.getTasksList(tasksList.getHref()));
} finally {
newContext.close();
newApi.close();
}
}
}
@ -721,14 +710,14 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
public void testGetTask() throws Exception {
for (Org org : orgs) {
for (ReferenceType tasksList : org.getTasksLists().values()) {
org.jclouds.trmk.vcloud_0_8.domain.TasksList response = connection.findTasksListInOrgNamed(org.getName(),
org.jclouds.trmk.vcloud_0_8.domain.TasksList response = api.findTasksListInOrgNamed(org.getName(),
tasksList.getName());
assertNotNull(response);
assertNotNull(response.getLocation());
assertNotNull(response.getTasks());
if (response.getTasks().size() > 0) {
Task task = response.getTasks().last();
assertEquals(connection.getTask(task.getHref()).getHref(), task.getHref());
assertEquals(api.getTask(task.getHref()).getHref(), task.getHref());
}
}
}
@ -736,17 +725,12 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
protected Iterable<Org> orgs;
@AfterGroups(groups = { "live" })
public void teardownClient() {
view.close();
}
protected Iterable<Org> listOrgs() {
return Iterables.transform(connection.listOrgs().values(), new Function<ReferenceType, Org>() {
return Iterables.transform(api.listOrgs().values(), new Function<ReferenceType, Org>() {
@Override
public Org apply(ReferenceType arg0) {
return connection.getOrg(arg0.getHref());
return api.getOrg(arg0.getHref());
}
});
@ -756,12 +740,12 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
public void testGetVAppTemplate() throws Exception {
for (Org org : orgs) {
for (ReferenceType cat : org.getCatalogs().values()) {
Catalog response = connection.getCatalog(cat.getHref());
Catalog response = api.getCatalog(cat.getHref());
for (ReferenceType resource : response.values()) {
if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
CatalogItem item = connection.getCatalogItem(resource.getHref());
CatalogItem item = api.getCatalogItem(resource.getHref());
if (item.getEntity().getType().equals(TerremarkVCloudMediaType.VAPPTEMPLATE_XML)) {
assertNotNull(connection.getVAppTemplate(item.getEntity().getHref()));
assertNotNull(api.getVAppTemplate(item.getEntity().getHref()));
}
}
}
@ -771,13 +755,13 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
@Test
public void testGetVApp() throws Exception {
for (Org org : listOrgs()) {
for (Org org : orgs) {
for (ReferenceType vdc : org.getVDCs().values()) {
VDC response = connection.getVDC(vdc.getHref());
VDC response = api.getVDC(vdc.getHref());
for (ReferenceType item : response.getResourceEntities().values()) {
if (item.getType().equals(TerremarkVCloudMediaType.VAPP_XML)) {
try {
VApp app = connection.getVApp(item.getHref());
VApp app = api.getVApp(item.getHref());
assertNotNull(app);
} catch (RuntimeException e) {
@ -790,14 +774,14 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
@Test
public void testFindVAppTemplate() throws Exception {
for (Org org : listOrgs()) {
for (Org org : orgs) {
for (ReferenceType cat : org.getCatalogs().values()) {
Catalog response = connection.getCatalog(cat.getHref());
Catalog response = api.getCatalog(cat.getHref());
for (ReferenceType resource : response.values()) {
if (resource.getType().equals(TerremarkVCloudMediaType.CATALOGITEM_XML)) {
CatalogItem item = connection.getCatalogItem(resource.getHref());
CatalogItem item = api.getCatalogItem(resource.getHref());
if (item.getEntity().getType().equals(TerremarkVCloudMediaType.VAPPTEMPLATE_XML)) {
assertNotNull(connection.findVAppTemplateInOrgCatalogNamed(org.getName(), response.getName(), item
assertNotNull(api.findVAppTemplateInOrgCatalogNamed(org.getName(), response.getName(), item
.getEntity().getName()));
}
}
@ -807,8 +791,7 @@ public abstract class TerremarkClientLiveTest<S extends TerremarkVCloudClient, A
}
@Override
protected Module getSshModule() {
return new SshjSshClientModule();
protected Iterable<Module> setupModules() {
return ImmutableSet.<Module> of(getLoggingModule(), new SshjSshClientModule());
}
}

View File

@ -24,10 +24,8 @@ import static org.jclouds.util.Predicates2.retry;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.predicates.SocketOpen;
import org.jclouds.rest.RestContext;
import org.jclouds.ssh.SshClient.Factory;
import org.jclouds.sshj.config.SshjSshClientModule;
import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient;
import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@ -42,7 +40,7 @@ import com.google.inject.Module;
* @author Adrian Cole
*/
@Test(groups = "live", enabled = true, singleThreaded = true)
public abstract class BaseTerremarkClientLiveTest<S extends TerremarkVCloudClient, A extends TerremarkVCloudAsyncClient> extends BaseComputeServiceContextLiveTest {
public abstract class BaseTerremarkClientLiveTest extends BaseComputeServiceContextLiveTest {
protected String prefix = System.getProperty("user.name");
@ -54,9 +52,8 @@ public abstract class BaseTerremarkClientLiveTest<S extends TerremarkVCloudClien
protected Predicate<HostAndPort> socketTester;
protected Factory sshFactory;
protected S connection;
protected TerremarkVCloudClient api;
@SuppressWarnings("unchecked")
@Override
@BeforeClass(groups = { "integration", "live" })
public void setupContext() {
@ -65,7 +62,7 @@ public abstract class BaseTerremarkClientLiveTest<S extends TerremarkVCloudClien
SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
socketTester = retry(socketOpen, 300, 1, SECONDS);
sshFactory = injector.getInstance(Factory.class);
connection = (S) RestContext.class.cast(view.unwrap()).getApi();
api = injector.getInstance(TerremarkVCloudClient.class);
}
protected Module getSshModule() {

View File

@ -0,0 +1,148 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds licenses this file
* to you 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.apis;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.io.Closeables.closeQuietly;
import static org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME;
import static org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS;
import java.io.Closeable;
import java.util.NoSuchElementException;
import java.util.Properties;
import java.util.logging.Logger;
import org.jclouds.ContextBuilder;
import org.jclouds.logging.LoggingModules;
import org.jclouds.logging.config.LoggingModule;
import org.jclouds.providers.ProviderMetadata;
import org.jclouds.providers.Providers;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
public abstract class BaseApiLiveTest<A extends Closeable> {
protected String prefix = System.getProperty("user.name");
protected String provider;
protected volatile A api;
protected String identity;
protected String credential;
protected String endpoint;
protected String apiVersion;
protected Properties setupProperties() {
Properties overrides = new Properties();
overrides.setProperty(PROPERTY_TRUST_ALL_CERTS, "true");
overrides.setProperty(PROPERTY_RELAX_HOSTNAME, "true");
identity = setIfTestSystemPropertyPresent(overrides, provider + ".identity");
credential = setIfTestSystemPropertyPresent(overrides, provider + ".credential");
endpoint = setIfTestSystemPropertyPresent(overrides, provider + ".endpoint");
apiVersion = setIfTestSystemPropertyPresent(overrides, provider + ".api-version");
setIfTestSystemPropertyPresent(overrides, provider + ".build-version");
return overrides;
}
protected String setIfTestSystemPropertyPresent(Properties overrides, String key) {
if (System.getProperties().containsKey("test." + key)) {
String val = System.getProperty("test." + key);
overrides.setProperty(key, val);
return val;
}
return null;
}
@BeforeClass(groups = { "integration", "live" })
public void setup() {
initialize();
}
protected void initialize() {
closeQuietly(api);
api = create(setupProperties(), setupModules());
}
protected Iterable<Module> setupModules() {
return ImmutableSet.<Module> of(getLoggingModule());
}
protected LoggingModule getLoggingModule() {
return LoggingModules.firstOrJDKLoggingModule();
}
/**
* @see org.jclouds.providers.Providers#withId
*/
protected ProviderMetadata createProviderMetadata() {
try {
return Providers.withId(provider);
} catch (NoSuchElementException e) {
return null;
}
}
/**
* @see org.jclouds.apis.Apis#withId
*/
protected ApiMetadata createApiMetadata() {
try {
return Apis.withId(provider);
} catch (NoSuchElementException e) {
return null;
}
}
@SuppressWarnings("serial")
protected A create(Properties props, Iterable<Module> modules) {
return newBuilder().modules(modules).overrides(props).buildApi(new TypeToken<A>(getClass()) {
});
}
protected ContextBuilder newBuilder() {
if (provider != null)
try {
return ContextBuilder.newBuilder(provider);
} catch (NoSuchElementException e){
Logger.getAnonymousLogger()
.warning("provider ["
+ provider
+ "] is not setup as META-INF/services/org.jclouds.apis.ApiMetadata or META-INF/services/org.jclouds.providers.ProviderMetadata");
}
ProviderMetadata pm = createProviderMetadata();
ContextBuilder builder = pm != null ? ContextBuilder.newBuilder(pm) : ContextBuilder
.newBuilder(ApiMetadata.class.cast(checkNotNull(createApiMetadata(),
"either createApiMetadata or createProviderMetadata must be overridden")));
return builder;
}
@AfterClass(groups = { "integration", "live" })
protected void tearDown() {
closeQuietly(api);
}
}

View File

@ -33,6 +33,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
import java.net.MalformedURLException;
import java.net.URI;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@ -140,9 +141,9 @@ public abstract class BaseHttpCommandExecutorServiceIntegrationTest extends Base
}.hash(md5()).asBytes()), md5);
}
private InputStream getConsitution() {
private InputStream getConsitution() throws MalformedURLException, IOException {
URI constitutionUri = URI.create(format("http://localhost:%d/101constitutions", testPort));
return context.utils().http().get(constitutionUri);
return constitutionUri.toURL().openStream();
}
/**

View File

@ -61,7 +61,6 @@ import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.jclouds.ContextBuilder;
import org.jclouds.providers.AnonymousProviderMetadata;
import org.jclouds.rest.RestContext;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Optional;
@ -87,7 +86,6 @@ public abstract class BaseJettyTest {
protected Injector injector;
private AtomicInteger cycle = new AtomicInteger(0);
private Server server2;
protected RestContext<IntegrationTestClient, IntegrationTestAsyncClient> context;
protected int testPort;
protected String md5;
static final Pattern actionPattern = Pattern.compile("/objects/(.*)/action/([a-z]*);?(.*)");
@ -170,8 +168,7 @@ public abstract class BaseJettyTest {
Properties properties = new Properties();
addConnectionProperties(properties);
context = newBuilder(testPort, properties, createConnectionModule()).build();
client = context.getApi();
client = newBuilder(testPort, properties, createConnectionModule()).buildApi(IntegrationTestClient.class);
assert client != null;
assert client.newStringBuilder() != null;
@ -279,7 +276,7 @@ public abstract class BaseJettyTest {
@AfterClass
public void tearDownJetty() throws Exception {
closeQuietly(context);
closeQuietly(client);
if (server2 != null)
server2.stop();
server.stop();

View File

@ -37,7 +37,6 @@ import org.jclouds.aws.ec2.domain.AWSRunningInstance;
import org.jclouds.aws.ec2.domain.MonitoringState;
import org.jclouds.aws.ec2.services.AWSSecurityGroupClient;
import org.jclouds.cloudwatch.CloudWatchApi;
import org.jclouds.cloudwatch.CloudWatchAsyncApi;
import org.jclouds.cloudwatch.domain.Dimension;
import org.jclouds.cloudwatch.domain.EC2Constants;
import org.jclouds.cloudwatch.domain.GetMetricStatistics;
@ -56,7 +55,6 @@ import org.jclouds.ec2.domain.KeyPair;
import org.jclouds.ec2.domain.SecurityGroup;
import org.jclouds.ec2.services.InstanceClient;
import org.jclouds.ec2.services.KeyPairClient;
import org.jclouds.rest.RestContext;
import org.jclouds.scriptbuilder.domain.Statements;
import org.testng.annotations.Test;
@ -157,13 +155,13 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
// stop the spinner
future.cancel(true);
RestContext<CloudWatchApi, CloudWatchAsyncApi> monitoringContext = ContextBuilder
.newBuilder(new AWSCloudWatchProviderMetadata())
CloudWatchApi monitoringApi = ContextBuilder.newBuilder(new AWSCloudWatchProviderMetadata())
.credentials(identity, credential)
.modules(setupModules()).build();
.modules(setupModules())
.buildApi(CloudWatchApi.class);
try {
GetMetricStatisticsResponse datapoints = monitoringContext.getApi().getMetricApiForRegion(instance.getRegion())
GetMetricStatisticsResponse datapoints = monitoringApi.getMetricApiForRegion(instance.getRegion())
.getMetricStatistics(GetMetricStatistics.builder()
.dimension(new Dimension(EC2Constants.Dimension.INSTANCE_ID, instance.getId()))
.unit(Unit.PERCENT)
@ -176,7 +174,7 @@ public class AWSEC2ComputeServiceLiveTest extends EC2ComputeServiceLiveTest {
.build());
assert (datapoints.size() > 0) : instance;
} finally {
monitoringContext.close();
monitoringApi.close();
}
// make sure we made our dummy group and also let in the user's group

View File

@ -19,7 +19,8 @@
package org.jclouds.aws.ec2.compute.extensions;
import org.jclouds.aws.ec2.AWSEC2AsyncClient;
import static com.google.common.collect.Iterables.transform;
import org.jclouds.aws.ec2.AWSEC2Client;
import org.jclouds.aws.util.AWSUtils;
import org.jclouds.compute.domain.Image;
@ -27,11 +28,9 @@ import org.jclouds.compute.extensions.ImageExtension;
import org.jclouds.compute.extensions.internal.BaseImageExtensionLiveTest;
import org.jclouds.ec2.compute.functions.EC2ImageParser;
import org.jclouds.ec2.options.DescribeImagesOptions;
import org.jclouds.rest.RestContext;
import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
import com.google.inject.Module;
/**
@ -49,14 +48,14 @@ public class AWSEC2ImageExtensionLiveTest extends BaseImageExtensionLiveTest {
@Override
protected Iterable<? extends Image> listImages() {
RestContext<AWSEC2Client, AWSEC2AsyncClient> unwrapped = view.unwrap();
AWSEC2Client client = view.utils().getInjector().getInstance(AWSEC2Client.class);
String[] parts = AWSUtils.parseHandle(imageId);
String region = parts[0];
String imageId = parts[1];
EC2ImageParser parser = view.utils().getInjector().getInstance(EC2ImageParser.class);
return Iterables.transform(
unwrapped.getApi().getAMIServices()
.describeImagesInRegion(region, new DescribeImagesOptions().imageIds(imageId)), parser);
return transform(
client.getAMIServices().describeImagesInRegion(region, new DescribeImagesOptions().imageIds(imageId)),
parser);
}
@Override

View File

@ -54,6 +54,6 @@ public class TagSecurityGroupLiveTest extends BaseTagApiLiveTest {
}
private AWSSecurityGroupClient securityGroupApi() {
return AWSEC2Client.class.cast(context.getApi()).getSecurityGroupServices();
return AWSEC2Client.class.cast(api).getSecurityGroupServices();
}
}

View File

@ -28,7 +28,6 @@ import org.jclouds.aws.s3.AWSS3Client;
import org.jclouds.aws.s3.predicates.validators.AWSS3BucketNameValidator;
import org.jclouds.location.Region;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestContext;
import org.jclouds.s3.S3AsyncClient;
import org.jclouds.s3.S3Client;
import org.jclouds.s3.config.S3RestClientModule;
@ -72,15 +71,4 @@ public class AWSS3RestClientModule extends S3RestClientModule<AWSS3Client, AWSS3
S3AsyncClient provide(AWSS3AsyncClient in) {
return in;
}
/**
* so that we can inject RestContext<S3Client, S3AsyncClient>
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
@Singleton
@Provides
RestContext<S3Client, S3AsyncClient> provideBaseContext(RestContext<AWSS3Client, AWSS3AsyncClient> in) {
return (RestContext) in;
}
}

View File

@ -18,6 +18,8 @@
*/
package org.jclouds.dynect.v3;
import java.io.Closeable;
import javax.ws.rs.PathParam;
import org.jclouds.dynect.v3.domain.Job;
@ -36,7 +38,7 @@ import org.jclouds.rest.annotations.Delegate;
* />
* @author Adrian Cole
*/
public interface DynECTApi {
public interface DynECTApi extends Closeable {
/**
* returns the current status of a job.
*

View File

@ -20,6 +20,8 @@ package org.jclouds.dynect.v3;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import java.io.Closeable;
import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
@ -48,7 +50,7 @@ import com.google.common.util.concurrent.ListenableFuture;
* @see <a href="https://manage.dynect.net/help/docs/api2/rest/" />
* @author Adrian Cole
*/
public interface DynECTAsyncApi {
public interface DynECTAsyncApi extends Closeable {
/**
* @see DynECTApi#getJob
*/

View File

@ -54,7 +54,7 @@ public class DynectApiMockTest {
.endpoint(uri)
.overrides(overrides)
.modules(modules)
.build(DynECTApiMetadata.CONTEXT_TOKEN).getApi();
.buildApi(DynECTApi.class);
}
String session = "{\"status\": \"success\", \"data\": {\"token\": \"FFFFFFFFFF\", \"version\": \"3.3.8\"}, \"job_id\": 254417252, \"msgs\": [{\"INFO\": \"login: Login successful\", \"SOURCE\": \"BLL\", \"ERR_CD\": null, \"LVL\": \"INFO\"}]}";

View File

@ -199,7 +199,7 @@ public class RecordApiLiveTest extends BaseDynECTApiLiveTest {
checkNotNull(job, "unable to create zone %s", zoneFQDN);
getAnonymousLogger().info("created zone: " + job);
assertEquals(job.getStatus(), Status.SUCCESS);
assertEquals(context.getApi().getJob(job.getId()), job);
assertEquals(api.getJob(job.getId()), job);
Zone zone = zoneApi().publish(zoneFQDN);
checkNotNull(zone, "unable to publish zone %s", zoneFQDN);
getAnonymousLogger().info("published zone: " + zone);
@ -229,7 +229,7 @@ public class RecordApiLiveTest extends BaseDynECTApiLiveTest {
checkNotNull(job, "unable to create record %s", record);
getAnonymousLogger().info("created record: " + job);
assertEquals(job.getStatus(), Status.SUCCESS);
assertEquals(context.getApi().getJob(job.getId()), job);
assertEquals(api.getJob(job.getId()), job);
zoneApi().publish(zoneFQDN);
}
@ -265,22 +265,22 @@ public class RecordApiLiveTest extends BaseDynECTApiLiveTest {
checkNotNull(job, "unable to delete record %s", id);
getAnonymousLogger().info("deleted record: " + job);
assertEquals(job.getStatus(), Status.SUCCESS);
assertEquals(context.getApi().getJob(job.getId()), job);
assertEquals(api.getJob(job.getId()), job);
zoneApi().publish(zoneFQDN);
}
protected RecordApi api(String zoneFQDN) {
return context.getApi().getRecordApiForZone(zoneFQDN);
return api.getRecordApiForZone(zoneFQDN);
}
protected ZoneApi zoneApi() {
return context.getApi().getZoneApi();
return api.getZoneApi();
}
@Override
@AfterClass(groups = "live", alwaysRun = true)
protected void tearDownContext() {
protected void tearDown() {
zoneApi().delete(zoneFQDN);
super.tearDownContext();
super.tearDown();
}
}

View File

@ -50,14 +50,14 @@ public class SessionApiLiveTest extends BaseDynECTApiLiveTest {
}
protected SessionApi api() {
return context.getApi().getSessionApi();
return api.getSessionApi();
}
@AfterClass(groups = { "integration", "live" })
@Override
protected void tearDownContext() {
protected void tearDown() {
if (session != null)
api().logout(session.getToken());
super.tearDownContext();
super.tearDown();
}
}

View File

@ -75,7 +75,7 @@ public class ZoneApiLiveTest extends BaseDynECTApiLiveTest {
checkNotNull(job, "unable to create zone %s", fqdn);
getAnonymousLogger().info("created zone: " + job);
assertEquals(job.getStatus(), Status.SUCCESS);
assertEquals(context.getApi().getJob(job.getId()), job);
assertEquals(api.getJob(job.getId()), job);
}
@Test(dependsOnMethods = "testCreateZone")
@ -90,7 +90,7 @@ public class ZoneApiLiveTest extends BaseDynECTApiLiveTest {
public void testFreezeZone() {
Job job = api().freeze(fqdn);
assertEquals(job.getStatus(), Status.SUCCESS);
assertEquals(context.getApi().getJob(job.getId()), job);
assertEquals(api.getJob(job.getId()), job);
// TODO: determine how to prove it is frozen
}
@ -98,7 +98,7 @@ public class ZoneApiLiveTest extends BaseDynECTApiLiveTest {
public void testThawZone() {
Job job = api().thaw(fqdn);
assertEquals(job.getStatus(), Status.SUCCESS);
assertEquals(context.getApi().getJob(job.getId()), job);
assertEquals(api.getJob(job.getId()), job);
// TODO: determine how to prove it is thawed
}
@ -106,25 +106,25 @@ public class ZoneApiLiveTest extends BaseDynECTApiLiveTest {
public void testDeleteZoneChanges() {
Job job = api().deleteChanges(fqdn);
assertEquals(job.getStatus(), Status.SUCCESS);
assertEquals(context.getApi().getJob(job.getId()), job);
assertEquals(api.getJob(job.getId()), job);
}
@Test(dependsOnMethods = "testDeleteZoneChanges")
public void testDeleteZone() {
Job job = api().delete(fqdn);
assertEquals(job.getStatus(), Status.SUCCESS);
assertEquals(context.getApi().getJob(job.getId()), job);
assertEquals(api.getJob(job.getId()), job);
assertNull(api().get(fqdn), "job " + job + " didn't delete zone" + fqdn);
}
protected ZoneApi api() {
return context.getApi().getZoneApi();
return api.getZoneApi();
}
@Override
@AfterClass(groups = "live", alwaysRun = true)
protected void tearDownContext() {
protected void tearDown() {
api().delete(fqdn);
super.tearDownContext();
super.tearDown();
}
}

View File

@ -18,24 +18,13 @@
*/
package org.jclouds.dynect.v3.internal;
import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.apis.BaseApiLiveTest;
import org.jclouds.dynect.v3.DynECTApi;
import org.jclouds.dynect.v3.DynECTApiMetadata;
import org.jclouds.dynect.v3.DynECTAsyncApi;
import org.jclouds.rest.RestContext;
import org.testng.annotations.Test;
import com.google.common.reflect.TypeToken;
@Test(groups = "live")
public class BaseDynECTApiLiveTest extends BaseContextLiveTest<RestContext<DynECTApi, DynECTAsyncApi>> {
public class BaseDynECTApiLiveTest extends BaseApiLiveTest<DynECTApi> {
public BaseDynECTApiLiveTest() {
provider = "dynect";
}
@Override
protected TypeToken<RestContext<DynECTApi, DynECTAsyncApi>> contextType() {
return DynECTApiMetadata.CONTEXT_TOKEN;
}
}

View File

@ -18,6 +18,8 @@
*/
package org.jclouds.glesys;
import java.io.Closeable;
import org.jclouds.glesys.features.ArchiveApi;
import org.jclouds.glesys.features.DomainApi;
import org.jclouds.glesys.features.EmailAccountApi;
@ -33,7 +35,7 @@ import org.jclouds.rest.annotations.Delegate;
* @see <a href="https://customer.glesys.com/api.php" />
* @author Adrian Cole
*/
public interface GleSYSApi {
public interface GleSYSApi extends Closeable {
/**
* Provides synchronous access to Server features.

View File

@ -18,6 +18,8 @@
*/
package org.jclouds.glesys;
import java.io.Closeable;
import org.jclouds.glesys.features.ArchiveAsyncApi;
import org.jclouds.glesys.features.DomainAsyncApi;
import org.jclouds.glesys.features.EmailAccountAsyncApi;
@ -33,7 +35,7 @@ import org.jclouds.rest.annotations.Delegate;
* @see <a href="https://customer.glesys.com/api.php" />
* @author Adrian Cole
*/
public interface GleSYSAsyncApi {
public interface GleSYSAsyncApi extends Closeable {
/**
* Provides asynchronous access to Server features.

View File

@ -42,34 +42,34 @@ import com.google.common.base.Predicate;
public class ArchiveApiLiveTest extends BaseGleSYSApiLiveTest {
@BeforeClass(groups = { "integration", "live" })
public void setupContext() {
super.setupContext();
public void setup() {
super.setup();
api = gleContext.getApi().getArchiveApi();
archiveUser = gleContext.getIdentity().toLowerCase() + "_test9";
archiveApi = api.getArchiveApi();
archiveUser = identity.toLowerCase() + "_test9";
archiveCounter = retry(new Predicate<Integer>() {
public boolean apply(Integer value) {
return api.list().size() == value;
return archiveApi.list().size() == value;
}
}, 30, 1, SECONDS);
}
@AfterClass(groups = { "integration", "live" })
protected void tearDownContext() {
int before = api.list().size();
api.delete(archiveUser);
protected void tearDown() {
int before = archiveApi.list().size();
archiveApi.delete(archiveUser);
assertTrue(archiveCounter.apply(before - 1));
super.tearDownContext();
super.tearDown();
}
private ArchiveApi api;
private ArchiveApi archiveApi;
private String archiveUser;
private Predicate<Integer> archiveCounter;
@Test
public void testAllowedArguments() throws Exception {
ArchiveAllowedArguments args = api.getAllowedArguments();
ArchiveAllowedArguments args = archiveApi.getAllowedArguments();
assertNotNull(args);
assertNotNull(args.getSizes());
assertTrue(args.getSizes().size() > 0);
@ -82,36 +82,36 @@ public class ArchiveApiLiveTest extends BaseGleSYSApiLiveTest {
@Test
public void testCreateArchive() throws Exception {
try {
api.delete(archiveUser);
archiveApi.delete(archiveUser);
} catch(Exception ex) {
}
int before = api.list().size();
int before = archiveApi.list().size();
api.createWithCredentialsAndSize(archiveUser, "password", 10);
archiveApi.createWithCredentialsAndSize(archiveUser, "password", 10);
assertTrue(archiveCounter.apply(before + 1));
}
@Test(dependsOnMethods = "testCreateArchive")
public void testArchiveDetails() throws Exception {
Archive details = api.get(archiveUser);
Archive details = archiveApi.get(archiveUser);
assertEquals(details.getUsername(), archiveUser);
}
@Test(dependsOnMethods = "testCreateArchive")
public void testChangePassword() throws Exception {
api.changePassword(archiveUser, "newpassword");
archiveApi.changePassword(archiveUser, "newpassword");
// TODO assert something useful!
}
@Test(dependsOnMethods = "testCreateArchive")
public void testResizeArchive() throws Exception {
api.resize(archiveUser, 20);
archiveApi.resize(archiveUser, 20);
assertTrue(retry(new Predicate<String>() {
public boolean apply(String value) {
return api.get(archiveUser) != null && value.equals(api.get(archiveUser).getTotalSize());
return archiveApi.get(archiveUser) != null && value.equals(archiveApi.get(archiveUser).getTotalSize());
}
}, 30, 1, SECONDS).apply("20 GB"));
}

View File

@ -47,23 +47,23 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
public String testDomain;
@BeforeClass(groups = { "integration", "live" })
public void setupContext() {
super.setupContext();
public void setup() {
super.setup();
testDomain = identity.toLowerCase() + "-domain.jclouds.org";
api = gleContext.getApi().getDomainApi();
domainApi = api.getDomainApi();
domainCounter = retry(new Predicate<Integer>() {
public boolean apply(Integer value) {
return api.list().size() == value;
return domainApi.list().size() == value;
}
}, 30, 1, SECONDS);
recordCounter = retry(new Predicate<Integer>() {
public boolean apply(Integer value) {
return api.listRecords(testDomain).size() == value;
return domainApi.listRecords(testDomain).size() == value;
}
}, 30, 1, SECONDS);
try {
api.delete(testDomain);
domainApi.delete(testDomain);
} catch (Exception ex) {
}
@ -71,21 +71,21 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
}
@AfterClass(groups = { "integration", "live" })
public void tearDownContext() {
int before = api.list().size();
api.delete(testDomain);
public void tearDown() {
int before = domainApi.list().size();
domainApi.delete(testDomain);
assertTrue(domainCounter.apply(before - 1));
super.tearDownContext();
super.tearDown();
}
private DomainApi api;
private DomainApi domainApi;
private Predicate<Integer> domainCounter;
private Predicate<Integer> recordCounter;
@Test
public void testGetDomain() throws Exception {
Domain domain = api.get(testDomain);
Domain domain = domainApi.get(testDomain);
assertNotNull(domain);
assertEquals(domain.getName(), testDomain);
assertNotNull(domain.getCreateTime());
@ -93,20 +93,20 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
@Test
public void testUpdateDomain() throws Exception {
api.update(testDomain, DomainOptions.Builder.responsiblePerson("another-tester.jclouds.org."));
Domain domain = api.get(testDomain);
domainApi.update(testDomain, DomainOptions.Builder.responsiblePerson("another-tester.jclouds.org."));
Domain domain = domainApi.get(testDomain);
assertEquals(domain.getResponsiblePerson(), "another-tester.jclouds.org.");
}
@Test
public void testCreateRecord() throws Exception {
int before = api.listRecords(testDomain).size();
int before = domainApi.listRecords(testDomain).size();
api.createRecord(testDomain, "test", "A", "127.0.0.1");
domainApi.createRecord(testDomain, "test", "A", "127.0.0.1");
assertTrue(recordCounter.apply(before + 1));
for(DomainRecord record : api.listRecords(testDomain)) {
for(DomainRecord record : domainApi.listRecords(testDomain)) {
if ("test".equals(record.getHost())) {
assertEquals(record.getType(), "A");
assertEquals(record.getData(), "127.0.0.1");
@ -116,14 +116,14 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
@Test
public void testUpdateRecord() throws Exception {
int before = api.listRecords(testDomain).size();
int before = domainApi.listRecords(testDomain).size();
api.createRecord(testDomain, "testeditbefore", "A", "127.0.0.1");
domainApi.createRecord(testDomain, "testeditbefore", "A", "127.0.0.1");
assertTrue(recordCounter.apply(before + 1));
String recordId = null;
for(DomainRecord record : api.listRecords(testDomain)) {
for(DomainRecord record : domainApi.listRecords(testDomain)) {
if ("testeditbefore".equals(record.getHost())) {
assertEquals(record.getType(), "A");
assertEquals(record.getData(), "127.0.0.1");
@ -133,10 +133,10 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
assertNotNull(recordId);
api.updateRecord(recordId, UpdateRecordOptions.Builder.host("testeditafter"));
domainApi.updateRecord(recordId, UpdateRecordOptions.Builder.host("testeditafter"));
boolean found = false;
for(DomainRecord record : api.listRecords(testDomain)) {
for(DomainRecord record : domainApi.listRecords(testDomain)) {
if (recordId.equals(record.getId())) {
assertEquals(record.getHost(), "testeditafter");
assertEquals(record.getType(), "A");
@ -149,11 +149,11 @@ public class DomainApiLiveTest extends BaseGleSYSApiLiveTest {
@Test
public void testDeleteRecord() throws Exception {
Set<DomainRecord> domainRecords = api.listRecords(testDomain);
Set<DomainRecord> domainRecords = domainApi.listRecords(testDomain);
int before = domainRecords.size();
api.deleteRecord(domainRecords.iterator().next().getId());
domainApi.deleteRecord(domainRecords.iterator().next().getId());
assertTrue(recordCounter.apply(before - 1));
}

View File

@ -53,17 +53,17 @@ public class EmailAccountApiLiveTest extends BaseGleSYSApiLiveTest {
@BeforeClass(groups = { "integration", "live" })
@Override
public void setupContext() {
super.setupContext();
public void setup() {
super.setup();
testDomain = hostName + ".test.jclouds.org";
api = gleContext.getApi().getEmailAccountApi();
emailAccountApi = api.getEmailAccountApi();
deleteAll();
createDomain(testDomain);
emailAccountCounter = retry(new Predicate<Integer>() {
public boolean apply(Integer value) {
return api.listDomain(testDomain).size() == value;
return emailAccountApi.listDomain(testDomain).size() == value;
}
}, 180, 5, SECONDS);
@ -73,61 +73,61 @@ public class EmailAccountApiLiveTest extends BaseGleSYSApiLiveTest {
@AfterClass(groups = { "integration", "live" })
@Override
public void tearDownContext() {
public void tearDown() {
deleteAll();
super.tearDownContext();
super.tearDown();
}
private void deleteAll() {
api.delete("test@" + testDomain);
api.delete("test1@" + testDomain);
emailAccountApi.delete("test@" + testDomain);
emailAccountApi.delete("test1@" + testDomain);
}
private EmailAccountApi api;
private EmailAccountApi emailAccountApi;
private String testDomain;
private Predicate<Integer> emailAccountCounter;
@Test
public void testCreateEmail() {
api.createWithPassword("test@" + testDomain, "password", CreateAccountOptions.Builder.antiVirus(true)
emailAccountApi.createWithPassword("test@" + testDomain, "password", CreateAccountOptions.Builder.antiVirus(true)
.autorespond(true).autorespondMessage("out of office"));
assertTrue(emailAccountCounter.apply(1));
api.createWithPassword("test1@" + testDomain, "password");
emailAccountApi.createWithPassword("test1@" + testDomain, "password");
assertTrue(emailAccountCounter.apply(2));
}
@Test(dependsOnMethods = "testCreateEmail")
public void testAliases() {
assertTrue(api.listAliasesInDomain(testDomain).isEmpty());
assertTrue(emailAccountApi.listAliasesInDomain(testDomain).isEmpty());
EmailAlias alias = api.createAlias("test2@" + testDomain, "test@" + testDomain);
EmailAlias alias = emailAccountApi.createAlias("test2@" + testDomain, "test@" + testDomain);
assertEquals(alias.getAlias(), "test2@" + testDomain);
assertEquals(alias.getForwardTo(), "test@" + testDomain);
EmailAlias aliasFromList = Iterables.getOnlyElement(api.listAliasesInDomain(testDomain));
EmailAlias aliasFromList = Iterables.getOnlyElement(emailAccountApi.listAliasesInDomain(testDomain));
assertEquals(aliasFromList, alias);
EmailOverview overview = api.getOverview();
EmailOverview overview = emailAccountApi.getOverview();
assertEquals(1, overview.getSummary().getAliases());
alias = api.updateAlias("test2@" + testDomain, "test1@" + testDomain);
overview = api.getOverview();
alias = emailAccountApi.updateAlias("test2@" + testDomain, "test1@" + testDomain);
overview = emailAccountApi.getOverview();
assertEquals(1, overview.getSummary().getAliases());
aliasFromList = Iterables.getOnlyElement(api.listAliasesInDomain(testDomain));
aliasFromList = Iterables.getOnlyElement(emailAccountApi.listAliasesInDomain(testDomain));
assertEquals(aliasFromList, alias);
api.delete("test2@" + testDomain);
overview = api.getOverview();
emailAccountApi.delete("test2@" + testDomain);
overview = emailAccountApi.getOverview();
assertEquals(0, overview.getSummary().getAliases());
}
@Test(dependsOnMethods = "testCreateEmail")
public void testOverview() throws Exception {
EmailOverview overview = api.getOverview();
EmailOverview overview = emailAccountApi.getOverview();
assertNotNull(overview.getSummary());
assertTrue(overview.getSummary().getAccounts() > 0);
assertTrue(overview.getSummary().getAliases() > -1);
@ -142,22 +142,22 @@ public class EmailAccountApiLiveTest extends BaseGleSYSApiLiveTest {
@Test(dependsOnMethods = "testCreateEmail")
public void testListAccounts() throws Exception {
FluentIterable<EmailAccount> accounts = api.listDomain(testDomain);
FluentIterable<EmailAccount> accounts = emailAccountApi.listDomain(testDomain);
assertTrue(accounts.size() >= 1);
}
@Test(dependsOnMethods = "testCreateEmail")
public void testUpdateAccount() throws Exception {
FluentIterable<EmailAccount> accounts = api.listDomain(testDomain);
FluentIterable<EmailAccount> accounts = emailAccountApi.listDomain(testDomain);
for (EmailAccount account : accounts) {
if (account.getAccount().equals("test@" + testDomain)) {
assertTrue(account.isAntiVirus());
}
}
api.update("test@" + testDomain, UpdateAccountOptions.Builder.antiVirus(false));
emailAccountApi.update("test@" + testDomain, UpdateAccountOptions.Builder.antiVirus(false));
accounts = api.listDomain(testDomain);
accounts = emailAccountApi.listDomain(testDomain);
for (EmailAccount account : accounts) {
if (account.getAccount().equals("test@" + testDomain)) {
assertFalse(account.isAntiVirus());

View File

@ -50,41 +50,41 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
@BeforeClass(groups = { "integration", "live" })
@Override
public void setupContext() {
super.setupContext();
api = gleContext.getApi().getIpApi();
public void setup() {
super.setup();
ipApi = api.getIpApi();
}
@AfterClass(groups = { "integration", "live" })
@Override
public void tearDownContext() {
public void tearDown() {
if (reservedIp != null) {
api.release(reservedIp.getAddress());
ipApi.release(reservedIp.getAddress());
}
super.tearDownContext();
super.tearDown();
}
private IpApi api;
private IpApi ipApi;
private IpDetails reservedIp;
@Test
public void testListFree() throws Exception {
FluentIterable<String> freeIps = api.listFree(4, "Falkenberg", "Xen");
FluentIterable<String> freeIps = ipApi.listFree(4, "Falkenberg", "Xen");
assertFalse(freeIps.isEmpty());
}
@Test
public void reserveIp() throws Exception {
FluentIterable<String> openVzIps = api.listFree(4, "Falkenberg", "OpenVZ");
FluentIterable<String> openVzIps = ipApi.listFree(4, "Falkenberg", "OpenVZ");
assertFalse(openVzIps.isEmpty());
reservedIp = api.take(Iterables.get(openVzIps, 0));
reservedIp = ipApi.take(Iterables.get(openVzIps, 0));
assertTrue(reservedIp.isReserved());
checkOpenVZDefailsInFalkenberg(reservedIp);
}
@Test(dependsOnMethods = "reserveIp")
public void reserveAndReleaseIp() throws Exception {
IpDetails details = api.release(reservedIp.getAddress());
IpDetails details = ipApi.release(reservedIp.getAddress());
assertEquals(details.getAddress(), reservedIp.getAddress());
assertFalse(details.isReserved());
@ -94,21 +94,21 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
@Test(dependsOnMethods = "reserveIp")
public void testList() throws Exception {
FluentIterable<IpDetails> ownIps = api.list();
FluentIterable<IpDetails> ownIps = ipApi.list();
assertTrue(ownIps.contains(reservedIp));
ownIps = api.list(ListIpOptions.Builder.datacenter(reservedIp.getDatacenter()));
ownIps = ipApi.list(ListIpOptions.Builder.datacenter(reservedIp.getDatacenter()));
assertTrue(ownIps.contains(reservedIp));
ownIps = api.list(ListIpOptions.Builder.platform(reservedIp.getPlatform()));
ownIps = ipApi.list(ListIpOptions.Builder.platform(reservedIp.getPlatform()));
assertTrue(ownIps.contains(reservedIp));
ownIps = api.list(ListIpOptions.Builder.ipVersion(reservedIp.getVersion()));
ownIps = ipApi.list(ListIpOptions.Builder.ipVersion(reservedIp.getVersion()));
assertTrue(ownIps.contains(reservedIp));
ownIps = api.list(ListIpOptions.Builder.datacenter(reservedIp.getDatacenter()),
ownIps = ipApi.list(ListIpOptions.Builder.datacenter(reservedIp.getDatacenter()),
ListIpOptions.Builder.platform(reservedIp.getPlatform()),
ListIpOptions.Builder.ipVersion(reservedIp.getVersion()));
assertTrue(ownIps.contains(reservedIp));
ownIps = api.list(ListIpOptions.Builder.serverId("xmthisisnotaserverid"));
ownIps = ipApi.list(ListIpOptions.Builder.serverId("xmthisisnotaserverid"));
assertTrue(ownIps.isEmpty());
}
@ -123,20 +123,20 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
@Test
public void testGetOpenVZDetails() throws Exception {
FluentIterable<String> openVzIps = api.listFree(4, "Falkenberg", "OpenVZ");
FluentIterable<String> openVzIps = ipApi.listFree(4, "Falkenberg", "OpenVZ");
assertFalse(openVzIps.isEmpty());
String openVzIp = openVzIps.iterator().next();
IpDetails ipDetails = api.get(openVzIp);
IpDetails ipDetails = ipApi.get(openVzIp);
checkOpenVZDefailsInFalkenberg(ipDetails);
assertEquals(ipDetails.getAddress(), openVzIp);
}
@Test
public void testGetXenDetails() throws Exception {
FluentIterable<String> xenVzIps = api.listFree(4, "Falkenberg", "Xen");
FluentIterable<String> xenVzIps = ipApi.listFree(4, "Falkenberg", "Xen");
assertFalse(xenVzIps.isEmpty());
String xenIp = xenVzIps.iterator().next();
IpDetails ipDetails = api.get(xenIp);
IpDetails ipDetails = ipApi.get(xenIp);
assertEquals(ipDetails.getDatacenter(), "Falkenberg");
assertEquals(ipDetails.getPlatform(), "Xen");
assertEquals(ipDetails.getVersion(), 4);
@ -152,42 +152,42 @@ public class IpApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
public void testPtrSetReset() throws Exception {
IpDetails original = reservedIp;
IpDetails modified = api.setPtr(reservedIp.getAddress(), "wibble.");
IpDetails modified2 = api.get(reservedIp.getAddress());
IpDetails modified = ipApi.setPtr(reservedIp.getAddress(), "wibble.");
IpDetails modified2 = ipApi.get(reservedIp.getAddress());
assertEquals(modified.getPtr(), "wibble.");
assertEquals(modified2, modified);
reservedIp = api.resetPtr(reservedIp.getAddress());
reservedIp = ipApi.resetPtr(reservedIp.getAddress());
assertEquals(reservedIp, original);
}
@Test(dependsOnMethods = "reserveIp")
public void testAddRemove() throws Exception {
IpDetails added = api.addToServer(reservedIp.getAddress(), serverId);
IpDetails added = ipApi.addToServer(reservedIp.getAddress(), serverId);
assertEquals(added.getAddress(), reservedIp.getAddress());
assertEquals(added.getPtr(), reservedIp.getPtr());
assertEquals(added.getServerId(), serverId);
IpDetails again = api.get(reservedIp.getAddress());
IpDetails again = ipApi.get(reservedIp.getAddress());
assertEquals(again, added);
IpDetails removed = api.removeFromServer(reservedIp.getAddress(), serverId);
IpDetails removed = ipApi.removeFromServer(reservedIp.getAddress(), serverId);
assertEquals(removed, added.toBuilder().serverId(null).build());
assertEquals(removed, reservedIp);
Set<String> openVzIps = Sets.newHashSet(api.listFree(4, "Falkenberg", "OpenVZ"));
Set<String> openVzIps = Sets.newHashSet(ipApi.listFree(4, "Falkenberg", "OpenVZ"));
openVzIps.remove(reservedIp.getAddress());
assertFalse(openVzIps.isEmpty());
added = api.addToServer(reservedIp.getAddress(), serverId);
added = ipApi.addToServer(reservedIp.getAddress(), serverId);
assertEquals(added.getServerId(), serverId);
removed = api.removeFromServerAndRelease(reservedIp.getAddress(), serverId);
removed = ipApi.removeFromServerAndRelease(reservedIp.getAddress(), serverId);
assertNull(removed.getServerId());
assertFalse(removed.isReserved());

View File

@ -61,22 +61,22 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
@BeforeClass(groups = { "integration", "live" })
@Override
public void setupContext() {
public void setup() {
hostName = hostName + "-server";
super.setupContext();
api = gleContext.getApi().getServerApi();
super.setup();
serverApi = api.getServerApi();
}
@AfterClass(groups = { "integration", "live" })
@Override
public void tearDownContext() {
public void tearDown() {
if (testServerId2 != null) {
api.destroy(testServerId2, DestroyServerOptions.Builder.discardIp());
serverApi.destroy(testServerId2, DestroyServerOptions.Builder.discardIp());
}
super.tearDownContext();
super.tearDown();
}
private ServerApi api;
private ServerApi serverApi;
private String testServerId2;
@BeforeMethod
@ -86,7 +86,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
@Test
public void testAllowedArguments() throws Exception {
Map<String,AllowedArgumentsForCreateServer> templates = api.getAllowedArgumentsForCreateByPlatform();
Map<String,AllowedArgumentsForCreateServer> templates = serverApi.getAllowedArgumentsForCreateByPlatform();
assertTrue(templates.containsKey("OpenVZ"));
assertTrue(templates.containsKey("Xen"));
@ -108,7 +108,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
}
public void testListTemplates() throws Exception {
FluentIterable<OSTemplate> oSTemplates = api.listTemplates();
FluentIterable<OSTemplate> oSTemplates = serverApi.listTemplates();
for(OSTemplate oSTemplate : oSTemplates) {
checkTemplate(oSTemplate);
@ -126,12 +126,12 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
}
public void testListServers() throws Exception {
FluentIterable<Server> response = api.list();
FluentIterable<Server> response = serverApi.list();
assertNotNull(response);
assertTrue(response.size() > 0);
for (Server server : response) {
ServerDetails newDetails = api.get(server.getId());
ServerDetails newDetails = serverApi.get(server.getId());
assertEquals(newDetails.getId(), server.getId());
assertEquals(newDetails.getHostname(), server.getHostname());
assertEquals(newDetails.getPlatform(), server.getPlatform());
@ -141,7 +141,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
}
public void testServerDetails() throws Exception {
ServerDetails details = api.get(serverId);
ServerDetails details = serverApi.get(serverId);
checkServer(details);
assertEquals("Ubuntu 10.04 LTS 32-bit", details.getTemplateName());
assertEquals("Falkenberg", details.getDatacenter());
@ -153,22 +153,22 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
}
public void testServerStatus() throws Exception {
ServerStatus newStatus = api.getStatus(serverId);
ServerStatus newStatus = serverApi.getStatus(serverId);
checkStatus(newStatus);
}
public void testUpdateServer() throws Exception {
ServerDetails edited = api.update(serverId, UpdateServerOptions.Builder.description("this is a different description!"));
ServerDetails edited = serverApi.update(serverId, UpdateServerOptions.Builder.description("this is a different description!"));
assertEquals(edited.getDescription(), "this is a different description!");
edited = api.update(serverId, UpdateServerOptions.Builder.description("another description!").hostname("host-name1"));
edited = serverApi.update(serverId, UpdateServerOptions.Builder.description("another description!").hostname("host-name1"));
assertEquals(edited.getDescription(), "another description!");
assertEquals(edited.getHostname(), "host-name1");
edited = api.resetPassword(serverId, "anotherpass");
edited = serverApi.resetPassword(serverId, "anotherpass");
assertEquals(edited.getHostname(), "host-name1");
edited = api.update(serverId, UpdateServerOptions.Builder.hostname(hostName));
edited = serverApi.update(serverId, UpdateServerOptions.Builder.hostname(hostName));
assertEquals(edited.getHostname(), hostName);
}
@ -176,7 +176,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
public void testRebootServer() throws Exception {
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
api.reboot(serverId);
serverApi.reboot(serverId);
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
}
@ -185,17 +185,17 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
public void testStopAndStartServer() throws Exception {
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
api.stop(serverId);
serverApi.stop(serverId);
assertTrue(serverStatusChecker.apply(Server.State.STOPPED));
api.start(serverId);
serverApi.start(serverId);
assertTrue(serverStatusChecker.apply(Server.State.RUNNING));
}
public void testServerLimits() throws Exception {
Map<String, ServerLimit> limits = api.getLimits(serverId);
Map<String, ServerLimit> limits = serverApi.getLimits(serverId);
assertNotNull(limits);
for (Map.Entry<String, ServerLimit> entry : limits.entrySet()) {
assertNotNull(entry.getKey());
@ -211,16 +211,16 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
public void testResourceUsage() throws Exception {
// test server has only been in existence for less than a minute - check all servers
for (Server server : api.list()) {
for (Server server : serverApi.list()) {
try {
ResourceUsage usage = api.getResourceUsage(server.getId(), "diskioread", "minute");
ResourceUsage usage = serverApi.getResourceUsage(server.getId(), "diskioread", "minute");
assertEquals(usage.getInfo().getResource(), "diskioread");
assertEquals(usage.getInfo().getResolution(), "minute");
} catch (UnsupportedOperationException e) {
}
try {
ResourceUsage usage = api.getResourceUsage(server.getId(), "cpuusage", "minute");
ResourceUsage usage = serverApi.getResourceUsage(server.getId(), "cpuusage", "minute");
assertEquals(usage.getInfo().getResource(), "cpuusage");
assertEquals(usage.getInfo().getResolution(), "minute");
} catch (UnsupportedOperationException e) {
@ -230,7 +230,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
}
public void testConsole() throws Exception {
Console console = api.getConsole(serverId);
Console console = serverApi.getConsole(serverId);
assertNotNull(console);
assertNotNull(console.getHost());
assertTrue(console.getPort() > 0 && console.getPort() < 65537);
@ -240,7 +240,7 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
// takes a few minutes and requires an extra server (used 1 already)
@Test(enabled=false)
public void testCloneServer() throws Exception {
ServerDetails testServer2 = api.clone(serverId, testHostName2, CloneServerOptions.Builder.cpucores(1));
ServerDetails testServer2 = serverApi.clone(serverId, testHostName2, CloneServerOptions.Builder.cpucores(1));
assertNotNull(testServer2.getId());
assertEquals(testServer2.getHostname(), "jclouds-test2");
@ -248,19 +248,19 @@ public class ServerApiLiveTest extends BaseGleSYSApiWithAServerLiveTest {
testServerId2 = testServer2.getId();
Predicate<State> cloneChecker = statusChecker(api, testServerId2);
Predicate<State> cloneChecker = statusChecker(serverApi, testServerId2);
assertTrue(cloneChecker.apply(Server.State.STOPPED));
api.start(testServer2.getId());
serverApi.start(testServer2.getId());
// TODO ServerStatus==STOPPED suggests the previous call to start should have worked
cloneChecker = retry(new Predicate<Server.State>() {
public boolean apply(Server.State value) {
ServerStatus status = api.getStatus(testServerId2, ServerStatusOptions.Builder.state());
ServerStatus status = serverApi.getStatus(testServerId2, ServerStatusOptions.Builder.state());
if (status.getState() == value) {
return true;
}
api.start(testServerId2);
serverApi.start(testServerId2);
return false;
}
}, 600, 30, SECONDS);

View File

@ -22,12 +22,9 @@ import static java.util.concurrent.TimeUnit.SECONDS;
import static org.jclouds.util.Predicates2.retry;
import static org.testng.Assert.assertTrue;
import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.apis.BaseApiLiveTest;
import org.jclouds.glesys.GleSYSApi;
import org.jclouds.glesys.GleSYSAsyncApi;
import org.jclouds.glesys.features.DomainApi;
import org.jclouds.rest.RestContext;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Predicate;
@ -38,24 +35,15 @@ import com.google.common.base.Predicate;
* @author Adrian Cole, Adam Lowe
*/
@Test(groups = "live")
public class BaseGleSYSApiLiveTest extends BaseComputeServiceContextLiveTest {
public class BaseGleSYSApiLiveTest extends BaseApiLiveTest<GleSYSApi> {
protected String hostName = System.getProperty("user.name").replace('.','-').toLowerCase();
protected RestContext<GleSYSApi, GleSYSAsyncApi> gleContext;
public BaseGleSYSApiLiveTest() {
provider = "glesys";
}
@BeforeClass(groups = { "integration", "live" })
@Override
public void setupContext() {
super.setupContext();
gleContext = view.unwrap();
}
protected void createDomain(String domain) {
final DomainApi api = gleContext.getApi().getDomainApi();
final DomainApi api = this.api.getDomainApi();
int before = api.list().size();
api.create(domain);

View File

@ -60,21 +60,21 @@ public class BaseGleSYSApiWithAServerLiveTest extends BaseGleSYSApiLiveTest {
@BeforeClass(groups = { "integration", "live" })
@Override
public void setupContext() {
public void setup() {
assertNull(serverId, "This method should be called EXACTLY once per run");
super.setupContext();
super.setup();
serverStatusChecker = createServer(hostName);
}
@AfterClass(groups = { "integration", "live" })
@Override
public void tearDownContext() {
gleContext.getApi().getServerApi().destroy(serverId, DestroyServerOptions.Builder.discardIp());
super.tearDownContext();
public void tearDown() {
api.getServerApi().destroy(serverId, DestroyServerOptions.Builder.discardIp());
super.tearDown();
}
protected void createDomain(String domain) {
final DomainApi api = gleContext.getApi().getDomainApi();
final DomainApi api = this.api.getDomainApi();
int before = api.list().size();
api.create(domain);
Predicate<Integer> result = retry(new Predicate<Integer>() {
@ -86,7 +86,7 @@ public class BaseGleSYSApiWithAServerLiveTest extends BaseGleSYSApiLiveTest {
}
protected Predicate<State> createServer(String hostName) {
final ServerApi api = gleContext.getApi().getServerApi();
final ServerApi api = this.api.getServerApi();
ServerDetails testServer = api.createWithHostnameAndRootPassword(
ServerSpec.builder().datacenter("Falkenberg").platform("OpenVZ").templateName("Ubuntu 10.04 LTS 32-bit")

View File

@ -18,6 +18,8 @@
*/
package org.jclouds.gogrid;
import java.io.Closeable;
import org.jclouds.gogrid.services.GridImageAsyncClient;
import org.jclouds.gogrid.services.GridIpAsyncClient;
import org.jclouds.gogrid.services.GridJobAsyncClient;
@ -28,7 +30,7 @@ import org.jclouds.rest.annotations.Delegate;
/**
* @author Oleksiy Yarmula
*/
public interface GoGridAsyncClient {
public interface GoGridAsyncClient extends Closeable {
public static final String VERSION = "1.5";
/**

View File

@ -18,6 +18,8 @@
*/
package org.jclouds.gogrid;
import java.io.Closeable;
import org.jclouds.gogrid.services.GridImageClient;
import org.jclouds.gogrid.services.GridIpClient;
import org.jclouds.gogrid.services.GridJobClient;
@ -28,7 +30,7 @@ import org.jclouds.rest.annotations.Delegate;
/**
* @author Oleksiy Yarmula
*/
public interface GoGridClient {
public interface GoGridClient extends Closeable {
/**
* Services with methods, related to managing servers

Some files were not shown because too many files have changed in this diff Show More