You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ev...@apache.org on 2014/11/18 21:21:12 UTC
[3/6] jclouds git commit: JCLOUDS-716: Remove Rackspace First-Gen
Cloud Servers
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java
deleted file mode 100644
index 8dfde33..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersClientLiveTest.java
+++ /dev/null
@@ -1,608 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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 java.util.concurrent.TimeUnit.SECONDS;
-import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withFile;
-import static org.jclouds.cloudservers.options.CreateSharedIpGroupOptions.Builder.withServer;
-import static org.jclouds.cloudservers.options.ListOptions.Builder.withDetails;
-import static org.jclouds.util.Predicates2.retry;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.io.IOException;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.security.SecureRandom;
-import java.util.Map;
-import java.util.Set;
-
-import org.jclouds.cloudservers.domain.BackupSchedule;
-import org.jclouds.cloudservers.domain.DailyBackup;
-import org.jclouds.cloudservers.domain.Flavor;
-import org.jclouds.cloudservers.domain.Image;
-import org.jclouds.cloudservers.domain.ImageStatus;
-import org.jclouds.cloudservers.domain.Limits;
-import org.jclouds.cloudservers.domain.RebootType;
-import org.jclouds.cloudservers.domain.Server;
-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.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.predicates.SocketOpen;
-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;
-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.Iterables;
-import com.google.common.net.HostAndPort;
-import com.google.inject.Injector;
-import com.google.inject.Module;
-
-/**
- * Tests behavior of {@code CloudServersClient}
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "CloudServersClientLiveTest")
-public class CloudServersClientLiveTest extends BaseComputeServiceContextLiveTest {
-
- public CloudServersClientLiveTest() {
- provider = "cloudservers";
- }
-
- protected CloudServersClient client;
- protected SshClient.Factory sshFactory;
- protected Predicate<HostAndPort> socketTester;
-
- @BeforeGroups(groups = { "integration", "live" })
- @Override
- public void setupContext() {
- super.setupContext();
- Injector injector = view.utils().injector();
- client = injector.getInstance(CloudServersClient.class);
- sshFactory = injector.getInstance(SshClient.Factory.class);
- SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
- socketTester = retry(socketOpen, 120, 1, SECONDS);
- injector.injectMembers(socketOpen); // add logger
- }
-
- public void testLimits() throws Exception {
- Limits response = client.getLimits();
- assert null != response;
- assertTrue(response.getAbsolute().size() > 0);
- assertTrue(response.getRate().size() > 0);
- }
-
- public void testListServers() throws Exception {
-
- Set<Server> response = client.listServers();
- assert null != response;
- long initialContainerCount = response.size();
- assertTrue(initialContainerCount >= 0);
-
- }
-
- public void testListServersDetail() throws Exception {
- Set<Server> response = client.listServers(withDetails());
- assert null != response;
- long initialContainerCount = response.size();
- assertTrue(initialContainerCount >= 0);
- }
-
- public void testListImages() throws Exception {
- Set<Image> response = client.listImages();
- assert null != response;
- long imageCount = response.size();
- assertTrue(imageCount >= 1);
- for (Image image : response) {
- assertTrue(image.getId() >= 0);
- assert null != image.getName() : image;
- }
-
- }
-
- public void testListImagesDetail() throws Exception {
- Set<Image> response = client.listImages(withDetails());
- assert null != response;
- long imageCount = response.size();
- assertTrue(imageCount >= 0);
- for (Image image : response) {
- assertTrue(image.getId() >= 1);
- assert null != image.getName() : image;
- assert null != image.getStatus() : image;
- }
- }
-
- public void testGetImagesDetail() throws Exception {
- Set<Image> response = client.listImages(withDetails());
- assert null != response;
- long imageCount = response.size();
- assertTrue(imageCount >= 0);
- for (Image image : response) {
- Image newDetails = client.getImage(image.getId());
- assertEquals(image, newDetails);
- }
- }
-
- @Test
- public void testGetImageDetailsNotFound() throws Exception {
- assert client.getImage(12312987) == null;
- }
-
- @Test
- public void testGetServerDetailsNotFound() throws Exception {
- assert client.getServer(12312987) == null;
- }
-
- public void testGetServersDetail() throws Exception {
- Set<Server> response = client.listServers(withDetails());
- assert null != response;
- long serverCount = response.size();
- assertTrue(serverCount >= 0);
- for (Server server : response) {
- Server newDetails = client.getServer(server.getId());
- assertEquals(server, newDetails);
- }
- }
-
- public void testListFlavors() throws Exception {
- Set<Flavor> response = client.listFlavors();
- assert null != response;
- long flavorCount = response.size();
- assertTrue(flavorCount >= 1);
- for (Flavor flavor : response) {
- assertTrue(flavor.getId() >= 0);
- assert null != flavor.getName() : flavor;
- }
-
- }
-
- public void testListFlavorsDetail() throws Exception {
- Set<Flavor> response = client.listFlavors(withDetails());
- assert null != response;
- long flavorCount = response.size();
- assertTrue(flavorCount >= 0);
- for (Flavor flavor : response) {
- assertTrue(flavor.getId() >= 1);
- assert null != flavor.getName() : flavor;
- assert null != flavor.getDisk() : flavor;
- assert null != flavor.getRam() : flavor;
- }
- }
-
- public void testGetFlavorsDetail() throws Exception {
- Set<Flavor> response = client.listFlavors(withDetails());
- assert null != response;
- long flavorCount = response.size();
- assertTrue(flavorCount >= 0);
- for (Flavor flavor : response) {
- Flavor newDetails = client.getFlavor(flavor.getId());
- assertEquals(flavor, newDetails);
- }
- }
-
- @Test
- public void testGetFlavorDetailsNotFound() throws Exception {
- assert client.getFlavor(12312987) == null;
- }
-
- public void testListSharedIpGroups() throws Exception {
- Set<SharedIpGroup> response = client.listSharedIpGroups();
- assert null != response;
- long sharedIpGroupCount = response.size();
- assertTrue(sharedIpGroupCount >= 0);
- for (SharedIpGroup sharedIpGroup : response) {
- assertTrue(sharedIpGroup.getId() >= 0);
- assert null != sharedIpGroup.getName() : sharedIpGroup;
- }
-
- }
-
- public void testListSharedIpGroupsDetail() throws Exception {
- Set<SharedIpGroup> response = client.listSharedIpGroups(withDetails());
- assert null != response;
- long sharedIpGroupCount = response.size();
- assertTrue(sharedIpGroupCount >= 0);
- for (SharedIpGroup sharedIpGroup : response) {
- assertTrue(sharedIpGroup.getId() >= 1);
- assert null != sharedIpGroup.getName() : sharedIpGroup;
- assert null != sharedIpGroup.getServers() : sharedIpGroup;
- }
- }
-
- public void testGetSharedIpGroupsDetail() throws Exception {
- Set<SharedIpGroup> response = client.listSharedIpGroups(withDetails());
- assert null != response;
- long sharedIpGroupCount = response.size();
- assertTrue(sharedIpGroupCount >= 0);
- for (SharedIpGroup sharedIpGroup : response) {
- SharedIpGroup newDetails = client.getSharedIpGroup(sharedIpGroup.getId());
- assertEquals(sharedIpGroup, newDetails);
- }
- }
-
- @Test
- public void testGetSharedIpGroupDetailsNotFound() throws Exception {
- assert client.getSharedIpGroup(12312987) == null;
- }
-
- @Test(timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateServer")
- public void testCreateSharedIpGroup() throws Exception {
- SharedIpGroup sharedIpGroup = null;
- while (sharedIpGroup == null) {
- String sharedIpGroupName = serverPrefix + "createSharedIpGroup" + new SecureRandom().nextInt();
- try {
- sharedIpGroup = client.createSharedIpGroup(sharedIpGroupName, withServer(serverId));
- } catch (UndeclaredThrowableException e) {
- HttpResponseException htpe = (HttpResponseException) e.getCause().getCause();
- if (htpe.getResponse().getStatusCode() == 400)
- continue;
- throw e;
- }
- }
- assertNotNull(sharedIpGroup.getName());
- sharedIpGroupId = sharedIpGroup.getId();
- // Response doesn't include the server id Web Hosting #119311
- assert !sharedIpGroup.getServers().equals(ImmutableList.of(serverId));
- }
-
- private int sharedIpGroupId;
-
- private String serverPrefix = System.getProperty("user.name") + ".cs";
- private int serverId;
- private String adminPass;
- Map<String, String> metadata = ImmutableMap.of("jclouds", "rackspace");
- private String ip;
- private int serverId2;
- private String adminPass2;
- private int imageId;
-
- public void testCreateServer() throws Exception {
- int imageId = 14362;
- int flavorId = 1;
- Server server = null;
- while (server == null) {
- String serverName = serverPrefix + "createserver" + new SecureRandom().nextInt();
- try {
- server = client.createServer(serverName, imageId, flavorId, withFile("/etc/jclouds.txt",
- "rackspace".getBytes()).withMetadata(metadata));
- } catch (UndeclaredThrowableException e) {
- HttpResponseException htpe = (HttpResponseException) e.getCause().getCause();
- if (htpe.getResponse().getStatusCode() == 400)
- continue;
- throw e;
- }
- }
- assertNotNull(server.getAdminPass());
- serverId = server.getId();
- adminPass = server.getAdminPass();
- ip = server.getAddresses().getPublicAddresses().iterator().next();
- assertEquals(server.getStatus(), ServerStatus.BUILD);
- blockUntilServerActive(serverId);
- }
-
- private void blockUntilServerActive(int serverId) throws InterruptedException {
- Server currentDetails = null;
- for (currentDetails = client.getServer(serverId); currentDetails.getStatus() != ServerStatus.ACTIVE; currentDetails = client
- .getServer(serverId)) {
- System.out.printf("blocking on status active%n%s%n", currentDetails);
- Thread.sleep(5 * 1000);
- }
- }
-
- private void blockUntilServerVerifyResize(int serverId) throws InterruptedException {
- Server currentDetails = null;
- for (currentDetails = client.getServer(serverId); currentDetails.getStatus() != ServerStatus.VERIFY_RESIZE; currentDetails = client
- .getServer(serverId)) {
- System.out.printf("blocking on status verify resize%n%s%n", currentDetails);
- Thread.sleep(5 * 1000);
- }
- }
-
- private void blockUntilImageActive(int imageId) throws InterruptedException {
- Image currentDetails = null;
- for (currentDetails = client.getImage(imageId); currentDetails.getStatus() != ImageStatus.ACTIVE; currentDetails = client
- .getImage(imageId)) {
- System.out.printf("blocking on status active%n%s%n", currentDetails);
- Thread.sleep(5 * 1000);
- }
- }
-
- @Test(timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateServer")
- public void testServerDetails() throws Exception {
- Server server = client.getServer(serverId);
-
- assertNotNull(server.getHostId());
- assertEquals(server.getStatus(), ServerStatus.ACTIVE);
- assert server.getProgress() >= 0 : "newDetails.getProgress()" + server.getProgress();
- assertEquals(Integer.valueOf(14362), server.getImageId());
- assertEquals(Integer.valueOf(1), server.getFlavorId());
- assertNotNull(server.getAddresses());
- // listAddresses tests..
- assertEquals(client.getAddresses(serverId), server.getAddresses());
- assertEquals(server.getAddresses().getPublicAddresses().size(), 1);
- assertEquals(client.listPublicAddresses(serverId), server.getAddresses().getPublicAddresses());
- assertEquals(server.getAddresses().getPrivateAddresses().size(), 1);
- assertEquals(client.listPrivateAddresses(serverId), server.getAddresses().getPrivateAddresses());
-
- // check metadata
- assertEquals(server.getMetadata(), metadata);
-
- checkPassOk(server, adminPass);
- }
-
- /**
- * this tests "personality" as the file looked up was sent during server creation
- */
- private void checkPassOk(Server newDetails, String pass) throws IOException {
- try {
- doCheckPass(newDetails, pass);
- } catch (SshException e) {// try twice in case there is a network timeout
- try {
- Thread.sleep(10 * 1000);
- } catch (InterruptedException e1) {
- }
- doCheckPass(newDetails, pass);
- }
- }
-
- private void doCheckPass(Server newDetails, String pass) throws IOException {
- HostAndPort socket = HostAndPort.fromParts(Iterables.get(newDetails.getAddresses().getPublicAddresses(), 0), 22);
- socketTester.apply(socket);
-
- SshClient client = sshFactory.create(socket, LoginCredentials.builder().user("root").password(pass).build());
- try {
- client.connect();
- Payload etcPasswd = client.get("/etc/jclouds.txt");
- String etcPasswdContents = Strings2.toString(etcPasswd);
- assertEquals("rackspace", etcPasswdContents.trim());
- } finally {
- if (client != null)
- client.disconnect();
- }
- }
-
- private ExecResponse exec(Server details, String pass, String command) throws IOException {
- HostAndPort socket = HostAndPort.fromParts(Iterables.get(details.getAddresses().getPublicAddresses(), 0), 22);
- socketTester.apply(socket);
- SshClient client = sshFactory.create(socket, LoginCredentials.builder().user("root").password(pass).build());
- try {
- client.connect();
- return client.exec(command);
- } finally {
- if (client != null)
- client.disconnect();
- }
- }
-
- @Test(timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateServer")
- public void testRenameServer() throws Exception {
- Server server = client.getServer(serverId);
- String oldName = server.getName();
- client.renameServer(serverId, oldName + "new");
- blockUntilServerActive(serverId);
- assertEquals(oldName + "new", client.getServer(serverId).getName());
- }
-
- @Test(timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateServer")
- public void testChangePassword() throws Exception {
- client.changeAdminPass(serverId, "elmo");
- blockUntilServerActive(serverId);
- checkPassOk(client.getServer(serverId), "elmo");
- this.adminPass = "elmo";
- }
-
- @Test(timeOut = 5 * 60 * 1000, dependsOnMethods = "testCreateSharedIpGroup")
- public void testCreateServerIp() throws Exception {
- int imageId = 14362;
- int flavorId = 1;
- Server server = null;
- while (server == null) {
- String serverName = serverPrefix + "createserver" + new SecureRandom().nextInt();
- try {
- server = client
- .createServer(serverName, imageId, flavorId, withFile("/etc/jclouds.txt", "rackspace".getBytes())
- .withMetadata(metadata).withSharedIpGroup(sharedIpGroupId).withSharedIp(ip));
- } catch (UndeclaredThrowableException e) {
- HttpResponseException htpe = (HttpResponseException) e.getCause().getCause();
- if (htpe.getResponse().getStatusCode() == 400)
- continue;
- throw e;
- }
- }
- assertNotNull(server.getAdminPass());
- serverId2 = server.getId();
- adminPass2 = server.getAdminPass();
- blockUntilServerActive(serverId2);
- assertIpConfigured(server, adminPass2);
- assert server.getAddresses().getPublicAddresses().contains(ip) : server.getAddresses() + " doesn't contain " + ip;
- assertEquals(server.getSharedIpGroupId(), Integer.valueOf(sharedIpGroupId));
- }
-
- private void assertIpConfigured(Server server, String password) {
- try {
- ExecResponse response = exec(server, password, "ifconfig -a");
- assert response.getOutput().indexOf(ip) > 0 : String.format("server %s didn't get ip %s%n%s", server, ip,
- response);
- } catch (Exception e) {
- e.printStackTrace();
- } catch (AssertionError e) {
- e.printStackTrace();
- }
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testCreateServerIp")
- public void testUnshare() throws Exception {
- client.unshareIp(ip, serverId2);
- blockUntilServerActive(serverId2);
- Server server = client.getServer(serverId2);
- assert !server.getAddresses().getPublicAddresses().contains(ip) : server.getAddresses();
- assertIpNotConfigured(server, adminPass2);
- }
-
- private void assertIpNotConfigured(Server server, String password) {
- try {
- ExecResponse response = exec(server, password, "ifconfig -a");
- assert response.getOutput().indexOf(ip) == -1 : String.format("server %s still has get ip %s%n%s", server, ip,
- response);
- } catch (Exception e) {
- e.printStackTrace();
- } catch (AssertionError e) {
- e.printStackTrace();
- }
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testUnshare")
- public void testShareConfig() throws Exception {
- client.shareIp(ip, serverId2, sharedIpGroupId, true);
- blockUntilServerActive(serverId2);
- Server server = client.getServer(serverId2);
- assert server.getAddresses().getPublicAddresses().contains(ip) : server.getAddresses();
- assertIpConfigured(server, adminPass2);
- testUnshare();
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testShareConfig")
- public void testShareNoConfig() throws Exception {
- client.shareIp(ip, serverId2, sharedIpGroupId, false);
- blockUntilServerActive(serverId2);
- Server server = client.getServer(serverId2);
- assert server.getAddresses().getPublicAddresses().contains(ip) : server.getAddresses();
- assertIpNotConfigured(server, adminPass2);
- testUnshare();
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testShareNoConfig")
- public void testBackup() throws Exception {
- assertEquals(BackupSchedule.builder().build(), client.getBackupSchedule(serverId));
- BackupSchedule dailyWeekly = BackupSchedule.builder().enabled(true).weekly(WeeklyBackup.FRIDAY).daily(DailyBackup.H_0400_0600).build();
- client.replaceBackupSchedule(serverId, dailyWeekly);
- client.deleteBackupSchedule(serverId);
- // disables, doesn't delete: Web Hosting #119571
- assertEquals(client.getBackupSchedule(serverId).isEnabled(), false);
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testBackup")
- public void testCreateImage() throws Exception {
- Image image = client.createImageFromServer("hoofie", serverId);
- assertEquals("hoofie", image.getName());
- assertEquals(Integer.valueOf(serverId), image.getServerId());
- imageId = image.getId();
- blockUntilImageActive(imageId);
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testCreateImage")
- public void testRebuildServer() throws Exception {
- client.rebuildServer(serverId, new RebuildServerOptions().withImage(imageId));
- blockUntilServerActive(serverId);
- // issue Web Hosting #119580 imageId comes back incorrect after rebuild
- assert !Integer.valueOf(imageId).equals(client.getServer(serverId).getImageId());
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testRebuildServer")
- public void testRebootHard() throws Exception {
- client.rebootServer(serverId, RebootType.HARD);
- blockUntilServerActive(serverId);
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testRebootHard")
- public void testRebootSoft() throws Exception {
- client.rebootServer(serverId, RebootType.SOFT);
- blockUntilServerActive(serverId);
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testRebootSoft")
- public void testRevertResize() throws Exception {
- client.resizeServer(serverId, 2);
- blockUntilServerVerifyResize(serverId);
- client.revertResizeServer(serverId);
- blockUntilServerActive(serverId);
- assertEquals(Integer.valueOf(1), client.getServer(serverId).getFlavorId());
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testRebootSoft")
- public void testConfirmResize() throws Exception {
- client.resizeServer(serverId2, 2);
- blockUntilServerVerifyResize(serverId2);
- client.confirmResizeServer(serverId2);
- blockUntilServerActive(serverId2);
- assertEquals(Integer.valueOf(2), client.getServer(serverId2).getFlavorId());
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = { "testRebootSoft", "testRevertResize", "testConfirmResize" })
- void deleteServer2() {
- if (serverId2 > 0) {
- client.deleteServer(serverId2);
- assert client.getServer(serverId2) == null;
- }
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "deleteServer2")
- void testDeleteImage() {
- if (imageId > 0) {
- client.deleteImage(imageId);
- assert client.getImage(imageId) == null;
- }
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = "testDeleteImage")
- void deleteServer1() {
- if (serverId > 0) {
- client.deleteServer(serverId);
- assert client.getServer(serverId) == null;
- }
- }
-
- @Test(timeOut = 10 * 60 * 1000, dependsOnMethods = { "deleteServer1" })
- void testDeleteSharedIpGroup() {
- if (sharedIpGroupId > 0) {
- client.deleteSharedIpGroup(sharedIpGroupId);
- assert client.getSharedIpGroup(sharedIpGroupId) == null;
- }
- }
-
- @AfterTest
- void deleteServersOnEnd() {
- if (serverId > 0) {
- client.deleteServer(serverId);
- }
- if (serverId2 > 0) {
- client.deleteServer(serverId2);
- }
- if (sharedIpGroupId > 0) {
- client.deleteSharedIpGroup(sharedIpGroupId);
- }
- }
-
- @Override
- protected Module getSshModule() {
- return new SshjSshClientModule();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersExpectTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersExpectTest.java
deleted file mode 100644
index ad45cd5..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/CloudServersExpectTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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 java.net.URI;
-
-import org.jclouds.cloudservers.internal.BaseCloudServersRestClientExpectTest;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMultimap;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit", testName = "CloudServersExpectTest")
-public class CloudServersExpectTest extends BaseCloudServersRestClientExpectTest {
-
- public void deleteImageReturnsTrueOn200AndFalseOn404() {
-
- HttpRequest deleteImage11 = HttpRequest.builder().method("DELETE").endpoint(
- URI.create("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/11?now=1257695648897")).headers(
- ImmutableMultimap.<String, String> builder()
- .put("X-Auth-Token", authToken).build()).build();
-
- HttpResponse imageDeleted = HttpResponse.builder().statusCode(204).message("HTTP/1.1 204 No Content").build();
-
- CloudServersClient clientWhenImageExists = requestsSendResponses(initialAuth, responseWithAuth, deleteImage11, imageDeleted);
- assert clientWhenImageExists.deleteImage(11);
-
- HttpResponse imageNotFound = HttpResponse.builder().statusCode(404).message("HTTP/1.1 404 Not Found").build();
-
- CloudServersClient clientWhenImageDoesntExist = requestsSendResponses(initialAuth, responseWithAuth, deleteImage11, imageNotFound);
- assert !clientWhenImageDoesntExist.deleteImage(11);
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java
----------------------------------------------------------------------
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
deleted file mode 100644
index 189c767..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/CloudServersComputeServiceLiveTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.compute;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
-import org.jclouds.domain.LocationScope;
-import org.jclouds.sshj.config.SshjSshClientModule;
-import org.testng.annotations.Test;
-
-import com.google.inject.Module;
-
-/**
- *
- * Generally disabled, as it incurs higher fees.
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", enabled = true, singleThreaded = true, testName = "CloudServersComputeServiceLiveTest")
-public class CloudServersComputeServiceLiveTest extends BaseComputeServiceLiveTest {
-
- public CloudServersComputeServiceLiveTest() {
- provider = "cloudservers";
- }
-
- @Override
- protected Module getSshModule() {
- return new SshjSshClientModule();
- }
-
- @Override
- protected void checkNodes(Iterable<? extends NodeMetadata> nodes, String group, String task) throws IOException {
- super.checkNodes(nodes, group, task);
- for (NodeMetadata node : nodes) {
- assertEquals(node.getLocation().getScope(), LocationScope.HOST);
- }
- }
-
- @Test(enabled = true, dependsOnMethods = "testReboot", expectedExceptions = UnsupportedOperationException.class)
- public void testSuspendResume() throws Exception {
- super.testSuspendResume();
- }
-
- @Test(enabled = true, dependsOnMethods = "testSuspendResume")
- @Override
- public void testGetNodesWithDetails() throws Exception {
- super.testGetNodesWithDetails();
- }
-
- @Test(enabled = true, dependsOnMethods = "testSuspendResume")
- @Override
- public void testListNodes() throws Exception {
- super.testListNodes();
- }
-
- @Test(enabled = true, dependsOnMethods = "testSuspendResume")
- @Override
- public void testListNodesByIds() throws Exception {
- super.testListNodesByIds();
- }
-
- @Test(enabled = true, dependsOnMethods = { "testListNodes", "testGetNodesWithDetails", "listNodesByIds" })
- @Override
- public void testDestroyNodes() {
- super.testDestroyNodes();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModuleTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModuleTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModuleTest.java
deleted file mode 100644
index dba3279..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/config/CloudServersComputeServiceContextModuleTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.compute.config;
-
-import org.jclouds.cloudservers.domain.ServerStatus;
-import org.testng.annotations.Test;
-
-/**
- * @author Adrian Cole
- */
-@Test(groups = "unit", testName = "CloudServersComputeServiceContextModuleTest")
-public class CloudServersComputeServiceContextModuleTest {
-
- public void testAllStatusCovered() {
-
- for (ServerStatus state : ServerStatus.values()) {
- assert CloudServersComputeServiceContextModule.toPortableNodeStatus.containsKey(state) : state;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/extensions/CloudServersImageExtensionExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/extensions/CloudServersImageExtensionExpectTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/extensions/CloudServersImageExtensionExpectTest.java
deleted file mode 100644
index 12f9bef..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/extensions/CloudServersImageExtensionExpectTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.compute.extensions;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.cloudservers.internal.BaseCloudServersComputeServiceExpectTest;
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.ComputeServiceContext;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.ImageTemplate;
-import org.jclouds.compute.extensions.ImageExtension;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMap.Builder;
-import com.google.common.net.HttpHeaders;
-import com.google.common.util.concurrent.Futures;
-
-/**
- *
- * @author David Alves
- *
- */
-@Test(groups = "unit", testName = "CloudServersImageExtensionExpectTest")
-public class CloudServersImageExtensionExpectTest extends BaseCloudServersComputeServiceExpectTest<ComputeService> {
- private HttpRequest getServerDetail = HttpRequest.builder().method("GET")
- .endpoint("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/servers/1234?format=json&now=1257695648897")
- .addHeader(HttpHeaders.ACCEPT, "application/json")
- .addHeader("X-Auth-Token", authToken).build();
-
- private HttpResponse getServerResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/test_get_server_detail.json")).build();
-
- HttpRequest createImage = HttpRequest.builder().method("POST")
- .endpoint("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images?format=json&now=1257695648897")
- .addHeader("Accept", "application/json")
- .addHeader("X-Auth-Token", authToken)
- .payload(
- payloadFromStringWithContentType(
- "{\"image\":{\"serverId\":1234,\"name\":\"test\"}}",
- "application/json")).build();
-
- HttpResponse createImageResponse = HttpResponse.builder().statusCode(200)
- .payload(
- payloadFromStringWithContentType(
- "{\"image\":{\"id\":2,\"serverId\":1234,\"name\":\"test\",\"status\":\"SAVING\"}}",
- "application/json")).build();
-
- private HttpRequest getImage = HttpRequest.builder().method("GET")
- .endpoint("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/2?format=json&now=1257695648897")
- .addHeader(HttpHeaders.ACCEPT, "application/json")
- .addHeader("X-Auth-Token", authToken).build();
-
- private HttpResponse getImageResponse = HttpResponse.builder().statusCode(200)
- .payload(payloadFromResource("/test_get_image_active.json")).build();
-
-
- public void testCreateImage() {
- Builder<HttpRequest, HttpResponse> requestResponseMap = ImmutableMap.<HttpRequest, HttpResponse> builder();
- requestResponseMap.put(initialAuth, responseWithAuth);
- requestResponseMap.put(getServerDetail, getServerResponse).build();
- requestResponseMap.put(createImage, createImageResponse).build();
- requestResponseMap.put(getImage, getImageResponse).build();
-
- ImageExtension apiThatCreatesImage = requestsSendResponses(requestResponseMap.build()).getImageExtension().get();
-
- ImageTemplate newImageTemplate = apiThatCreatesImage.buildImageTemplateFromNode("test", "1234");
-
- Image image = Futures.getUnchecked(apiThatCreatesImage.createImage(newImageTemplate));
- assertEquals(image.getId(), "2");
- }
-
- public ComputeService apply(ComputeServiceContext input) {
- return input.getComputeService();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/extensions/CloudServersImageExtensionLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/extensions/CloudServersImageExtensionLiveTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/extensions/CloudServersImageExtensionLiveTest.java
deleted file mode 100644
index f3bbfb3..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/extensions/CloudServersImageExtensionLiveTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.compute.extensions;
-
-import org.jclouds.compute.extensions.internal.BaseImageExtensionLiveTest;
-import org.jclouds.sshj.config.SshjSshClientModule;
-import org.testng.annotations.Test;
-
-import com.google.inject.Module;
-
-/**
- * Live test for cloudservers {@link ImageExtension} implementation
- *
- * @author David Alves
- *
- */
-@Test(groups = "live", singleThreaded = true, testName = "CloudServersImageExtensionLiveTest")
-public class CloudServersImageExtensionLiveTest extends BaseImageExtensionLiveTest {
-
- public CloudServersImageExtensionLiveTest() {
- provider = "cloudservers";
- }
-
- @Override
- protected Module getSshModule() {
- return new SshjSshClientModule();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/CloudServersImageToImageTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/CloudServersImageToImageTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/CloudServersImageToImageTest.java
deleted file mode 100644
index 8a51e26..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/CloudServersImageToImageTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.compute.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule;
-import org.jclouds.cloudservers.functions.ParseImageFromJsonResponseTest;
-import org.jclouds.compute.config.BaseComputeServiceContextModule;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.ImageBuilder;
-import org.jclouds.compute.domain.OperatingSystem;
-import org.jclouds.compute.domain.OsFamily;
-import org.jclouds.compute.reference.ComputeServiceConstants;
-import org.jclouds.json.Json;
-import org.jclouds.json.config.GsonModule;
-import org.testng.annotations.Test;
-
-import com.google.inject.Guice;
-
-/**
- * @author Adrian Cole
- */
-@Test(groups = "unit", testName = "CloudServersImageToImageTest")
-public class CloudServersImageToImageTest {
-
- @Test
- public void test() {
- Image toTest = convertImage();
- assertEquals(toTest, new ImageBuilder().name("CentOS 5.2").operatingSystem(
- new OperatingSystem.Builder().family(OsFamily.CENTOS).version("5.2").description("CentOS 5.2").is64Bit(
- true).build()).description("CentOS 5.2").ids("2").status(Image.Status.PENDING).version(
- "1286712000000").build());
- assertEquals(toTest.getStatus(), Image.Status.PENDING);
- }
-
- public static Image convertImage() {
- org.jclouds.cloudservers.domain.Image image = ParseImageFromJsonResponseTest.parseImage();
-
- CloudServersImageToImage parser = new CloudServersImageToImage(
- CloudServersComputeServiceContextModule.toPortableImageStatus, new CloudServersImageToOperatingSystem(
- new BaseComputeServiceContextModule() {
- }.provideOsVersionMap(new ComputeServiceConstants.ReferenceData(), Guice.createInjector(
- new GsonModule()).getInstance(Json.class))));
-
- return parser.apply(image);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/FlavorToHardwareTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/FlavorToHardwareTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/FlavorToHardwareTest.java
deleted file mode 100644
index 85a56d3..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/FlavorToHardwareTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.compute.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import java.net.UnknownHostException;
-
-import org.jclouds.cloudservers.domain.Flavor;
-import org.jclouds.cloudservers.functions.ParseFlavorFromJsonResponseTest;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.HardwareBuilder;
-import org.jclouds.compute.domain.Processor;
-import org.jclouds.compute.domain.Volume;
-import org.jclouds.compute.domain.VolumeBuilder;
-import org.jclouds.domain.Location;
-import org.jclouds.domain.LocationBuilder;
-import org.jclouds.domain.LocationScope;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class FlavorToHardwareTest {
- Location provider = new LocationBuilder().scope(LocationScope.ZONE).id("dallas").description("description").build();
-
- @Test
- public void test() throws UnknownHostException {
- assertEquals(convertFlavor(), new HardwareBuilder().ids("1").name("256 MB Server").processors(
- ImmutableList.of(new Processor(1.0, 1.0))).ram(256).volumes(
- ImmutableList.of(new VolumeBuilder().type(Volume.Type.LOCAL).size(10.0f).durable(true).bootDevice(true)
- .build())).build());
- }
-
- public static Hardware convertFlavor() {
- Flavor flavor = ParseFlavorFromJsonResponseTest.parseFlavor();
-
- FlavorToHardware parser = new FlavorToHardware();
-
- return parser.apply(flavor);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java
deleted file mode 100644
index 427305a..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/compute/functions/ServerToNodeMetadataTest.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.compute.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.jclouds.cloudservers.compute.config.CloudServersComputeServiceContextModule;
-import org.jclouds.cloudservers.domain.Server;
-import org.jclouds.cloudservers.domain.ServerStatus;
-import org.jclouds.cloudservers.functions.ParseServerFromJsonResponseTest;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.HardwareBuilder;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.NodeMetadataBuilder;
-import org.jclouds.compute.domain.OperatingSystem;
-import org.jclouds.compute.domain.OsFamily;
-import org.jclouds.compute.domain.Processor;
-import org.jclouds.compute.domain.Volume;
-import org.jclouds.compute.domain.VolumeBuilder;
-import org.jclouds.compute.domain.NodeMetadata.Status;
-import org.jclouds.compute.functions.GroupNamingConvention;
-import org.jclouds.domain.Location;
-import org.jclouds.domain.LocationBuilder;
-import org.jclouds.domain.LocationScope;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Suppliers;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Guice;
-
-/**
- * @author Adrian Cole
- */
-@Test(groups = "unit", testName = "ServerToNodeMetadataTest")
-public class ServerToNodeMetadataTest {
- Location provider = new LocationBuilder().scope(LocationScope.ZONE).id("dallas").description("description").build();
- GroupNamingConvention.Factory namingConvention = Guice.createInjector().getInstance(GroupNamingConvention.Factory.class);
-
- @Test
- public void testApplyWhereImageAndHardwareNotFound() {
- Map<ServerStatus, Status> serverStateToNodeStatus = CloudServersComputeServiceContextModule.toPortableNodeStatus;
- Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of();
- Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of();
- Server server = ParseServerFromJsonResponseTest.parseServer();
-
- ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeStatus, Suppliers.<Set<? extends Image>> ofInstance(images), Suppliers
- .ofInstance(provider), Suppliers.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
-
- NodeMetadata metadata = parser.apply(server);
-
- assertEquals(
- metadata,
- new NodeMetadataBuilder()
- .status(Status.PENDING)
- .publicAddresses(ImmutableSet.of("67.23.10.132", "67.23.10.131"))
- .privateAddresses(ImmutableSet.of("10.176.42.16"))
- .imageId("2")
- .id("1234")
- .providerId("1234")
- .name("sample-server")
- .group("sample")
- .hostname("sample-server")
- .location(
- new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0")
- .description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build())
- .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
-
- }
-
- @Test
- public void testApplyWhereImageFoundAndHardwareNotFound() {
- Map<ServerStatus, Status> serverStateToNodeStatus = CloudServersComputeServiceContextModule.toPortableNodeStatus;
- org.jclouds.compute.domain.Image jcImage = CloudServersImageToImageTest.convertImage();
- Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of(jcImage);
- Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of();
- Server server = ParseServerFromJsonResponseTest.parseServer();
-
- ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeStatus, Suppliers.<Set<? extends Image>> ofInstance(images), Suppliers
- .ofInstance(provider), Suppliers.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
-
- NodeMetadata metadata = parser.apply(server);
-
- assertEquals(
- metadata,
- new NodeMetadataBuilder()
- .status(Status.PENDING)
- .publicAddresses(ImmutableSet.of("67.23.10.132", "67.23.10.131"))
- .privateAddresses(ImmutableSet.of("10.176.42.16"))
- .imageId("2")
- .operatingSystem(
- new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2")
- .is64Bit(true).build())
- .id("1234")
- .providerId("1234")
- .name("sample-server")
- .hostname("sample-server")
- .group("sample")
- .location(
- new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0")
- .description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build())
- .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
-
- }
-
- @Test
- public void testApplyWhereImageAndHardwareFound() {
- Map<ServerStatus, Status> serverStateToNodeStatus = CloudServersComputeServiceContextModule.toPortableNodeStatus;
- Set<org.jclouds.compute.domain.Image> images = ImmutableSet.of(CloudServersImageToImageTest.convertImage());
- Set<org.jclouds.compute.domain.Hardware> hardwares = ImmutableSet.of(FlavorToHardwareTest.convertFlavor());
- Server server = ParseServerFromJsonResponseTest.parseServer();
-
- ServerToNodeMetadata parser = new ServerToNodeMetadata(serverStateToNodeStatus, Suppliers.<Set<? extends Image>> ofInstance(images), Suppliers
- .ofInstance(provider), Suppliers.<Set<? extends Hardware>> ofInstance(hardwares), namingConvention);
-
- NodeMetadata metadata = parser.apply(server);
-
- assertEquals(
- metadata,
- new NodeMetadataBuilder()
- .status(Status.PENDING)
- .publicAddresses(ImmutableSet.of("67.23.10.132", "67.23.10.131"))
- .privateAddresses(ImmutableSet.of("10.176.42.16"))
- .imageId("2")
- .hardware(
- new HardwareBuilder()
- .ids("1")
- .name("256 MB Server")
- .processors(ImmutableList.of(new Processor(1.0, 1.0)))
- .ram(256)
- .volumes(
- ImmutableList.of(new VolumeBuilder().type(Volume.Type.LOCAL).size(10.0f)
- .durable(true).bootDevice(true).build())).build())
- .operatingSystem(
- new OperatingSystem.Builder().family(OsFamily.CENTOS).description("CentOS 5.2").version("5.2")
- .is64Bit(true).build())
- .id("1234")
- .providerId("1234")
- .name("sample-server")
- .group("sample")
- .hostname("sample-server")
- .location(
- new LocationBuilder().scope(LocationScope.HOST).id("e4d909c290d0fb1ca068ffaddf22cbd0")
- .description("e4d909c290d0fb1ca068ffaddf22cbd0").parent(provider).build())
- .userMetadata(ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1")).build());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/domain/ServerTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/domain/ServerTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/domain/ServerTest.java
deleted file mode 100644
index 9aa15dd..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/domain/ServerTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.domain;
-
-import static org.testng.Assert.assertEquals;
-
-import org.testng.annotations.Test;
-
-/**
- * Tests behavior of {@code CreateImageBinder}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class ServerTest {
- public void testStatusDoesntAffectEquals() {
- Server server1 = Server.builder().id(1).name("hello").status(ServerStatus.ACTIVE).build();
- Server server2 = Server.builder().id(1).name("hello").status(ServerStatus.BUILD).build();
- assertEquals(server1, server2);
- }
-
- public void testProgressDoesntAffectEquals() {
- Server server1 = Server.builder().id(1).name("hello").progress(1).build();
- Server server2 = Server.builder().id(1).name("hello").progress(2).build();
- assertEquals(server1, server2);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseAddressesFromJsonResponseTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseAddressesFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseAddressesFromJsonResponseTest.java
deleted file mode 100644
index 26b3d68..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseAddressesFromJsonResponseTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-import java.net.UnknownHostException;
-import java.util.List;
-
-import org.jclouds.cloudservers.domain.Addresses;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.UnwrapOnlyJsonValue;
-import org.jclouds.json.config.GsonModule;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Key;
-import com.google.inject.TypeLiteral;
-
-/**
- * Tests behavior of {@code ParseAddressesFromJsonResponse}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class ParseAddressesFromJsonResponseTest {
- Injector i = Guice.createInjector(new GsonModule());
-
- public void testApplyInputStreamDetails() throws UnknownHostException {
- InputStream is = getClass().getResourceAsStream("/test_list_addresses.json");
-
- UnwrapOnlyJsonValue<Addresses> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Addresses>>() {
- }));
- Addresses response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
- List<String> publicAddresses = ImmutableList.of("67.23.10.132", "67.23.10.131");
-
- List<String> privateAddresses = ImmutableList.of("10.176.42.16");
-
- assertEquals(response.getPublicAddresses(), publicAddresses);
- assertEquals(response.getPrivateAddresses(), privateAddresses);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseBackupScheduleFromJsonResponseTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseBackupScheduleFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseBackupScheduleFromJsonResponseTest.java
deleted file mode 100644
index d361c81..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseBackupScheduleFromJsonResponseTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-import java.net.UnknownHostException;
-
-import org.jclouds.cloudservers.domain.BackupSchedule;
-import org.jclouds.cloudservers.domain.DailyBackup;
-import org.jclouds.cloudservers.domain.WeeklyBackup;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.UnwrapOnlyJsonValue;
-import org.jclouds.json.config.GsonModule;
-import org.testng.annotations.Test;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Key;
-import com.google.inject.TypeLiteral;
-
-/**
- * Tests behavior of {@code ParseBackupScheduleFromJsonResponse}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class ParseBackupScheduleFromJsonResponseTest {
- Injector i = Guice.createInjector(new GsonModule());
-
- public void testApplyInputStreamDetails() throws UnknownHostException {
- InputStream is = getClass().getResourceAsStream("/test_list_backupschedule.json");
-
- UnwrapOnlyJsonValue<BackupSchedule> parser = i.getInstance(Key
- .get(new TypeLiteral<UnwrapOnlyJsonValue<BackupSchedule>>() {
- }));
- BackupSchedule response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
- assertEquals(BackupSchedule.builder().weekly(WeeklyBackup.THURSDAY).daily(DailyBackup.H_0400_0600).enabled(true).build(), response);
- }
-
- public void testNoSchedule() throws UnknownHostException {
-
- UnwrapOnlyJsonValue<BackupSchedule> parser = i.getInstance(Key
- .get(new TypeLiteral<UnwrapOnlyJsonValue<BackupSchedule>>() {
- }));
- BackupSchedule response = parser.apply(HttpResponse.builder()
- .statusCode(200).message("ok")
- .payload("{\"backupSchedule\":{\"enabled\" : false}}").build());
- assertEquals(BackupSchedule.builder().build(), response);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseFlavorFromJsonResponseTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseFlavorFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseFlavorFromJsonResponseTest.java
deleted file mode 100644
index 76d8a91..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseFlavorFromJsonResponseTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-
-import org.jclouds.cloudservers.domain.Flavor;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.UnwrapOnlyJsonValue;
-import org.jclouds.json.config.GsonModule;
-import org.testng.annotations.Test;
-
-import com.google.gson.Gson;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Key;
-import com.google.inject.TypeLiteral;
-
-/**
- * Tests behavior of {@code ParseFlavorFromJsonResponse}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class ParseFlavorFromJsonResponseTest {
- public void test() {
- Flavor response = parseFlavor();
-
- String json = new Gson().toJson(response);
-
- assertEquals(json, "{\"id\":1,\"name\":\"256 MB Server\",\"disk\":10,\"ram\":256}");
- }
-
- public static Flavor parseFlavor() {
- Injector i = Guice.createInjector(new GsonModule());
-
- InputStream is = ParseFlavorFromJsonResponseTest.class.getResourceAsStream("/test_get_flavor_details.json");
-
- UnwrapOnlyJsonValue<Flavor> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Flavor>>() {
- }));
- Flavor response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
- return response;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseFlavorListFromJsonResponseTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseFlavorListFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseFlavorListFromJsonResponseTest.java
deleted file mode 100644
index 416f622..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseFlavorListFromJsonResponseTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-import java.net.UnknownHostException;
-import java.util.List;
-
-import org.jclouds.cloudservers.domain.Flavor;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.UnwrapOnlyJsonValue;
-import org.jclouds.json.config.GsonModule;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Key;
-import com.google.inject.TypeLiteral;
-
-/**
- * Tests behavior of {@code ParseFlavorListFromJsonResponse}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class ParseFlavorListFromJsonResponseTest {
-
- Injector i = Guice.createInjector(new GsonModule());
-
- public void testApplyInputStream() {
- InputStream is = getClass().getResourceAsStream("/test_list_flavors.json");
-
- List<Flavor> expects = ImmutableList.of(Flavor.builder().id(1).name("256 MB Server").build(),
- Flavor.builder().id(2).name("512 MB Server").build());
-
- UnwrapOnlyJsonValue<List<Flavor>> parser = i.getInstance(Key
- .get(new TypeLiteral<UnwrapOnlyJsonValue<List<Flavor>>>() {
- }));
- List<Flavor> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
- assertEquals(response, expects);
- }
-
- public void testApplyInputStreamDetails() throws UnknownHostException {
- InputStream is = getClass().getResourceAsStream("/test_list_flavors_detail.json");
-
- UnwrapOnlyJsonValue<List<Flavor>> parser = i.getInstance(Key
- .get(new TypeLiteral<UnwrapOnlyJsonValue<List<Flavor>>>() {
- }));
- List<Flavor> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
- assertEquals(response.get(0).getId(), 1);
- assertEquals(response.get(0).getName(), "256 MB Server");
- assertEquals(response.get(0).getDisk(), Integer.valueOf(10));
- assertEquals(response.get(0).getRam(), Integer.valueOf(256));
-
- assertEquals(response.get(1).getId(), 2);
- assertEquals(response.get(1).getName(), "512 MB Server");
- assertEquals(response.get(1).getDisk(), Integer.valueOf(20));
- assertEquals(response.get(1).getRam(), Integer.valueOf(512));
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseImageFromJsonResponseTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseImageFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseImageFromJsonResponseTest.java
deleted file mode 100644
index cc0533d..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseImageFromJsonResponseTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-import java.net.UnknownHostException;
-
-import org.jclouds.cloudservers.domain.Image;
-import org.jclouds.cloudservers.domain.ImageStatus;
-import org.jclouds.date.DateService;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.UnwrapOnlyJsonValue;
-import org.jclouds.json.config.GsonModule;
-import org.jclouds.json.config.GsonModule.DateAdapter;
-import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
-import org.testng.annotations.Test;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Key;
-import com.google.inject.TypeLiteral;
-
-/**
- * Tests behavior of {@code ParseImageFromJsonResponse}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class ParseImageFromJsonResponseTest {
- Injector i = Guice.createInjector(new AbstractModule() {
-
- @Override
- protected void configure() {
- bind(DateAdapter.class).to(Iso8601DateAdapter.class);
- }
-
- }, new GsonModule());
-
- DateService dateService = i.getInstance(DateService.class);
-
- public void testApplyInputStreamDetails() throws UnknownHostException {
- Image response = parseImage();
-
- assertEquals(response.getId(), 2);
- assertEquals(response.getName(), "CentOS 5.2");
- assertEquals(response.getCreated(), dateService.iso8601SecondsDateParse("2010-08-10T12:00:00Z"));
- assertEquals(response.getProgress(), Integer.valueOf(80));
- assertEquals(response.getServerId(), Integer.valueOf(12));
- assertEquals(response.getStatus(), ImageStatus.SAVING);
- assertEquals(response.getUpdated(), dateService.iso8601SecondsDateParse("2010-10-10T12:00:00Z"));
-
- }
-
- public static Image parseImage() {
- Injector i = Guice.createInjector(new AbstractModule() {
-
- @Override
- protected void configure() {
- bind(DateAdapter.class).to(Iso8601DateAdapter.class);
- }
-
- }, new GsonModule());
-
- InputStream is = ParseImageFromJsonResponseTest.class.getResourceAsStream("/test_get_image_details.json");
-
- UnwrapOnlyJsonValue<Image> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Image>>() {
- }));
- Image response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
- return response;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseImageListFromJsonResponseTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseImageListFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseImageListFromJsonResponseTest.java
deleted file mode 100644
index 1bb4a5b..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseImageListFromJsonResponseTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-import java.net.UnknownHostException;
-import java.util.List;
-
-import org.jclouds.cloudservers.domain.Image;
-import org.jclouds.cloudservers.domain.ImageStatus;
-import org.jclouds.date.DateService;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.UnwrapOnlyJsonValue;
-import org.jclouds.json.config.GsonModule;
-import org.jclouds.json.config.GsonModule.DateAdapter;
-import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Key;
-import com.google.inject.TypeLiteral;
-
-/**
- * Tests behavior of {@code ParseImageListFromJsonResponse}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class ParseImageListFromJsonResponseTest {
- Injector i = Guice.createInjector(new AbstractModule() {
-
- @Override
- protected void configure() {
- bind(DateAdapter.class).to(Iso8601DateAdapter.class);
- }
-
- },new GsonModule());
- DateService dateService = i.getInstance(DateService.class);
-
- public void testApplyInputStream() {
- InputStream is = getClass().getResourceAsStream("/test_list_images.json");
-
- List<Image> expects = ImmutableList.of(Image.builder().id(2).name("CentOS 5.2").build(),
- Image.builder().id(743).name("My Server Backup").build());
-
- UnwrapOnlyJsonValue<List<Image>> parser = i.getInstance(Key
- .get(new TypeLiteral<UnwrapOnlyJsonValue<List<Image>>>() {
- }));
- List<Image> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
-
- assertEquals(response, expects);
- }
-
- public void testApplyInputStreamDetails() throws UnknownHostException {
- InputStream is = getClass().getResourceAsStream("/test_list_images_detail.json");
-
- UnwrapOnlyJsonValue<List<Image>> parser = i.getInstance(Key
- .get(new TypeLiteral<UnwrapOnlyJsonValue<List<Image>>>() {
- }));
- List<Image> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
-
- assertEquals(response.get(0).getId(), 2);
- assertEquals(response.get(0).getName(), "CentOS 5.2");
- assertEquals(response.get(0).getCreated(), dateService.iso8601SecondsDateParse("2010-08-10T12:00:00Z"));
- assertEquals(response.get(0).getProgress(), null);
- assertEquals(response.get(0).getServerId(), null);
- assertEquals(response.get(0).getStatus(), ImageStatus.ACTIVE);
- assertEquals(response.get(0).getUpdated(), dateService.iso8601SecondsDateParse("2010-10-10T12:00:00Z"));
-
- assertEquals(response.get(1).getId(), 743);
- assertEquals(response.get(1).getName(), "My Server Backup");
- assertEquals(response.get(1).getCreated(), dateService.iso8601SecondsDateParse("2009-07-07T09:56:16-05:00"));
-
- assertEquals(response.get(1).getProgress(), Integer.valueOf(80));
- assertEquals(response.get(1).getServerId(), Integer.valueOf(12));
- assertEquals(response.get(1).getStatus(), ImageStatus.SAVING);
- assertEquals(response.get(1).getUpdated(), dateService.iso8601SecondsDateParse("2010-10-10T12:00:00Z"));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseInetAddressListFromJsonResponseTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseInetAddressListFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseInetAddressListFromJsonResponseTest.java
deleted file mode 100644
index 4487d3c..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseInetAddressListFromJsonResponseTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-import java.net.UnknownHostException;
-import java.util.List;
-
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.UnwrapOnlyJsonValue;
-import org.jclouds.json.config.GsonModule;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Key;
-import com.google.inject.TypeLiteral;
-
-/**
- * Tests behavior of {@code ParseInetAddressListFromJsonResponse}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class ParseInetAddressListFromJsonResponseTest {
-
- Injector i = Guice.createInjector(new GsonModule());
-
- public void testPublic() throws UnknownHostException {
- InputStream is = getClass().getResourceAsStream("/test_list_addresses_public.json");
-
- UnwrapOnlyJsonValue<List<String>> parser = i.getInstance(Key
- .get(new TypeLiteral<UnwrapOnlyJsonValue<List<String>>>() {
- }));
- List<String> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
-
- assertEquals(response, ImmutableList.of("67.23.10.132", "67.23.10.131"));
- }
-
- public void testPrivate() throws UnknownHostException {
- InputStream is = getClass().getResourceAsStream("/test_list_addresses_private.json");
-
- UnwrapOnlyJsonValue<List<String>> parser = i.getInstance(Key
- .get(new TypeLiteral<UnwrapOnlyJsonValue<List<String>>>() {
- }));
- List<String> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
-
- assertEquals(response, ImmutableList.of("10.176.42.16"));
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/42cc3ce5/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseServerFromJsonResponseTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseServerFromJsonResponseTest.java b/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseServerFromJsonResponseTest.java
deleted file mode 100644
index 18f332f..0000000
--- a/apis/cloudservers/src/test/java/org/jclouds/cloudservers/functions/ParseServerFromJsonResponseTest.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-import java.net.UnknownHostException;
-import java.util.List;
-
-import org.jclouds.cloudservers.domain.Addresses;
-import org.jclouds.cloudservers.domain.Server;
-import org.jclouds.cloudservers.domain.ServerStatus;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.UnwrapOnlyJsonValue;
-import org.jclouds.json.config.GsonModule;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-import com.google.inject.Key;
-import com.google.inject.TypeLiteral;
-
-/**
- * Tests behavior of {@code ParseServerFromJsonResponse}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class ParseServerFromJsonResponseTest {
-
- public void testApplyInputStreamDetails() throws UnknownHostException {
- Server response = parseServer();
-
- assertEquals(response.getId(), 1234);
- assertEquals(response.getName(), "sample-server");
- assertEquals(response.getImageId(), Integer.valueOf(2));
- assertEquals(response.getFlavorId(), Integer.valueOf(1));
- assertEquals(response.getHostId(), "e4d909c290d0fb1ca068ffaddf22cbd0");
- assertEquals(response.getStatus(), ServerStatus.BUILD);
- assertEquals(response.getProgress(), Integer.valueOf(60));
- List<String> publicAddresses = Lists.newArrayList("67.23.10.132", "67.23.10.131");
- List<String> privateAddresses = Lists.newArrayList("10.176.42.16");
- Addresses addresses1 = Addresses.builder().publicAddresses(publicAddresses).privateAddresses(privateAddresses).build();
- assertEquals(response.getAddresses(), addresses1);
- assertEquals(response.getMetadata(), ImmutableMap.of("Server Label", "Web Head 1", "Image Version", "2.1"));
-
- }
-
- public static Server parseServer() {
- Injector i = Guice.createInjector(new GsonModule());
-
- InputStream is = ParseServerFromJsonResponseTest.class.getResourceAsStream("/test_get_server_detail.json");
-
- UnwrapOnlyJsonValue<Server> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Server>>() {
- }));
- Server response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
- return response;
- }
-
-}