diff --git a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java b/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java
index 9e67de8d7f..0c4b3c2a3b 100644
--- a/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java
+++ b/antcontrib/src/main/java/org/jclouds/tools/ant/taskdefs/compute/ComputeTaskUtils.java
@@ -18,8 +18,6 @@
*/
package org.jclouds.tools.ant.taskdefs.compute;
-import static org.jclouds.rest.RestContextFactory.getPropertiesFromResource;
-
import java.io.IOException;
import java.net.URI;
import java.util.NoSuchElementException;
@@ -73,13 +71,13 @@ public class ComputeTaskUtils {
@SuppressWarnings("unchecked")
@Override
public ComputeServiceContext load(URI from) {
- Properties props = getPropertiesFromResource("/rest.properties");
+ Properties props = new Properties();
props.putAll(projectProvider.get().getProperties());
// adding the properties to the factory will allow us to pass
// alternate endpoints
String provider = from.getHost();
Credentials creds = Credentials.parse(from);
- return new ComputeServiceContextFactory(props).createContext(provider, creds.identity, creds.credential,
+ return new ComputeServiceContextFactory().createContext(provider, creds.identity, creds.credential,
ImmutableSet.of((Module) new AntLoggingModule(projectProvider.get(),
ComputeServiceConstants.COMPUTE_LOGGER), new JschSshClientModule()), props);
diff --git a/apis/atmos/pom.xml b/apis/atmos/pom.xml
index 5a794c889f..eac3f8804e 100644
--- a/apis/atmos/pom.xml
+++ b/apis/atmos/pom.xml
@@ -34,8 +34,7 @@
bundle
- org.jclouds.atmos.blobstore.integration.AtmosStorageTestInitializer
- https://accesspoint.atmos.com
+ https://accesspoint.atmosonline.com
1.3.0
FIXME
diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java
index 20fe7cd5e3..1dd282eff9 100644
--- a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java
+++ b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosApiMetadata.java
@@ -18,50 +18,75 @@
*/
package org.jclouds.atmos;
+import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX;
+import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
+
import java.net.URI;
+import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
-import org.jclouds.apis.ApiType;
-import org.jclouds.apis.BaseApiMetadata;
+import org.jclouds.blobstore.BlobStoreContext;
+import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata;
+
+import com.google.common.reflect.TypeToken;
/**
- * Implementation of {@link ApiMetadata} for EMC's Atmos API.
+ * Implementation of {@link ApiMetadata} for Rackspace Cloud Files API
*
* @author Adrian Cole
*/
-public class AtmosApiMetadata extends BaseApiMetadata {
-
- public AtmosApiMetadata() {
- this(builder()
- .id("atmos")
- .type(ApiType.BLOBSTORE)
- .name("EMC's Atmos API")
- .identityName("Subtenant ID (UID)")
- .credentialName("Shared Secret")
- .documentation(URI.create("https://community.emc.com/docs/DOC-10508")));
+public class AtmosApiMetadata
+ extends
+ BaseBlobStoreApiMetadata, AtmosApiMetadata> {
+ private static Builder builder() {
+ return new Builder();
}
- // below are so that we can reuse builders, toString, hashCode, etc.
- // we have to set concrete classes here, as our base class cannot be
- // concrete due to serviceLoader
- protected AtmosApiMetadata(Builder> builder) {
+ @Override
+ public Builder toBuilder() {
+ return builder().fromApiMetadata(this);
+ }
+
+ public AtmosApiMetadata() {
+ this(builder());
+ }
+
+ protected AtmosApiMetadata(Builder builder) {
super(builder);
}
- private static class ConcreteBuilder extends Builder {
+ protected static Properties defaultProperties() {
+ Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties();
+ properties.setProperty(PROPERTY_REGIONS, "DEFAULT");
+ properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-");
+ return properties;
+ }
+
+ public static class Builder
+ extends
+ BaseBlobStoreApiMetadata.Builder, AtmosApiMetadata> {
+ protected Builder() {
+ id("atmos")
+ .name("EMC's Atmos API")
+ .identityName("Subtenant ID (UID)")
+ .credentialName("Shared Secret")
+ .documentation(URI.create("https://community.emc.com/docs/DOC-10508"))
+ .version("1.4.0")
+ .defaultEndpoint("https://accesspoint.atmosonline.com")
+ .contextBuilder(TypeToken.of(AtmosContextBuilder.class))
+ .defaultProperties(AtmosApiMetadata.defaultProperties())
+ .javaApi(AtmosClient.class, AtmosAsyncClient.class);
+ }
@Override
public AtmosApiMetadata build() {
return new AtmosApiMetadata(this);
}
- }
- public static ConcreteBuilder builder() {
- return new ConcreteBuilder();
- }
-
- @Override
- public ConcreteBuilder toBuilder() {
- return builder().fromApiMetadata(this);
+ @Override
+ public Builder fromApiMetadata(AtmosApiMetadata in) {
+ super.fromApiMetadata(in);
+ return this;
+ }
}
}
\ No newline at end of file
diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosContextBuilder.java b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosContextBuilder.java
index 19c7a16d7a..6856023dee 100644
--- a/apis/atmos/src/main/java/org/jclouds/atmos/AtmosContextBuilder.java
+++ b/apis/atmos/src/main/java/org/jclouds/atmos/AtmosContextBuilder.java
@@ -19,35 +19,45 @@
package org.jclouds.atmos;
import java.util.List;
-import java.util.Properties;
import org.jclouds.atmos.blobstore.config.AtmosBlobStoreContextModule;
import org.jclouds.atmos.config.AtmosRestClientModule;
+import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.BlobStoreContextBuilder;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule;
+import org.jclouds.providers.ProviderMetadata;
import com.google.inject.Injector;
import com.google.inject.Module;
/**
- * Creates {@link AtmosBlobStoreContext} or {@link Injector} instances based on the most commonly
- * requested arguments.
+ * Creates {@link AtmosStoreContext} or {@link Injector} instances based on
+ * the most commonly requested arguments.
*
- * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
+ * Note that Threadsafe objects will be bound as singletons to the Injector or
+ * Context provided.
*
*
- * If no Module
s are specified, the default {@link JDKLoggingModule logging} and
- * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
+ * If no Module
s are specified, the default
+ * {@link JDKLoggingModule logging} and
+ * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be
+ * installed.
*
* @author Adrian Cole, Andrew Newdigate
- * @see AtmosBlobStoreContext
+ * @see AtmosStoreContext
*/
-public class AtmosContextBuilder extends
- BlobStoreContextBuilder {
+public class AtmosContextBuilder
+ extends
+ BlobStoreContextBuilder, AtmosApiMetadata> {
- public AtmosContextBuilder(Properties props) {
- super(AtmosClient.class, AtmosAsyncClient.class, props);
+ public AtmosContextBuilder(
+ ProviderMetadata, AtmosApiMetadata> providerMetadata) {
+ super(providerMetadata);
+ }
+
+ public AtmosContextBuilder(AtmosApiMetadata apiMetadata) {
+ super(apiMetadata);
}
@Override
diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java
index 18c1b084be..7c5db767a6 100644
--- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java
+++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosAsyncBlobStore.java
@@ -85,7 +85,7 @@ public class AtmosAsyncBlobStore extends BaseAsyncBlobStore {
private final LoadingCache isPublic;
@Inject
- AtmosAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
+ AtmosAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation,
@Memoized Supplier> locations, AtmosAsyncClient async, AtmosClient sync,
ObjectToBlob object2Blob, ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object,
diff --git a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java
index 4ba8c4b63b..5dafd49b28 100644
--- a/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java
+++ b/apis/atmos/src/main/java/org/jclouds/atmos/blobstore/AtmosBlobStore.java
@@ -73,7 +73,7 @@ public class AtmosBlobStore extends BaseBlobStore {
private final LoadingCache isPublic;
@Inject
- AtmosBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation,
+ AtmosBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation,
@Memoized Supplier> locations, AtmosClient sync, ObjectToBlob object2Blob,
ObjectToBlobMetadata object2BlobMd, BlobToObject blob2Object,
BlobStoreListOptionsToListOptions container2ContainerListOptions,
diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosApiMetadataTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosApiMetadataTest.java
index 9f5f407922..c9fedebe65 100644
--- a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosApiMetadataTest.java
+++ b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosApiMetadataTest.java
@@ -18,8 +18,7 @@
*/
package org.jclouds.atmos;
-import org.jclouds.apis.ApiType;
-import org.jclouds.apis.BaseApiMetadataTest;
+import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadataTest;
import org.testng.annotations.Test;
/**
@@ -27,9 +26,9 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "AtmosApiMetadataTest")
-public class AtmosApiMetadataTest extends BaseApiMetadataTest {
+public class AtmosApiMetadataTest extends BaseBlobStoreApiMetadataTest {
public AtmosApiMetadataTest() {
- super(new AtmosApiMetadata(), ApiType.BLOBSTORE);
+ super(new AtmosApiMetadata());
}
}
diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java
index 7f41fe9b34..6722aeffc4 100644
--- a/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java
+++ b/apis/atmos/src/test/java/org/jclouds/atmos/AtmosAsyncClientTest.java
@@ -22,10 +22,10 @@ import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.lang.reflect.Method;
-import java.util.Properties;
import javax.ws.rs.core.HttpHeaders;
+import org.jclouds.apis.ApiMetadata;
import org.jclouds.atmos.blobstore.functions.BlobToObject;
import org.jclouds.atmos.config.AtmosRestClientModule;
import org.jclouds.atmos.domain.AtmosObject;
@@ -47,12 +47,10 @@ import org.jclouds.http.functions.ParseURIFromListOrLocationHeaderIf20x;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
import org.jclouds.http.options.GetOptions;
import org.jclouds.rest.ConfiguresRestClient;
-import org.jclouds.rest.RestClientTest;
-import org.jclouds.rest.RestContextFactory;
-import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
+import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -68,7 +66,7 @@ import com.google.inject.TypeLiteral;
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
@Test(groups = "unit", testName = "AtmosAsyncClientTest")
-public class AtmosAsyncClientTest extends RestClientTest {
+public class AtmosAsyncClientTest extends BaseAsyncClientTest {
private BlobToObject blobToObject;
@@ -339,10 +337,8 @@ public class AtmosAsyncClientTest extends RestClientTest {
protected String provider = "atmos";
@Override
- public RestContextSpec, ?> createContextSpec() {
- Properties props = new Properties();
- props.setProperty(provider + ".endpoint", "https://accesspoint.atmosonline.com");
- return new RestContextFactory().createContextSpec(provider, "identity", "credential", props);
+ public ApiMetadata, ?, ?, ?> createApiMetadata() {
+ return new AtmosApiMetadata();
}
}
diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java
index 44c1a03591..c4f2d593be 100644
--- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java
+++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/AtmosBlobRequestSignerTest.java
@@ -21,8 +21,9 @@ package org.jclouds.atmos.blobstore;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
-import java.util.Properties;
+import org.jclouds.apis.ApiMetadata;
+import org.jclouds.atmos.AtmosApiMetadata;
import org.jclouds.atmos.AtmosAsyncClient;
import org.jclouds.atmos.config.AtmosRestClientModule;
import org.jclouds.atmos.filters.SignRequest;
@@ -33,9 +34,7 @@ import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient;
-import org.jclouds.rest.RestClientTest;
-import org.jclouds.rest.RestContextFactory;
-import org.jclouds.rest.RestContextSpec;
+import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -51,7 +50,7 @@ import com.google.inject.TypeLiteral;
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
@Test(groups = "unit", testName = "AtmosBlobRequestSignerTest")
-public class AtmosBlobRequestSignerTest extends RestClientTest {
+public class AtmosBlobRequestSignerTest extends BaseAsyncClientTest {
private BlobRequestSigner signer;
private Factory blobFactory;
@@ -144,8 +143,8 @@ public class AtmosBlobRequestSignerTest extends RestClientTest
}
@Override
- public RestContextSpec, ?> createContextSpec() {
- return new RestContextFactory().createContextSpec("atmos", "identity", "credential", new Properties());
+ public ApiMetadata, ?, ?, ?> createApiMetadata() {
+ return new AtmosApiMetadata();
}
}
diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreModuleTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreModuleTest.java
index 7c87d6eeb9..ccf9a5c840 100644
--- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreModuleTest.java
+++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/config/AtmosBlobStoreModuleTest.java
@@ -20,13 +20,14 @@ package org.jclouds.atmos.blobstore.config;
import static org.testng.Assert.assertEquals;
+import org.jclouds.atmos.AtmosApiMetadata;
import org.jclouds.atmos.blobstore.strategy.FindMD5InUserMetadata;
import org.jclouds.blobstore.BlobStoreContext;
+import org.jclouds.blobstore.BlobStoreContextBuilder;
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
import org.jclouds.logging.config.NullLoggingModule;
-import org.jclouds.rest.BaseRestClientTest.MockModule;
-import org.jclouds.rest.RestContextFactory;
+import org.jclouds.rest.internal.BaseRestClientTest.MockModule;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@@ -40,15 +41,19 @@ import com.google.inject.Module;
public class AtmosBlobStoreModuleTest {
Injector createInjector() {
- return new RestContextFactory().createContextBuilder("atmos", "uid", "key",
- ImmutableSet. of(new MockModule(), new NullLoggingModule())).buildInjector();
+ return BlobStoreContextBuilder
+ .newBuilder(new AtmosApiMetadata())
+ .credentials("uid", "key")
+ .modules(
+ ImmutableSet. of(new MockModule(),new NullLoggingModule()))
+ .buildInjector();
}
@Test
void testContextImpl() {
Injector injector = createInjector();
- BlobStoreContext handler = injector.getInstance(BlobStoreContext.class);
+ BlobStoreContext, ?> handler = injector.getInstance(BlobStoreContext.class);
assertEquals(handler.getClass(), BlobStoreContextImpl.class);
ContainsValueInListStrategy valueList = injector
.getInstance(ContainsValueInListStrategy.class);
diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosBlobSignerLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosBlobSignerLiveTest.java
index df8da0418c..8521358067 100644
--- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosBlobSignerLiveTest.java
+++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosBlobSignerLiveTest.java
@@ -27,5 +27,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = { "live" })
public class AtmosBlobSignerLiveTest extends BaseBlobSignerLiveTest {
-
+ public AtmosBlobSignerLiveTest() {
+ provider = "atmos";
+ }
}
diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerIntegrationLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerIntegrationLiveTest.java
index a2f31c766b..a134e0fab6 100644
--- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerIntegrationLiveTest.java
+++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerIntegrationLiveTest.java
@@ -31,7 +31,9 @@ import org.testng.annotations.Test;
*/
@Test(groups = "live")
public class AtmosContainerIntegrationLiveTest extends BaseContainerIntegrationTest {
-
+ public AtmosContainerIntegrationLiveTest() {
+ provider = "atmos";
+ }
@Override
public void testListContainerMaxResults() throws InterruptedException {
// Not currently working
diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerLiveTest.java
index 57a690d067..90c28d9b7a 100644
--- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerLiveTest.java
+++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosContainerLiveTest.java
@@ -26,5 +26,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = { "live" })
public class AtmosContainerLiveTest extends BaseContainerLiveTest {
-
+ public AtmosContainerLiveTest() {
+ provider = "atmos";
+ }
}
diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosInputStreamMapIntegrationLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosInputStreamMapIntegrationLiveTest.java
index 5e8cfd49ea..ec4fcf4e57 100644
--- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosInputStreamMapIntegrationLiveTest.java
+++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosInputStreamMapIntegrationLiveTest.java
@@ -29,7 +29,10 @@ import org.testng.annotations.Test;
*/
@Test(groups = "live")
public class AtmosInputStreamMapIntegrationLiveTest extends BaseInputStreamMapIntegrationTest {
-
+ public AtmosInputStreamMapIntegrationLiveTest() {
+ provider = "atmos";
+ }
+
@Override
@Test(enabled = false)
public void testContainsBytesValue() throws InterruptedException, ExecutionException,
diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosIntegrationLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosIntegrationLiveTest.java
index aad3085662..56246296de 100644
--- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosIntegrationLiveTest.java
+++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosIntegrationLiveTest.java
@@ -35,7 +35,9 @@ import org.testng.annotations.Test;
*/
@Test(groups = { "integration", "live" })
public class AtmosIntegrationLiveTest extends BaseBlobIntegrationTest {
-
+ public AtmosIntegrationLiveTest() {
+ provider = "atmos";
+ }
@DataProvider(name = "delete")
// no unicode support
@Override
diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosLiveTest.java
index 06cf5c12c6..4c17e48f31 100644
--- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosLiveTest.java
+++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosLiveTest.java
@@ -29,6 +29,9 @@ import org.testng.annotations.Test;
*/
@Test(groups = { "live" })
public class AtmosLiveTest extends BaseBlobLiveTest {
+ public AtmosLiveTest() {
+ provider = "atmos";
+ }
protected void checkMD5(String container, String name, byte[] md5) {
// atmos does not support content-md5 yet
assertEquals(context.getBlobStore().blobMetadata(container, name).getContentMetadata().getContentMD5(), null);
diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosMapIntegrationLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosMapIntegrationLiveTest.java
index ada6ffb7b3..86d9dc5680 100644
--- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosMapIntegrationLiveTest.java
+++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosMapIntegrationLiveTest.java
@@ -30,7 +30,9 @@ import org.testng.annotations.Test;
*/
@Test(groups = "live")
public class AtmosMapIntegrationLiveTest extends BaseBlobMapIntegrationTest {
-
+ public AtmosMapIntegrationLiveTest() {
+ provider = "atmos";
+ }
@Override
// NO support for Content-MD5, so contains cannot work
public void testContains() throws InterruptedException, ExecutionException, TimeoutException, IOException {
diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosServiceIntegrationLiveTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosServiceIntegrationLiveTest.java
index 47e58e83cc..a36d98e76e 100644
--- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosServiceIntegrationLiveTest.java
+++ b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosServiceIntegrationLiveTest.java
@@ -26,5 +26,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = "live")
public class AtmosServiceIntegrationLiveTest extends BaseServiceIntegrationTest {
-
+ public AtmosServiceIntegrationLiveTest() {
+ provider = "atmos";
+ }
}
diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosTestInitializer.java b/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosTestInitializer.java
deleted file mode 100644
index 1cc02f150e..0000000000
--- a/apis/atmos/src/test/java/org/jclouds/atmos/blobstore/integration/AtmosTestInitializer.java
+++ /dev/null
@@ -1,47 +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.atmos.blobstore.integration;
-
-import java.io.IOException;
-
-import org.jclouds.blobstore.BlobStoreContext;
-import org.jclouds.blobstore.BlobStoreContextFactory;
-import org.jclouds.blobstore.integration.TransientBlobStoreTestInitializer;
-import org.jclouds.logging.log4j.config.Log4JLoggingModule;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
-
-/**
- *
- * @author Adrian Cole
- */
-public class AtmosTestInitializer extends TransientBlobStoreTestInitializer {
- public AtmosTestInitializer() {
- provider = "synaptic";
- }
-
- @Override
- protected BlobStoreContext createLiveContext(Module configurationModule, String endpoint, String apiVersion,
- String buildVersion, String app, String identity, String credential) throws IOException {
- return new BlobStoreContextFactory().createContext(provider, ImmutableSet.of(configurationModule,
- new Log4JLoggingModule()), setupProperties(endpoint, apiVersion, buildVersion, identity, credential));
- }
-
-}
diff --git a/apis/atmos/src/test/java/org/jclouds/atmos/filters/SignRequestTest.java b/apis/atmos/src/test/java/org/jclouds/atmos/filters/SignRequestTest.java
index 8e4caeb019..dc07a557d8 100644
--- a/apis/atmos/src/test/java/org/jclouds/atmos/filters/SignRequestTest.java
+++ b/apis/atmos/src/test/java/org/jclouds/atmos/filters/SignRequestTest.java
@@ -24,20 +24,19 @@ import java.io.IOException;
import java.net.URI;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
-import java.util.Properties;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import org.jclouds.atmos.config.AtmosRestClientModule;
import org.jclouds.atmos.reference.AtmosHeaders;
+import org.jclouds.blobstore.BlobStoreContextBuilder;
import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.logging.config.NullLoggingModule;
-import org.jclouds.rest.BaseRestClientTest.MockModule;
import org.jclouds.rest.ConfiguresRestClient;
-import org.jclouds.rest.RestContextFactory;
+import org.jclouds.rest.internal.BaseRestClientTest.MockModule;
import org.jclouds.util.Strings2;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
@@ -98,13 +97,12 @@ public class SignRequestTest {
@BeforeClass
protected void createFilter() {
- Injector injector = new RestContextFactory()
- .createContextBuilder(
- "atmos",
- UID,
- KEY,
- ImmutableSet. of(new MockModule(), new TestAtmosRestClientModule(),
- new NullLoggingModule()), new Properties()).buildInjector();
+ Injector injector = BlobStoreContextBuilder
+ .newBuilder("atmos")
+ .credentials(UID, KEY)
+ .modules(
+ ImmutableSet. of(new MockModule(), new TestAtmosRestClientModule(), new NullLoggingModule()))
+ .buildInjector();
filter = injector.getInstance(SignRequest.class);
diff --git a/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java b/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java
index b818a6ef33..a094713c0b 100644
--- a/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java
+++ b/apis/byon/src/main/java/org/jclouds/byon/BYONApiMetadata.java
@@ -19,49 +19,74 @@
package org.jclouds.byon;
import java.net.URI;
+import java.util.Properties;
+import org.jclouds.JcloudsVersion;
import org.jclouds.apis.ApiMetadata;
-import org.jclouds.apis.ApiType;
-import org.jclouds.apis.BaseApiMetadata;
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.compute.internal.BaseComputeServiceApiMetadata;
+
+import com.google.common.base.Supplier;
+import com.google.common.reflect.TypeToken;
/**
* Implementation of {@link ApiMetadata} for jclouds BYON API
*
+ * note
+ *
+ * This class is not setup to allow a subclasses to override the type of api,
+ * asyncapi, or context. This is an optimization for s.
+ *
* @author Adrian Cole
*/
-public class BYONApiMetadata extends BaseApiMetadata {
+@SuppressWarnings("rawtypes")
+public class BYONApiMetadata extends BaseComputeServiceApiMetadata, BYONApiMetadata> {
- public BYONApiMetadata() {
- this(builder()
- .id("byon")
- .type(ApiType.COMPUTE)
- .name("Bring Your Own Node (BYON) API")
- .identityName("Unused")
- .documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/apis/byon")));
+ @Override
+ public Builder toBuilder() {
+ return new Builder().fromApiMetadata(this);
}
- // below are so that we can reuse builders, toString, hashCode, etc.
- // we have to set concrete classes here, as our base class cannot be
- // concrete due to serviceLoader
- protected BYONApiMetadata(Builder> builder) {
+ public BYONApiMetadata() {
+ this(new Builder());
+ }
+
+ protected BYONApiMetadata(Builder builder) {
super(builder);
}
- private static class ConcreteBuilder extends Builder {
+ protected static Properties defaultProperties() {
+ return BaseComputeServiceApiMetadata.Builder.defaultProperties();
+ }
+
+ public static class Builder extends BaseComputeServiceApiMetadata.Builder, BYONApiMetadata> {
+
+ protected Builder() {
+ id("byon")
+ .name("Bring Your Own Node (BYON) API")
+ .identityName("Unused")
+ .defaultIdentity("foo")
+ .defaultCredential("bar")
+ .defaultEndpoint("file://byon.yaml")
+ .documentation(URI.create("https://github.com/jclouds/jclouds/tree/master/apis/byon"))
+ .version(String.format("%s.%s", JcloudsVersion.get().majorVersion, JcloudsVersion.get().minorVersion))
+ .buildVersion(JcloudsVersion.get().toString())
+ .defaultProperties(BYONApiMetadata.defaultProperties())
+ .javaApi(Supplier.class, Supplier.class)
+ .contextBuilder(TypeToken.of(BYONComputeServiceContextBuilder.class));
+ }
@Override
public BYONApiMetadata build() {
return new BYONApiMetadata(this);
}
- }
- public static ConcreteBuilder builder() {
- return new ConcreteBuilder();
- }
+ @Override
+ public Builder fromApiMetadata(BYONApiMetadata in) {
+ super.fromApiMetadata(in);
+ return this;
+ }
- @Override
- public ConcreteBuilder toBuilder() {
- return builder().fromApiMetadata(this);
}
}
\ No newline at end of file
diff --git a/apis/byon/src/main/java/org/jclouds/byon/BYONComputeServiceContextBuilder.java b/apis/byon/src/main/java/org/jclouds/byon/BYONComputeServiceContextBuilder.java
index 15bdb626a9..2def88a0d3 100644
--- a/apis/byon/src/main/java/org/jclouds/byon/BYONComputeServiceContextBuilder.java
+++ b/apis/byon/src/main/java/org/jclouds/byon/BYONComputeServiceContextBuilder.java
@@ -19,12 +19,13 @@
package org.jclouds.byon;
import java.util.List;
-import java.util.Properties;
import org.jclouds.byon.config.BYONComputeServiceContextModule;
import org.jclouds.byon.config.ConfiguresNodeStore;
import org.jclouds.byon.config.YamlNodeStoreModule;
+import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.StandaloneComputeServiceContextBuilder;
+import org.jclouds.providers.ProviderMetadata;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
@@ -36,12 +37,17 @@ import com.google.inject.Module;
* @author Adrian Cole
*/
@SuppressWarnings("rawtypes")
-public class BYONComputeServiceContextBuilder extends StandaloneComputeServiceContextBuilder {
+public class BYONComputeServiceContextBuilder extends StandaloneComputeServiceContextBuilder, BYONApiMetadata> {
- public BYONComputeServiceContextBuilder(Properties props) {
- super(Supplier.class, props);
+ public BYONComputeServiceContextBuilder(
+ ProviderMetadata, BYONApiMetadata> providerMetadata) {
+ super(providerMetadata);
}
-
+
+ public BYONComputeServiceContextBuilder(BYONApiMetadata apiMetadata) {
+ super(apiMetadata);
+ }
+
@Override
protected void addContextModule(List modules) {
modules.add(new BYONComputeServiceContextModule());
diff --git a/apis/byon/src/main/java/org/jclouds/byon/BYONPropertiesBuilder.java b/apis/byon/src/main/java/org/jclouds/byon/BYONPropertiesBuilder.java
deleted file mode 100644
index 5965595704..0000000000
--- a/apis/byon/src/main/java/org/jclouds/byon/BYONPropertiesBuilder.java
+++ /dev/null
@@ -1,48 +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.byon;
-
-import static org.jclouds.Constants.PROPERTY_API_VERSION;
-import static org.jclouds.Constants.PROPERTY_CREDENTIAL;
-import static org.jclouds.Constants.PROPERTY_IDENTITY;
-
-import java.util.Properties;
-
-import org.jclouds.PropertiesBuilder;
-
-/**
- * Builds properties used in byon Clients
- *
- * @author Adrian Cole
- */
-public class BYONPropertiesBuilder extends PropertiesBuilder {
- @Override
- protected Properties defaultProperties() {
- Properties properties = super.defaultProperties();
- properties.setProperty(PROPERTY_API_VERSION, "1.0");
- properties.setProperty(PROPERTY_IDENTITY, "foo");
- properties.setProperty(PROPERTY_CREDENTIAL, "bar");
- return properties;
- }
-
- public BYONPropertiesBuilder(Properties properties) {
- super(properties);
- }
-
-}
diff --git a/apis/byon/src/test/java/org/jclouds/byon/BYONApiMetadataTest.java b/apis/byon/src/test/java/org/jclouds/byon/BYONApiMetadataTest.java
index 6265ff3c0e..2e0fb1bd98 100644
--- a/apis/byon/src/test/java/org/jclouds/byon/BYONApiMetadataTest.java
+++ b/apis/byon/src/test/java/org/jclouds/byon/BYONApiMetadataTest.java
@@ -18,8 +18,7 @@
*/
package org.jclouds.byon;
-import org.jclouds.apis.ApiType;
-import org.jclouds.apis.BaseApiMetadataTest;
+import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest;
import org.testng.annotations.Test;
/**
@@ -27,9 +26,9 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "BYONApiMetadataTest")
-public class BYONApiMetadataTest extends BaseApiMetadataTest {
+public class BYONApiMetadataTest extends BaseComputeServiceApiMetadataTest {
public BYONApiMetadataTest() {
- super(new BYONApiMetadata(), ApiType.COMPUTE);
+ super(new BYONApiMetadata());
}
}
diff --git a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java
index 60b1a286d2..4668ad7a45 100644
--- a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java
+++ b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceLiveTest.java
@@ -28,10 +28,10 @@ import java.util.Map.Entry;
import java.util.Properties;
import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
+import org.jclouds.rest.internal.ContextBuilder;
import org.jclouds.scriptbuilder.domain.OsFamily;
import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.annotations.AfterClass;
@@ -49,7 +49,7 @@ import com.google.inject.Module;
@Test(groups = "live")
public class BYONComputeServiceLiveTest {
- private ComputeServiceContext context;
+ private ComputeServiceContext, ?> context;
@BeforeClass(groups = "live")
public void setup() throws FileNotFoundException, IOException {
@@ -72,9 +72,8 @@ public class BYONComputeServiceLiveTest {
.append("\n");
contextProperties.setProperty("byon.nodes", nodes.toString());
-
- context = new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet. of(
- new SshjSshClientModule(), new Log4JLoggingModule()), contextProperties);
+ context = ContextBuilder.newBuilder(new BYONApiMetadata()).overrides(contextProperties)
+ .modules(ImmutableSet. of(new SshjSshClientModule(), new Log4JLoggingModule())).build();
}
public void testCanRunCommandAsCurrentUser() throws Exception {
diff --git a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java
index 2a86fb13d0..ded60ea37f 100644
--- a/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java
+++ b/apis/byon/src/test/java/org/jclouds/byon/BYONComputeServiceTest.java
@@ -24,15 +24,15 @@ import static org.jclouds.byon.functions.NodeToNodeMetadataTest.zoneCalled;
import static org.testng.Assert.assertEquals;
import java.net.URI;
-import java.util.Properties;
import org.jclouds.byon.config.CacheNodeStoreModule;
import org.jclouds.byon.functions.NodesFromYamlTest;
import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.domain.Location;
import org.jclouds.domain.LoginCredentials;
+import org.jclouds.rest.AnonymousProviderMetadata;
+import org.jclouds.rest.internal.ContextBuilder;
import org.testng.annotations.Test;
import com.google.common.base.Supplier;
@@ -68,13 +68,13 @@ public class BYONComputeServiceTest {
}
private void assertNodesParse(String endpoint, Iterable modules) {
- ComputeServiceContext context = null;
+ ComputeServiceContext, ?> context = null;
try {
Location providerLocation = expectedProviderLocationFromResource(endpoint);
- Properties props = new Properties();
- props.setProperty("byon.endpoint", endpoint);
- context = new ComputeServiceContextFactory().createContext("byon", "foo", "bar", modules, props);
+ context = ContextBuilder.newBuilder(
+ AnonymousProviderMetadata.forApiWithEndpoint(new BYONApiMetadata(), endpoint))
+ .modules(modules).build();
assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint));
@@ -96,13 +96,11 @@ public class BYONComputeServiceTest {
}
public void testNodesWithLocations() {
- ComputeServiceContext context = null;
+ ComputeServiceContext, ?> context = null;
try {
String endpoint = "file://" + getClass().getResource("/test_location.yaml").getPath();
- Properties props = new Properties();
- props.setProperty("byon.endpoint", endpoint);
- context = new ComputeServiceContextFactory().createContext("byon", "foo", "bar", ImmutableSet. of(),
- props);
+ context = ContextBuilder.newBuilder(
+ AnonymousProviderMetadata.forApiWithEndpoint(new BYONApiMetadata(), endpoint)).build();
assertEquals(context.getProviderSpecificContext().getEndpoint(), URI.create(endpoint));
diff --git a/apis/cloudfiles/pom.xml b/apis/cloudfiles/pom.xml
index a7bb4b0e4a..13bb997d70 100644
--- a/apis/cloudfiles/pom.xml
+++ b/apis/cloudfiles/pom.xml
@@ -34,7 +34,6 @@
bundle
- org.jclouds.cloudfiles.blobstore.integration.CloudFilesTestInitializer
https://auth.api.rackspacecloud.com
1.0
@@ -107,7 +106,6 @@
- ${test.initializer}
${jclouds.blobstore.httpstream.url}
${jclouds.blobstore.httpstream.md5}
${test.cloudfiles.endpoint}
diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java
index 654c040c04..5d7cf50a69 100644
--- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java
+++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesApiMetadata.java
@@ -18,51 +18,75 @@
*/
package org.jclouds.cloudfiles;
+import static org.jclouds.blobstore.reference.BlobStoreConstants.PROPERTY_USER_METADATA_PREFIX;
+import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
+
import java.net.URI;
+import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
-import org.jclouds.apis.ApiType;
-import org.jclouds.apis.BaseApiMetadata;
+import org.jclouds.blobstore.BlobStoreContext;
+import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadata;
+import org.jclouds.openstack.OpenStackAuthAsyncClient;
+
+import com.google.common.reflect.TypeToken;
/**
* Implementation of {@link ApiMetadata} for Rackspace Cloud Files API
*
- * @author Dan Lo Bianco
+ * @author Adrian Cole
*/
-public class CloudFilesApiMetadata extends BaseApiMetadata {
-
- public CloudFilesApiMetadata() {
- this(builder()
- .id("cloudfiles")
- .type(ApiType.BLOBSTORE)
- .name("Rackspace Cloud Files API")
- .identityName("Username")
- .credentialName("API Key")
- .documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html")));
+public class CloudFilesApiMetadata
+ extends
+ BaseBlobStoreApiMetadata, CloudFilesApiMetadata> {
+ private static Builder builder() {
+ return new Builder();
}
- // below are so that we can reuse builders, toString, hashCode, etc.
- // we have to set concrete classes here, as our base class cannot be
- // concrete due to serviceLoader
- protected CloudFilesApiMetadata(Builder> builder) {
+ @Override
+ public Builder toBuilder() {
+ return builder().fromApiMetadata(this);
+ }
+
+ public CloudFilesApiMetadata() {
+ this(builder());
+ }
+
+ protected CloudFilesApiMetadata(Builder builder) {
super(builder);
}
- private static class ConcreteBuilder extends Builder {
+ protected static Properties defaultProperties() {
+ Properties properties = BaseBlobStoreApiMetadata.Builder.defaultProperties();
+ properties.setProperty(PROPERTY_REGIONS, "DEFAULT");
+ properties.setProperty(PROPERTY_USER_METADATA_PREFIX, "X-Object-Meta-");
+ return properties;
+ }
+
+ public static class Builder
+ extends
+ BaseBlobStoreApiMetadata.Builder, CloudFilesApiMetadata> {
+ protected Builder() {
+ id("cloudfiles")
+ .name("Rackspace Cloud Files API")
+ .identityName("Username")
+ .credentialName("API Key")
+ .documentation(URI.create("http://docs.rackspacecloud.com/files/api/v1/cfdevguide_d5/content/ch01.html"))
+ .version(OpenStackAuthAsyncClient.VERSION)
+ .contextBuilder(TypeToken.of(CloudFilesContextBuilder.class))
+ .defaultProperties(CloudFilesApiMetadata.defaultProperties())
+ .javaApi(CloudFilesClient.class, CloudFilesAsyncClient.class);
+ }
@Override
public CloudFilesApiMetadata build() {
return new CloudFilesApiMetadata(this);
}
- }
- public static ConcreteBuilder builder() {
- return new ConcreteBuilder();
+ @Override
+ public Builder fromApiMetadata(CloudFilesApiMetadata in) {
+ super.fromApiMetadata(in);
+ return this;
+ }
}
-
- @Override
- public ConcreteBuilder toBuilder() {
- return builder().fromApiMetadata(this);
- }
-
}
\ No newline at end of file
diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java
index 05f95822f4..84f966e358 100644
--- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java
+++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/CloudFilesContextBuilder.java
@@ -19,34 +19,45 @@
package org.jclouds.cloudfiles;
import java.util.List;
-import java.util.Properties;
+import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.BlobStoreContextBuilder;
import org.jclouds.cloudfiles.blobstore.config.CloudFilesBlobStoreContextModule;
import org.jclouds.cloudfiles.config.CloudFilesRestClientModule;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule;
+import org.jclouds.providers.ProviderMetadata;
import com.google.inject.Injector;
import com.google.inject.Module;
/**
- * Creates {@link CloudFilesBlobStoreContext} or {@link Injector} instances based on the most
- * commonly requested arguments.
+ * Creates {@link CloudFilesStoreContext} or {@link Injector} instances based on
+ * the most commonly requested arguments.
*
- * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
+ * Note that Threadsafe objects will be bound as singletons to the Injector or
+ * Context provided.
*
*
- * If no Module
s are specified, the default {@link JDKLoggingModule logging} and
- * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
+ * If no Module
s are specified, the default
+ * {@link JDKLoggingModule logging} and
+ * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be
+ * installed.
*
* @author Adrian Cole, Andrew Newdigate
- * @see CloudFilesBlobStoreContext
+ * @see CloudFilesStoreContext
*/
-public class CloudFilesContextBuilder extends BlobStoreContextBuilder {
+public class CloudFilesContextBuilder
+ extends
+ BlobStoreContextBuilder, CloudFilesApiMetadata> {
- public CloudFilesContextBuilder(Properties props) {
- super(CloudFilesClient.class, CloudFilesAsyncClient.class, props);
+ public CloudFilesContextBuilder(
+ ProviderMetadata, CloudFilesApiMetadata> providerMetadata) {
+ super(providerMetadata);
+ }
+
+ public CloudFilesContextBuilder(CloudFilesApiMetadata apiMetadata) {
+ super(apiMetadata);
}
@Override
diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java
index 34b61b03de..af064f61c1 100644
--- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java
+++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesAsyncBlobStore.java
@@ -59,7 +59,7 @@ public class CloudFilesAsyncBlobStore extends SwiftAsyncBlobStore {
private final EnableCDNAndCache enableCDNAndCache;
@Inject
- protected CloudFilesAsyncBlobStore(BlobStoreContext context, BlobUtils blobUtils,
+ protected CloudFilesAsyncBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils,
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService service, Supplier defaultLocation,
@Memoized Supplier> locations, CloudFilesClient sync, CloudFilesAsyncClient async,
ContainerToResourceMetadata container2ResourceMd,
diff --git a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java
index 42be6d884c..d7309f99bc 100644
--- a/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java
+++ b/apis/cloudfiles/src/main/java/org/jclouds/cloudfiles/blobstore/CloudFilesBlobStore.java
@@ -53,7 +53,7 @@ public class CloudFilesBlobStore extends SwiftBlobStore {
private EnableCDNAndCache enableCDNAndCache;
@Inject
- protected CloudFilesBlobStore(BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation,
+ protected CloudFilesBlobStore(@SuppressWarnings("rawtypes") BlobStoreContext context, BlobUtils blobUtils, Supplier defaultLocation,
@Memoized Supplier> locations, CommonSwiftClient sync,
ContainerToResourceMetadata container2ResourceMd,
BlobStoreListContainerOptionsToListContainerOptions container2ContainerListOptions,
diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesApiMetadataTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesApiMetadataTest.java
index 2672d7e980..ba6a4d55c9 100644
--- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesApiMetadataTest.java
+++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesApiMetadataTest.java
@@ -18,8 +18,7 @@
*/
package org.jclouds.cloudfiles;
-import org.jclouds.apis.ApiType;
-import org.jclouds.apis.BaseApiMetadataTest;
+import org.jclouds.blobstore.internal.BaseBlobStoreApiMetadataTest;
import org.testng.annotations.Test;
/**
@@ -27,9 +26,9 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "CloudFilesApiMetadataTest")
-public class CloudFilesApiMetadataTest extends BaseApiMetadataTest {
+public class CloudFilesApiMetadataTest extends BaseBlobStoreApiMetadataTest {
public CloudFilesApiMetadataTest() {
- super(new CloudFilesApiMetadata(), ApiType.BLOBSTORE);
+ super(new CloudFilesApiMetadata());
}
}
diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java
index 7c5706a761..91bd107f73 100644
--- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java
+++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/CloudFilesClientLiveTest.java
@@ -41,6 +41,10 @@ import com.google.common.collect.Iterables;
@Test(groups = "live")
public class CloudFilesClientLiveTest extends CommonSwiftClientLiveTest {
+ public CloudFilesClientLiveTest(){
+ provider = "cloudfiles";
+ }
+
@Override
public CloudFilesClient getApi() {
return (CloudFilesClient) context.getProviderSpecificContext().getApi();
diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobIntegrationLiveTest.java
index 5dc7f166eb..ce04b4f47e 100644
--- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobIntegrationLiveTest.java
+++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobIntegrationLiveTest.java
@@ -28,6 +28,10 @@ import org.testng.annotations.Test;
*/
@Test(groups = "live")
public class CloudFilesBlobIntegrationLiveTest extends SwiftBlobIntegrationLiveTest {
+ public CloudFilesBlobIntegrationLiveTest(){
+ provider = "cloudfiles";
+ }
+
@Override
protected void checkContentDisposition(Blob blob, String contentDisposition) {
assert blob.getPayload().getContentMetadata().getContentDisposition().startsWith(contentDisposition) : blob
diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobLiveTest.java
index cb66f7c794..edae3c1abf 100644
--- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobLiveTest.java
+++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobLiveTest.java
@@ -27,5 +27,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = { "live" })
public class CloudFilesBlobLiveTest extends SwiftBlobLiveTest {
-
+ public CloudFilesBlobLiveTest(){
+ provider = "cloudfiles";
+ }
}
diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobMapIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobMapIntegrationLiveTest.java
index ff7a240fee..e091cc1642 100644
--- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobMapIntegrationLiveTest.java
+++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobMapIntegrationLiveTest.java
@@ -26,5 +26,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = "live")
public class CloudFilesBlobMapIntegrationLiveTest extends SwiftBlobMapIntegrationLiveTest {
-
+ public CloudFilesBlobMapIntegrationLiveTest(){
+ provider = "cloudfiles";
+ }
}
diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobSignerLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobSignerLiveTest.java
index 1437aa506e..7add9a211d 100644
--- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobSignerLiveTest.java
+++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesBlobSignerLiveTest.java
@@ -27,5 +27,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = { "live" })
public class CloudFilesBlobSignerLiveTest extends SwiftBlobSignerLiveTest {
-
+ public CloudFilesBlobSignerLiveTest(){
+ provider = "cloudfiles";
+ }
}
diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerIntegrationLiveTest.java
index f55abb8f77..c9dc3f6cf0 100644
--- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerIntegrationLiveTest.java
+++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerIntegrationLiveTest.java
@@ -26,5 +26,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = "live")
public class CloudFilesContainerIntegrationLiveTest extends SwiftContainerIntegrationLiveTest {
-
+ public CloudFilesContainerIntegrationLiveTest(){
+ provider = "cloudfiles";
+ }
}
diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerLiveTest.java
index 86b7a471e5..11217a5c10 100644
--- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerLiveTest.java
+++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesContainerLiveTest.java
@@ -26,5 +26,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = { "live" })
public class CloudFilesContainerLiveTest extends BaseContainerLiveTest {
-
+ public CloudFilesContainerLiveTest(){
+ provider = "cloudfiles";
+ }
}
diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesInputStreamMapIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesInputStreamMapIntegrationLiveTest.java
index c4f99d274e..1fd19dc1cc 100644
--- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesInputStreamMapIntegrationLiveTest.java
+++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesInputStreamMapIntegrationLiveTest.java
@@ -26,5 +26,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = "live")
public class CloudFilesInputStreamMapIntegrationLiveTest extends SwiftInputStreamMapIntegrationLiveTest {
-
+ public CloudFilesInputStreamMapIntegrationLiveTest(){
+ provider = "cloudfiles";
+ }
}
diff --git a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesServiceIntegrationLiveTest.java b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesServiceIntegrationLiveTest.java
index 1265764550..c89574c8e6 100644
--- a/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesServiceIntegrationLiveTest.java
+++ b/apis/cloudfiles/src/test/java/org/jclouds/cloudfiles/blobstore/integration/CloudFilesServiceIntegrationLiveTest.java
@@ -26,5 +26,7 @@ import org.testng.annotations.Test;
*/
@Test(groups = "live")
public class CloudFilesServiceIntegrationLiveTest extends SwiftServiceIntegrationLiveTest {
-
+ public CloudFilesServiceIntegrationLiveTest(){
+ provider = "cloudfiles";
+ }
}
diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java
index 4885acb21d..0cadebfbc6 100644
--- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java
+++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadata.java
@@ -19,50 +19,71 @@
package org.jclouds.cloudloadbalancers;
import java.net.URI;
+import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
import org.jclouds.apis.ApiType;
-import org.jclouds.apis.BaseApiMetadata;
+import org.jclouds.loadbalancer.LoadBalancerServiceContext;
+import org.jclouds.loadbalancer.internal.BaseLoadBalancerServiceApiMetadata;
+import org.jclouds.openstack.OpenStackAuthAsyncClient;
+
+import com.google.common.reflect.TypeToken;
/**
- * Implementation of {@link ApiMetadata} for Rackspace Cloud Load Balancers API
+ * Implementation of {@link ApiMetadata} for CloudLoadBalancers 1.0 API
*
- * @author Dan Lo Bianco
+ * @author Adrian Cole
*/
-public class CloudLoadBalancersApiMetadata extends BaseApiMetadata {
+public class CloudLoadBalancersApiMetadata
+ extends
+ BaseLoadBalancerServiceApiMetadata, CloudLoadBalancersApiMetadata> {
- public CloudLoadBalancersApiMetadata() {
- this(builder()
- .id("cloudloadbalancers")
- .type(ApiType.LOADBALANCER)
- .name("Rackspace Cloud Load Balancers API")
- .identityName("Username")
- .credentialName("API Key")
- .documentation(URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html")));
+ @Override
+ public Builder toBuilder() {
+ return new Builder().fromApiMetadata(this);
}
- // below are so that we can reuse builders, toString, hashCode, etc.
- // we have to set concrete classes here, as our base class cannot be
- // concrete due to serviceLoader
- protected CloudLoadBalancersApiMetadata(Builder> builder) {
+ public CloudLoadBalancersApiMetadata() {
+ this(new Builder());
+ }
+
+ protected CloudLoadBalancersApiMetadata(Builder builder) {
super(builder);
}
- private static class ConcreteBuilder extends Builder {
+ protected static Properties defaultProperties() {
+ Properties properties = BaseLoadBalancerServiceApiMetadata.Builder.defaultProperties();
+ return properties;
+ }
+
+ public static class Builder
+ extends
+ BaseLoadBalancerServiceApiMetadata.Builder, CloudLoadBalancersApiMetadata> {
+
+ protected Builder() {
+ id("cloudloadbalancers")
+ .name("Rackspace Cloud Load Balancers API")
+ .identityName("Username")
+ .credentialName("API Key")
+ .documentation(URI.create("http://docs.rackspacecloud.com/loadbalancers/api/v1.0/clb-devguide/content/ch01.html"))
+ .version(OpenStackAuthAsyncClient.VERSION)
+ .defaultEndpoint("https://auth.api.rackspacecloud.com")
+ .javaApi(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class)
+ .defaultProperties(CloudLoadBalancersApiMetadata.defaultProperties())
+ .contextBuilder(TypeToken.of(CloudLoadBalancersContextBuilder.class));
+ }
@Override
public CloudLoadBalancersApiMetadata build() {
return new CloudLoadBalancersApiMetadata(this);
}
- }
- public static ConcreteBuilder builder() {
- return new ConcreteBuilder();
- }
+ @Override
+ public Builder fromApiMetadata(CloudLoadBalancersApiMetadata in) {
+ super.fromApiMetadata(in);
+ return this;
+ }
- @Override
- public ConcreteBuilder toBuilder() {
- return builder().fromApiMetadata(this);
}
}
\ No newline at end of file
diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersContextBuilder.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersContextBuilder.java
index 93b51fc864..2e4c8e7827 100644
--- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersContextBuilder.java
+++ b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersContextBuilder.java
@@ -19,11 +19,12 @@
package org.jclouds.cloudloadbalancers;
import java.util.List;
-import java.util.Properties;
import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
import org.jclouds.cloudloadbalancers.loadbalancer.config.CloudLoadBalancersLoadBalancerContextModule;
+import org.jclouds.loadbalancer.LoadBalancerServiceContext;
import org.jclouds.loadbalancer.LoadBalancerServiceContextBuilder;
+import org.jclouds.providers.ProviderMetadata;
import com.google.inject.Module;
@@ -31,11 +32,17 @@ import com.google.inject.Module;
*
* @author Adrian Cole
*/
-public class CloudLoadBalancersContextBuilder extends
- LoadBalancerServiceContextBuilder {
+public class CloudLoadBalancersContextBuilder
+ extends
+ LoadBalancerServiceContextBuilder, CloudLoadBalancersApiMetadata> {
- public CloudLoadBalancersContextBuilder(Properties props) {
- super(CloudLoadBalancersClient.class, CloudLoadBalancersAsyncClient.class, props);
+ public CloudLoadBalancersContextBuilder(
+ ProviderMetadata, CloudLoadBalancersApiMetadata> providerMetadata) {
+ super(providerMetadata);
+ }
+
+ public CloudLoadBalancersContextBuilder(CloudLoadBalancersApiMetadata apiMetadata) {
+ super(apiMetadata);
}
@Override
@@ -47,4 +54,4 @@ public class CloudLoadBalancersContextBuilder extends
modules.add(new CloudLoadBalancersRestClientModule());
}
-}
+}
\ No newline at end of file
diff --git a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersPropertiesBuilder.java b/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersPropertiesBuilder.java
deleted file mode 100644
index fe8c881636..0000000000
--- a/apis/cloudloadbalancers/src/main/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersPropertiesBuilder.java
+++ /dev/null
@@ -1,44 +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.cloudloadbalancers;
-
-import static org.jclouds.Constants.PROPERTY_API_VERSION;
-
-import java.util.Properties;
-
-import org.jclouds.PropertiesBuilder;
-
-/**
- * Builds properties used inRackspace Cloud Load Balancers Clients
- *
- * @author Dan Lo Bianco
- */
-public class CloudLoadBalancersPropertiesBuilder extends PropertiesBuilder {
- @Override
- protected Properties defaultProperties() {
- Properties properties = super.defaultProperties();
- properties.setProperty(PROPERTY_API_VERSION, "1.0");
- return properties;
- }
-
- public CloudLoadBalancersPropertiesBuilder(Properties properties) {
- super(properties);
- }
-
- }
diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadataTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadataTest.java
index 77aa57b660..a31007e3d9 100644
--- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadataTest.java
+++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/CloudLoadBalancersApiMetadataTest.java
@@ -18,8 +18,7 @@
*/
package org.jclouds.cloudloadbalancers;
-import org.jclouds.apis.ApiType;
-import org.jclouds.apis.BaseApiMetadataTest;
+import org.jclouds.loadbalancer.internal.BaseLoadBalancerServiceApiMetadataTest;
import org.testng.annotations.Test;
/**
@@ -27,9 +26,9 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "CloudLoadBalancersApiMetadataTest")
-public class CloudLoadBalancersApiMetadataTest extends BaseApiMetadataTest {
+public class CloudLoadBalancersApiMetadataTest extends BaseLoadBalancerServiceApiMetadataTest {
public CloudLoadBalancersApiMetadataTest() {
- super(new CloudLoadBalancersApiMetadata(), ApiType.LOADBALANCER);
+ super(new CloudLoadBalancersApiMetadata());
}
}
diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java
index e11bda0e72..b95b023667 100644
--- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java
+++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/features/LoadBalancerClientLiveTest.java
@@ -46,8 +46,8 @@ public class LoadBalancerClientLiveTest extends BaseCloudLoadBalancersClientLive
private Set lbs = Sets.newLinkedHashSet();
@Override
- public void setupClient() {
- super.setupClient();
+ public void setupContext() {
+ super.setupContext();
assertEquals(client.getConfiguredRegions(), Arrays.asList(regions));
Logger.getAnonymousLogger().info("running against regions " + client.getConfiguredRegions());
}
diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java
index eb8aa9132a..3ddb2f6e45 100644
--- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java
+++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersAsyncClientTest.java
@@ -31,12 +31,10 @@ import java.util.Properties;
import javax.inject.Singleton;
+import org.jclouds.apis.ApiMetadata;
+import org.jclouds.cloudloadbalancers.CloudLoadBalancersApiMetadata;
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
-import org.jclouds.cloudloadbalancers.CloudLoadBalancersContextBuilder;
-import org.jclouds.cloudloadbalancers.CloudLoadBalancersPropertiesBuilder;
import org.jclouds.cloudloadbalancers.config.CloudLoadBalancersRestClientModule;
-import org.jclouds.cloudloadbalancers.features.LoadBalancerAsyncClient;
-import org.jclouds.cloudloadbalancers.features.LoadBalancerClient;
import org.jclouds.cloudloadbalancers.reference.Region;
import org.jclouds.domain.Credentials;
import org.jclouds.http.HttpRequest;
@@ -48,13 +46,10 @@ import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule.Ge
import org.jclouds.openstack.keystone.v1_1.domain.Auth;
import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest;
import org.jclouds.rest.ConfiguresRestClient;
-import org.jclouds.rest.RestClientTest;
-import org.jclouds.rest.RestContextFactory;
-import org.jclouds.rest.RestContextSpec;
+import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.testng.annotations.BeforeClass;
import com.google.common.base.Throwables;
-import com.google.common.collect.ImmutableSet;
import com.google.inject.AbstractModule;
import com.google.inject.Module;
import com.google.inject.Provides;
@@ -62,7 +57,7 @@ import com.google.inject.Provides;
/**
* @author Adrian Cole
*/
-public abstract class BaseCloudLoadBalancersAsyncClientTest extends RestClientTest {
+public abstract class BaseCloudLoadBalancersAsyncClientTest extends BaseAsyncClientTest {
protected String provider;
@@ -131,15 +126,9 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest extends RestClien
return overrides;
}
- /**
- * this is only here as "cloudloadbalancers" is not in rest.properties
- */
- @SuppressWarnings( { "unchecked", "rawtypes" })
@Override
- public RestContextSpec, ?> createContextSpec() {
- return RestContextFactory. contextSpec(provider, "https://auth",
- "1.0", "", "", "identity", "credential", LoadBalancerClient.class, LoadBalancerAsyncClient.class,
- (Class) CloudLoadBalancersPropertiesBuilder.class, (Class) CloudLoadBalancersContextBuilder.class,
- ImmutableSet. of());
+ protected ApiMetadata, ?, ?, ?> createApiMetadata() {
+ return new CloudLoadBalancersApiMetadata();
}
+
}
\ No newline at end of file
diff --git a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java
index b8a1fdd898..fc178ac0f7 100644
--- a/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java
+++ b/apis/cloudloadbalancers/src/test/java/org/jclouds/cloudloadbalancers/internal/BaseCloudLoadBalancersClientLiveTest.java
@@ -18,7 +18,6 @@
*/
package org.jclouds.cloudloadbalancers.internal;
-import java.util.Properties;
import java.util.concurrent.TimeUnit;
import org.jclouds.cloudloadbalancers.CloudLoadBalancersAsyncClient;
@@ -26,32 +25,33 @@ import org.jclouds.cloudloadbalancers.CloudLoadBalancersClient;
import org.jclouds.cloudloadbalancers.domain.LoadBalancer;
import org.jclouds.cloudloadbalancers.predicates.LoadBalancerActive;
import org.jclouds.cloudloadbalancers.predicates.LoadBalancerDeleted;
-import org.jclouds.loadbalancer.LoadBalancerServiceContextFactory;
+import org.jclouds.loadbalancer.LoadBalancerServiceContext;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.net.IPSocket;
import org.jclouds.predicates.RetryablePredicate;
-import org.jclouds.rest.BaseRestClientLiveTest;
import org.jclouds.rest.RestContext;
+import org.jclouds.rest.internal.BaseContextLiveTest;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableSet;
import com.google.inject.Guice;
import com.google.inject.Injector;
-import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
-public class BaseCloudLoadBalancersClientLiveTest extends BaseRestClientLiveTest {
+public class BaseCloudLoadBalancersClientLiveTest
+ extends
+ BaseContextLiveTest> {
+
public BaseCloudLoadBalancersClientLiveTest() {
provider = "cloudloadbalancers";
}
protected CloudLoadBalancersClient client;
- protected RestContext context;
+ protected RestContext lbContext;
protected String[] regions = {};
protected Predicate socketTester;
protected RetryablePredicate loadBalancerActive;
@@ -59,15 +59,13 @@ public class BaseCloudLoadBalancersClientLiveTest extends BaseRestClientLiveTest
protected Injector injector;
+ @BeforeGroups(groups = { "integration", "live" })
+ @Override
+ public void setupContext() {
+ super.setupContext();
+ lbContext = context.getProviderSpecificContext();
- @BeforeGroups(groups = "live")
- public void setupClient() {
- setupCredentials();
- Properties overrides = setupProperties();
- context = new LoadBalancerServiceContextFactory().createContext(provider, ImmutableSet. of(new Log4JLoggingModule()),
- overrides).getProviderSpecificContext();
-
- client = context.getApi();
+ client = lbContext.getApi();
injector = Guice.createInjector(new Log4JLoggingModule());
loadBalancerActive = new RetryablePredicate(new LoadBalancerActive(client), 300, 1, 1,
@@ -80,8 +78,8 @@ public class BaseCloudLoadBalancersClientLiveTest extends BaseRestClientLiveTest
@AfterGroups(groups = "live")
protected void tearDown() {
- if (context != null)
- context.close();
+ if (lbContext != null)
+ lbContext.close();
}
}
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java
index c41c0a1aba..7ab3010dec 100644
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java
+++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersApiMetadata.java
@@ -19,50 +19,70 @@
package org.jclouds.cloudservers;
import java.net.URI;
+import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
-import org.jclouds.apis.ApiType;
-import org.jclouds.apis.BaseApiMetadata;
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.compute.internal.BaseComputeServiceApiMetadata;
+import org.jclouds.openstack.OpenStackAuthAsyncClient;
+
+import com.google.common.reflect.TypeToken;
/**
- * Implementation of {@link ApiMetadata} for Rackspace Cloud Servers API
+ * Implementation of {@link ApiMetadata} for CloudServers 1.0 API
*
* @author Adrian Cole
*/
-public class CloudServersApiMetadata extends BaseApiMetadata {
+public class CloudServersApiMetadata
+ extends
+ BaseComputeServiceApiMetadata, CloudServersApiMetadata> {
- public CloudServersApiMetadata() {
- this(builder()
- .id("cloudservers")
- .type(ApiType.COMPUTE)
- .name("Rackspace Cloud Servers API")
- .identityName("Username")
- .credentialName("API Key")
- .documentation(URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html")));
+ @Override
+ public Builder toBuilder() {
+ return new Builder().fromApiMetadata(this);
}
- // below are so that we can reuse builders, toString, hashCode, etc.
- // we have to set concrete classes here, as our base class cannot be
- // concrete due to serviceLoader
- protected CloudServersApiMetadata(Builder> builder) {
+ public CloudServersApiMetadata() {
+ this(new Builder());
+ }
+
+ protected CloudServersApiMetadata(Builder builder) {
super(builder);
}
- private static class ConcreteBuilder extends Builder {
+ protected static Properties defaultProperties() {
+ Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties();
+ return properties;
+ }
+
+ public static class Builder
+ extends
+ BaseComputeServiceApiMetadata.Builder, CloudServersApiMetadata> {
+
+ protected Builder() {
+ id("cloudservers")
+ .name("Rackspace Cloud Servers API")
+ .identityName("Username")
+ .credentialName("API Key")
+ .documentation(URI.create("http://docs.rackspacecloud.com/servers/api/v1.0/cs-devguide/content/ch01.html"))
+ .version(OpenStackAuthAsyncClient.VERSION)
+ .defaultEndpoint("https://auth.api.rackspacecloud.com")
+ .javaApi(CloudServersClient.class, CloudServersAsyncClient.class)
+ .defaultProperties(CloudServersApiMetadata.defaultProperties())
+ .contextBuilder(TypeToken.of(CloudServersContextBuilder.class));
+ }
@Override
public CloudServersApiMetadata build() {
return new CloudServersApiMetadata(this);
}
- }
- public static ConcreteBuilder builder() {
- return new ConcreteBuilder();
- }
+ @Override
+ public Builder fromApiMetadata(CloudServersApiMetadata in) {
+ super.fromApiMetadata(in);
+ return this;
+ }
- @Override
- public ConcreteBuilder toBuilder() {
- return builder().fromApiMetadata(this);
}
}
\ No newline at end of file
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersContextBuilder.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersContextBuilder.java
index 9c322927d5..52e43a7d3a 100644
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersContextBuilder.java
+++ b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersContextBuilder.java
@@ -19,35 +19,30 @@
package org.jclouds.cloudservers;
import java.util.List;
-import java.util.Properties;
import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule;
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
+import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextBuilder;
-import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
-import org.jclouds.logging.jdk.config.JDKLoggingModule;
+import org.jclouds.providers.ProviderMetadata;
-import com.google.inject.Injector;
import com.google.inject.Module;
/**
- * Creates {@link CloudServersComputeServiceContext} or {@link Injector} instances based on the most
- * commonly requested arguments.
- *
- * Note that Threadsafe objects will be bound as singletons to the Injector or Context provided.
- *
- *
- * If no Module
s are specified, the default {@link JDKLoggingModule logging} and
- * {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
*
* @author Adrian Cole
- * @see CloudServersComputeServiceContext
*/
-public class CloudServersContextBuilder extends
- ComputeServiceContextBuilder {
+public class CloudServersContextBuilder
+ extends
+ ComputeServiceContextBuilder, CloudServersApiMetadata> {
- public CloudServersContextBuilder(Properties props) {
- super(CloudServersClient.class, CloudServersAsyncClient.class, props);
+ public CloudServersContextBuilder(
+ ProviderMetadata, CloudServersApiMetadata> providerMetadata) {
+ super(providerMetadata);
+ }
+
+ public CloudServersContextBuilder(CloudServersApiMetadata apiMetadata) {
+ super(apiMetadata);
}
@Override
@@ -55,9 +50,8 @@ public class CloudServersContextBuilder extends
modules.add(new CloudServersComputeServiceContextModule());
}
- @Override
protected void addClientModule(List modules) {
modules.add(new CloudServersRestClientModule());
}
-}
+}
\ No newline at end of file
diff --git a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersPropertiesBuilder.java b/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersPropertiesBuilder.java
deleted file mode 100644
index b4af167dbe..0000000000
--- a/apis/cloudservers/src/main/java/org/jclouds/cloudservers/CloudServersPropertiesBuilder.java
+++ /dev/null
@@ -1,45 +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.cloudservers;
-
-import static org.jclouds.Constants.PROPERTY_API_VERSION;
-
-import java.util.Properties;
-
-import org.jclouds.PropertiesBuilder;
-import org.jclouds.openstack.OpenStackAuthAsyncClient;
-
-/**
- *
- * @author Dan Lo Bianco
- */
-public class CloudServersPropertiesBuilder extends PropertiesBuilder {
-
- @Override
- protected Properties defaultProperties() {
- Properties properties = super.defaultProperties();
- properties.setProperty(PROPERTY_API_VERSION, OpenStackAuthAsyncClient.VERSION);
- return properties;
- }
-
- public CloudServersPropertiesBuilder(Properties properties) {
- super(properties);
- }
-
-}
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java
index f4d822af98..6587b5ab3c 100644
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java
+++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersApiMetadataTest.java
@@ -18,8 +18,7 @@
*/
package org.jclouds.cloudservers;
-import org.jclouds.apis.ApiType;
-import org.jclouds.apis.BaseApiMetadataTest;
+import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest;
import org.testng.annotations.Test;
/**
@@ -27,9 +26,9 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "CloudServersApiMetadataTest")
-public class CloudServersApiMetadataTest extends BaseApiMetadataTest {
+public class CloudServersApiMetadataTest extends BaseComputeServiceApiMetadataTest {
public CloudServersApiMetadataTest() {
- super(new CloudServersApiMetadata(), ApiType.COMPUTE);
+ super(new CloudServersApiMetadata());
}
}
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java
index 50713095c9..829b7a8cef 100644
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java
+++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersAsyncClientTest.java
@@ -38,6 +38,7 @@ import java.util.Properties;
import javax.inject.Singleton;
import javax.ws.rs.core.MediaType;
+import org.jclouds.apis.ApiMetadata;
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
import org.jclouds.cloudservers.domain.BackupSchedule;
import org.jclouds.cloudservers.domain.DailyBackup;
@@ -60,14 +61,12 @@ import org.jclouds.openstack.keystone.v1_1.config.AuthenticationServiceModule.Ge
import org.jclouds.openstack.keystone.v1_1.domain.Auth;
import org.jclouds.openstack.keystone.v1_1.parse.ParseAuthTest;
import org.jclouds.rest.ConfiguresRestClient;
-import org.jclouds.rest.RestClientTest;
-import org.jclouds.rest.RestContextFactory;
-import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
+import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test;
@@ -84,7 +83,7 @@ import com.google.inject.TypeLiteral;
// NOTE:without testName, this will not call @Before* and fail w/NPE during
// surefire
@Test(groups = "unit", singleThreaded = true, testName = "CloudServersAsyncClientTest")
-public class CloudServersAsyncClientTest extends RestClientTest {
+public class CloudServersAsyncClientTest extends BaseAsyncClientTest {
private static final Class extends ListOptions[]> listOptionsVarargsClass = new ListOptions[] {}.getClass();
private static final Class extends CreateServerOptions[]> createServerOptionsVarargsClass = new CreateServerOptions[] {}
.getClass();
@@ -910,8 +909,8 @@ public class CloudServersAsyncClientTest extends RestClientTest createContextSpec() {
- return new RestContextFactory(setupRestProperties()).createContextSpec(provider, "user", "password", setupProperties());
+ protected ApiMetadata, ?, ?, ?> createApiMetadata() {
+ return new CloudServersApiMetadata();
}
@Override
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java
index 7835e6beee..3618a2c58e 100644
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java
+++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java
@@ -29,7 +29,6 @@ import java.io.IOException;
import java.lang.reflect.UndeclaredThrowableException;
import java.security.SecureRandom;
import java.util.Map;
-import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -45,19 +44,17 @@ import org.jclouds.cloudservers.domain.ServerStatus;
import org.jclouds.cloudservers.domain.SharedIpGroup;
import org.jclouds.cloudservers.domain.WeeklyBackup;
import org.jclouds.cloudservers.options.RebuildServerOptions;
-import org.jclouds.compute.BaseVersionedServiceLiveTest;
+import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.ExecResponse;
+import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.http.HttpResponseException;
import org.jclouds.io.Payload;
-import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.net.IPSocket;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.predicates.SocketOpen;
-import org.jclouds.rest.RestContextFactory;
import org.jclouds.ssh.SshClient;
import org.jclouds.ssh.SshException;
-import org.jclouds.sshj.config.SshjSshClientModule;
import org.jclouds.util.Strings2;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeGroups;
@@ -66,10 +63,8 @@ import org.testng.annotations.Test;
import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
import com.google.inject.Injector;
-import com.google.inject.Module;
/**
* Tests behavior of {@code CloudServersClient}
@@ -77,7 +72,10 @@ import com.google.inject.Module;
* @author Adrian Cole
*/
@Test(groups = "live", singleThreaded = true, testName = "CloudServersClientLiveTest")
-public class CloudServersClientLiveTest extends BaseVersionedServiceLiveTest {
+public class CloudServersClientLiveTest
+ extends
+ BaseComputeServiceContextLiveTest> {
+
public CloudServersClientLiveTest() {
provider = "cloudservers";
}
@@ -86,15 +84,11 @@ public class CloudServersClientLiveTest extends BaseVersionedServiceLiveTest {
protected SshClient.Factory sshFactory;
protected Predicate socketTester;
- @BeforeGroups(groups = { "live" })
- public void setupClient() {
- setupCredentials();
- Properties overrides = setupProperties();
-
- Injector injector = new RestContextFactory().createContextBuilder(provider,
- ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides)
- .buildInjector();
-
+ @BeforeGroups(groups = { "integration", "live" })
+ @Override
+ public void setupContext() {
+ super.setupContext();
+ Injector injector = context.utils().injector();
client = injector.getInstance(CloudServersClient.class);
sshFactory = injector.getInstance(SshClient.Factory.class);
SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java
index c725549435..d7af173018 100644
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java
+++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java
@@ -24,11 +24,10 @@ import java.io.IOException;
import org.jclouds.cloudservers.CloudServersAsyncClient;
import org.jclouds.cloudservers.CloudServersClient;
-import org.jclouds.compute.BaseComputeServiceLiveTest;
-import org.jclouds.compute.ComputeServiceContextFactory;
+import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
import org.jclouds.domain.LocationScope;
-import org.jclouds.rest.RestContext;
import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.annotations.Test;
@@ -41,7 +40,10 @@ import com.google.inject.Module;
* @author Adrian Cole
*/
@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CloudServersComputeServiceLiveTest")
-public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTest {
+public class CloudServersComputeServiceLiveTest
+ extends
+ BaseComputeServiceLiveTest> {
+
public CloudServersComputeServiceLiveTest() {
provider = "cloudservers";
}
@@ -51,12 +53,6 @@ public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTe
return new SshjSshClientModule();
}
- public void testAssignability() throws Exception {
- @SuppressWarnings("unused")
- RestContext tmContext = new ComputeServiceContextFactory()
- .createContext(provider, identity, credential).getProviderSpecificContext();
- }
-
@Override
protected void checkNodes(Iterable extends NodeMetadata> nodes, String group, String task) throws IOException {
super.checkNodes(nodes, group, task);
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java
index fd1e37bd06..71cc584289 100644
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java
+++ b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/internal/BaseCloudServersRestClientExpectTest.java
@@ -23,9 +23,9 @@ import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
import java.util.Date;
import java.util.Properties;
+import org.jclouds.apis.ApiMetadata;
+import org.jclouds.cloudservers.CloudServersApiMetadata;
import org.jclouds.cloudservers.CloudServersClient;
-import org.jclouds.cloudservers.CloudServersContextBuilder;
-import org.jclouds.cloudservers.CloudServersPropertiesBuilder;
import org.jclouds.cloudservers.config.CloudServersRestClientModule;
import org.jclouds.date.internal.SimpleDateFormatDateService;
import org.jclouds.http.RequiresHttp;
@@ -47,14 +47,18 @@ public class BaseCloudServersRestClientExpectTest extends BaseKeystoneRestClient
public BaseCloudServersRestClientExpectTest() {
provider = "cloudservers";
}
+
+ @Override
+ protected ApiMetadata, ?, ?, ?> createApiMetadata() {
+ return new CloudServersApiMetadata();
+ }
+
@Override
- protected Properties setupRestProperties() {
+ protected Properties setupProperties() {
Properties overrides = new Properties();
overrides.setProperty(PROPERTY_REGIONS, "US");
overrides.setProperty(provider + ".endpoint", endpoint);
- overrides.setProperty(provider + ".contextbuilder", CloudServersContextBuilder.class.getName());
- overrides.setProperty(provider + ".propertiesbuilder", CloudServersPropertiesBuilder.class.getName());
return overrides;
}
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java
index 7d9a7f992e..96cfb3893a 100644
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java
+++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaApiMetadata.java
@@ -18,51 +18,77 @@
*/
package org.jclouds.cloudsigma;
+import static org.jclouds.cloudsigma.reference.CloudSigmaConstants.PROPERTY_VNC_PASSWORD;
+
import java.net.URI;
+import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
-import org.jclouds.apis.ApiType;
-import org.jclouds.apis.BaseApiMetadata;
+import org.jclouds.compute.ComputeServiceContext;
+import org.jclouds.compute.internal.BaseComputeServiceApiMetadata;
+
+import com.google.common.reflect.TypeToken;
/**
* Implementation of {@link ApiMetadata} for the Cloud Sigma API
*
* @author Adrian Cole
*/
-public class CloudSigmaApiMetadata extends BaseApiMetadata {
+public class CloudSigmaApiMetadata
+ extends
+ BaseComputeServiceApiMetadata, CloudSigmaApiMetadata> {
- public CloudSigmaApiMetadata() {
- this(builder()
- .id("cloudsigma")
- .type(ApiType.COMPUTE)
- .name("CloudSigma API")
- .identityName("Email")
- .credentialName("Password")
- .documentation(URI.create("http://cloudsigma.com/en/platform-details/the-api")));
+ @Override
+ public Builder toBuilder() {
+ return new Builder().fromApiMetadata(this);
}
- // below are so that we can reuse builders, toString, hashCode, etc.
- // we have to set concrete classes here, as our base class cannot be
- // concrete due to serviceLoader
- protected CloudSigmaApiMetadata(Builder> builder) {
+ public CloudSigmaApiMetadata() {
+ this(new Builder());
+ }
+
+ protected CloudSigmaApiMetadata(Builder builder) {
super(builder);
}
- private static class ConcreteBuilder extends Builder {
+ protected static Properties defaultProperties() {
+ Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties();
+ properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d");
+ // passwords are set post-boot, so auth failures are possible
+ // from a race condition applying the password set script
+ properties.setProperty("jclouds.ssh.max-retries", "7");
+ properties.setProperty("jclouds.ssh.retry-auth", "true");
+ return properties;
+ }
+
+ public static class Builder
+ extends
+ BaseComputeServiceApiMetadata.Builder, CloudSigmaApiMetadata> {
+
+ protected Builder() {
+ id("cloudsigma")
+ .name("CloudSigma API")
+ .identityName("Email")
+ .credentialName("Password")
+ .documentation(URI.create("http://cloudsigma.com/en/platform-details/the-api"))
+ .version("1.0")
+ .defaultEndpoint("https://api.cloudsigma.com")
+ .defaultProperties(CloudSigmaApiMetadata.defaultProperties())
+ .javaApi(CloudSigmaClient.class, CloudSigmaAsyncClient.class)
+ .contextBuilder(TypeToken.of(CloudSigmaContextBuilder.class));
+ }
@Override
public CloudSigmaApiMetadata build() {
return new CloudSigmaApiMetadata(this);
}
- }
- public static ConcreteBuilder builder() {
- return new ConcreteBuilder();
- }
+ @Override
+ public Builder fromApiMetadata(CloudSigmaApiMetadata in) {
+ super.fromApiMetadata(in);
+ return this;
+ }
- @Override
- public ConcreteBuilder toBuilder() {
- return builder().fromApiMetadata(this);
}
}
\ No newline at end of file
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java
index c777e0e408..222e790707 100644
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java
+++ b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaContextBuilder.java
@@ -19,11 +19,12 @@
package org.jclouds.cloudsigma;
import java.util.List;
-import java.util.Properties;
import org.jclouds.cloudsigma.compute.config.CloudSigmaComputeServiceContextModule;
import org.jclouds.cloudsigma.config.CloudSigmaRestClientModule;
+import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextBuilder;
+import org.jclouds.providers.ProviderMetadata;
import com.google.inject.Module;
@@ -31,10 +32,17 @@ import com.google.inject.Module;
*
* @author Adrian Cole
*/
-public class CloudSigmaContextBuilder extends ComputeServiceContextBuilder {
+public class CloudSigmaContextBuilder
+ extends
+ ComputeServiceContextBuilder, CloudSigmaApiMetadata> {
- public CloudSigmaContextBuilder(Properties props) {
- super(CloudSigmaClient.class, CloudSigmaAsyncClient.class, props);
+ public CloudSigmaContextBuilder(
+ ProviderMetadata, CloudSigmaApiMetadata> providerMetadata) {
+ super(providerMetadata);
+ }
+
+ public CloudSigmaContextBuilder(CloudSigmaApiMetadata apiMetadata) {
+ super(apiMetadata);
}
@Override
diff --git a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaPropertiesBuilder.java b/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaPropertiesBuilder.java
deleted file mode 100644
index bf13f88b68..0000000000
--- a/apis/cloudsigma/src/main/java/org/jclouds/cloudsigma/CloudSigmaPropertiesBuilder.java
+++ /dev/null
@@ -1,50 +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.cloudsigma;
-
-import static org.jclouds.Constants.PROPERTY_API_VERSION;
-import static org.jclouds.cloudsigma.reference.CloudSigmaConstants.PROPERTY_VNC_PASSWORD;
-
-import java.util.Properties;
-
-import org.jclouds.PropertiesBuilder;
-
-/**
- * Builds properties used in CloudSigma Clients
- *
- * @author Adrian Cole
- */
-public class CloudSigmaPropertiesBuilder extends PropertiesBuilder {
- @Override
- protected Properties defaultProperties() {
- Properties properties = super.defaultProperties();
- properties.setProperty(PROPERTY_API_VERSION, "1.0");
- properties.setProperty(PROPERTY_VNC_PASSWORD, "IL9vs34d");
- // passwords are set post-boot, so auth failures are possible
- // from a race condition applying the password set script
- properties.setProperty("jclouds.ssh.max-retries", "7");
- properties.setProperty("jclouds.ssh.retry-auth", "true");
- return properties;
- }
-
- public CloudSigmaPropertiesBuilder(Properties properties) {
- super(properties);
- }
-
-}
diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java
index f5a9898fd0..3394075e41 100644
--- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java
+++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaApiMetadataTest.java
@@ -18,8 +18,7 @@
*/
package org.jclouds.cloudsigma;
-import org.jclouds.apis.ApiType;
-import org.jclouds.apis.BaseApiMetadataTest;
+import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest;
import org.testng.annotations.Test;
/**
@@ -27,9 +26,9 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "CloudSigmaApiMetadataTest")
-public class CloudSigmaApiMetadataTest extends BaseApiMetadataTest {
+public class CloudSigmaApiMetadataTest extends BaseComputeServiceApiMetadataTest {
public CloudSigmaApiMetadataTest() {
- super(new CloudSigmaApiMetadata(), ApiType.COMPUTE);
+ super(new CloudSigmaApiMetadata());
}
}
diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java
index 526ba3ef94..d7fafbaf17 100644
--- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java
+++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaAsyncClientTest.java
@@ -22,8 +22,8 @@ import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.lang.reflect.Method;
-import java.util.Properties;
+import org.jclouds.apis.ApiMetadata;
import org.jclouds.cloudsigma.binders.BindServerToPlainTextStringTest;
import org.jclouds.cloudsigma.domain.CreateDriveRequest;
import org.jclouds.cloudsigma.domain.Drive;
@@ -44,12 +44,10 @@ import org.jclouds.cloudsigma.options.CloneDriveOptions;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.filters.BasicAuthentication;
import org.jclouds.http.functions.ReleasePayloadAndReturn;
-import org.jclouds.rest.RestClientTest;
-import org.jclouds.rest.RestContextFactory;
-import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.functions.MapHttp4xxCodesToExceptions;
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
+import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.testng.annotations.Test;
@@ -64,7 +62,7 @@ import com.google.inject.TypeLiteral;
*/
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
@Test(groups = "unit", testName = "CloudSigmaAsyncClientTest")
-public class CloudSigmaAsyncClientTest extends RestClientTest {
+public class CloudSigmaAsyncClientTest extends BaseAsyncClientTest {
public void testGetProfileInfo() throws SecurityException, NoSuchMethodException, IOException {
Method method = CloudSigmaAsyncClient.class.getMethod("getProfileInfo");
@@ -243,7 +241,7 @@ public class CloudSigmaAsyncClientTest extends RestClientTest createContextSpec() {
- Properties props = new Properties();
- props.setProperty("cloudsigma.endpoint", "https://api.cloudsigma.com");
- return new RestContextFactory().createContextSpec("cloudsigma", "foo", "bar", props);
+ protected ApiMetadata, ?, ?, ?> createApiMetadata() {
+ return new CloudSigmaApiMetadata();
}
+
}
diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java
index babe31da6a..874a59309e 100644
--- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java
+++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/CloudSigmaClientLiveTest.java
@@ -22,7 +22,6 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import java.io.IOException;
-import java.util.Properties;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.logging.Logger;
@@ -44,12 +43,10 @@ import org.jclouds.cloudsigma.domain.VLANInfo;
import org.jclouds.cloudsigma.options.CloneDriveOptions;
import org.jclouds.cloudsigma.predicates.DriveClaimed;
import org.jclouds.cloudsigma.util.Servers;
-import org.jclouds.compute.BaseVersionedServiceLiveTest;
import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.compute.domain.ExecResponse;
+import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
import org.jclouds.domain.LoginCredentials;
-import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.net.IPSocket;
import org.jclouds.predicates.InetSocketAddressConnect;
import org.jclouds.predicates.RetryablePredicate;
@@ -67,7 +64,6 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.gson.Gson;
import com.google.inject.Guice;
-import com.google.inject.Module;
/**
* Tests behavior of {@code CloudSigmaClient}
@@ -75,37 +71,37 @@ import com.google.inject.Module;
* @author Adrian Cole
*/
@Test(groups = "live", singleThreaded = true, testName = "CloudSigmaClientLiveTest")
-public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest {
+public class CloudSigmaClientLiveTest
+ extends
+ BaseComputeServiceContextLiveTest> {
+
public CloudSigmaClientLiveTest() {
provider = "cloudsigma";
}
-
+
protected long driveSize = 8 * 1024 * 1024 * 1024l;
protected int maxDriveImageTime = 300;
protected String vncPassword = "Il0veVNC";
protected CloudSigmaClient client;
- protected RestContext context;
+ protected RestContext cloudSigmaContext;
protected Predicate socketTester;
protected Predicate driveNotClaimed;
- protected ComputeServiceContext computeContext;
+
+ @BeforeGroups(groups = { "integration", "live" })
+ @Override
+ public void setupContext() {
+ super.setupContext();
+ cloudSigmaContext = context.getProviderSpecificContext();
- @BeforeGroups(groups = "live")
- public void setupClient() {
- setupCredentials();
- Properties overrides = setupProperties();
- computeContext = new ComputeServiceContextFactory().createContext(provider,
- ImmutableSet. of(new Log4JLoggingModule()), overrides);
- context = computeContext.getProviderSpecificContext();
-
- client = context.getApi();
+ client = cloudSigmaContext.getApi();
driveNotClaimed = new RetryablePredicate(Predicates.not(new DriveClaimed(client)), maxDriveImageTime,
1, TimeUnit.SECONDS);
socketTester = new RetryablePredicate(new InetSocketAddressConnect(), maxDriveImageTime, 1,
TimeUnit.SECONDS);
-
+
if (Strings.emptyToNull(imageId) == null) {
- imageId = computeContext.getComputeService().templateBuilder().build().getImage().getId();
+ imageId = context.getComputeService().templateBuilder().build().getImage().getId();
}
}
@@ -259,7 +255,7 @@ public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest {
String prefix2 = prefix + "2";
vlan = client.renameVLAN(vlan.getUuid(), prefix2);
- assertEquals(vlan.getName(),prefix2);
+ assertEquals(vlan.getName(), prefix2);
} finally {
client.destroyVLAN(id);
}
@@ -354,7 +350,8 @@ public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest {
assertEquals(client.getServerInfo(server.getUuid()).getStatus(), ServerStatus.ACTIVE);
client.shutdownServer(server.getUuid());
- // behavior on shutdown depends on how your server OS is set up to respond to an ACPI power
+ // behavior on shutdown depends on how your server OS is set up to respond
+ // to an ACPI power
// button signal
assert (client.getServerInfo(server.getUuid()).getStatus() == ServerStatus.ACTIVE || client.getServerInfo(
server.getUuid()).getStatus() == ServerStatus.STOPPED);
@@ -415,8 +412,8 @@ public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest {
client.destroyServer(server.getUuid());
if (server != null)
client.destroyDrive(drive.getUuid());
- if (context != null)
- context.close();
+ if (cloudSigmaContext != null)
+ cloudSigmaContext.close();
}
@Test
@@ -444,13 +441,10 @@ public class CloudSigmaClientLiveTest extends BaseVersionedServiceLiveTest {
protected void prepareDrive() {
client.destroyDrive(drive.getUuid());
drive = client.cloneDrive(imageId, drive.getName(),
- new CloneDriveOptions()
- .size(driveSize)
- .tags("cat:mouse", "monkey:banana")
- );
+ new CloneDriveOptions().size(driveSize).tags("cat:mouse", "monkey:banana"));
// Block until the async clone operation has completed.
assert driveNotClaimed.apply(drive) : client.getDriveInfo(drive.getUuid());
-
+
DriveInfo clonedDrive = client.getDriveInfo(drive.getUuid());
System.err.println("after prepare" + clonedDrive);
assertEquals(clonedDrive.getTags(), ImmutableSet.of("cat:mouse", "monkey:banana"));
diff --git a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java
index 3410c37a60..7022468935 100644
--- a/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java
+++ b/apis/cloudsigma/src/test/java/org/jclouds/cloudsigma/compute/CloudSigmaComputeServiceLiveTest.java
@@ -18,9 +18,12 @@
*/
package org.jclouds.cloudsigma.compute;
-import org.jclouds.compute.BaseComputeServiceLiveTest;
+import org.jclouds.cloudsigma.CloudSigmaAsyncClient;
+import org.jclouds.cloudsigma.CloudSigmaClient;
+import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.domain.ExecResponse;
import org.jclouds.compute.domain.NodeMetadata;
+import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.annotations.Test;
@@ -31,7 +34,10 @@ import com.google.inject.Module;
* @author Adrian Cole
*/
@Test(groups = "live")
-public class CloudSigmaComputeServiceLiveTest extends BaseComputeServiceLiveTest {
+public class CloudSigmaComputeServiceLiveTest
+ extends
+ BaseComputeServiceLiveTest> {
+
public CloudSigmaComputeServiceLiveTest() {
provider = "cloudsigma";
}
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java
index d1b30a7e45..80f97b45cf 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackApiMetadata.java
@@ -19,50 +19,81 @@
package org.jclouds.cloudstack;
import java.net.URI;
+import java.util.Properties;
import org.jclouds.apis.ApiMetadata;
-import org.jclouds.apis.ApiType;
-import org.jclouds.apis.BaseApiMetadata;
+import org.jclouds.compute.internal.BaseComputeServiceApiMetadata;
+
+import com.google.common.reflect.TypeToken;
/**
- * Implementation of {@link ApiMetadata} for Citrix CloudStack API
+ * Implementation of {@link ApiMetadata} for Citrix/Apache CloudStack api.
+ *
+ * note
+ *
+ * This class allows overriding of types {@code S}(client) and {@code A}
+ * (asyncClient), so that children can add additional methods not declared here,
+ * such as new features from AWS.
+ *
+ *
+ * As this is a popular api, we also allow overrides for type {@code C}
+ * (context). This allows subtypes to add in new feature groups or extensions,
+ * not present in the base api. For example, you could make a subtype for
+ * context, that exposes admin operations.
*
* @author Adrian Cole
*/
-public class CloudStackApiMetadata extends BaseApiMetadata {
+public class CloudStackApiMetadata extends BaseComputeServiceApiMetadata
+{
- public CloudStackApiMetadata() {
- this(builder()
- .id("cloudstack")
- .type(ApiType.COMPUTE)
- .name("Citrix CloudStack API")
- .identityName("API Key")
- .credentialName("Secret Key")
- .documentation(URI.create("http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html")));
+ @Override
+ public Builder toBuilder() {
+ return new Builder().fromApiMetadata(this);
}
- // below are so that we can reuse builders, toString, hashCode, etc.
- // we have to set concrete classes here, as our base class cannot be
- // concrete due to serviceLoader
- protected CloudStackApiMetadata(Builder> builder) {
+ public CloudStackApiMetadata() {
+ this(new Builder());
+ }
+
+ protected CloudStackApiMetadata(Builder builder) {
super(builder);
}
- private static class ConcreteBuilder extends Builder {
+ protected static Properties defaultProperties() {
+ Properties properties = BaseComputeServiceApiMetadata.Builder.defaultProperties();
+ properties.setProperty("jclouds.ssh.max-retries", "7");
+ properties.setProperty("jclouds.ssh.retry-auth", "true");
+ return properties;
+ }
+ public static class Builder
+ extends BaseComputeServiceApiMetadata.Builder {
+
+ protected Builder() {
+ id("cloudstack")
+ .name("Citrix CloudStack API")
+ .identityName("API Key")
+ .credentialName("Secret Key")
+ .documentation(URI.create("http://download.cloud.com/releases/2.2.0/api_2.2.12/TOC_User.html"))
+ .defaultEndpoint("http://localhost:8080/client/api")
+ .version("2.2")
+ .defaultProperties(CloudStackApiMetadata.defaultProperties())
+ .javaApi(CloudStackClient.class, CloudStackAsyncClient.class)
+ .context(TypeToken.of(CloudStackContext.class))
+ .contextBuilder(TypeToken.of(CloudStackContextBuilder.class));
+ }
+
@Override
public CloudStackApiMetadata build() {
return new CloudStackApiMetadata(this);
}
- }
+
+ @Override
+ public Builder fromApiMetadata(CloudStackApiMetadata in) {
+ super.fromApiMetadata(in);
+ return this;
+ }
- public static ConcreteBuilder builder() {
- return new ConcreteBuilder();
- }
-
- @Override
- public ConcreteBuilder toBuilder() {
- return builder().fromApiMetadata(this);
}
}
\ No newline at end of file
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContext.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContext.java
index 1eb716f5a4..add5192c58 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContext.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContext.java
@@ -31,9 +31,8 @@ import com.google.inject.ImplementedBy;
*
*/
@ImplementedBy(CloudStackContextImpl.class)
-public interface CloudStackContext extends ComputeServiceContext {
+public interface CloudStackContext extends ComputeServiceContext {
- @SuppressWarnings("unchecked")
@Override
RestContext getProviderSpecificContext();
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java
index f1fa6232e9..904972e5ac 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackContextBuilder.java
@@ -23,24 +23,26 @@ import java.util.Properties;
import org.jclouds.cloudstack.compute.config.CloudStackComputeServiceContextModule;
import org.jclouds.cloudstack.config.CloudStackRestClientModule;
-import org.jclouds.cloudstack.internal.CloudStackContextImpl;
import org.jclouds.compute.ComputeServiceContextBuilder;
+import org.jclouds.providers.ProviderMetadata;
+import com.google.common.annotations.VisibleForTesting;
import com.google.inject.Module;
/**
*
* @author Adrian Cole
*/
-public class CloudStackContextBuilder extends ComputeServiceContextBuilder {
+public class CloudStackContextBuilder extends
+ ComputeServiceContextBuilder {
- public CloudStackContextBuilder(Properties props) {
- super(CloudStackClient.class, CloudStackAsyncClient.class, props);
+ public CloudStackContextBuilder(
+ ProviderMetadata providerMetadata) {
+ super(providerMetadata);
}
- @Override
- protected void addContextModule(List modules) {
- modules.add(new CloudStackComputeServiceContextModule());
+ public CloudStackContextBuilder(CloudStackApiMetadata apiMetadata) {
+ super(apiMetadata);
}
@Override
@@ -49,7 +51,13 @@ public class CloudStackContextBuilder extends ComputeServiceContextBuilder modules) {
+ modules.add(new CloudStackComputeServiceContextModule());
}
+
+ @VisibleForTesting
+ public Properties getOverrides() {
+ return overrides;
+ }
+
}
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackPropertiesBuilder.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackPropertiesBuilder.java
deleted file mode 100644
index a271e36510..0000000000
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/CloudStackPropertiesBuilder.java
+++ /dev/null
@@ -1,48 +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.cloudstack;
-
-import static org.jclouds.Constants.PROPERTY_API_VERSION;
-import static org.jclouds.Constants.PROPERTY_ENDPOINT;
-
-import java.util.Properties;
-
-import org.jclouds.PropertiesBuilder;
-
-/**
- * Builds properties used in cloudstack Clients
- *
- * @author Adrian Cole
- */
-public class CloudStackPropertiesBuilder extends PropertiesBuilder {
- @Override
- protected Properties defaultProperties() {
- Properties properties = super.defaultProperties();
- properties.setProperty(PROPERTY_ENDPOINT, "http://localhost:8080/client/api");
- properties.setProperty(PROPERTY_API_VERSION, "2.2");
- properties.setProperty("jclouds.ssh.max-retries", "7");
- properties.setProperty("jclouds.ssh.retry-auth", "true");
- return properties;
- }
-
- public CloudStackPropertiesBuilder(Properties properties) {
- super(properties);
- }
-
-}
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java
index 3995f1cfd7..4508246b79 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/config/CloudStackProperties.java
@@ -18,7 +18,7 @@
*/
package org.jclouds.cloudstack.config;
-import org.jclouds.compute.ComputeServiceContextFactory;
+import org.jclouds.compute.ComputeServiceContextBuilder;
/**
* Configuration properties and constants used in CloudStack connections.
@@ -28,7 +28,7 @@ import org.jclouds.compute.ComputeServiceContextFactory;
public interface CloudStackProperties {
/**
- * Type of credentials specified during {@link ComputeServiceContextFactory#createContext}. If
+ * Type of credentials specified during {@link ComputeServiceContextBuilder#overrides}. If
* {@link CredentialType#API_ACCESS_KEY_CREDENTIALS}, the request signing is used. If
* {@link CredentialType#PASSWORD_CREDENTIALS}, login will happen and a session will be
* persisted.
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java
index 34b8e7077d..2be7231dd2 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/internal/CloudStackContextImpl.java
@@ -57,7 +57,6 @@ public class CloudStackContextImpl extends ComputeServiceContextImpl getProviderSpecificContext() {
return providerSpecificContext;
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/util/ApiKeyPairs.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/util/ApiKeyPairs.java
index 4e9ee91773..1683fd9524 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/util/ApiKeyPairs.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/util/ApiKeyPairs.java
@@ -26,24 +26,19 @@ import java.util.Properties;
import java.util.Set;
import org.jclouds.Constants;
+import org.jclouds.cloudstack.CloudStackApiMetadata;
import org.jclouds.cloudstack.CloudStackClient;
+import org.jclouds.cloudstack.CloudStackContext;
import org.jclouds.cloudstack.domain.Account;
import org.jclouds.cloudstack.domain.ApiKeyPair;
import org.jclouds.cloudstack.domain.User;
-import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.compute.ComputeServiceContextFactory;
-import org.jclouds.rest.RestContextFactory;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
+import org.jclouds.compute.ComputeServiceContextBuilder;
/**
* @author Andrei Savu
*/
public class ApiKeyPairs {
- private final static String PROVIDER = "cloudstack";
-
/**
* Retrieve the API key pair for a given CloudStack user
*
@@ -60,10 +55,17 @@ public class ApiKeyPairs {
*/
public static ApiKeyPair loginToEndpointAsUsernameInDomainWithPasswordAndReturnApiKeyPair(
URI endpoint, String username, String password, String domain) {
- ComputeServiceContext context = null;
+ CloudStackContext context = null;
try {
- context = new ComputeServiceContextFactory(setupRestProperties()).
- createContext(PROVIDER, ImmutableSet.of(), setupProperties(endpoint, username, password, domain));
+ Properties overrides = new Properties();
+ overrides.put(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
+ overrides.put(Constants.PROPERTY_RELAX_HOSTNAME, "true");
+ overrides.put("jclouds.cloudstack.credential-type", "passwordCredentials");
+
+ context = ComputeServiceContextBuilder.newBuilder(new CloudStackApiMetadata())
+ .endpoint(checkNotNull(endpoint, "endpoint").toASCIIString())
+ .credentials(String.format("%s/%s", checkNotNull(domain, "domain"), checkNotNull(username, "username")), password)
+ .overrides(overrides).build();
CloudStackClient client = CloudStackClient.class.cast(context.getProviderSpecificContext().getApi());
Set listOfAccounts = client.getAccountClient().listAccounts();
@@ -85,23 +87,4 @@ public class ApiKeyPairs {
}
}
- private static Properties setupRestProperties() {
- return RestContextFactory.getPropertiesFromResource("/rest.properties");
- }
-
- private static Properties setupProperties(URI endpoint, String username, String password, String domain) {
- Properties overrides = new Properties();
-
- overrides.put(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
- overrides.put(Constants.PROPERTY_RELAX_HOSTNAME, "true");
-
- overrides.put("jclouds.cloudstack.credential-type", "passwordCredentials");
-
- overrides.put(PROVIDER + ".endpoint", checkNotNull(endpoint, "endpoint").toASCIIString());
- overrides.put(PROVIDER + ".identity",
- String.format("%s/%s", checkNotNull(domain, "domain"), checkNotNull(username, "username")));
- overrides.put(PROVIDER + ".credential", checkNotNull(password, "password"));
-
- return overrides;
- }
}
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/CloudStackApiMetadataTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/CloudStackApiMetadataTest.java
index d2d5676dad..81c9746861 100644
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/CloudStackApiMetadataTest.java
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/CloudStackApiMetadataTest.java
@@ -18,8 +18,7 @@
*/
package org.jclouds.cloudstack;
-import org.jclouds.apis.ApiType;
-import org.jclouds.apis.BaseApiMetadataTest;
+import org.jclouds.compute.internal.BaseComputeServiceApiMetadataTest;
import org.testng.annotations.Test;
/**
@@ -27,9 +26,9 @@ import org.testng.annotations.Test;
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "CloudStackApiMetadataTest")
-public class CloudStackApiMetadataTest extends BaseApiMetadataTest {
+public class CloudStackApiMetadataTest extends BaseComputeServiceApiMetadataTest {
public CloudStackApiMetadataTest() {
- super(new CloudStackApiMetadata(), ApiType.COMPUTE);
+ super(new CloudStackApiMetadata());
}
}
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java
index 791e1d9047..8dad16187e 100644
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/compute/CloudStackComputeServiceAdapterLiveTest.java
@@ -23,9 +23,7 @@ import static com.google.inject.name.Names.bindProperties;
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.fail;
-import java.io.IOException;
import java.util.Map;
import java.util.Random;
import java.util.Set;
@@ -97,21 +95,21 @@ public class CloudStackComputeServiceAdapterLiveTest extends BaseCloudStackClien
Map credentialStore = Maps.newLinkedHashMap();
@BeforeGroups(groups = { "live" })
- public void setupClient() {
- super.setupClient();
+ public void setupContext() {
+ super.setupContext();
Module module = new AbstractModule() {
@Override
protected void configure() {
bindProperties(binder(), setupProperties());
- bind(String.class).annotatedWith(Identity.class).toInstance(identity);
+ bind(String.class).annotatedWith(Identity.class).toInstance(context.getProviderSpecificContext().getIdentity());
bind(new TypeLiteral>() {
}).annotatedWith(Memoized.class).to(GetCurrentUser.class).in(Scopes.SINGLETON);
bind(new TypeLiteral>>() {
}).annotatedWith(Memoized.class).to(NetworksForCurrentUser.class).in(Scopes.SINGLETON);
bind(new TypeLiteral