refactored to create typed contextspec objects

This commit is contained in:
Adrian Cole 2010-10-24 22:59:01 -05:00
parent 9d91b1704d
commit fb93e81301
40 changed files with 353 additions and 318 deletions

View File

@ -49,7 +49,7 @@ import org.jclouds.http.options.GetOptions;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
@ -270,7 +270,7 @@ public class AtmosStorageAsyncClientTest extends RestClientTest<AtmosStorageAsyn
} }
@Override @Override
public ContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec("atmosonline", "identity", "credential", new Properties()); return new RestContextFactory().createContextSpec("atmosonline", "identity", "credential", new Properties());
} }

View File

@ -36,7 +36,7 @@ import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -139,7 +139,7 @@ public class AtmosBlobRequestSignerTest extends RestClientTest<AtmosStorageAsync
} }
@Override @Override
public ContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec("atmosonline", "identity", "credential", new Properties()); return new RestContextFactory().createContextSpec("atmosonline", "identity", "credential", new Properties());
} }

View File

@ -39,7 +39,7 @@ import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -101,7 +101,7 @@ public class CloudWatchAsyncClientTest extends RestClientTest<CloudWatchAsyncCli
} }
@Override @Override
public ContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec("cloudwatch", "identity", "credential", new Properties()); return new RestContextFactory().createContextSpec("cloudwatch", "identity", "credential", new Properties());
} }

View File

@ -40,7 +40,7 @@ import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.testng.annotations.BeforeTest; import org.testng.annotations.BeforeTest;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
@ -102,7 +102,7 @@ public abstract class BaseEC2AsyncClientTest<T> extends RestClientTest<T> {
} }
@Override @Override
public ContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec("ec2", "identity", "credential", new Properties()); return new RestContextFactory().createContextSpec("ec2", "identity", "credential", new Properties());
} }

View File

@ -38,7 +38,7 @@ import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -103,7 +103,7 @@ public class ELBAsyncClientTest extends RestClientTest<ELBAsyncClient> {
} }
@Override @Override
public ContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec("elb", "identity", "credential", return new RestContextFactory().createContextSpec("elb", "identity", "credential",
new Properties()); new Properties());
} }

View File

@ -29,7 +29,7 @@ import org.jclouds.aws.s3.filters.RequestAuthorizeSignature;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
@ -65,7 +65,7 @@ public abstract class BaseS3AsyncClientTest extends RestClientTest<S3AsyncClient
} }
@Override @Override
public ContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec("s3", "identity", "credential", new Properties()); return new RestContextFactory().createContextSpec("s3", "identity", "credential", new Properties());
} }

View File

@ -36,7 +36,7 @@ import org.jclouds.io.payloads.PhantomPayload;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -135,7 +135,7 @@ public class S3BlobRequestSignerTest extends RestClientTest<S3AsyncClient> {
} }
@Override @Override
public ContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec("s3", "identity", "credential", new Properties()); return new RestContextFactory().createContextSpec("s3", "identity", "credential", new Properties());
} }

View File

@ -44,7 +44,7 @@ import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -170,7 +170,7 @@ public class SQSAsyncClientTest extends RestClientTest<SQSAsyncClient> {
} }
@Override @Override
public ContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec("sqs", "identity", "credential", new Properties()); return new RestContextFactory().createContextSpec("sqs", "identity", "credential", new Properties());
} }

View File

@ -47,7 +47,7 @@ import org.jclouds.http.functions.ReturnTrueOn404;
import org.jclouds.http.options.GetOptions; import org.jclouds.http.options.GetOptions;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -277,7 +277,7 @@ public class AzureBlobAsyncClientTest extends RestClientTest<AzureBlobAsyncClien
} }
@Override @Override
public ContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec("azureblob", "identity", "credential", new Properties()); return new RestContextFactory().createContextSpec("azureblob", "identity", "credential", new Properties());
} }
} }

View File

@ -35,7 +35,7 @@ import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -133,7 +133,7 @@ public class AzureBlobRequestSignerTest extends RestClientTest<AzureBlobAsyncCli
} }
@Override @Override
public ContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec("azureblob", "identity", "credential", new Properties()); return new RestContextFactory().createContextSpec("azureblob", "identity", "credential", new Properties());
} }

View File

@ -42,7 +42,7 @@ import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.functions.ReturnTrueIf2xx; import org.jclouds.http.functions.ReturnTrueIf2xx;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -233,7 +233,7 @@ public class AzureQueueAsyncClientTest extends RestClientTest<AzureQueueAsyncCli
} }
@Override @Override
public ContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec("azurequeue", "identity", "credential", new Properties()); return new RestContextFactory().createContextSpec("azurequeue", "identity", "credential", new Properties());
} }

View File

@ -41,7 +41,6 @@ public abstract class BlobStoreContextBuilder<S, A> extends RestContextBuilder<S
public BlobStoreContextBuilder(Class<S> syncClientType, Class<A> asyncClientType, Properties properties) { public BlobStoreContextBuilder(Class<S> syncClientType, Class<A> asyncClientType, Properties properties) {
super(syncClientType, asyncClientType, properties); super(syncClientType, asyncClientType, properties);
} }
public BlobStoreContext buildBlobStoreContext() { public BlobStoreContext buildBlobStoreContext() {

View File

@ -27,7 +27,7 @@ import java.util.Properties;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import com.google.inject.Module; import com.google.inject.Module;
@ -124,18 +124,18 @@ public class BlobStoreContextFactory {
} }
/** /**
* @see RestContextFactory#createContextBuilder(ContextSpec) * @see RestContextFactory#createContextBuilder(RestContextSpec)
*/ */
public <S, A> BlobStoreContext createContext(ContextSpec<S, A> contextSpec) { public <S, A> BlobStoreContext createContext(RestContextSpec<S, A> contextSpec) {
BlobStoreContextBuilder<?, ?> builder = BlobStoreContextBuilder.class.cast(createContextBuilder(contextSpec)); BlobStoreContextBuilder<?, ?> builder = BlobStoreContextBuilder.class.cast(createContextBuilder(contextSpec));
return buildContextUnwrappingExceptions(builder); return buildContextUnwrappingExceptions(builder);
} }
/** /**
* @see RestContextFactory#createContextBuilder(ContextSpec, Properties) * @see RestContextFactory#createContextBuilder(RestContextSpec, Properties)
*/ */
public <S, A> BlobStoreContext createContext(ContextSpec<S, A> contextSpec, Properties overrides) { public <S, A> BlobStoreContext createContext(RestContextSpec<S, A> contextSpec, Properties overrides) {
BlobStoreContextBuilder<?, ?> builder = BlobStoreContextBuilder.class.cast(createContextBuilder(contextSpec, BlobStoreContextBuilder<?, ?> builder = BlobStoreContextBuilder.class.cast(createContextBuilder(contextSpec,
overrides)); overrides));
return buildContextUnwrappingExceptions(builder); return buildContextUnwrappingExceptions(builder);

View File

@ -30,7 +30,7 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.io.payloads.PhantomPayload; import org.jclouds.io.payloads.PhantomPayload;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -97,7 +97,7 @@ public class TransientBlobRequestSignerTest extends RestClientTest<TransientAsyn
} }
@Override @Override
public ContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec("transient", "identity", "credential", new Properties()); return new RestContextFactory().createContextSpec("transient", "identity", "credential", new Properties());
} }

View File

