diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java index 9a8369f897..91fd1fbd2f 100644 --- a/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java +++ b/apis/vcloud/src/test/java/org/jclouds/vcloud/internal/BaseVCloudClientLiveTest.java @@ -25,6 +25,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; import org.jclouds.Constants; +import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.logging.log4j.config.Log4JLoggingModule; @@ -44,43 +45,19 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public abstract class BaseVCloudClientLiveTest { +public abstract class BaseVCloudClientLiveTest extends BaseVersionedServiceLiveTest { protected String prefix = System.getProperty("user.name"); protected ComputeService client; - protected String provider = "vcloud"; - protected String identity; - protected String credential; - protected String endpoint; - protected String apiversion; + public BaseVCloudClientLiveTest() { + provider = "vcloud"; + } protected VCloudClient getVCloudApi() { return VCloudClient.class.cast(client.getContext().getProviderSpecificContext().getApi()); } - @BeforeClass - protected void setupCredentials() { - identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"); - credential = System.getProperty("test." + provider + ".credential"); - endpoint = System.getProperty("test." + provider + ".endpoint"); - apiversion = System.getProperty("test." + provider + ".apiversion"); - } - - protected Properties setupProperties() { - Properties overrides = new Properties(); - overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); - overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); - overrides.setProperty(provider + ".identity", identity); - if (credential != null) - overrides.setProperty(provider + ".credential", credential); - if (endpoint != null) - overrides.setProperty(provider + ".endpoint", endpoint); - if (apiversion != null) - overrides.setProperty(provider + ".apiversion", apiversion); - return overrides; - } - @BeforeGroups(groups = { "live" }) public void setupClient() { setupCredentials(); diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java index 5eea4fdc51..7d8d2c15af 100644 --- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java +++ b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkClientLiveTest.java @@ -25,7 +25,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.jclouds.Constants; +import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.compute.ComputeService; import org.jclouds.compute.ComputeServiceContextFactory; import org.jclouds.logging.log4j.config.Log4JLoggingModule; @@ -37,7 +37,6 @@ import org.jclouds.ssh.SshClient.Factory; import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient; import org.testng.annotations.AfterGroups; -import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeGroups; import org.testng.annotations.Test; @@ -50,16 +49,14 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live", enabled = true, singleThreaded = true) -public abstract class BaseTerremarkClientLiveTest { +public abstract class BaseTerremarkClientLiveTest extends BaseVersionedServiceLiveTest { protected String prefix = System.getProperty("user.name"); protected ComputeService client; - protected String provider = "trmk-ecloud"; - protected String identity; - protected String credential; - protected String endpoint; - protected String apiversion; + public BaseTerremarkClientLiveTest() { + provider = "trmk-ecloud"; + } protected RetryablePredicate socketTester; protected Factory sshFactory; @@ -69,28 +66,6 @@ public abstract class BaseTerremarkClientLiveTest keyPair; - protected String provider; - protected String identity; - protected String credential; - protected String endpoint; - protected String apiversion; - - protected Properties setupProperties() { - Properties overrides = new Properties(); - overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); - overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); - overrides.setProperty(provider + ".identity", identity); - if (credential != null) - overrides.setProperty(provider + ".credential", credential); - if (endpoint != null) - overrides.setProperty(provider + ".endpoint", endpoint); - if (apiversion != null) - overrides.setProperty(provider + ".apiversion", apiversion); - return overrides; - } - @BeforeGroups(groups = { "integration", "live" }) public void setupClient() throws InterruptedException, ExecutionException, TimeoutException, IOException { setServiceDefaults(); @@ -172,13 +152,6 @@ public abstract class BaseComputeServiceLiveTest { } - protected void setupCredentials() { - identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"); - credential = System.getProperty("test." + provider + ".credential"); - endpoint = System.getProperty("test." + provider + ".endpoint"); - apiversion = System.getProperty("test." + provider + ".apiversion"); - } - protected void setupKeyPairForTest() throws FileNotFoundException, IOException { keyPair = ComputeTestUtils.setupKeyPair(); } diff --git a/compute/src/test/java/org/jclouds/compute/BaseVersionedServiceLiveTest.java b/compute/src/test/java/org/jclouds/compute/BaseVersionedServiceLiveTest.java new file mode 100644 index 0000000000..ccdd026ebb --- /dev/null +++ b/compute/src/test/java/org/jclouds/compute/BaseVersionedServiceLiveTest.java @@ -0,0 +1,71 @@ +/** + * 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.compute; + +import org.jclouds.Constants; +import org.testng.annotations.BeforeClass; + +import java.util.Properties; + +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Strings.emptyToNull; + +/** + * + * @author Jason King + */ +public abstract class BaseVersionedServiceLiveTest { + + protected String provider; + protected String identity; + protected String credential; + protected String endpoint; + protected String apiversion; + + protected Properties setupProperties() { + + if (emptyToNull(provider) == null) throw new NullPointerException("provider must not be null or empty:"+provider); + if (emptyToNull(identity) == null) throw new NullPointerException("identity must not be null or empty:"+provider); + + Properties overrides = new Properties(); + overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); + overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); + + overrides.setProperty(provider + ".identity", identity); + + if (credential != null) + overrides.setProperty(provider + ".credential", credential); + if (endpoint != null) + overrides.setProperty(provider + ".endpoint", endpoint); + if (apiversion != null) + overrides.setProperty(provider + ".apiversion", apiversion); + + return overrides; + } + + @BeforeClass + protected void setupCredentials() { + identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"); + credential = System.getProperty("test." + provider + ".credential"); + endpoint = System.getProperty("test." + provider + ".endpoint"); + apiversion = System.getProperty("test." + provider + ".apiversion"); + } + + +} diff --git a/sandbox-providers/trmk-enterprisecloud/pom.xml b/sandbox-providers/trmk-enterprisecloud/pom.xml index 346302da5b..4741c64504 100644 --- a/sandbox-providers/trmk-enterprisecloud/pom.xml +++ b/sandbox-providers/trmk-enterprisecloud/pom.xml @@ -48,10 +48,10 @@ - http://209.251.187.125/livespec + https://services-beta.enterprisecloud.terremark.com/cloudapi 2011-07-01 - readonly@terremark.com - T3rr3m@rk + FIXME + FIXME diff --git a/sandbox-providers/trmk-enterprisecloud/src/main/java/org/jclouds/trmk/enterprisecloud/TerremarkEnterpriseCloudPropertiesBuilder.java b/sandbox-providers/trmk-enterprisecloud/src/main/java/org/jclouds/trmk/enterprisecloud/TerremarkEnterpriseCloudPropertiesBuilder.java index 8c50bb1a92..cdf78549e2 100644 --- a/sandbox-providers/trmk-enterprisecloud/src/main/java/org/jclouds/trmk/enterprisecloud/TerremarkEnterpriseCloudPropertiesBuilder.java +++ b/sandbox-providers/trmk-enterprisecloud/src/main/java/org/jclouds/trmk/enterprisecloud/TerremarkEnterpriseCloudPropertiesBuilder.java @@ -34,8 +34,7 @@ public class TerremarkEnterpriseCloudPropertiesBuilder extends PropertiesBuilder @Override protected Properties defaultProperties() { Properties properties = super.defaultProperties(); - // TODO replace with the actual rest url - properties.setProperty(PROPERTY_ENDPOINT, "http://209.251.187.125/livespec"); + properties.setProperty(PROPERTY_ENDPOINT, "https://services-beta.enterprisecloud.terremark.com/cloudapi"); properties.setProperty(PROPERTY_API_VERSION, "2011-07-01"); return properties; } diff --git a/sandbox-providers/trmk-enterprisecloud/src/test/java/org/jclouds/trmk/enterprisecloud/features/BaseTerremarkEnterpriseCloudClientLiveTest.java b/sandbox-providers/trmk-enterprisecloud/src/test/java/org/jclouds/trmk/enterprisecloud/features/BaseTerremarkEnterpriseCloudClientLiveTest.java index d51c6d13fc..27bc89286e 100644 --- a/sandbox-providers/trmk-enterprisecloud/src/test/java/org/jclouds/trmk/enterprisecloud/features/BaseTerremarkEnterpriseCloudClientLiveTest.java +++ b/sandbox-providers/trmk-enterprisecloud/src/test/java/org/jclouds/trmk/enterprisecloud/features/BaseTerremarkEnterpriseCloudClientLiveTest.java @@ -20,6 +20,7 @@ package org.jclouds.trmk.enterprisecloud.features; import java.util.Properties; +import org.jclouds.compute.BaseVersionedServiceLiveTest; import org.jclouds.logging.log4j.config.Log4JLoggingModule; import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContextFactory; @@ -39,21 +40,22 @@ import com.google.inject.Module; * @author Adrian Cole */ @Test(groups = "live") -public class BaseTerremarkEnterpriseCloudClientLiveTest { +public class BaseTerremarkEnterpriseCloudClientLiveTest extends BaseVersionedServiceLiveTest { protected RestContext context; protected Module module; + public BaseTerremarkEnterpriseCloudClientLiveTest() { + provider = "trmk-enterprisecloud"; + } + @BeforeGroups(groups = { "live" }) public void setupClient() { - // TODO organize this like other compute tests - String identity = System.getProperty("test.trmk-enterprisecloud.identity", "readonly@terremark.com"); - String credential = System.getProperty("test.trmk-enterprisecloud.credential", "T3rr3m@rk"); + setupCredentials(); + Properties overrides = setupProperties(); - Properties props = new Properties(); - - context = new RestContextFactory().createContext("trmk-enterprisecloud", identity, credential, - ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), props); + context = new RestContextFactory().createContext(provider, identity, credential, + ImmutableSet. of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides); } @AfterGroups(groups = "live") diff --git a/sandbox-providers/trmk-enterprisecloud/src/test/java/org/jclouds/trmk/enterprisecloud/features/TaskClientLiveTest.java b/sandbox-providers/trmk-enterprisecloud/src/test/java/org/jclouds/trmk/enterprisecloud/features/TaskClientLiveTest.java index 09cd937d64..775266d59c 100644 --- a/sandbox-providers/trmk-enterprisecloud/src/test/java/org/jclouds/trmk/enterprisecloud/features/TaskClientLiveTest.java +++ b/sandbox-providers/trmk-enterprisecloud/src/test/java/org/jclouds/trmk/enterprisecloud/features/TaskClientLiveTest.java @@ -47,7 +47,7 @@ public class TaskClientLiveTest extends BaseTerremarkEnterpriseCloudClientLiveTe // TODO: don't hard-code id // TODO: docs say don't parse the href, yet no xml includes "identifier", // I suspect we may need to change to URI args as opposed to long - Set response = client.getTasksInEnvironment(1); + Set response = client.getTasksInEnvironment(77); assert null != response; assertTrue(response.size() >= 0);