Merge pull request #1508 from jclouds/deprecate-async

Deprecate async
This commit is contained in:
Adrian Cole 2013-04-09 13:04:19 -07:00
commit 109db817ed
205 changed files with 1635 additions and 1848 deletions

View File

@ -28,7 +28,6 @@ import org.jclouds.apis.ApiMetadata;
import org.jclouds.atmos.blobstore.config.AtmosBlobStoreContextModule;
import org.jclouds.atmos.config.AtmosRestClientModule;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
@ -42,7 +41,12 @@ import com.google.inject.Module;
*/
public class AtmosApiMetadata extends BaseRestApiMetadata {
public static final TypeToken<RestContext<AtmosClient, AtmosAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<AtmosClient, AtmosAsyncClient>>() {
/**
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(AtmosClient.class)} as
* {@link AtmosAsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
public static final TypeToken<org.jclouds.rest.RestContext<AtmosClient, AtmosAsyncClient>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<AtmosClient, AtmosAsyncClient>>() {
private static final long serialVersionUID = 1L;
};
@ -71,6 +75,7 @@ public class AtmosApiMetadata extends BaseRestApiMetadata {
}
public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
@SuppressWarnings("deprecation")
protected Builder() {
super(AtmosClient.class, AtmosAsyncClient.class);
id("atmos")

View File

@ -75,7 +75,11 @@ import com.google.inject.Provides;
* @see AtmosClient
* @see <a href="https://community.emc.com/community/labs/atmos_online" />
* @author Adrian Cole
*
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(AtmosClient.class)} as
* {@link AtmosAsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
@RequestFilters(SignRequest.class)
@Path("/rest/namespace")
public interface AtmosAsyncClient extends Closeable {

View File

@ -29,7 +29,6 @@ import org.jclouds.cloudfiles.config.CloudFilesRestClientModule.StorageAndCDNMan
import org.jclouds.openstack.swift.SwiftApiMetadata;
import org.jclouds.openstack.swift.blobstore.SwiftBlobSigner;
import org.jclouds.openstack.swift.blobstore.config.TemporaryUrlExtensionModule;
import org.jclouds.rest.RestContext;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
@ -43,7 +42,12 @@ import com.google.inject.TypeLiteral;
*/
public class CloudFilesApiMetadata extends SwiftApiMetadata {
public static final TypeToken<RestContext<CloudFilesClient, CloudFilesAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudFilesClient, CloudFilesAsyncClient>>() {
/**
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudFilesClient.class)} as
* {@link CloudFilesAsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
public static final TypeToken<org.jclouds.rest.RestContext<CloudFilesClient, CloudFilesAsyncClient>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<CloudFilesClient, CloudFilesAsyncClient>>() {
private static final long serialVersionUID = 1L;
};
@ -66,6 +70,7 @@ public class CloudFilesApiMetadata extends SwiftApiMetadata {
}
public static class Builder extends SwiftApiMetadata.Builder<Builder> {
@SuppressWarnings("deprecation")
protected Builder(){
super(CloudFilesClient.class, CloudFilesAsyncClient.class);
id("cloudfiles")

View File

@ -64,7 +64,10 @@ import com.google.common.util.concurrent.ListenableFuture;
* @see CloudFilesClient
* @see <a href="http://www.rackspacecloud.com/cf-devguide-20090812.pdf" />
* @author Adrian Cole
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudFilesClient.class)} as
* {@link CloudFilesAsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
@RequestFilters(AuthenticateRequest.class)
@Endpoint(Storage.class)
public interface CloudFilesAsyncClient extends SwiftAsyncClient {

View File

@ -27,7 +27,6 @@ import org.jclouds.apis.ApiMetadata;
import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule;
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
@ -41,7 +40,12 @@ import com.google.inject.Module;
*/
public class CloudServersApiMetadata extends BaseRestApiMetadata {
public static final TypeToken<RestContext<CloudServersClient, CloudServersAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudServersClient, CloudServersAsyncClient>>() {
/**
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudServersClient.class)} as
* {@link CloudServersAsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
public static final TypeToken<org.jclouds.rest.RestContext<CloudServersClient, CloudServersAsyncClient>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<CloudServersClient, CloudServersAsyncClient>>() {
private static final long serialVersionUID = 1L;
};
@ -65,6 +69,7 @@ public class CloudServersApiMetadata extends BaseRestApiMetadata {
public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
@SuppressWarnings("deprecation")
protected Builder() {
super(CloudServersClient.class, CloudServersAsyncClient.class);
id("cloudservers")

View File

@ -74,7 +74,10 @@ import com.google.common.util.concurrent.ListenableFuture;
* @see CloudServersClient
* @see <a href="http://docs.rackspacecloud.com/servers/api/cs-devguide-latest.pdf" />
* @author Adrian Cole
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudServersClient.class)} as
* {@link CloudServersAsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
@RequestFilters({ AuthenticateRequest.class, AddTimestampQuery.class })
@Endpoint(Compute.class)
public interface CloudServersAsyncClient extends Closeable {

View File

@ -28,7 +28,6 @@ import org.jclouds.apis.ApiMetadata;
import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule;
import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
@ -42,7 +41,12 @@ import com.google.inject.Module;
*/
public class CloudSigmaApiMetadata extends BaseRestApiMetadata {
public static final TypeToken<RestContext<CloudSigmaClient, CloudSigmaAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudSigmaClient, CloudSigmaAsyncClient>>() {
/**
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudSigmaClient.class)} as
* {@link CloudSigmaAsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
public static final TypeToken<org.jclouds.rest.RestContext<CloudSigmaClient, CloudSigmaAsyncClient>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<CloudSigmaClient, CloudSigmaAsyncClient>>() {
private static final long serialVersionUID = 1L;
};
@ -72,6 +76,7 @@ public class CloudSigmaApiMetadata extends BaseRestApiMetadata {
public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
@SuppressWarnings("deprecation")
protected Builder() {
super(CloudSigmaClient.class, CloudSigmaAsyncClient.class);
id("cloudsigma")

View File

@ -73,7 +73,10 @@ import com.google.common.util.concurrent.ListenableFuture;
* @see CloudSigmaClient
* @see <a href="http://cloudsigma.com/en/platform-details/the-api" />
* @author Adrian Cole
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudSigmaClient.class)} as
* {@link CloudSigmaAsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
@RequestFilters(BasicAuthentication.class)
@Consumes(MediaType.TEXT_PLAIN)
public interface CloudSigmaAsyncClient extends Closeable {

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

@ -26,7 +26,6 @@ import org.jclouds.apis.ApiMetadata;
import org.jclouds.cloudstack.compute.config.CloudStackComputeServiceContextModule;
import org.jclouds.cloudstack.config.CloudStackParserModule;
import org.jclouds.cloudstack.config.CloudStackRestClientModule;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
@ -39,7 +38,12 @@ import com.google.inject.Module;
*/
public class CloudStackApiMetadata extends BaseRestApiMetadata {
public static final TypeToken<RestContext<CloudStackClient, CloudStackAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudStackClient, CloudStackAsyncClient>>() {
/**
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudStackClient.class)} as
* {@link CloudStackAsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
public static final TypeToken<org.jclouds.rest.RestContext<CloudStackClient, CloudStackAsyncClient>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<CloudStackClient, CloudStackAsyncClient>>() {
private static final long serialVersionUID = 1L;
};
@ -65,6 +69,7 @@ public class CloudStackApiMetadata extends BaseRestApiMetadata {
public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
@SuppressWarnings("deprecation")
protected Builder() {
super(CloudStackClient.class, CloudStackAsyncClient.class);
id("cloudstack")

View File

@ -50,7 +50,10 @@ import org.jclouds.rest.annotations.Delegate;
* @author Adrian Cole
* @see CloudStackClient
* @see <a href="http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html" />
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudStackClient.class)} as
* {@link CloudStackAsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
public interface CloudStackAsyncClient {
/**

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

@ -33,7 +33,10 @@ import org.jclouds.rest.annotations.Delegate;
* @see <a href=
* "http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_Domain_Admin.html"
* />
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudStackDomainClient.class)} as
* {@link CloudStackDomainAsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
public interface CloudStackDomainAsyncClient extends CloudStackAsyncClient {
/**

View File

@ -38,11 +38,14 @@ import org.jclouds.rest.annotations.Delegate;
* <p/>
*
* @author Adrian Cole
* @see CloudStackDomainClient
* @see CloudStackGlobalClient
* @see <a href=
* "http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_Global_Admin.html"
* />
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudStackGlobalClient.class)} as
* {@link CloudStackGlobalAsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
public interface CloudStackGlobalAsyncClient extends CloudStackDomainAsyncClient {
/**

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

@ -26,7 +26,6 @@ import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.cloudwatch.config.CloudWatchRestClientModule;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.reflect.TypeToken;
@ -38,7 +37,12 @@ import com.google.common.reflect.TypeToken;
*/
public class CloudWatchApiMetadata extends BaseRestApiMetadata {
public static final TypeToken<RestContext<CloudWatchApi, CloudWatchAsyncApi>> CONTEXT_TOKEN = new TypeToken<RestContext<CloudWatchApi, CloudWatchAsyncApi>>() {
/**
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudWatchApi.class)} as
* {@link CloudWatchAsyncApi} interface will be removed in jclouds 1.7.
*/
@Deprecated
public static final TypeToken<org.jclouds.rest.RestContext<CloudWatchApi, CloudWatchAsyncApi>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<CloudWatchApi, CloudWatchAsyncApi>>() {
private static final long serialVersionUID = 1L;
};
@ -47,6 +51,7 @@ public class CloudWatchApiMetadata extends BaseRestApiMetadata {
return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this);
}
@SuppressWarnings("deprecation")
public CloudWatchApiMetadata() {
this(new Builder(CloudWatchApi.class, CloudWatchAsyncApi.class));
}

View File

@ -38,7 +38,10 @@ import com.google.inject.Provides;
* href="http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference"
* />
* @author Adrian Cole
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudWatchApi.class)} as
* {@link CloudWatchAsyncApi} interface will be removed in jclouds 1.7.
*/
@Deprecated
public interface CloudWatchAsyncApi extends Closeable {
/**
*

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

@ -1,38 +0,0 @@
/**
* 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.cloudwatch.internal;
import java.util.Properties;
import org.jclouds.cloudwatch.CloudWatchAsyncApi;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import com.google.common.base.Function;
import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
public class BaseCloudWatchAsyncApiExpectTest extends BaseCloudWatchExpectTest<CloudWatchAsyncApi> {
public CloudWatchAsyncApi createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
return createInjector(fn, module, props).getInstance(CloudWatchAsyncApi.class);
}
}

View File

@ -34,7 +34,6 @@ import org.jclouds.ec2.compute.EC2ComputeServiceContext;
import org.jclouds.ec2.compute.config.EC2ComputeServiceContextModule;
import org.jclouds.ec2.compute.config.EC2ResolveImagesModule;
import org.jclouds.ec2.config.EC2RestClientModule;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
@ -59,8 +58,13 @@ import com.google.inject.Module;
* @author Adrian Cole
*/
public class EC2ApiMetadata extends BaseRestApiMetadata {
public static final TypeToken<RestContext<? extends EC2Client, ? extends EC2AsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<? extends EC2Client, ? extends EC2AsyncClient>>() {
/**
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(EC2Client.class)} as
* {@link EC2AsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
public static final TypeToken<org.jclouds.rest.RestContext<? extends EC2Client, ? extends EC2AsyncClient>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<? extends EC2Client, ? extends EC2AsyncClient>>() {
private static final long serialVersionUID = 1L;
};
@ -90,6 +94,7 @@ public class EC2ApiMetadata extends BaseRestApiMetadata {
}
public static abstract class Builder<T extends Builder<T>> extends BaseRestApiMetadata.Builder<T> {
@SuppressWarnings("deprecation")
protected Builder() {
this(EC2Client.class, EC2AsyncClient.class);
}
@ -102,7 +107,7 @@ public class EC2ApiMetadata extends BaseRestApiMetadata {
.credentialName("Secret Access Key")
.defaultEndpoint("https://ec2.us-east-1.amazonaws.com")
.documentation(URI.create("http://docs.amazonwebservices.com/AWSEC2/latest/APIReference"))
.version(EC2AsyncClient.VERSION)
.version("2010-06-15")
.defaultProperties(EC2ApiMetadata.defaultProperties())
.context(CONTEXT_TOKEN)
.view(EC2ComputeServiceContext.class)

View File

@ -32,9 +32,11 @@ import org.jclouds.rest.annotations.Delegate;
* Provides asynchronous access to EC2 services.
*
* @author Adrian Cole
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(EC2Client.class)} as
* {@link EC2AsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
public interface EC2AsyncClient extends EC2AsyncApi {
public static final String VERSION = "2010-06-15";
/**
* Provides asynchronous access to AMI services.

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

@ -28,7 +28,6 @@ import org.jclouds.apis.ApiMetadata;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.elasticstack.compute.config.ElasticStackComputeServiceContextModule;
import org.jclouds.elasticstack.config.ElasticStackRestClientModule;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
@ -42,7 +41,12 @@ import com.google.inject.Module;
*/
public class ElasticStackApiMetadata extends BaseRestApiMetadata {
public static final TypeToken<RestContext<ElasticStackClient, ElasticStackAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<ElasticStackClient, ElasticStackAsyncClient>>() {
/**
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(ElasticStackClient.class)} as
* {@link ElasticStackAsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
public static final TypeToken<org.jclouds.rest.RestContext<ElasticStackClient, ElasticStackAsyncClient>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<ElasticStackClient, ElasticStackAsyncClient>>() {
private static final long serialVersionUID = 1L;
};
@ -71,6 +75,7 @@ public class ElasticStackApiMetadata extends BaseRestApiMetadata {
public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
@SuppressWarnings("deprecation")
protected Builder() {
super(ElasticStackClient.class, ElasticStackAsyncClient.class);
id("elasticstack")

View File

@ -62,7 +62,10 @@ import com.google.common.util.concurrent.ListenableFuture;
* @see ElasticStackClient
* @see <a href="TODO: insert URL of provider documentation" />
* @author Adrian Cole
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(ElasticStackClient.class)} as
* {@link ElasticStackAsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
@RequestFilters(BasicAuthentication.class)
@Consumes(MediaType.TEXT_PLAIN)
public interface ElasticStackAsyncClient extends Closeable {

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

@ -31,7 +31,6 @@ import org.jclouds.openstack.keystone.v2_0.config.CredentialTypes;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneAuthenticationModule.ZoneModule;
import org.jclouds.openstack.v2_0.ServiceType;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
@ -45,7 +44,12 @@ import com.google.inject.Module;
*/
public class CinderApiMetadata extends BaseRestApiMetadata {
public static final TypeToken<RestContext<CinderApi, CinderAsyncApi>> CONTEXT_TOKEN = new TypeToken<RestContext<CinderApi, CinderAsyncApi>>() {
/**
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CinderApi.class)} as
* {@link CinderAsyncApi} interface will be removed in jclouds 1.7.
*/
@Deprecated
public static final TypeToken<org.jclouds.rest.RestContext<CinderApi, CinderAsyncApi>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<CinderApi, CinderAsyncApi>>() {
private static final long serialVersionUID = 1L;
};
@ -71,6 +75,7 @@ public class CinderApiMetadata extends BaseRestApiMetadata {
public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
@SuppressWarnings("deprecation")
protected Builder() {
super(CinderApi.class, CinderAsyncApi.class);
id("openstack-cinder")

View File

@ -39,7 +39,10 @@ import com.google.inject.Provides;
* @see CinderApi
* @see <a href="http://api.openstack.org/">API Doc</a>
* @author Everett Toews
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CinderApi.class)} as
* {@link CinderAsyncApi} interface will be removed in jclouds 1.7.
*/
@Deprecated
public interface CinderAsyncApi extends Closeable {
/**
* @return the Zone codes configured

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

@ -30,7 +30,6 @@ import org.jclouds.openstack.keystone.v2_0.config.KeystoneParserModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule.KeystoneAdminURLModule;
import org.jclouds.openstack.v2_0.ServiceType;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
@ -44,7 +43,12 @@ import com.google.inject.Module;
*/
public class KeystoneApiMetadata extends BaseRestApiMetadata {
public static final TypeToken<RestContext<? extends KeystoneApi,? extends KeystoneAsyncApi>> CONTEXT_TOKEN = new TypeToken<RestContext<? extends KeystoneApi,? extends KeystoneAsyncApi>>() {
/**
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(KeystoneApi.class)} as
* {@link KeystoneAsyncApi} interface will be removed in jclouds 1.7.
*/
@Deprecated
public static final TypeToken<org.jclouds.rest.RestContext<KeystoneApi, KeystoneAsyncApi>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<KeystoneApi, KeystoneAsyncApi>>() {
private static final long serialVersionUID = 1L;
};
@ -69,6 +73,7 @@ public class KeystoneApiMetadata extends BaseRestApiMetadata {
}
public static abstract class Builder<T extends Builder<T>> extends BaseRestApiMetadata.Builder<T> {
@SuppressWarnings("deprecation")
protected Builder() {
this(KeystoneApi.class, KeystoneAsyncApi.class);
}

View File

@ -45,7 +45,10 @@ import com.google.common.util.concurrent.ListenableFuture;
* @author Adam Lowe
* @see <a href="http://keystone.openstack.org/" />
* @see KeystoneApi
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(KeystoneApi.class)} as
* {@link KeystoneAsyncApi} interface will be removed in jclouds 1.7.
*/
@Deprecated
public interface KeystoneAsyncApi extends Closeable {
/**

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

View File

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

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
@ -46,25 +49,30 @@ import com.google.common.collect.Iterables;
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();
assertTrue(api.isValid(token));
Token result = api.get(token);
TokenApi tokenApi = api.getTokenApi().get();
assertTrue(tokenApi.isValid(token));
Token result = tokenApi.get(token);
assertNotNull(result);
assertEquals(result.getId(), token);
assertNotNull(result.getTenant());
User user = api.getUserOfToken(token);
User user = tokenApi.getUserOfToken(token);
assertNotNull(user);
assertNotNull(user.getId());
assertNotNull(user.getName());
@ -73,16 +81,16 @@ public class TokenApiLiveTest extends BaseKeystoneApiLiveTest {
public void testInvalidToken() {
TokenApi api = keystoneContext.getApi().getTokenApi().get();
assertFalse(api.isValid("thisisnotarealtoken!"));
assertNull(api.get("thisisnotarealtoken!"));
TokenApi tokenApi = api.getTokenApi().get();
assertFalse(tokenApi.isValid("thisisnotarealtoken!"));
assertNull(tokenApi.get("thisisnotarealtoken!"));
}
public void testTokenEndpoints() {
TokenApi api = keystoneContext.getApi().getTokenApi().get();
Set<? extends Endpoint> endpoints = api.listEndpointsForToken(token);
TokenApi tokenApi = api.getTokenApi().get();
Set<? extends Endpoint> endpoints = tokenApi.listEndpointsForToken(token);
assertNotNull(endpoints);
assertFalse(endpoints.isEmpty());
@ -90,8 +98,8 @@ public class TokenApiLiveTest extends BaseKeystoneApiLiveTest {
public void testInvalidTokenEndpoints() {
TokenApi api = keystoneContext.getApi().getTokenApi().get();
assertTrue(api.listEndpointsForToken("thisisnotarealtoken!").isEmpty());
TokenApi tokenApi = api.getTokenApi().get();
assertTrue(tokenApi.listEndpointsForToken("thisisnotarealtoken!").isEmpty());
}
}

View File

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

@ -33,7 +33,6 @@ import org.jclouds.ec2.compute.config.EC2ResolveImagesModule;
import org.jclouds.openstack.nova.ec2.config.HyphenToNullIso8601Module;
import org.jclouds.openstack.nova.ec2.config.NovaEC2ComputeServiceContextModule;
import org.jclouds.openstack.nova.ec2.config.NovaEC2RestClientModule;
import org.jclouds.rest.RestContext;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
@ -46,7 +45,12 @@ import com.google.inject.Module;
*/
public class NovaEC2ApiMetadata extends EC2ApiMetadata {
public static final TypeToken<RestContext<NovaEC2Client, NovaEC2AsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<NovaEC2Client, NovaEC2AsyncClient>>() {
/**
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(NovaEC2Client.class)} as
* {@link NovaEC2AsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
public static final TypeToken<org.jclouds.rest.RestContext<NovaEC2Client, NovaEC2AsyncClient>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<NovaEC2Client, NovaEC2AsyncClient>>() {
private static final long serialVersionUID = 1L;
};
@ -81,6 +85,7 @@ public class NovaEC2ApiMetadata extends EC2ApiMetadata {
}
public static class Builder extends EC2ApiMetadata.Builder<Builder> {
@SuppressWarnings("deprecation")
protected Builder(){
super(NovaEC2Client.class, NovaEC2AsyncClient.class);
id("openstack-nova-ec2")

View File

@ -26,7 +26,10 @@ import org.jclouds.rest.annotations.Delegate;
* Provides asynchronous access to EC2 services.
*
* @author Adam Lowe
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(NovaEC2Client.class)} as
* {@link NovaEC2AsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
public interface NovaEC2AsyncClient extends EC2AsyncClient {
/**
* {@inheritDoc}

View File

@ -38,7 +38,6 @@ import org.jclouds.openstack.nova.v2_0.compute.config.NovaComputeServiceContextM
import org.jclouds.openstack.nova.v2_0.config.NovaParserModule;
import org.jclouds.openstack.nova.v2_0.config.NovaRestClientModule;
import org.jclouds.openstack.v2_0.ServiceType;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
@ -52,7 +51,12 @@ import com.google.inject.Module;
*/
public class NovaApiMetadata extends BaseRestApiMetadata {
public static final TypeToken<RestContext<NovaApi, NovaAsyncApi>> CONTEXT_TOKEN = new TypeToken<RestContext<NovaApi, NovaAsyncApi>>() {
/**
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(NovaApi.class)} as
* {@link NovaAsyncApi} interface will be removed in jclouds 1.7.
*/
@Deprecated
public static final TypeToken<org.jclouds.rest.RestContext<NovaApi, NovaAsyncApi>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<NovaApi, NovaAsyncApi>>() {
private static final long serialVersionUID = 1L;
};
@ -88,6 +92,7 @@ public class NovaApiMetadata extends BaseRestApiMetadata {
public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
@SuppressWarnings("deprecation")
protected Builder() {
super(NovaApi.class, NovaAsyncApi.class);
id("openstack-nova")

View File

@ -57,7 +57,10 @@ import com.google.inject.Provides;
* @see <a href="http://docs.openstack.org/api/openstack-compute/1.1/content/"
* />
* @author Adrian Cole
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(NovaApi.class)} as
* {@link NovaAsyncApi} interface will be removed in jclouds 1.7.
*/
@Deprecated
public interface NovaAsyncApi extends Closeable {
/**

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

@ -1,197 +0,0 @@
/**
* 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.openstack.nova.v2_0.extensions;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.openstack.nova.v2_0.NovaAsyncApi;
import org.jclouds.openstack.nova.v2_0.internal.BaseNovaAsyncApiExpectTest;
import org.jclouds.openstack.nova.v2_0.parse.ParseFloatingIPListTest;
import org.jclouds.openstack.nova.v2_0.parse.ParseFloatingIPTest;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
/**
* Tests annotation parsing of {@code FloatingIPAsyncApi}
*
* @author Michael Arnold
*/
@Test(groups = "unit", testName = "FloatingIPAsyncApiExpectTest")
public class FloatingIPAsyncApiExpectTest extends BaseNovaAsyncApiExpectTest {
public void testWhenNamespaceInExtensionsListFloatingIpPresent() throws Exception {
NovaAsyncApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse);
assertEquals(apiWhenExtensionNotInList.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertTrue(apiWhenExtensionNotInList.getFloatingIPExtensionForZone("az-1.region-a.geo-1").isPresent());
}
public void testWhenNamespaceNotInExtensionsListFloatingIpNotPresent() throws Exception {
NovaAsyncApi apiWhenExtensionNotInList = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, unmatchedExtensionsOfNovaResponse);
assertEquals(apiWhenExtensionNotInList.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertFalse(apiWhenExtensionNotInList.getFloatingIPExtensionForZone("az-1.region-a.geo-1").isPresent());
}
public void testListFloatingIPsWhenResponseIs2xx() throws Exception {
HttpRequest list = HttpRequest
.builder()
.method("GET")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")
.addHeader("Accept", "application/json")
.addHeader("X-Auth-Token", authToken).build();
HttpResponse listResponse = HttpResponse.builder().statusCode(200)
.payload(payloadFromResource("/floatingip_list.json")).build();
NovaAsyncApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
assertEquals(apiWhenFloatingIPsExist.getConfiguredZones(), ImmutableSet.of("az-1.region-a.geo-1", "az-2.region-a.geo-1", "az-3.region-a.geo-1"));
assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().list().get()
.toString(), new ParseFloatingIPListTest().expected().toString());
}
public void testListFloatingIPsWhenResponseIs404() throws Exception {
HttpRequest list = HttpRequest
.builder()
.method("GET")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")
.addHeader("Accept", "application/json")
.addHeader("X-Auth-Token", authToken).build();
HttpResponse listResponse = HttpResponse.builder().statusCode(404).build();
NovaAsyncApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, list, listResponse);
assertTrue(apiWhenNoServersExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().list().get()
.isEmpty());
}
public void testGetFloatingIPWhenResponseIs2xx() throws Exception {
HttpRequest get = HttpRequest
.builder()
.method("GET")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips/1")
.addHeader("Accept", "application/json")
.addHeader("X-Auth-Token", authToken).build();
HttpResponse getResponse = HttpResponse.builder().statusCode(200)
.payload(payloadFromResource("/floatingip_details.json")).build();
NovaAsyncApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, get, getResponse);
assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().get("1").get()
.toString(), new ParseFloatingIPTest().expected().toString());
}
public void testGetFloatingIPWhenResponseIs404() throws Exception {
HttpRequest get = HttpRequest
.builder()
.method("GET")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips/1")
.addHeader("Accept", "application/json")
.addHeader("X-Auth-Token", authToken).build();
HttpResponse getResponse = HttpResponse.builder().statusCode(404).build();
NovaAsyncApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, get, getResponse);
assertNull(apiWhenNoServersExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().get("1").get());
}
public void testAllocateWhenResponseIs2xx() throws Exception {
HttpRequest createFloatingIP = HttpRequest
.builder()
.method("POST")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")
.addHeader("Accept", "application/json")
.addHeader("X-Auth-Token", authToken)
.payload(payloadFromStringWithContentType("{}", "application/json")).build();
HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(200)
.payload(payloadFromResource("/floatingip_details.json")).build();
NovaAsyncApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
createFloatingIPResponse);
assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().create().get()
.toString(), new ParseFloatingIPTest().expected().toString());
}
public void testAllocateWhenResponseIs404() throws Exception {
HttpRequest createFloatingIP = HttpRequest
.builder()
.method("POST")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")
.addHeader("Accept", "application/json")
.addHeader("X-Auth-Token", authToken)
.payload(payloadFromStringWithContentType("{}", "application/json")).build();
HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(404).build();
NovaAsyncApi apiWhenNoServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
createFloatingIPResponse);
assertNull(apiWhenNoServersExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().create().get());
}
public void testAllocateWithPoolNameWhenResponseIs2xx() throws Exception {
HttpRequest createFloatingIP = HttpRequest
.builder()
.method("POST")
.endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-floating-ips")
.addHeader("Accept", "application/json")
.addHeader("X-Auth-Token", authToken)
.payload(payloadFromStringWithContentType("{\"pool\":\"myPool\"}", "application/json")).build();
HttpResponse createFloatingIPResponse = HttpResponse.builder().statusCode(200)
.payload(payloadFromResource("/floatingip_details.json")).build();
NovaAsyncApi apiWhenFloatingIPsExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName,
responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, createFloatingIP,
createFloatingIPResponse);
assertEquals(apiWhenFloatingIPsExist.getFloatingIPExtensionForZone("az-1.region-a.geo-1").get().allocateFromPool("myPool")
.get()
.toString(), new ParseFloatingIPTest().expected().toString());
}
}

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,24 +35,24 @@ 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();
FluentIterable<? extends KeyPair> keyPairsList = api.list();
for (String zoneId : api.getConfiguredZones()) {
KeyPairApi keyPairApi = api.getKeyPairExtensionForZone(zoneId).get();
FluentIterable<? extends KeyPair> keyPairsList = keyPairApi.list();
assertNotNull(keyPairsList);
}
}
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 keyPairApi = api.getKeyPairExtensionForZone(zoneId).get();
KeyPair keyPair = null;
try {
keyPair = api.create(KEYPAIR_NAME);
keyPair = keyPairApi.create(KEYPAIR_NAME);
assertNotNull(keyPair);
} finally {
if (keyPair != null) {
api.delete(KEYPAIR_NAME);
keyPairApi.delete(KEYPAIR_NAME);
}
}
}
@ -62,15 +62,15 @@ 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 keyPairApi = api.getKeyPairExtensionForZone(zoneId).get();
KeyPair keyPair = null;
try {
keyPair = api.createWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY);
keyPair = keyPairApi.createWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY);
assertNotNull(keyPair);
} finally {
if (keyPair != null) {
api.delete(KEYPAIR_NAME);
keyPairApi.delete(KEYPAIR_NAME);
}
}
}

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,58 +42,58 @@ 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();
Set<? extends SecurityGroup> securityGroupsList = api.list().toSet();
for (String zoneId : api.getConfiguredZones()) {
SecurityGroupApi securityGroupApi = api.getSecurityGroupExtensionForZone(zoneId).get();
Set<? extends SecurityGroup> securityGroupsList = securityGroupApi.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 securityGroupApi = api.getSecurityGroupExtensionForZone(zoneId).get();
SecurityGroup securityGroup = null;
String id;
try {
securityGroup = api
securityGroup = securityGroupApi
.createWithDescription(SECURITY_GROUP_NAME, "test security group");
assertNotNull(securityGroup);
id = securityGroup.getId();
SecurityGroup theGroup = api.get(id);
SecurityGroup theGroup = securityGroupApi.get(id);
assertNotNull(theGroup);
} finally {
if (securityGroup != null) {
api.delete(securityGroup.getId());
securityGroupApi.delete(securityGroup.getId());
}
}
}
}
public void createAndDeleteSecurityGroupRule() throws Exception {
for (String zoneId : novaContext.getApi().getConfiguredZones()) {
SecurityGroupApi api = novaContext.getApi().getSecurityGroupExtensionForZone(zoneId).get();
for (String zoneId : api.getConfiguredZones()) {
SecurityGroupApi securityGroupApi = api.getSecurityGroupExtensionForZone(zoneId).get();
SecurityGroup securityGroup = null;
try {
securityGroup = api.createWithDescription(SECURITY_GROUP_NAME, "test security group");
securityGroup = securityGroupApi.createWithDescription(SECURITY_GROUP_NAME, "test security group");
assertNotNull(securityGroup);
for (int port : ImmutableSet.of(22, 8080)) {
SecurityGroupRule rule = api.createRuleAllowingCidrBlock(securityGroup.getId(), Ingress
SecurityGroupRule rule = securityGroupApi.createRuleAllowingCidrBlock(securityGroup.getId(), Ingress
.builder().ipProtocol(IpProtocol.TCP).fromPort(port).toPort(port).build(), "0.0.0.0/0");
assertNotNull(rule);
SecurityGroupRule rule2 = api.createRuleAllowingSecurityGroupId(securityGroup.getId(),
SecurityGroupRule rule2 = securityGroupApi.createRuleAllowingSecurityGroupId(securityGroup.getId(),
Ingress.builder().ipProtocol(IpProtocol.TCP).fromPort(port).toPort(port).build(), securityGroup
.getId());
assertNotNull(rule2);
}
securityGroup = api.get(securityGroup.getId());
securityGroup = securityGroupApi.get(securityGroup.getId());
} finally {
if (securityGroup != null) {
api.delete(securityGroup.getId());
securityGroupApi.delete(securityGroup.getId());
}
}
}

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,8 +45,8 @@ 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);
Set<? extends Extension> response = api.list();
ExtensionApi extensionApi = api.getExtensionApiForZone(zoneId);
Set<? extends Extension> response = extensionApi.list();
assertNotNull(response);
assertFalse(response.isEmpty());
for (Extension extension : response) {
@ -68,10 +68,10 @@ 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);
Set<? extends Extension> response = api.list();
ExtensionApi extensionApi = api.getExtensionApiForZone(zoneId);
Set<? extends Extension> response = extensionApi.list();
for (Extension extension : response) {
Extension details = api.get(extension.getId());
Extension details = extensionApi.get(extension.getId());
assertNotNull(details);
assertEquals(details.getId(), extension.getId());
assertEquals(details.getName(), extension.getName());

View File

@ -46,8 +46,8 @@ 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);
Set<? extends Resource> response = api.list().concat().toSet();
FlavorApi flavorApi = api.getFlavorApiForZone(zoneId);
Set<? extends Resource> response = flavorApi.list().concat().toSet();
assertNotNull(response);
assertFalse(response.isEmpty());
for (Resource flavor : response) {
@ -66,8 +66,8 @@ 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);
Set<? extends Flavor> response = api.listInDetail().concat().toSet();
FlavorApi flavorApi = api.getFlavorApiForZone(zoneId);
Set<? extends Flavor> response = flavorApi.listInDetail().concat().toSet();
assertNotNull(response);
assertFalse(response.isEmpty());
for (Flavor flavor : response) {
@ -89,10 +89,10 @@ 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);
Set<? extends Flavor> response = api.listInDetail().concat().toSet();
FlavorApi flavorApi = api.getFlavorApiForZone(zoneId);
Set<? extends Flavor> response = flavorApi.listInDetail().concat().toSet();
for (Flavor flavor : response) {
Flavor details = api.get(flavor.getId());
Flavor details = flavorApi.get(flavor.getId());
assertNotNull(details);
assertEquals(details.getId(), flavor.getId());
assertEquals(details.getName(), flavor.getName());

View File

@ -41,8 +41,8 @@ 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);
Set<? extends Resource> response = api.list().concat().toSet();
ImageApi imageApi = api.getImageApiForZone(zoneId);
Set<? extends Resource> response = imageApi.list().concat().toSet();
assertNotNull(response);
assertFalse(response.isEmpty());
for (Resource image : response) {
@ -55,9 +55,9 @@ 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);
Set<? extends Image> response = api.listInDetail().concat().toSet();
for (String zoneId : api.getConfiguredZones()) {
ImageApi imageApi = api.getImageApiForZone(zoneId);
Set<? extends Image> response = imageApi.listInDetail().concat().toSet();
assertNotNull(response);
assertFalse(response.isEmpty());
for (Image image : response) {
@ -79,11 +79,11 @@ 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);
Set<? extends Image> response = api.listInDetail().concat().toSet();
for (String zoneId : api.getConfiguredZones()) {
ImageApi imageApi = api.getImageApiForZone(zoneId);
Set<? extends Image> response = imageApi.listInDetail().concat().toSet();
for (Image image : response) {
Image details = api.get(image.getId());
Image details = imageApi.get(image.getId());
assertNotNull(details);
assertEquals(details.getId(), image.getId());
assertEquals(details.getName(), image.getName());

View File

@ -43,8 +43,8 @@ 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);
for (Resource server : api.list().concat()) {
ServerApi serverApi = api.getServerApiForZone(zoneId);
for (Resource server : serverApi.list().concat()) {
checkResource(server);
}
}
@ -53,8 +53,8 @@ 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);
for (Server server : api.listInDetail().concat()) {
ServerApi serverApi = api.getServerApiForZone(zoneId);
for (Server server : serverApi.listInDetail().concat()) {
checkServer(server);
}
}
@ -63,9 +63,9 @@ 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);
for (Resource server : api.list().concat()) {
Server details = api.get(server.getId());
ServerApi serverApi = api.getServerApiForZone(zoneId);
for (Resource server : serverApi.list().concat()) {
Server details = serverApi.get(server.getId());
assertEquals(details.getId(), server.getId());
assertEquals(details.getName(), server.getName());
assertEquals(details.getLinks(), server.getLinks());

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,19 +55,17 @@ 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);
for (Resource server : api.list().concat()){
ServerApi serverApi = api.getServerApiForZone(zone);
for (Resource server : serverApi.list().concat()){
if (server.getName().equals(hostName))
api.delete(server.getId());
serverApi.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

@ -1,39 +0,0 @@
/**
* 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.openstack.nova.v2_0.internal;
import java.util.Properties;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.openstack.nova.v2_0.NovaAsyncApi;
import com.google.common.base.Function;
import com.google.inject.Module;
/**
* Base class for writing KeyStone Rest Api Expect tests
*
* @author Adrian Cole
*/
public class BaseNovaAsyncApiExpectTest extends BaseNovaExpectTest<NovaAsyncApi> {
public NovaAsyncApi createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
return createInjector(fn, module, props).getInstance(NovaAsyncApi.class);
}
}

View File

@ -33,7 +33,6 @@ import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule;
import org.jclouds.openstack.keystone.v2_0.config.KeystoneRestClientModule.KeystoneAdminURLModule;
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticationModule;
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes;
import org.jclouds.rest.RestContext;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.TypeToken;
@ -46,7 +45,12 @@ import com.google.inject.Module;
*/
public class CloudIdentityApiMetadata extends KeystoneApiMetadata {
public static final TypeToken<RestContext<KeystoneApi, KeystoneAsyncApi>> CONTEXT_TOKEN = new TypeToken<RestContext<KeystoneApi, KeystoneAsyncApi>>() {
/**
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(KeystoneApi.class)} as
* {@link KeystoneAsyncApi} interface will be removed in jclouds 1.7.
*/
@Deprecated
public static final TypeToken<org.jclouds.rest.RestContext<KeystoneApi, KeystoneAsyncApi>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<KeystoneApi, KeystoneAsyncApi>>() {
private static final long serialVersionUID = 1L;
};
@ -70,6 +74,7 @@ public class CloudIdentityApiMetadata extends KeystoneApiMetadata {
}
public static class Builder extends KeystoneApiMetadata.Builder<Builder> {
@SuppressWarnings("deprecation")
protected Builder(){
super(KeystoneApi.class, KeystoneAsyncApi.class);
id("rackspace-cloudidentity")

View File

@ -32,7 +32,6 @@ import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityAuthenticati
import org.jclouds.rackspace.cloudidentity.v2_0.config.CloudIdentityCredentialTypes;
import org.jclouds.rackspace.cloudloadbalancers.v1.config.CloudLoadBalancersRestClientModule;
import org.jclouds.rackspace.cloudloadbalancers.v1.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import com.google.common.collect.ImmutableSet;
@ -45,8 +44,12 @@ import com.google.inject.Module;
*/
public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata {
public static final TypeToken<RestContext<CloudLoadBalancersApi, CloudLoadBalancersAsyncApi>> CONTEXT_TOKEN =
new TypeToken<RestContext<CloudLoadBalancersApi, CloudLoadBalancersAsyncApi>>() {
/**
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudLoadBalancersApi.class)} as
* {@link CloudLoadBalancersAsyncApi} interface will be removed in jclouds 1.7.
*/
@Deprecated
public static final TypeToken<org.jclouds.rest.RestContext<CloudLoadBalancersApi, CloudLoadBalancersAsyncApi>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<CloudLoadBalancersApi, CloudLoadBalancersAsyncApi>>() {
private static final long serialVersionUID = 1L;
};
@ -72,6 +75,7 @@ public class CloudLoadBalancersApiMetadata extends BaseRestApiMetadata {
public static class Builder extends BaseRestApiMetadata.Builder<Builder> {
@SuppressWarnings("deprecation")
protected Builder() {
super(CloudLoadBalancersApi.class, CloudLoadBalancersAsyncApi.class);
id("rackspace-cloudloadbalancers")

View File

@ -49,7 +49,10 @@ import com.google.inject.Provides;
*
* @see CloudLoadBalancersApi
* @author Adrian Cole
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(CloudLoadBalancersApi.class)} as
* {@link CloudLoadBalancersAsyncApi} interface will be removed in jclouds 1.7.
*/
@Deprecated
public interface CloudLoadBalancersAsyncApi extends Closeable {
/**
* @return the Zone codes configured

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

@ -25,7 +25,6 @@ import java.net.URI;
import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import org.jclouds.route53.config.Route53RestClientModule;
@ -38,7 +37,12 @@ import com.google.common.reflect.TypeToken;
*/
public class Route53ApiMetadata extends BaseRestApiMetadata {
public static final TypeToken<RestContext<? extends Route53Api, ? extends Route53AsyncApi>> CONTEXT_TOKEN = new TypeToken<RestContext<? extends Route53Api, ? extends Route53AsyncApi>>() {
/**
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(Route53Api.class)} as
* {@link Route53AsyncApi} interface will be removed in jclouds 1.7.
*/
@Deprecated
public static final TypeToken<org.jclouds.rest.RestContext<? extends Route53Api, ? extends Route53AsyncApi>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<? extends Route53Api, ? extends Route53AsyncApi>>() {
private static final long serialVersionUID = 1L;
};
@ -47,6 +51,7 @@ public class Route53ApiMetadata extends BaseRestApiMetadata {
return new Builder(getApi(), getAsyncApi()).fromApiMetadata(this);
}
@SuppressWarnings("deprecation")
public Route53ApiMetadata() {
this(new Builder(Route53Api.class, Route53AsyncApi.class));
}

View File

@ -46,7 +46,10 @@ import com.google.common.util.concurrent.ListenableFuture;
* @see <a href="http://docs.amazonwebservices.com/Route53/latest/APIReference"
* />
* @author Adrian Cole
* @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(Route53Api.class)} as
* {@link Route53AsyncApi} interface will be removed in jclouds 1.7.
*/
@Deprecated
@RequestFilters(RestAuthentication.class)
@VirtualHost
@Path("/{jclouds.api-version}")

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

@ -18,7 +18,6 @@
*/
package org.jclouds.s3;
import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
@ -32,7 +31,6 @@ import java.net.URI;
import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.rest.RestContext;
import org.jclouds.rest.internal.BaseRestApiMetadata;
import org.jclouds.s3.blobstore.S3BlobStoreContext;
import org.jclouds.s3.blobstore.config.S3BlobStoreContextModule;
@ -62,7 +60,12 @@ import com.google.inject.Module;
*/
public class S3ApiMetadata extends BaseRestApiMetadata {
public static final TypeToken<RestContext<? extends S3Client,? extends S3AsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<? extends S3Client,? extends S3AsyncClient>>() {
/**
* @deprecated please use {@code org.jclouds.ContextBuilder#buildClient(S3Client.class)} as
* {@link S3AsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
public static final TypeToken<org.jclouds.rest.RestContext<? extends S3Client, ? extends S3AsyncClient>> CONTEXT_TOKEN = new TypeToken<org.jclouds.rest.RestContext<? extends S3Client, ? extends S3AsyncClient>>() {
private static final long serialVersionUID = 1L;
};
@ -81,7 +84,6 @@ public class S3ApiMetadata extends BaseRestApiMetadata {
public static Properties defaultProperties() {
Properties properties = BaseRestApiMetadata.defaultProperties();
properties.setProperty(PROPERTY_API_VERSION, S3AsyncClient.VERSION);
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
properties.setProperty(PROPERTY_HEADER_TAG, S3Headers.DEFAULT_AMAZON_HEADERTAG);
properties.setProperty(PROPERTY_S3_SERVICE_PATH, "/");
@ -93,6 +95,7 @@ public class S3ApiMetadata extends BaseRestApiMetadata {
}
public static abstract class Builder<T extends Builder<T>> extends BaseRestApiMetadata.Builder<T> {
@SuppressWarnings("deprecation")
protected Builder() {
this(S3Client.class, S3AsyncClient.class);
}
@ -105,7 +108,7 @@ public class S3ApiMetadata extends BaseRestApiMetadata {
.credentialName("Secret Access Key")
.defaultEndpoint("https://s3.amazonaws.com")
.documentation(URI.create("http://docs.amazonwebservices.com/AmazonS3/latest/API"))
.version(S3AsyncClient.VERSION)
.version("2006-03-01")
.defaultProperties(S3ApiMetadata.defaultProperties())
.context(CONTEXT_TOKEN)
.view(typeToken(S3BlobStoreContext.class))

View File

@ -104,9 +104,13 @@ import com.google.inject.Provides;
*
* @author Adrian Cole
* @author James Murty
* @see S3Client
* @see AWSS3Client
* @see <a href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/RESTAPI.html" />
* @deprecated please use
* {@code org.jclouds.ContextBuilder#buildApi(S3Client.class)}
* as {@link S3AsyncClient} interface will be removed in jclouds 1.7.
*/
@Deprecated
@RequestFilters(RequestAuthorizeSignature.class)
@BlobScope(CONTAINER)
public interface S3AsyncClient extends Closeable {

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