@ -22,8 +22,9 @@
(:import (:import
[org.jclouds.ssh SshClient ExecResponse] [org.jclouds.ssh SshClient ExecResponse]
com.google.inject.Module com.google.inject.Module
com.google.common.collect.ImmutableSet
org.jclouds.net.IPSocket org.jclouds.net.IPSocket
[org.jclouds.compute ComputeService ComputeServiceContextFactory] [org.jclouds.compute ComputeService ComputeServiceContextFactory StandaloneComputeServiceContextSpec]
[java.util Set Map] [java.util Set Map]
[org.jclouds.compute.domain NodeMetadata Template] [org.jclouds.compute.domain NodeMetadata Template]
[com.google.common.base Supplier Predicate] [com.google.common.base Supplier Predicate]
@ -52,8 +53,11 @@
(^void rebootNode [this ^String id] (^void rebootNode [this ^String id]
())))) ()))))
(defn compute-context [module] (defn compute-context [^RestContextSpec spec]
(ComputeServiceContextFactory/createStandaloneContext module)) (.createContext (ComputeServiceContextFactory.) spec))
(^RestContextSpec defn context-spec [^StandaloneComputeServiceContextModule module]
(StandaloneComputeServiceContextSpec. "servermanager", "http://host", "1", "identity", "credential", module, (ImmutableSet/of)))
(defrecord NodeListComputeService (defrecord NodeListComputeService
[node-list] [node-list]

View File

@ -26,12 +26,9 @@ import java.util.Properties;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.jclouds.PropertiesBuilder;
import org.jclouds.compute.config.StandaloneComputeServiceContextModule;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module; import com.google.inject.Module;
/** /**
@ -126,9 +123,9 @@ public class ComputeServiceContextFactory {
} }
/** /**
* @see RestContextFactory#createContextBuilder(ContextSpec) * @see RestContextFactory#createContextBuilder(RestContextSpec)
*/ */
public <S, A> ComputeServiceContext createContext(ContextSpec<S, A> contextSpec) { public <S, A> ComputeServiceContext createContext(RestContextSpec<S, A> contextSpec) {
ComputeServiceContextBuilder<?, ?> builder = ComputeServiceContextBuilder.class ComputeServiceContextBuilder<?, ?> builder = ComputeServiceContextBuilder.class
.cast(createContextBuilder(contextSpec)); .cast(createContextBuilder(contextSpec));
return buildContextUnwrappingExceptions(builder); return buildContextUnwrappingExceptions(builder);
@ -136,26 +133,22 @@ public class ComputeServiceContextFactory {
} }
/** /**
* @see RestContextFactory#createContextBuilder(ContextSpec, Properties) * @see RestContextFactory#createContextBuilder(RestContextSpec, Properties)
*/ */
public <S, A> ComputeServiceContext createContext(ContextSpec<S, A> contextSpec, Properties overrides) { public <S, A> ComputeServiceContext createContext(RestContextSpec<S, A> contextSpec, Properties overrides) {
ComputeServiceContextBuilder<?, ?> builder = ComputeServiceContextBuilder.class.cast(createContextBuilder( ComputeServiceContextBuilder<?, ?> builder = ComputeServiceContextBuilder.class.cast(createContextBuilder(
contextSpec, overrides)); contextSpec, overrides));
return buildContextUnwrappingExceptions(builder); return buildContextUnwrappingExceptions(builder);
} }
public static <N, H, I, L> ComputeServiceContext createStandaloneContext( /**
StandaloneComputeServiceContextModule<N, H, I, L> contextModule) { * @see RestContextFactory#createContextBuilder(RestContextSpec, Iterable, Properties)
return createStandaloneContext(contextModule, ImmutableSet.<Module> of()); */
public <S, A> ComputeServiceContext createContext(RestContextSpec<S, A> contextSpec, Iterable<Module> modules,
Properties overrides) {
ComputeServiceContextBuilder<?, ?> builder = ComputeServiceContextBuilder.class.cast(createContextBuilder(
contextSpec, modules, overrides));
return buildContextUnwrappingExceptions(builder);
} }
@SuppressWarnings("unchecked")
public static <N, H, I, L> ComputeServiceContext createStandaloneContext(
StandaloneComputeServiceContextModule<N, H, I, L> contextModule, Iterable<Module> modules) {
return new ComputeServiceContextFactory().createContext(RestContextFactory
.<ComputeService, ComputeService> contextSpec("standalone", "standalone", "1", "standalone", null,
(Class) null, (Class) null, PropertiesBuilder.class,
(Class) StandaloneComputeServiceContextBuilder.class,
ImmutableSet.<Module> builder().add(contextModule).addAll(modules).build()));
}
} }

View File

@ -0,0 +1,43 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.compute;
import org.jclouds.PropertiesBuilder;
import org.jclouds.compute.config.StandaloneComputeServiceContextModule;
import org.jclouds.rest.RestContextSpec;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.inject.Module;
/**
* @author Adrian Cole
*/
public class StandaloneComputeServiceContextSpec<N, H, I, L> extends RestContextSpec<ComputeService, ComputeService> {
@SuppressWarnings({ "unchecked", "rawtypes" })
public StandaloneComputeServiceContextSpec(String provider, String endpoint, String apiVersion, String identity,
String credential, StandaloneComputeServiceContextModule<N, H, I, L> contextModule, Iterable<Module> modules) {
super(provider, endpoint, apiVersion, identity, credential, ComputeService.class, ComputeService.class,
PropertiesBuilder.class, (Class) StandaloneComputeServiceContextBuilder.class, Iterables.concat(
ImmutableSet.of(contextModule), modules));
}
}

View File

@ -19,9 +19,16 @@
package org.jclouds.compute; package org.jclouds.compute;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.stub.config.StubComputeServiceContextModule; import org.jclouds.compute.stub.config.StubComputeServiceContextModule;
import org.jclouds.domain.Location;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
/** /**
* *
* @author Adrian Cole * @author Adrian Cole
@ -32,9 +39,11 @@ public class ComputeServiceContextFactoryTest {
@Test @Test
public void testStandalone() { public void testStandalone() {
ComputeServiceContext context = ComputeServiceContextFactory ComputeServiceContext context = new ComputeServiceContextFactory()
.createStandaloneContext(new StubComputeServiceContextModule()); .createContext(new StandaloneComputeServiceContextSpec<NodeMetadata, Hardware, Image, Location>("stub",
"stub", "1", "identity", "credential", new StubComputeServiceContextModule(), ImmutableSet
.<Module> of()));
context.getComputeService().listNodes(); context.getComputeService().listNodes();
} }
} }

View File

@ -19,7 +19,6 @@
package org.jclouds.rest; package org.jclouds.rest;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.propagate; import static com.google.common.base.Throwables.propagate;
import static com.google.common.collect.Iterables.concat; import static com.google.common.collect.Iterables.concat;
@ -73,145 +72,26 @@ import com.google.inject.Module;
*/ */
public class RestContextFactory { public class RestContextFactory {
public static <S, A> ContextSpec<S, A> contextSpec(String provider, String endpoint, String apiVersion, public static <S, A> RestContextSpec<S, A> contextSpec(String provider, String endpoint, String apiVersion,
String identity, String credential, Class<S> sync, Class<A> async, String identity, String credential, Class<S> sync, Class<A> async,
Class<PropertiesBuilder> propertiesBuilderClass, Class<RestContextBuilder<S, A>> contextBuilderClass, Class<PropertiesBuilder> propertiesBuilderClass, Class<RestContextBuilder<S, A>> contextBuilderClass,
Iterable<Module> modules) { Iterable<Module> modules) {
return new ContextSpec<S, A>(provider, endpoint, apiVersion, identity, credential, sync, async, return new RestContextSpec<S, A>(provider, endpoint, apiVersion, identity, credential, sync, async,
propertiesBuilderClass, contextBuilderClass, modules); propertiesBuilderClass, contextBuilderClass, modules);
} }
public static <S, A> ContextSpec<S, A> contextSpec(String provider, String endpoint, String apiVersion, public static <S, A> RestContextSpec<S, A> contextSpec(String provider, String endpoint, String apiVersion,
String identity, String credential, Class<S> sync, Class<A> async) { String identity, String credential, Class<S> sync, Class<A> async) {
return new ContextSpec<S, A>(provider, endpoint, apiVersion, identity, credential, sync, async); return new RestContextSpec<S, A>(provider, endpoint, apiVersion, identity, credential, sync, async);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <S, A> ContextSpec<S, A> contextSpec(String provider, String endpoint, String apiVersion, public static <S, A> RestContextSpec<S, A> contextSpec(String provider, String endpoint, String apiVersion,
String identity, String credential, Class<S> sync, Class<A> async, Iterable<Module> modules) { String identity, String credential, Class<S> sync, Class<A> async, Iterable<Module> modules) {
return new ContextSpec<S, A>(provider, endpoint, apiVersion, identity, credential, sync, async, return new RestContextSpec<S, A>(provider, endpoint, apiVersion, identity, credential, sync, async,
PropertiesBuilder.class, (Class) RestContextBuilder.class, modules); PropertiesBuilder.class, (Class) RestContextBuilder.class, modules);
} }
public static class ContextSpec<S, A> {
final String provider;
final String endpoint;
final String apiVersion;
final String identity;
final String credential;
final Class<S> sync;
final Class<A> async;
final Class<PropertiesBuilder> propertiesBuilderClass;
final Class<RestContextBuilder<S, A>> contextBuilderClass;
final Iterable<Module> modules;
ContextSpec(String provider, String endpoint, String apiVersion, String identity, String credential,
Class<S> sync, Class<A> async, Class<PropertiesBuilder> propertiesBuilderClass,
Class<RestContextBuilder<S, A>> contextBuilderClass, Iterable<Module> modules) {
this.provider = checkNotNull(provider, "provider");
this.endpoint = endpoint;
this.apiVersion = apiVersion;
this.identity = identity;
this.credential = credential;
this.sync = sync;
this.async = async;
checkArgument(RestContextBuilder.class.isAssignableFrom(contextBuilderClass), contextBuilderClass.getName()
+ " is not a subclass of " + RestContextBuilder.class.getName());
checkArgument(PropertiesBuilder.class.isAssignableFrom(propertiesBuilderClass), propertiesBuilderClass
.getName()
+ " is not a subclass of " + PropertiesBuilder.class.getName());
this.propertiesBuilderClass = propertiesBuilderClass;
this.contextBuilderClass = contextBuilderClass;
this.modules = modules;
}
@SuppressWarnings("unchecked")
public ContextSpec(String provider, String endpoint, String apiVersion, String identity, String credential,
Class<S> sync, Class<A> async) {
this(provider, endpoint, apiVersion, identity, credential, sync, async, PropertiesBuilder.class,
(Class) RestContextBuilder.class, EMPTY_LIST);
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((apiVersion == null) ? 0 : apiVersion.hashCode());
result = prime * result + ((async == null) ? 0 : async.hashCode());
result = prime * result + ((contextBuilderClass == null) ? 0 : contextBuilderClass.hashCode());
result = prime * result + ((credential == null) ? 0 : credential.hashCode());
result = prime * result + ((endpoint == null) ? 0 : endpoint.hashCode());
result = prime * result + ((identity == null) ? 0 : identity.hashCode());
result = prime * result + ((propertiesBuilderClass == null) ? 0 : propertiesBuilderClass.hashCode());
result = prime * result + ((provider == null) ? 0 : provider.hashCode());
result = prime * result + ((sync == null) ? 0 : sync.hashCode());
return result;
}
@Override
public String toString() {
return "[provider=" + provider + ", endpoint=" + endpoint + ", apiVersion=" + apiVersion + ", identity="
+ identity + "]";
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ContextSpec<?, ?> other = (ContextSpec<?, ?>) obj;
if (apiVersion == null) {
if (other.apiVersion != null)
return false;
} else if (!apiVersion.equals(other.apiVersion))
return false;
if (async == null) {
if (other.async != null)
return false;
} else if (!async.equals(other.async))
return false;
if (contextBuilderClass == null) {
if (other.contextBuilderClass != null)
return false;
} else if (!contextBuilderClass.equals(other.contextBuilderClass))
return false;
if (credential == null) {
if (other.credential != null)
return false;
} else if (!credential.equals(other.credential))
return false;
if (endpoint == null) {
if (other.endpoint != null)
return false;
} else if (!endpoint.equals(other.endpoint))
return false;
if (identity == null) {
if (other.identity != null)
return false;
} else if (!identity.equals(other.identity))
return false;
if (propertiesBuilderClass == null) {
if (other.propertiesBuilderClass != null)
return false;
} else if (!propertiesBuilderClass.equals(other.propertiesBuilderClass))
return false;
if (provider == null) {
if (other.provider != null)
return false;
} else if (!provider.equals(other.provider))
return false;
if (sync == null) {
if (other.sync != null)
return false;
} else if (!sync.equals(other.sync))
return false;
return true;
}
}
private final static Properties NO_PROPERTIES = new Properties(); private final static Properties NO_PROPERTIES = new Properties();
private final Properties properties; private final Properties properties;
@ -300,9 +180,9 @@ public class RestContextFactory {
/** /**
* *
* Identity will be found by searching {@code jclouds.identity} failing that {@code * Identity will be found by searching {@code jclouds.identity} failing that
* provider.identity} where provider corresponds to the parameter. Same pattern is used for * {@code provider.identity} where provider corresponds to the parameter. Same pattern is used
* credential ({@code jclouds.credential} failing that {@code provider.credential}). * for credential ({@code jclouds.credential} failing that {@code provider.credential}).
* *
* @param <S> * @param <S>
* Type of the provider specific client * Type of the provider specific client
@ -351,11 +231,11 @@ public class RestContextFactory {
public <S, A> RestContextBuilder<S, A> createContextBuilder(String providerName, @Nullable String identity, public <S, A> RestContextBuilder<S, A> createContextBuilder(String providerName, @Nullable String identity,
@Nullable String credential, Iterable<? extends Module> wiring, Properties _overrides) { @Nullable String credential, Iterable<? extends Module> wiring, Properties _overrides) {
checkNotNull(wiring, "wiring"); checkNotNull(wiring, "wiring");
ContextSpec<S, A> contextSpec = createContextSpec(providerName, identity, credential, wiring, _overrides); RestContextSpec<S, A> contextSpec = createContextSpec(providerName, identity, credential, wiring, _overrides);
return createContextBuilder(contextSpec, _overrides); return createContextBuilder(contextSpec, _overrides);
} }
public static Properties toProperties(ContextSpec<?, ?> contextSpec) { public static Properties toProperties(RestContextSpec<?, ?> contextSpec) {
checkNotNull(contextSpec, "contextSpec"); checkNotNull(contextSpec, "contextSpec");
Properties props = new Properties(); Properties props = new Properties();
@ -370,15 +250,15 @@ public class RestContextFactory {
props.setProperty(contextSpec.provider + ".async", checkNotNull(contextSpec.async, "contextSpec.async") props.setProperty(contextSpec.provider + ".async", checkNotNull(contextSpec.async, "contextSpec.async")
.getName()); .getName());
} else { } else {
props.setProperty(contextSpec.provider + ".contextbuilder", checkNotNull(contextSpec.contextBuilderClass, props.setProperty(contextSpec.provider + ".contextbuilder",
"contextSpec.contextBuilderClass").getName()); checkNotNull(contextSpec.contextBuilderClass, "contextSpec.contextBuilderClass").getName());
props.setProperty(contextSpec.provider + ".propertiesbuilder", checkNotNull( props.setProperty(contextSpec.provider + ".propertiesbuilder",
contextSpec.propertiesBuilderClass, "contextSpec.propertiesBuilderClass").getName()); checkNotNull(contextSpec.propertiesBuilderClass, "contextSpec.propertiesBuilderClass").getName());
} }
if (size(contextSpec.modules) > 0) { if (size(contextSpec.modules) > 0) {
props.setProperty(contextSpec.provider + ".modules", Joiner.on(',').join( props.setProperty(contextSpec.provider + ".modules",
transform(contextSpec.modules, new Function<Module, String>() { Joiner.on(',').join(transform(contextSpec.modules, new Function<Module, String>() {
@Override @Override
public String apply(Module from) { public String apply(Module from) {
@ -391,13 +271,13 @@ public class RestContextFactory {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <S, A> ContextSpec<S, A> createContextSpec(String providerName, String identity, String credential, public <S, A> RestContextSpec<S, A> createContextSpec(String providerName, String identity, String credential,
Properties _overrides) { Properties _overrides) {
return createContextSpec(providerName, identity, credential, EMPTY_LIST, _overrides); return createContextSpec(providerName, identity, credential, EMPTY_LIST, _overrides);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <S, A> ContextSpec<S, A> createContextSpec(String providerName, String identity, String credential, public <S, A> RestContextSpec<S, A> createContextSpec(String providerName, String identity, String credential,
Iterable<? extends Module> wiring, Properties _overrides) { Iterable<? extends Module> wiring, Properties _overrides) {
checkNotNull(providerName, "providerName"); checkNotNull(providerName, "providerName");
checkNotNull(_overrides, "overrides"); checkNotNull(_overrides, "overrides");
@ -409,8 +289,8 @@ public class RestContextFactory {
String endpoint = props.getProperty(providerName + ".endpoint", null); String endpoint = props.getProperty(providerName + ".endpoint", null);
String apiVersion = props.getProperty(providerName + ".apiversion", null); String apiVersion = props.getProperty(providerName + ".apiversion", null);
identity = props.getProperty(providerName + ".identity", props.getProperty("jclouds.identity", identity)); identity = props.getProperty(providerName + ".identity", props.getProperty("jclouds.identity", identity));
credential = loadCredentialOrDefault(props, providerName + ".credential", loadCredentialOrDefault(props, credential = loadCredentialOrDefault(props, providerName + ".credential",
"jclouds.credential", credential)); loadCredentialOrDefault(props, "jclouds.credential", credential));
String syncClassName = props.getProperty(providerName + ".sync", null); String syncClassName = props.getProperty(providerName + ".sync", null);
String asyncClassName = props.getProperty(providerName + ".async", null); String asyncClassName = props.getProperty(providerName + ".async", null);
Iterable<Module> modules = concat(modulesForProviderInProperties(providerName, props), wiring); Iterable<Module> modules = concat(modulesForProviderInProperties(providerName, props), wiring);
@ -429,8 +309,8 @@ public class RestContextFactory {
assert false : "exception should have propogated " + e; assert false : "exception should have propogated " + e;
return null; return null;
} }
ContextSpec<S, A> contextSpec = new ContextSpec<S, A>(providerName, endpoint, apiVersion, identity, credential, RestContextSpec<S, A> contextSpec = new RestContextSpec<S, A>(providerName, endpoint, apiVersion, identity,
sync, async, propertiesBuilderClass, contextBuilderClass, modules); credential, sync, async, propertiesBuilderClass, contextBuilderClass, modules);
return contextSpec; return contextSpec;
} }
@ -454,22 +334,22 @@ public class RestContextFactory {
return credential; return credential;
} }
public static <S, A> RestContextBuilder<S, A> createContextBuilder(ContextSpec<S, A> contextSpec) { public static <S, A> RestContextBuilder<S, A> createContextBuilder(RestContextSpec<S, A> contextSpec) {
return createContextBuilder(contextSpec, NO_PROPERTIES); return createContextBuilder(contextSpec, NO_PROPERTIES);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static <S, A> RestContextBuilder<S, A> createContextBuilder(ContextSpec<S, A> contextSpec, public static <S, A> RestContextBuilder<S, A> createContextBuilder(RestContextSpec<S, A> contextSpec,
Properties overrides) { Properties overrides) {
return createContextBuilder(contextSpec, EMPTY_LIST, overrides); return createContextBuilder(contextSpec, EMPTY_LIST, overrides);
} }
public static <S, A> RestContextBuilder<S, A> createContextBuilder(ContextSpec<S, A> contextSpec, public static <S, A> RestContextBuilder<S, A> createContextBuilder(RestContextSpec<S, A> contextSpec,
Iterable<Module> modules) { Iterable<Module> modules) {
return createContextBuilder(contextSpec, modules, NO_PROPERTIES); return createContextBuilder(contextSpec, modules, NO_PROPERTIES);
} }
public static <S, A> RestContextBuilder<S, A> createContextBuilder(ContextSpec<S, A> contextSpec, public static <S, A> RestContextBuilder<S, A> createContextBuilder(RestContextSpec<S, A> contextSpec,
Iterable<Module> modules, Properties overrides) { Iterable<Module> modules, Properties overrides) {
try { try {
PropertiesBuilder builder = contextSpec.propertiesBuilderClass.getConstructor(Properties.class).newInstance( PropertiesBuilder builder = contextSpec.propertiesBuilderClass.getConstructor(Properties.class).newInstance(
@ -555,33 +435,33 @@ public class RestContextFactory {
} }
/** /**
* @see RestContextFactory#createContextBuilder(ContextSpec) * @see RestContextFactory#createContextBuilder(RestContextSpec)
*/ */
public static <S, A> RestContext<S, A> createContext(ContextSpec<S, A> contextSpec) { public static <S, A> RestContext<S, A> createContext(RestContextSpec<S, A> contextSpec) {
RestContextBuilder<S, A> builder = createContextBuilder(contextSpec); RestContextBuilder<S, A> builder = createContextBuilder(contextSpec);
return buildContextUnwrappingExceptions(builder); return buildContextUnwrappingExceptions(builder);
} }
/** /**
* @see RestContextFactory#createContextBuilder(ContextSpec, Properties) * @see RestContextFactory#createContextBuilder(RestContextSpec, Properties)
*/ */
public static <S, A> RestContext<S, A> createContext(ContextSpec<S, A> contextSpec, Properties overrides) { public static <S, A> RestContext<S, A> createContext(RestContextSpec<S, A> contextSpec, Properties overrides) {
RestContextBuilder<S, A> builder = createContextBuilder(contextSpec, overrides); RestContextBuilder<S, A> builder = createContextBuilder(contextSpec, overrides);
return buildContextUnwrappingExceptions(builder); return buildContextUnwrappingExceptions(builder);
} }
/** /**
* @see RestContextFactory#createContextBuilder(ContextSpec, Iterable) * @see RestContextFactory#createContextBuilder(RestContextSpec, Iterable)
*/ */
public static <S, A> RestContext<S, A> createContext(ContextSpec<S, A> contextSpec, Iterable<Module> modules) { public static <S, A> RestContext<S, A> createContext(RestContextSpec<S, A> contextSpec, Iterable<Module> modules) {
RestContextBuilder<S, A> builder = createContextBuilder(contextSpec, modules); RestContextBuilder<S, A> builder = createContextBuilder(contextSpec, modules);
return buildContextUnwrappingExceptions(builder); return buildContextUnwrappingExceptions(builder);
} }
/** /**
* @see RestContextFactory#createContextBuilder(ContextSpec, Iterable, Properties) * @see RestContextFactory#createContextBuilder(RestContextSpec, Iterable, Properties)
*/ */
public static <S, A> RestContext<S, A> createContext(ContextSpec<S, A> contextSpec, Iterable<Module> modules, public static <S, A> RestContext<S, A> createContext(RestContextSpec<S, A> contextSpec, Iterable<Module> modules,
Properties overrides) { Properties overrides) {
RestContextBuilder<S, A> builder = createContextBuilder(contextSpec, modules, overrides); RestContextBuilder<S, A> builder = createContextBuilder(contextSpec, modules, overrides);
return buildContextUnwrappingExceptions(builder); return buildContextUnwrappingExceptions(builder);

View File

@ -0,0 +1,106 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*/
package org.jclouds.rest;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Collections.EMPTY_LIST;
import org.jclouds.PropertiesBuilder;
import com.google.common.base.Objects;
import com.google.common.collect.ImmutableList;
import com.google.inject.Module;
/**
* @author Adrian Cole
*/
public class RestContextSpec<S, A> {
protected final String provider;
protected final String endpoint;
protected final String apiVersion;
protected final String identity;
protected final String credential;
protected final Class<S> sync;
protected final Class<A> async;
protected final Class<PropertiesBuilder> propertiesBuilderClass;
protected final Class<RestContextBuilder<S, A>> contextBuilderClass;
protected final Iterable<Module> modules;
public RestContextSpec(String provider, String endpoint, String apiVersion, String identity, String credential,
Class<S> sync, Class<A> async, Class<PropertiesBuilder> propertiesBuilderClass,
Class<RestContextBuilder<S, A>> contextBuilderClass, Iterable<Module> modules) {
this.provider = checkNotNull(provider, "provider");
this.endpoint = endpoint;
this.apiVersion = apiVersion;
this.identity = identity;
this.credential = credential;
this.sync = sync;
this.async = async;
checkArgument(RestContextBuilder.class.isAssignableFrom(contextBuilderClass), contextBuilderClass.getName()
+ " is not a subclass of " + RestContextBuilder.class.getName());
checkArgument(PropertiesBuilder.class.isAssignableFrom(propertiesBuilderClass), propertiesBuilderClass.getName()
+ " is not a subclass of " + PropertiesBuilder.class.getName());
this.propertiesBuilderClass = propertiesBuilderClass;
this.contextBuilderClass = contextBuilderClass;
this.modules = ImmutableList.copyOf(modules);
}
@SuppressWarnings("unchecked")
public RestContextSpec(String provider, String endpoint, String apiVersion, String identity, String credential,
Class<S> sync, Class<A> async) {
this(provider, endpoint, apiVersion, identity, credential, sync, async, PropertiesBuilder.class,
(Class) RestContextBuilder.class, EMPTY_LIST);
}
/**
* this uses the inefficient {@link Objects} implementation as the object count will be
* relatively small and therefore efficiency is not a concern.
*/
@Override
public int hashCode() {
return Objects.hashCode(provider, endpoint, apiVersion, identity, credential, sync, async,
propertiesBuilderClass, contextBuilderClass, modules);
}
/**
* this uses the inefficient {@link Objects} implementation as the object count will be
* relatively small and therefore efficiency is not a concern.
*/
@Override
public boolean equals(Object that) {
if (that == null)
return false;
return Objects.equal(this.toString(), that.toString());
}
/**
* this uses the inefficient {@link Objects} implementation as the object count will be
* relatively small and therefore efficiency is not a concern.
*/
@Override
public String toString() {
return Objects.toStringHelper(this).add("provider", provider).add("endpoint", endpoint)
.add("apiVersion", apiVersion).add("identity", identity).add("sync", sync).add("async", async)
.add("propertiesBuilderClass", propertiesBuilderClass).add("contextBuilderClass", contextBuilderClass)
.add("modules", modules).toString();
}
}

View File

@ -51,7 +51,7 @@ import org.jclouds.crypto.CryptoStreams;
import org.jclouds.io.InputSuppliers; import org.jclouds.io.InputSuppliers;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.rest.RestContextBuilder; import org.jclouds.rest.RestContextBuilder;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.mortbay.jetty.Connector; import org.mortbay.jetty.Connector;
import org.mortbay.jetty.Handler; import org.mortbay.jetty.Handler;
import org.mortbay.jetty.Request; import org.mortbay.jetty.Request;
@ -264,7 +264,7 @@ public abstract class BaseJettyTest {
Properties properties, Module... connectionModules) { Properties properties, Module... connectionModules) {
properties.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); properties.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
properties.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); properties.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
ContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> contextSpec = contextSpec("test", RestContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> contextSpec = contextSpec("test",
"http://localhost:" + testPort, "1", "identity", null, IntegrationTestClient.class, "http://localhost:" + testPort, "1", "identity", null, IntegrationTestClient.class,
IntegrationTestAsyncClient.class, ImmutableSet.<Module> copyOf(connectionModules)); IntegrationTestAsyncClient.class, ImmutableSet.<Module> copyOf(connectionModules));
return createContextBuilder(contextSpec, properties); return createContextBuilder(contextSpec, properties);

View File

@ -33,7 +33,6 @@ import org.jclouds.concurrent.Timeout;
import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestAsyncClient;
import org.jclouds.http.IntegrationTestClient; import org.jclouds.http.IntegrationTestClient;
import org.jclouds.predicates.validators.AllLowerCaseValidator; import org.jclouds.predicates.validators.AllLowerCaseValidator;
import org.jclouds.rest.RestContextFactory.ContextSpec;
import org.jclouds.rest.annotations.ParamValidators; import org.jclouds.rest.annotations.ParamValidators;
import org.jclouds.rest.annotations.SkipEncoding; import org.jclouds.rest.annotations.SkipEncoding;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
@ -145,7 +144,7 @@ public class InputParamValidatorTest {
@BeforeClass @BeforeClass
void setupFactory() { void setupFactory() {
ContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> contextSpec = contextSpec("test", RestContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> contextSpec = contextSpec("test",
"http://localhost:9999", "1", "userFoo", null, IntegrationTestClient.class, "http://localhost:9999", "1", "userFoo", null, IntegrationTestClient.class,
IntegrationTestAsyncClient.class); IntegrationTestAsyncClient.class);

View File

@ -27,7 +27,6 @@ import java.util.Properties;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.logging.config.NullLoggingModule; import org.jclouds.logging.config.NullLoggingModule;
import org.jclouds.rest.RestContextFactory.ContextSpec;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
@ -45,7 +44,7 @@ public abstract class RestClientTest<T> extends BaseRestClientTest {
protected abstract void checkFilters(HttpRequest request); protected abstract void checkFilters(HttpRequest request);
abstract public ContextSpec<?, ?> createContextSpec(); abstract public RestContextSpec<?, ?> createContextSpec();
protected Module createModule() { protected Module createModule() {
return new Module() { return new Module() {
@ -60,7 +59,7 @@ public abstract class RestClientTest<T> extends BaseRestClientTest {
@BeforeClass @BeforeClass
protected void setupFactory() throws IOException { protected void setupFactory() throws IOException {
ContextSpec<?, ?> contextSpec = createContextSpec(); RestContextSpec<?, ?> contextSpec = createContextSpec();
injector = createContextBuilder(contextSpec, injector = createContextBuilder(contextSpec,
ImmutableSet.of(new MockModule(), new NullLoggingModule(), createModule()), ImmutableSet.of(new MockModule(), new NullLoggingModule(), createModule()),
getProperties()).buildInjector(); getProperties()).buildInjector();

View File

@ -34,7 +34,6 @@ import org.jclouds.PropertiesBuilder;
import org.jclouds.http.IntegrationTestAsyncClient; import org.jclouds.http.IntegrationTestAsyncClient;
import org.jclouds.http.IntegrationTestClient; import org.jclouds.http.IntegrationTestClient;
import org.jclouds.http.RequiresHttp; import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.RestContextFactory.ContextSpec;
import org.jclouds.rest.config.RestClientModule; import org.jclouds.rest.config.RestClientModule;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -54,14 +53,14 @@ public class RestContextFactoryTest {
private static final String provider = "test"; private static final String provider = "test";
public void testBuilder() { public void testBuilder() {
ContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> contextSpec = contextSpec(provider, RestContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> contextSpec = contextSpec(provider,
"http://localhost", "1", "dummy", null, IntegrationTestClient.class, IntegrationTestAsyncClient.class); "http://localhost", "1", "dummy", null, IntegrationTestClient.class, IntegrationTestAsyncClient.class);
createContextBuilder(contextSpec); createContextBuilder(contextSpec);
} }
public void testBuilderProperties() { public void testBuilderProperties() {
ContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> contextSpec = contextSpec(provider, RestContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> contextSpec = contextSpec(provider,
"http://localhost", "1", "dummy", null, IntegrationTestClient.class, IntegrationTestAsyncClient.class); "http://localhost", "1", "dummy", null, IntegrationTestClient.class, IntegrationTestAsyncClient.class);
Properties props = RestContextFactory.toProperties(contextSpec); Properties props = RestContextFactory.toProperties(contextSpec);
@ -79,7 +78,7 @@ public class RestContextFactoryTest {
} }
public void testBuilderPropertiesWithCredential() { public void testBuilderPropertiesWithCredential() {
ContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> contextSpec = contextSpec(provider, RestContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> contextSpec = contextSpec(provider,
"http://localhost", "1", "dummy", "credential", IntegrationTestClient.class, "http://localhost", "1", "dummy", "credential", IntegrationTestClient.class,
IntegrationTestAsyncClient.class); IntegrationTestAsyncClient.class);
@ -99,7 +98,7 @@ public class RestContextFactoryTest {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testBuilderPropertiesWithContextBuilder() { public void testBuilderPropertiesWithContextBuilder() {
ContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> contextSpec = contextSpec(provider, RestContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> contextSpec = contextSpec(provider,
"http://localhost", "1", "dummy", null, (Class) null, (Class) null, PropertiesBuilder.class, "http://localhost", "1", "dummy", null, (Class) null, (Class) null, PropertiesBuilder.class,
(Class) IntegrationTestContextBuilder.class, Collections.EMPTY_LIST); (Class) IntegrationTestContextBuilder.class, Collections.EMPTY_LIST);
@ -119,7 +118,7 @@ public class RestContextFactoryTest {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testBuilderPropertiesWithModule() { public void testBuilderPropertiesWithModule() {
ContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> contextSpec = contextSpec(provider, RestContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> contextSpec = contextSpec(provider,
"http://localhost", "1", "dummy", null, (Class) null, (Class) null, PropertiesBuilder.class, "http://localhost", "1", "dummy", null, (Class) null, (Class) null, PropertiesBuilder.class,
(Class) IntegrationTestContextBuilder.class, Collections.<Module> singleton(new A())); (Class) IntegrationTestContextBuilder.class, Collections.<Module> singleton(new A()));
@ -139,7 +138,7 @@ public class RestContextFactoryTest {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void testBuilderPropertiesWithModules() { public void testBuilderPropertiesWithModules() {
ContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> contextSpec = contextSpec(provider, RestContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> contextSpec = contextSpec(provider,
"http://localhost", "1", "dummy", null, (Class) null, (Class) null, PropertiesBuilder.class, "http://localhost", "1", "dummy", null, (Class) null, (Class) null, PropertiesBuilder.class,
(Class) IntegrationTestContextBuilder.class, Arrays.<Module> asList(new A(), new B())); (Class) IntegrationTestContextBuilder.class, Arrays.<Module> asList(new A(), new B()));
@ -174,9 +173,9 @@ public class RestContextFactoryTest {
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
@Override @Override
public <S, A> ContextSpec<S, A> createContextSpec(String providerName, String identity, String credential, public <S, A> RestContextSpec<S, A> createContextSpec(String providerName, String identity, String credential,
Iterable<? extends Module> wiring, Properties _overrides) { Iterable<? extends Module> wiring, Properties _overrides) {
ContextSpec<S, A> spec = super.createContextSpec(providerName, identity, credential, wiring, _overrides); RestContextSpec<S, A> spec = super.createContextSpec(providerName, identity, credential, wiring, _overrides);
assertEquals(spec.identity, "foo"); assertEquals(spec.identity, "foo");
assertEquals(spec.credential, "bar"); assertEquals(spec.credential, "bar");
assertEquals(Iterables.size(spec.modules), 2); assertEquals(Iterables.size(spec.modules), 2);
@ -206,9 +205,9 @@ public class RestContextFactoryTest {
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
@Override @Override
public <S, A> ContextSpec<S, A> createContextSpec(String providerName, String identity, String credential, public <S, A> RestContextSpec<S, A> createContextSpec(String providerName, String identity, String credential,
Iterable<? extends Module> wiring, Properties _overrides) { Iterable<? extends Module> wiring, Properties _overrides) {
ContextSpec<S, A> spec = super.createContextSpec(providerName, identity, credential, wiring, _overrides); RestContextSpec<S, A> spec = super.createContextSpec(providerName, identity, credential, wiring, _overrides);
assertEquals(spec.identity, "foo"); assertEquals(spec.identity, "foo");
assertEquals(spec.credential, "bar"); assertEquals(spec.credential, "bar");
assertEquals(Iterables.size(spec.modules), 2); assertEquals(Iterables.size(spec.modules), 2);
@ -240,7 +239,7 @@ public class RestContextFactoryTest {
@Test(expectedExceptions = IllegalArgumentException.class) @Test(expectedExceptions = IllegalArgumentException.class)
public void testBuilderPropertiesWithWrongConfig() { public void testBuilderPropertiesWithWrongConfig() {
@SuppressWarnings("unused") @SuppressWarnings("unused")
ContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> contextSpec = contextSpec(provider, RestContextSpec<IntegrationTestClient, IntegrationTestAsyncClient> contextSpec = contextSpec(provider,
"http://localhost", "1", "dummy", null, (Class) null, (Class) null, "http://localhost", "1", "dummy", null, (Class) null, (Class) null,
(Class) IntegrationTestContextBuilder.class, (Class) PropertiesBuilder.class, Collections.EMPTY_LIST); (Class) IntegrationTestContextBuilder.class, (Class) PropertiesBuilder.class, Collections.EMPTY_LIST);
} }

View File

@ -108,7 +108,7 @@ import org.jclouds.logging.config.NullLoggingModule;
import org.jclouds.rest.BaseRestClientTest; import org.jclouds.rest.BaseRestClientTest;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.InvocationContext; import org.jclouds.rest.InvocationContext;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.annotations.BinderParam; import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.Delegate; import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.Endpoint; import org.jclouds.rest.annotations.Endpoint;
@ -278,7 +278,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
private Injector injectorForClient() { private Injector injectorForClient() {
ContextSpec<Caller, AsyncCaller> contextSpec = contextSpec("test", "http://localhost:9999", "1", "userfoo", null, RestContextSpec<Caller, AsyncCaller> contextSpec = contextSpec("test", "http://localhost:9999", "1", "userfoo", null,
Caller.class, AsyncCaller.class, ImmutableSet.<Module> of(new MockModule(), new NullLoggingModule(), Caller.class, AsyncCaller.class, ImmutableSet.<Module> of(new MockModule(), new NullLoggingModule(),
new CallerCalleeModule())); new CallerCalleeModule()));
@ -2081,7 +2081,7 @@ public class RestAnnotationProcessorTest extends BaseRestClientTest {
@BeforeClass @BeforeClass
void setupFactory() { void setupFactory() {
ContextSpec<String, Integer> contextSpec = contextSpec("test", "http://localhost:9999", "1", "userfoo", null, RestContextSpec<String, Integer> contextSpec = contextSpec("test", "http://localhost:9999", "1", "userfoo", null,
String.class, Integer.class, ImmutableSet.<Module> of(new MockModule(), new NullLoggingModule(), String.class, Integer.class, ImmutableSet.<Module> of(new MockModule(), new NullLoggingModule(),
new AbstractModule() { new AbstractModule() {

View File

@ -31,7 +31,7 @@ import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.inject.Module; import com.google.inject.Module;
@ -67,7 +67,7 @@ public abstract class BaseGoGridAsyncClientTest<T> extends RestClientTest<T> {
} }
@Override @Override
public ContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec("gogrid", "foo", "bar", new Properties()); return new RestContextFactory().createContextSpec("gogrid", "foo", "bar", new Properties());
} }

View File

@ -30,7 +30,7 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.rackspace.RackspaceAuthAsyncClient.AuthenticationResponse; import org.jclouds.rackspace.RackspaceAuthAsyncClient.AuthenticationResponse;
import org.jclouds.rackspace.functions.ParseAuthenticationResponseFromHeaders; import org.jclouds.rackspace.functions.ParseAuthenticationResponseFromHeaders;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -60,7 +60,7 @@ public class RackspaceAuthAsyncClientTest extends RestClientTest<RackspaceAuthAs
} }
@Override @Override
public ContextSpec<RackspaceAuthClient, RackspaceAuthAsyncClient> createContextSpec() { public RestContextSpec<RackspaceAuthClient, RackspaceAuthAsyncClient> createContextSpec() {
return contextSpec("test", "http://localhost:8080", "1", "identity", "credential", RackspaceAuthClient.class, return contextSpec("test", "http://localhost:8080", "1", "identity", "credential", RackspaceAuthClient.class,
RackspaceAuthAsyncClient.class); RackspaceAuthAsyncClient.class);
} }

View File

@ -33,7 +33,7 @@ import org.jclouds.rackspace.cloudfiles.config.CloudFilesRestClientModule;
import org.jclouds.rackspace.cloudservers.TestRackspaceAuthenticationRestClientModule; import org.jclouds.rackspace.cloudservers.TestRackspaceAuthenticationRestClientModule;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -110,7 +110,7 @@ public class CloudFilesBlobRequestSignerTest extends RestClientTest<CloudFilesAs
} }
@Override @Override
public ContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec("cloudfiles", "identity", "credential", new Properties()); return new RestContextFactory().createContextSpec("cloudfiles", "identity", "credential", new Properties());
} }

View File

@ -54,7 +54,7 @@ import org.jclouds.rackspace.filters.AddTimestampQuery;
import org.jclouds.rackspace.filters.AuthenticateRequest; import org.jclouds.rackspace.filters.AuthenticateRequest;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404; import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
@ -863,7 +863,7 @@ public class CloudServersAsyncClientTest extends RestClientTest<CloudServersAsyn
} }
@Override @Override
public ContextSpec<CloudServersClient, CloudServersAsyncClient> createContextSpec() { public RestContextSpec<CloudServersClient, CloudServersAsyncClient> createContextSpec() {
return new RestContextFactory().createContextSpec("cloudservers", "user", "password", new Properties()); return new RestContextFactory().createContextSpec("cloudservers", "user", "password", new Properties());
} }

View File

@ -29,7 +29,7 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.UnwrapOnlyJsonValue; import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.GeneratedHttpRequest; import org.jclouds.rest.internal.GeneratedHttpRequest;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.rimuhosting.miro.binder.CreateServerOptions; import org.jclouds.rimuhosting.miro.binder.CreateServerOptions;
@ -80,7 +80,7 @@ public class RimuHostingAsyncClientTest extends RestClientTest<RimuHostingAsyncC
} }
@Override @Override
public ContextSpec<RimuHostingClient, RimuHostingAsyncClient> createContextSpec() { public RestContextSpec<RimuHostingClient, RimuHostingAsyncClient> createContextSpec() {
return new RestContextFactory().createContextSpec("rimuhosting", "apikey", "null", new Properties()); return new RestContextFactory().createContextSpec("rimuhosting", "apikey", "null", new Properties());
} }
} }

View File

@ -0,0 +1,2 @@
install libvirt on your os
* if os/x, see http://github.com/justinclift/libvirt

View File

@ -1,5 +1,6 @@
package org.jclouds.libvirt.compute; package org.jclouds.libvirt.compute;
import static org.easymock.classextension.EasyMock.createMock;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import java.net.URI; import java.net.URI;
@ -7,7 +8,7 @@ import java.util.Properties;
import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.config.StandaloneComputeServiceContextModule; import org.jclouds.compute.StandaloneComputeServiceContextSpec;
import org.jclouds.libvirt.Datacenter; import org.jclouds.libvirt.Datacenter;
import org.jclouds.libvirt.Hardware; import org.jclouds.libvirt.Hardware;
import org.jclouds.libvirt.Image; import org.jclouds.libvirt.Image;
@ -17,6 +18,9 @@ import org.libvirt.Domain;
import org.libvirt.LibvirtException; import org.libvirt.LibvirtException;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
/** /**
* *
* @author Adrian Cole * @author Adrian Cole
@ -24,39 +28,26 @@ import org.testng.annotations.Test;
*/ */
@Test(groups = "unit") @Test(groups = "unit")
public class LibvirtComputeServiceContextBuilderTest { public class LibvirtComputeServiceContextBuilderTest {
//
// @Test @Test
// public void testCreateContextModule() { public void testCreateContextModule() {
// assertNotNull(new LibvirtComputeServiceContextBuilder(new Properties()).createContextModule()); assertNotNull(new LibvirtComputeServiceContextBuilder(new Properties()).createContextModule());
// } }
//
// @Test @Test
// public void testCanBuildDirectly() { public void testCanBuildWithComputeService() {
// ComputeServiceContext context = new LibvirtComputeServiceContextBuilder(new Properties()) { ComputeServiceContext context = new ComputeServiceContextFactory()
// .createContext(new StandaloneComputeServiceContextSpec<Domain, Hardware, Image, Datacenter>("libvirt",
// @Override "stub", "1", "identity", "credential", new StubLibvirtComputeServiceContextModule(), ImmutableSet
// public StandaloneComputeServiceContextModule<Domain, Hardware, Image, Datacenter> createContextModule() { .<Module> of()));
// return new StubLibvirtComputeServiceContextModule(); context.close();
// } }
//
// }.buildComputeServiceContext();
// context.close();
// }
//
// @Test
// public void testCanBuildWithComputeService() {
// ComputeServiceContext context = ComputeServiceContextFactory
// .createStandaloneContext(new StubLibvirtComputeServiceContextModule());
// context.close();
//
// }
private static class StubLibvirtComputeServiceContextModule extends LibvirtComputeServiceContextModule { private static class StubLibvirtComputeServiceContextModule extends LibvirtComputeServiceContextModule {
@Override @Override
protected Connect createConnection(URI endpoint, String identity, String credential) throws LibvirtException { protected Connect createConnection(URI endpoint, String identity, String credential) throws LibvirtException {
// TODO replace with mock return createMock(Connect.class);
return null;
} }
} }

View File

@ -6,8 +6,16 @@ import java.util.Properties;
import org.jclouds.compute.ComputeServiceContext; import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.StandaloneComputeServiceContextSpec;
import org.jclouds.servermanager.Datacenter;
import org.jclouds.servermanager.Hardware;
import org.jclouds.servermanager.Image;
import org.jclouds.servermanager.Server;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
/** /**
* *
* @author Adrian Cole * @author Adrian Cole
@ -30,8 +38,11 @@ public class ServerManagerComputeServiceContextBuilderTest {
@Test @Test
public void testCanBuildWithComputeService() { public void testCanBuildWithComputeService() {
ComputeServiceContext context = ComputeServiceContextFactory ComputeServiceContext context = new ComputeServiceContextFactory()
.createStandaloneContext(ServerManagerComputeServiceContextBuilder.createContextModule()); .createContext(new StandaloneComputeServiceContextSpec<Server, Hardware, Image, Datacenter>(
"servermanager", "http://host", "1", "identity", "credential",
ServerManagerComputeServiceContextBuilder.createContextModule(), ImmutableSet.<Module> of()));
context.close(); context.close();
} }

View File

@ -30,7 +30,7 @@ import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ReleasePayloadAndReturn; import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
@ -252,7 +252,7 @@ public class SlicehostAsyncClientTest extends RestClientTest<SlicehostAsyncClien
} }
@Override @Override
public ContextSpec<SlicehostClient, SlicehostAsyncClient> createContextSpec() { public RestContextSpec<SlicehostClient, SlicehostAsyncClient> createContextSpec() {
return new RestContextFactory().createContextSpec("slicehost", "apikey", null, new Properties()); return new RestContextFactory().createContextSpec("slicehost", "apikey", null, new Properties());
} }

View File

@ -45,7 +45,7 @@ import org.jclouds.http.functions.ReturnInputStream;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions; import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
@ -809,7 +809,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
} }
@Override @Override
public ContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
Properties overrides = new Properties(); Properties overrides = new Properties();
overrides.setProperty("vcloud.endpoint", "https://vcenterprise.bluelock.com/api/v1.0"); overrides.setProperty("vcloud.endpoint", "https://vcenterprise.bluelock.com/api/v1.0");
return new RestContextFactory().createContextSpec("vcloud", "identity", "credential", overrides); return new RestContextFactory().createContextSpec("vcloud", "identity", "credential", overrides);

View File

@ -43,7 +43,7 @@ import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
@ -637,7 +637,7 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
} }
@Override @Override
public ContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
Properties overrides = new Properties(); Properties overrides = new Properties();
overrides.setProperty("vcloudexpress.endpoint", "https://vcloud.safesecureweb.com/api/v0.8"); overrides.setProperty("vcloudexpress.endpoint", "https://vcloud.safesecureweb.com/api/v0.8");
return new RestContextFactory().createContextSpec("vcloudexpress", "identity", "credential", overrides); return new RestContextFactory().createContextSpec("vcloudexpress", "identity", "credential", overrides);

View File

@ -33,7 +33,7 @@ import org.jclouds.concurrent.Timeout;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.filters.BasicAuthentication; import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.annotations.Provider; import org.jclouds.rest.annotations.Provider;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.vcloud.domain.VCloudSession; import org.jclouds.vcloud.domain.VCloudSession;
@ -109,7 +109,7 @@ public class VCloudLoginAsyncClientTest extends RestClientTest<VCloudExpressLogi
@Override @Override
public ContextSpec<VCloudLoginClient, VCloudExpressLoginAsyncClient> createContextSpec() { public RestContextSpec<VCloudLoginClient, VCloudExpressLoginAsyncClient> createContextSpec() {
return contextSpec("test", "http://localhost:8080/login", "1", "identity", "credential", VCloudLoginClient.class, return contextSpec("test", "http://localhost:8080/login", "1", "identity", "credential", VCloudLoginClient.class,
VCloudExpressLoginAsyncClient.class); VCloudExpressLoginAsyncClient.class);
} }

View File

@ -32,7 +32,7 @@ import org.jclouds.concurrent.Timeout;
import org.jclouds.http.HttpRequest; import org.jclouds.http.HttpRequest;
import org.jclouds.http.functions.ParseSax; import org.jclouds.http.functions.ParseSax;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.RestAnnotationProcessor; import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.vcloud.xml.SupportedVersionsHandler; import org.jclouds.vcloud.xml.SupportedVersionsHandler;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -82,7 +82,7 @@ public class VCloudVersionsAsyncClientTest extends RestClientTest<VCloudVersions
} }
@Override @Override
public ContextSpec<VCloudVersionsClient, VCloudVersionsAsyncClient> createContextSpec() { public RestContextSpec<VCloudVersionsClient, VCloudVersionsAsyncClient> createContextSpec() {
return contextSpec("test", "http://localhost:8080", "1", "identity", "credential", VCloudVersionsClient.class, return contextSpec("test", "http://localhost:8080", "1", "identity", "credential", VCloudVersionsClient.class,
VCloudVersionsAsyncClient.class); VCloudVersionsAsyncClient.class);
} }

View File

@ -42,7 +42,7 @@ import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.ResourceNotFoundException;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
@ -493,7 +493,7 @@ public class TerremarkECloudAsyncClientTest extends RestClientTest<TerremarkEClo
} }
@Override @Override
public ContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec("trmk-vcloudexpress", "identity", "credential", return new RestContextFactory().createContextSpec("trmk-vcloudexpress", "identity", "credential",
new Properties()); new Properties());
} }

View File

@ -42,7 +42,7 @@ import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.ResourceNotFoundException; import org.jclouds.rest.ResourceNotFoundException;
import org.jclouds.rest.RestClientTest; import org.jclouds.rest.RestClientTest;
import org.jclouds.rest.RestContextFactory; import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextFactory.ContextSpec; import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404; import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404; import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404; import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
@ -595,7 +595,7 @@ public class TerremarkVCloudExpressAsyncClientTest extends RestClientTest<Terrem
} }
@Override @Override
public ContextSpec<?, ?> createContextSpec() { public RestContextSpec<?, ?> createContextSpec() {
return new RestContextFactory().createContextSpec("trmk-vcloudexpress", "identity", "credential", return new RestContextFactory().createContextSpec("trmk-vcloudexpress", "identity", "credential",
new Properties()); new Properties());
} }