@Test
  public void testListServers() throws Exception {
    Set<Server> response = client.listServers();
    assertNotNull(response);
    assertTrue(response.size() > 0);

    for (Server server : response) {
      ServerDetails newDetails = client.getServerDetails(server.getId());
      assertEquals(newDetails.getId(), server.getId());
      assertEquals(newDetails.getHostname(), server.getHostname());
      assertEquals(newDetails.getPlatform(), server.getPlatform());
      assertEquals(newDetails.getDatacenter(), server.getDatacenter());
      checkServer(newDetails);
    }
  }
 @Test
 public void testServerDetails() throws Exception {
   ServerDetails details = client.getServerDetails(testServerId);
   checkServer(details);
   assertEquals("Ubuntu 10.04 LTS 32-bit", details.getTemplateName());
   assertEquals("Falkenberg", details.getDatacenter());
   assertEquals("OpenVZ", details.getPlatform());
   assertEquals(5, details.getDiskSizeGB());
   assertEquals(512, details.getMemorySizeMB());
   assertEquals(1, details.getCpuCores());
   assertEquals(50, details.getTransferGB());
 }
  private void checkServer(ServerDetails server) {
    // description can be null
    assert server.getCpuCores() > 0 : server;
    assert server.getDiskSizeGB() > 0 : server;
    assert server.getMemorySizeMB() > 0 : server;
    assert server.getCost() != null;
    assert server.getTransferGB() > 0 : server;

    assertNotNull(server.getTemplateName());
    assertNotNull(server.getIps());
  }
  // takes a few minutes and requires an extra server (using 2 already)
  @Test(enabled = false)
  public void testCloneServer() throws Exception {
    ServerDetails testServer2 =
        client.cloneServer(testServerId, testHostName2, CloneServerOptions.Builder.cpucores(1));

    assertNotNull(testServer2.getId());
    assertEquals(testServer2.getHostname(), "jclouds-test2");
    assertTrue(testServer2.getIps().isEmpty());

    testServerId2 = testServer2.getId();

    RetryablePredicate<Server.State> cloneChecker =
        new ServerStatusChecker(client, testServerId2, 300, 10, TimeUnit.SECONDS);
    assertTrue(cloneChecker.apply(Server.State.STOPPED));

    client.startServer(testServer2.getId());

    // TODO ServerStatus==STOPPED suggests the previous call to start should have worked
    cloneChecker =
        new RetryablePredicate<Server.State>(
            new Predicate<Server.State>() {

              public boolean apply(Server.State value) {
                ServerStatus status =
                    client.getServerStatus(testServerId2, ServerStatusOptions.Builder.state());
                if (status.getState() == value) {
                  return true;
                }

                client.startServer(testServerId2);
                return false;
              }
            },
            300,
            10,
            TimeUnit.SECONDS);

    assertTrue(cloneChecker.apply(Server.State.RUNNING));
  }