vcloud related changes for Issue 826

This commit is contained in:
Adrian Cole 2012-02-02 07:36:20 -08:00
parent 65336339e5
commit dc78a443de
13 changed files with 229 additions and 179 deletions

View File

@ -0,0 +1,31 @@
/**
* 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.vcloud;
import java.net.URI;
import java.util.SortedMap;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
public interface VCloudVersionsClient {
SortedMap<String, URI> getSupportedVersions();
}

View File

@ -1,51 +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.vcloud.compute.config;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.endpoints.VDC;
import com.google.common.base.Predicate;
@Singleton
public final class IsDefaultVDC implements Predicate<Location> {
private final ReferenceType defaultVDC;
@Inject
IsDefaultVDC(@VDC ReferenceType defaultVDC) {
this.defaultVDC = checkNotNull(defaultVDC, "defaultVDC");
}
@Override
public boolean apply(Location input) {
return input.getScope() == LocationScope.ZONE && input.getId().equals(defaultVDC.getHref().toASCIIString());
}
@Override
public String toString() {
return "isDefaultVDC()";
}
}

View File

@ -18,16 +18,11 @@
*/
package org.jclouds.vcloud.compute.config;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.find;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.collect.Memoized;
import org.jclouds.compute.ComputeServiceAdapter;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Image;
@ -56,11 +51,9 @@ import org.jclouds.vcloud.functions.VAppTemplatesInOrg;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMap;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.Scopes;
import com.google.inject.TypeLiteral;
/**
@ -87,8 +80,6 @@ public class VCloudComputeServiceDependenciesModule extends AbstractModule {
@SuppressWarnings("unchecked")
@Override
protected void configure() {
bind(new TypeLiteral<Supplier<Location>>() {
}).to(DefaultVDC.class).in(Scopes.SINGLETON);
bind(new TypeLiteral<ComputeServiceAdapter<VApp, VAppTemplate, VAppTemplate, Location>>() {
}).to(VCloudComputeServiceAdapter.class);
@ -121,23 +112,4 @@ public class VCloudComputeServiceDependenciesModule extends AbstractModule {
return new NetworkConfig(network.getName(), network.getHref(), defaultFenceMode);
}
@Singleton
public static class DefaultVDC implements Supplier<Location> {
private final Supplier<Set<? extends Location>> locationsSupplier;
private final IsDefaultVDC isDefaultVDC;
@Inject
DefaultVDC(@Memoized Supplier<Set<? extends Location>> locationsSupplier, IsDefaultVDC isDefaultVDC) {
this.locationsSupplier = checkNotNull(locationsSupplier, "locationsSupplierSupplier");
this.isDefaultVDC = checkNotNull(isDefaultVDC, "isDefaultVDC");
}
@Override
public Location get() {
return find(locationsSupplier.get(), isDefaultVDC);
}
}
}

View File

@ -40,7 +40,6 @@ import org.jclouds.vcloud.TaskInErrorStateException;
import org.jclouds.vcloud.TaskStillRunningException;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.compute.suppliers.OrgAndVDCToLocationSupplier;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.domain.Status;
@ -75,20 +74,18 @@ public class VCloudComputeServiceAdapter implements ComputeServiceAdapter<VApp,
protected final Supplier<Map<String, Org>> nameToOrg;
protected final Supplier<Set<VAppTemplate>> templates;
protected final Function<VAppTemplate, Envelope> templateToEnvelope;
protected final Supplier<Set<? extends Location>> locations;
@Inject
protected VCloudComputeServiceAdapter(VCloudClient client, Predicate<URI> successTester,
InstantiateVAppTemplateWithGroupEncodedIntoNameThenCustomizeDeployAndPowerOn booter,
Supplier<Map<String, Org>> nameToOrg, VAppTemplatesSupplier templates,
Function<VAppTemplate, Envelope> templateToEnvelope, OrgAndVDCToLocationSupplier locations) {
Function<VAppTemplate, Envelope> templateToEnvelope) {
this.client = checkNotNull(client, "client");
this.successTester = checkNotNull(successTester, "successTester");
this.booter = checkNotNull(booter, "booter");
this.nameToOrg = checkNotNull(nameToOrg, "nameToOrg");
this.templates = checkNotNull(templates, "templates");
this.templateToEnvelope = checkNotNull(templateToEnvelope, "templateToEnvelope");
this.locations = checkNotNull(locations, "locations");
}
@Override
@ -154,10 +151,10 @@ public class VCloudComputeServiceAdapter implements ComputeServiceAdapter<VApp,
}
}
@SuppressWarnings("unchecked")
@Override
public Iterable<Location> listLocations() {
return (Iterable<Location>) locations.get();
// Not using the adapter to determine locations
return ImmutableSet.<Location>of();
}
@Override

View File

@ -22,7 +22,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Predicates.notNull;
import static com.google.common.base.Suppliers.compose;
import static com.google.common.base.Throwables.propagate;
import static com.google.common.collect.Iterables.concat;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.getLast;
@ -31,6 +30,7 @@ import static com.google.common.collect.Maps.transformValues;
import static com.google.common.collect.Maps.uniqueIndex;
import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import static org.jclouds.rest.config.BinderUtils.bindClientAndAsyncClient;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
@ -38,9 +38,6 @@ import java.net.URI;
import java.util.Map;
import java.util.SortedMap;
import java.util.Map.Entry;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicReference;
import javax.inject.Inject;
@ -54,9 +51,10 @@ import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.location.suppliers.ImplicitLocationSupplier;
import org.jclouds.location.suppliers.LocationsSupplier;
import org.jclouds.ovf.Envelope;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.rest.AsyncClientFactory;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.config.RestClientModule;
@ -65,6 +63,7 @@ import org.jclouds.vcloud.VCloudAsyncClient;
import org.jclouds.vcloud.VCloudClient;
import org.jclouds.vcloud.VCloudToken;
import org.jclouds.vcloud.VCloudVersionsAsyncClient;
import org.jclouds.vcloud.VCloudVersionsClient;
import org.jclouds.vcloud.compute.functions.FindLocationForResource;
import org.jclouds.vcloud.compute.functions.ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException;
import org.jclouds.vcloud.domain.Catalog;
@ -103,14 +102,18 @@ import org.jclouds.vcloud.functions.OrgsForNames;
import org.jclouds.vcloud.functions.VAppTemplatesForCatalogItems;
import org.jclouds.vcloud.handlers.ParseVCloudErrorFromHttpResponse;
import org.jclouds.vcloud.internal.VCloudLoginAsyncClient;
import org.jclouds.vcloud.internal.VCloudLoginClient;
import org.jclouds.vcloud.loaders.OVFLoader;
import org.jclouds.vcloud.loaders.VAppTemplateLoader;
import org.jclouds.vcloud.location.DefaultVDC;
import org.jclouds.vcloud.location.OrgAndVDCToLocationSupplier;
import org.jclouds.vcloud.predicates.TaskSuccess;
import org.jclouds.vcloud.xml.ovf.VCloudResourceAllocationSettingDataHandler;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
@ -118,6 +121,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.inject.Injector;
import com.google.inject.Provides;
import com.google.inject.Scopes;
import com.google.inject.TypeLiteral;
/**
@ -144,28 +148,16 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
super(VCloudClient.class, VCloudAsyncClient.class, DELEGATE_MAP);
}
@Provides
@Singleton
protected VCloudLoginAsyncClient provideVCloudLogin(AsyncClientFactory factory) {
return factory.create(VCloudLoginAsyncClient.class);
}
@Provides
@Singleton
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
AtomicReference<AuthorizationException> authException, final VCloudLoginAsyncClient login) {
AtomicReference<AuthorizationException> authException, final VCloudLoginClient login) {
return new MemoizedRetryOnTimeOutButNotOnAuthorizationExceptionSupplier<VCloudSession>(authException, seconds,
new Supplier<VCloudSession>() {
@Override
public VCloudSession get() {
try {
return login.login().get(10, TimeUnit.SECONDS);
} catch (Exception e) {
propagate(e);
assert false : e;
return null;
}
return login.login();
}
});
@ -178,9 +170,6 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
}).to(new TypeLiteral<VAppTemplatesForCatalogItems>() {
});
bind(ResourceAllocationSettingDataHandler.class).to(VCloudResourceAllocationSettingDataHandler.class);
// Ensures we don't retry on authorization failures
bind(new TypeLiteral<AtomicReference<AuthorizationException>>() {
}).toInstance(new AtomicReference<AuthorizationException>());
installDefaultVCloudEndpointsModule();
bind(new TypeLiteral<Function<ReferenceType, Location>>() {
}).to(new TypeLiteral<FindLocationForResource>() {
@ -213,7 +202,8 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
bind(new TypeLiteral<Function<VAppTemplate, Envelope>>() {
}).to(new TypeLiteral<ValidateVAppTemplateAndReturnEnvelopeOrThrowIllegalArgumentException>() {
});
bindClientAndAsyncClient(binder(), VCloudVersionsClient.class, VCloudVersionsAsyncClient.class);
bindClientAndAsyncClient(binder(), VCloudLoginClient.class, VCloudLoginAsyncClient.class);
}
protected void bindCacheLoaders() {
@ -257,9 +247,20 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
@Provides
@Singleton
@OrgList
URI provideOrgListURI(Supplier<VCloudSession> sessionSupplier) {
VCloudSession session = sessionSupplier.get();
return URI.create(getLast(session.getOrgs().values()).getHref().toASCIIString().replaceAll("org/.*", "org"));
protected Supplier<URI> provideOrgListURI(Supplier<VCloudSession> sessionSupplier) {
return Suppliers.compose(new Function<VCloudSession, URI>() {
@Override
public URI apply(VCloudSession arg0) {
return URI.create(getLast(arg0.getOrgs().values()).getHref().toASCIIString().replaceAll("org/.*", "org"));
}
@Override
public String toString() {
return "orgListURI()";
}
}, sessionSupplier);
}
@Singleton
@ -381,15 +382,24 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
@Provides
@Singleton
@org.jclouds.vcloud.endpoints.VCloudLogin
protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService,
@Named(PROPERTY_API_VERSION) String version) throws InterruptedException, ExecutionException,
TimeoutException {
SortedMap<String, URI> versions = versionService.getSupportedVersions().get(180, TimeUnit.SECONDS);
protected Supplier<URI> provideAuthenticationURI(final VCloudVersionsClient versionService,
@Named(PROPERTY_API_VERSION) final String version) {
return new Supplier<URI>() {
@Override
public URI get() {
SortedMap<String, URI> versions = versionService.getSupportedVersions();
checkState(versions.size() > 0, "No versions present");
checkState(versions.containsKey(version), "version " + version + " not present in: " + versions);
return versions.get(version);
}
public String toString() {
return "login()";
}
};
}
@Singleton
private static class OrgNameToOrgSupplier implements Supplier<Map<String, ReferenceType>> {
private final Supplier<VCloudSession> sessionSupplier;
@ -407,12 +417,6 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
}
@Provides
@Singleton
protected VCloudVersionsAsyncClient provideVCloudVersions(AsyncClientFactory factory) {
return factory.create(VCloudVersionsAsyncClient.class);
}
@Provides
@Singleton
protected Org provideOrg(Supplier<Map<String, Org>> orgSupplier,
@ -519,7 +523,6 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
authException, seconds, supplier);
}
@Provides
@Singleton
protected FenceMode defaultFenceMode(@Named(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) String fenceMode) {
@ -544,4 +547,11 @@ public class VCloudRestClientModule extends RestClientModule<VCloudClient, VClou
bind(HttpErrorHandler.class).annotatedWith(ClientError.class).to(ParseVCloudErrorFromHttpResponse.class);
bind(HttpErrorHandler.class).annotatedWith(ServerError.class).to(ParseVCloudErrorFromHttpResponse.class);
}
@Override
protected void installLocations() {
super.installLocations();
bind(ImplicitLocationSupplier.class).to(DefaultVDC.class).in(Scopes.SINGLETON);
bind(LocationsSupplier.class).to(OrgAndVDCToLocationSupplier.class).in(Scopes.SINGLETON);
}
}

View File

@ -0,0 +1,30 @@
/**
* 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.vcloud.internal;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.vcloud.domain.VCloudSession;
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
public interface VCloudLoginClient {
VCloudSession login();
}

View File

@ -0,0 +1,75 @@
/**
* 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.vcloud.location;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Iterables.find;
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.collect.Memoized;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationScope;
import org.jclouds.location.suppliers.ImplicitLocationSupplier;
import org.jclouds.vcloud.domain.ReferenceType;
import org.jclouds.vcloud.endpoints.VDC;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
@Singleton
public class DefaultVDC implements ImplicitLocationSupplier {
private final Supplier<Set<? extends Location>> locationsSupplier;
private final IsDefaultVDC isDefaultVDC;
@Inject
DefaultVDC(@Memoized Supplier<Set<? extends Location>> locationsSupplier, IsDefaultVDC isDefaultVDC) {
this.locationsSupplier = checkNotNull(locationsSupplier, "locationsSupplierSupplier");
this.isDefaultVDC = checkNotNull(isDefaultVDC, "isDefaultVDC");
}
@Override
public Location get() {
return find(locationsSupplier.get(), isDefaultVDC);
}
@Singleton
public static class IsDefaultVDC implements Predicate<Location> {
private final ReferenceType defaultVDC;
@Inject
IsDefaultVDC(@VDC ReferenceType defaultVDC) {
this.defaultVDC = checkNotNull(defaultVDC, "defaultVDC");
}
@Override
public boolean apply(Location input) {
return input.getScope() == LocationScope.ZONE && input.getId().equals(defaultVDC.getHref().toASCIIString());
}
@Override
public String toString() {
return "isDefaultVDC()";
}
}
}

View File

@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.compute.suppliers;
package org.jclouds.vcloud.location;
import static com.google.common.base.Preconditions.checkNotNull;
@ -32,7 +32,8 @@ import org.jclouds.domain.LocationBuilder;
import org.jclouds.domain.LocationScope;
import org.jclouds.location.Iso3166;
import org.jclouds.location.Provider;
import org.jclouds.location.suppliers.JustProvider;
import org.jclouds.location.suppliers.LocationsSupplier;
import org.jclouds.location.suppliers.all.JustProvider;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.ReferenceType;
@ -45,20 +46,21 @@ import com.google.common.collect.ImmutableSet.Builder;
* @author Adrian Cole
*/
@Singleton
public class OrgAndVDCToLocationSupplier extends JustProvider {
public class OrgAndVDCToLocationSupplier extends JustProvider implements LocationsSupplier {
private final Supplier<Map<String, ReferenceType>> orgNameToResource;
private final Supplier<Map<String, Org>> orgNameToVDCResource;
private final Map<String, Set<String>> isoCodesById;
private final Supplier<Map<String, Supplier<Set<String>>>> isoCodesByIdSupplier;
@Inject
OrgAndVDCToLocationSupplier(@Iso3166 Set<String> isoCodes, @Provider String providerName, @Provider URI endpoint,
@org.jclouds.vcloud.endpoints.Org Supplier<Map<String, ReferenceType>> orgNameToResource,
Supplier<Map<String, Org>> orgNameToVDCResource, @Iso3166 Map<String, Set<String>> isoCodesById) {
Supplier<Map<String, Org>> orgNameToVDCResource,
@Iso3166 Supplier<Map<String, Supplier<Set<String>>>> isoCodesByIdSupplier) {
super(providerName, endpoint, isoCodes);
this.orgNameToResource = checkNotNull(orgNameToResource, "orgNameToResource");
this.orgNameToVDCResource = checkNotNull(orgNameToVDCResource, "orgNameToVDCResource");
this.isoCodesById = checkNotNull(isoCodesById, "isoCodesById");
this.isoCodesByIdSupplier = checkNotNull(isoCodesByIdSupplier, "isoCodesByIdSupplier");
}
@Override
@ -71,18 +73,18 @@ public class OrgAndVDCToLocationSupplier extends JustProvider {
Location provider = Iterables.getOnlyElement(super.get());
if (orgNameToResource.get().size() == 0)
return locations.add(provider);
else
Map<String, Supplier<Set<String>>> isoCodesById = isoCodesByIdSupplier.get();
for (ReferenceType org : orgNameToResource.get().values()) {
LocationBuilder builder = new LocationBuilder().scope(LocationScope.REGION).id(
org.getHref().toASCIIString()).description((org.getName())).parent(provider);
LocationBuilder builder = new LocationBuilder().scope(LocationScope.REGION).id(org.getHref().toASCIIString())
.description((org.getName())).parent(provider);
if (isoCodesById.containsKey(org.getHref().toASCIIString()))
builder.iso3166Codes(isoCodesById.get(org.getHref().toASCIIString()));
builder.iso3166Codes(isoCodesById.get(org.getHref().toASCIIString()).get());
Location orgL = builder.build();
for (ReferenceType vdc : orgNameToVDCResource.get().get(org.getName()).getVDCs().values()) {
builder = new LocationBuilder().scope(LocationScope.ZONE).id(vdc.getHref().toASCIIString()).description(
(vdc.getName())).parent(orgL);
if (isoCodesById.containsKey(vdc.getHref().toASCIIString()))
builder.iso3166Codes(isoCodesById.get(vdc.getHref().toASCIIString()));
builder.iso3166Codes(isoCodesById.get(vdc.getHref().toASCIIString()).get());
locations.add(builder.build());
}
}

View File

@ -23,11 +23,7 @@ import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URI;
import java.util.SortedMap;
import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.RestClientTest;
@ -73,12 +69,6 @@ public class VCloudVersionsAsyncClientTest extends RestClientTest<VCloudVersions
};
}
@Timeout(duration = 10, timeUnit = TimeUnit.SECONDS)
public interface VCloudVersionsClient {
SortedMap<String, URI> getSupportedVersions();
}
@Override
public RestContextSpec<VCloudVersionsClient, VCloudVersionsAsyncClient> createContextSpec() {
return contextSpec("test", "http://localhost:8080", "1", "", "", "identity", "credential",

View File

@ -34,7 +34,7 @@ import org.jclouds.domain.LocationScope;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.location.suppliers.JustProvider;
import org.jclouds.location.suppliers.all.JustProvider;
import org.jclouds.vcloud.compute.BaseVCloudComputeServiceExpectTest;
import org.testng.annotations.Test;

View File

@ -40,7 +40,7 @@ import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextSpec;
import org.jclouds.vcloud.VCloudMediaType;
import org.jclouds.vcloud.VCloudVersionsAsyncClient;
import org.jclouds.vcloud.VCloudVersionsClient;
import org.jclouds.vcloud.config.VCloudRestClientModule;
import org.jclouds.vcloud.domain.AllocationModel;
import org.jclouds.vcloud.domain.Org;
@ -134,8 +134,8 @@ public abstract class BaseVCloudAsyncClientTest<T> extends RestClientTest<T> {
public static class VCloudRestClientModuleExtension extends VCloudRestClientModule {
@Override
protected URI provideAuthenticationURI(VCloudVersionsAsyncClient versionService, String version) {
return URI.create("https://vcenterprise.bluelock.com/api/v1.0/login");
protected Supplier<URI> provideAuthenticationURI(VCloudVersionsClient versionService, String version) {
return Suppliers.ofInstance(URI.create("https://vcenterprise.bluelock.com/api/v1.0/login"));
}
@Override
@ -165,7 +165,7 @@ public abstract class BaseVCloudAsyncClientTest<T> extends RestClientTest<T> {
@Override
protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds,
AtomicReference<AuthorizationException> authException, final VCloudLoginAsyncClient login) {
AtomicReference<AuthorizationException> authException, final VCloudLoginClient login) {
return Suppliers.<VCloudSession> ofInstance(new VCloudSession() {
@Override

View File

@ -24,22 +24,21 @@ import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URI;
import java.util.concurrent.TimeUnit;
import javax.ws.rs.core.HttpHeaders;
import org.jclouds.concurrent.Timeout;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.location.Provider;
import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.vcloud.domain.VCloudSession;
import org.jclouds.vcloud.endpoints.VCloudLogin;
import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders;
import org.testng.annotations.Test;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.inject.Binder;
import com.google.inject.Module;
import com.google.inject.Provides;
@ -92,18 +91,13 @@ public class VCloudLoginAsyncClientTest extends RestClientTest<VCloudLoginAsyncC
@SuppressWarnings("unused")
@Provides
@VCloudLogin
URI provideURI(@Provider URI uri) {
return uri;
Supplier<URI> provideURI(@Provider URI uri) {
return Suppliers.ofInstance(uri);
}
};
}
@Timeout(duration = 10, timeUnit = TimeUnit.SECONDS)
public interface VCloudLoginClient {
VCloudSession login();
}
@Override
public RestContextSpec<VCloudLoginClient, VCloudLoginAsyncClient> createContextSpec() {