From 7206ca1892a345ca6d01948d21b6b5838ca0d345 Mon Sep 17 00:00:00 2001 From: Jason King Date: Fri, 18 Nov 2011 12:13:55 +0000 Subject: [PATCH] Issue 695: Added live test for VirtualMachineClient. Hardcodes exising vm for now --- .../TerremarkEnterpriseCloudAsyncClient.java | 7 +++ .../TerremarkEnterpriseCloudClient.java | 7 +++ ...remarkEnterpriseCloudRestClientModule.java | 7 ++- .../VirtualMachineClientLiveTest.java | 49 +++++++++++++++++++ .../xml/VirtualMachineJAXBParsingTest.java | 1 - 5 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClientLiveTest.java diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/TerremarkEnterpriseCloudAsyncClient.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/TerremarkEnterpriseCloudAsyncClient.java index 99d7e734f2..ffb9417a55 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/TerremarkEnterpriseCloudAsyncClient.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/TerremarkEnterpriseCloudAsyncClient.java @@ -20,6 +20,7 @@ package org.jclouds.tmrk.enterprisecloud; import org.jclouds.rest.annotations.Delegate; import org.jclouds.tmrk.enterprisecloud.features.TaskAsyncClient; +import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineAsyncClient; /** * Provides asynchronous access to TerremarkEnterpriseCloud via their REST API. @@ -38,4 +39,10 @@ public interface TerremarkEnterpriseCloudAsyncClient { */ @Delegate TaskAsyncClient getTaskClient(); + + /** + * Provides asynchronous access to VirtualMachine features. + */ + @Delegate + VirtualMachineAsyncClient getVirtualMachineClient(); } diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/TerremarkEnterpriseCloudClient.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/TerremarkEnterpriseCloudClient.java index cd3741c797..eab698ac66 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/TerremarkEnterpriseCloudClient.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/TerremarkEnterpriseCloudClient.java @@ -23,6 +23,7 @@ import java.util.concurrent.TimeUnit; import org.jclouds.concurrent.Timeout; import org.jclouds.rest.annotations.Delegate; import org.jclouds.tmrk.enterprisecloud.features.TaskClient; +import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineClient; /** * Provides synchronous access to TerremarkEnterpriseCloud. @@ -42,4 +43,10 @@ public interface TerremarkEnterpriseCloudClient { */ @Delegate TaskClient getTaskClient(); + + /** + * Provides synchronous access to VirtualMachine features. + */ + @Delegate + VirtualMachineClient getVirtualMachineClient(); } diff --git a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/config/TerremarkEnterpriseCloudRestClientModule.java b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/config/TerremarkEnterpriseCloudRestClientModule.java index 37eaa46335..92e73f0227 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/config/TerremarkEnterpriseCloudRestClientModule.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/main/java/org/jclouds/tmrk/enterprisecloud/config/TerremarkEnterpriseCloudRestClientModule.java @@ -33,6 +33,8 @@ import org.jclouds.tmrk.enterprisecloud.TerremarkEnterpriseCloudAsyncClient; import org.jclouds.tmrk.enterprisecloud.TerremarkEnterpriseCloudClient; import org.jclouds.tmrk.enterprisecloud.features.TaskAsyncClient; import org.jclouds.tmrk.enterprisecloud.features.TaskClient; +import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineAsyncClient; +import org.jclouds.tmrk.enterprisecloud.features.VirtualMachineClient; import org.jclouds.tmrk.enterprisecloud.handlers.TerremarkEnterpriseCloudErrorHandler; import com.google.common.collect.ImmutableMap; @@ -47,8 +49,9 @@ import com.google.common.collect.ImmutableMap; public class TerremarkEnterpriseCloudRestClientModule extends RestClientModule { - public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder()// - .put(TaskClient.class, TaskAsyncClient.class)// + public static final Map, Class> DELEGATE_MAP = ImmutableMap., Class> builder() + .put(TaskClient.class, TaskAsyncClient.class) + .put(VirtualMachineClient.class, VirtualMachineAsyncClient.class) .build(); public TerremarkEnterpriseCloudRestClientModule() { diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClientLiveTest.java b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClientLiveTest.java new file mode 100644 index 0000000000..af4978b5f5 --- /dev/null +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/features/VirtualMachineClientLiveTest.java @@ -0,0 +1,49 @@ +/** + * 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.tmrk.enterprisecloud.features; + +import org.jclouds.tmrk.enterprisecloud.domain.VirtualMachine; +import org.testng.annotations.BeforeGroups; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; + +/** + * Tests behavior of {@code VirtualMachineClient} + * + * @author Jason King + */ +@Test(groups = "live", testName = "VirtualMachineClientLiveTest") +public class VirtualMachineClientLiveTest extends BaseTerremarkEnterpriseCloudClientLiveTest { + @BeforeGroups(groups = { "live" }) + public void setupClient() { + super.setupClient(); + client = context.getApi().getVirtualMachineClient(); + } + + private VirtualMachineClient client; + + @Test + public void testGetVirtualMachine() { + // TODO: don't hard-code id + VirtualMachine virtualMachine = client.getVirtualMachine(5504); + assert null != virtualMachine; + assertEquals(virtualMachine.getStatus(),VirtualMachine.VirtualMachineStatus.DEPLOYED); + } +} diff --git a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/VirtualMachineJAXBParsingTest.java b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/VirtualMachineJAXBParsingTest.java index ac4a28ca47..c84f924fa1 100644 --- a/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/VirtualMachineJAXBParsingTest.java +++ b/sandbox-providers/tmrk-enterprisecloud/src/test/java/org/jclouds/tmrk/enterprisecloud/xml/VirtualMachineJAXBParsingTest.java @@ -41,7 +41,6 @@ import org.testng.Assert; import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import org.testng.collections.Sets; import javax.inject.Named; import java.io.InputStream;