mirror of https://github.com/apache/jclouds.git
Glesys api unit test and javadoc improvements
This commit is contained in:
parent
a1c4ec13ca
commit
7d5a791071
|
@ -20,13 +20,11 @@ package org.jclouds.glesys.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,26 +145,47 @@ public class ServerAllowedArguments {
|
||||||
this.dataCenters = dataCenters;
|
this.dataCenters = dataCenters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a list of disk sizes, in GB, that can be used for creating servers on this platform
|
||||||
|
* @see org.jclouds.glesys.domain.ServerTemplate#getMinDiskSize()
|
||||||
|
*/
|
||||||
public List<Integer> getDiskSizes() {
|
public List<Integer> getDiskSizes() {
|
||||||
return diskSizes;
|
return diskSizes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a list of memory sizes, in MB, that can be used for creating servers on this platform
|
||||||
|
* @see org.jclouds.glesys.domain.ServerTemplate#getMinMemSize()
|
||||||
|
*/
|
||||||
public List<Integer> getMemorySizes() {
|
public List<Integer> getMemorySizes() {
|
||||||
return memorySizes;
|
return memorySizes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a list of which core counts can be used for creating servers on this platform
|
||||||
|
*/
|
||||||
public List<Integer> getCpuCores() {
|
public List<Integer> getCpuCores() {
|
||||||
return cpuCores;
|
return cpuCores;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a list of template names available for creating servers on this platform
|
||||||
|
* @see org.jclouds.glesys.domain.ServerTemplate#getName()
|
||||||
|
*/
|
||||||
public List<String> getTemplates() {
|
public List<String> getTemplates() {
|
||||||
return templates;
|
return templates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the list of transfer settings available for creating servers on this platform
|
||||||
|
*/
|
||||||
public List<Integer> getTransfers() {
|
public List<Integer> getTransfers() {
|
||||||
return transfers;
|
return transfers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the list of datacenters available that support creating servers on this platform
|
||||||
|
*/
|
||||||
public List<String> getDataCenters() {
|
public List<String> getDataCenters() {
|
||||||
return dataCenters;
|
return dataCenters;
|
||||||
}
|
}
|
||||||
|
@ -204,7 +223,9 @@ public class ServerAllowedArguments {
|
||||||
checkNotNull(dataCenters, "dataCenters");
|
checkNotNull(dataCenters, "dataCenters");
|
||||||
|
|
||||||
Joiner commaJoiner = Joiner.on(", ");
|
Joiner commaJoiner = Joiner.on(", ");
|
||||||
return String.format("[disksize=[%s], memorysize=[%s], cpuCores=[%s], templates=[%s], transfers=[%s], datacenters=[%s]]", commaJoiner.join(diskSizes), commaJoiner.join(memorySizes), commaJoiner.join(cpuCores), commaJoiner.join(templates), commaJoiner.join(transfers), commaJoiner.join(dataCenters));
|
return String.format("[disksize=[%s], memorysize=[%s], cpuCores=[%s], templates=[%s], transfers=[%s], datacenters=[%s]]",
|
||||||
|
commaJoiner.join(diskSizes), commaJoiner.join(memorySizes), commaJoiner.join(cpuCores), commaJoiner.join(templates),
|
||||||
|
commaJoiner.join(transfers), commaJoiner.join(dataCenters));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,39 @@ import com.google.common.base.Objects;
|
||||||
* @see <a href="https://customer.glesys.com/api.php?a=doc#server_console" />
|
* @see <a href="https://customer.glesys.com/api.php?a=doc#server_console" />
|
||||||
*/
|
*/
|
||||||
public class ServerConsole {
|
public class ServerConsole {
|
||||||
|
public static Builder builder() {
|
||||||
|
return new Builder();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private String host;
|
||||||
|
private int port;
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
public Builder host(String host) {
|
||||||
|
this.host = host;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder port(int port) {
|
||||||
|
this.port = port;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder password(String password) {
|
||||||
|
this.password = password;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ServerConsole build() {
|
||||||
|
return new ServerConsole(host, port, password);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder fromServerConsole(ServerConsole in) {
|
||||||
|
return host(in.getHost()).port(in.getPort()).password(in.getPassword());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private final String host;
|
private final String host;
|
||||||
private final int port;
|
private final int port;
|
||||||
|
@ -20,19 +53,27 @@ public class ServerConsole {
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the host name to use to connect to the server
|
||||||
|
*/
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
return host;
|
return host;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the port to use to connect to the server
|
||||||
|
*/
|
||||||
public int getPort() {
|
public int getPort() {
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the password to use to connect to the server
|
||||||
|
*/
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object object) {
|
public boolean equals(Object object) {
|
||||||
if (this == object) {
|
if (this == object) {
|
||||||
|
|
|
@ -22,7 +22,10 @@ package org.jclouds.glesys.domain;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents detailed information about an available IP ip.
|
* Represents detailed information about an available ip address of a new server.
|
||||||
|
*
|
||||||
|
* @author Adam Lowe
|
||||||
|
* @see ServerCreated
|
||||||
*/
|
*/
|
||||||
public class ServerCreatedIp {
|
public class ServerCreatedIp {
|
||||||
|
|
||||||
|
@ -69,14 +72,23 @@ public class ServerCreatedIp {
|
||||||
this.cost = cost;
|
this.cost = cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the IP version, ex. 4
|
||||||
|
*/
|
||||||
public int getVersion() {
|
public int getVersion() {
|
||||||
return version;
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the ip address of the new server
|
||||||
|
*/
|
||||||
public String getIp() {
|
public String getIp() {
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the cost of the ip address allocated to the new server
|
||||||
|
*/
|
||||||
public double getCost() {
|
public double getCost() {
|
||||||
return cost;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ import com.google.common.base.CaseFormat;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Valid states for a server hosted in a Glesys cloud
|
||||||
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
* @see ServerStatus
|
* @see ServerStatus
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -4,11 +4,12 @@ import com.google.common.base.Objects;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Operating system template
|
||||||
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
* @see <a href= "https://customer.glesys.com/api.php?a=doc#server_status" />
|
* @see <a href= "https://customer.glesys.com/api.php?a=doc#server_templates" />
|
||||||
*/
|
*/
|
||||||
public class Template {
|
public class ServerTemplate {
|
||||||
|
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
|
@ -46,11 +47,11 @@ public class Template {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Template build() {
|
public ServerTemplate build() {
|
||||||
return new Template(name, minDiskSize, minMemSize, os, platform);
|
return new ServerTemplate(name, minDiskSize, minMemSize, os, platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromTemplate(Template in) {
|
public Builder fromTemplate(ServerTemplate in) {
|
||||||
return name(in.getName()).minDiskSize(in.getMinDiskSize()).minMemSize(in.getMinMemSize()).os(in.getOs()).platform(in.getPlatform());
|
return name(in.getName()).minDiskSize(in.getMinDiskSize()).minMemSize(in.getMinMemSize()).os(in.getOs()).platform(in.getPlatform());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +65,7 @@ public class Template {
|
||||||
private final String os;
|
private final String os;
|
||||||
private final String platform;
|
private final String platform;
|
||||||
|
|
||||||
public Template(String name, int minDiskSize, int minMemSize, String os, String platform) {
|
public ServerTemplate(String name, int minDiskSize, int minMemSize, String os, String platform) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.minDiskSize = minDiskSize;
|
this.minDiskSize = minDiskSize;
|
||||||
this.minMemSize = minMemSize;
|
this.minMemSize = minMemSize;
|
||||||
|
@ -76,18 +77,32 @@ public class Template {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the minimum allowed disk size in GB
|
||||||
|
* @see org.jclouds.glesys.domain.ServerAllowedArguments#getDiskSizes()
|
||||||
|
*/
|
||||||
public int getMinDiskSize() {
|
public int getMinDiskSize() {
|
||||||
return minDiskSize;
|
return minDiskSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the minimum allowed memory size in MB
|
||||||
|
* @see org.jclouds.glesys.domain.ServerAllowedArguments#getMemorySizes()
|
||||||
|
*/
|
||||||
public int getMinMemSize() {
|
public int getMinMemSize() {
|
||||||
return minMemSize;
|
return minMemSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name of the operating system type ex. "linux"
|
||||||
|
*/
|
||||||
public String getOs() {
|
public String getOs() {
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name of the platform this template is available in, ex. "Xen"
|
||||||
|
*/
|
||||||
public String getPlatform() {
|
public String getPlatform() {
|
||||||
return platform;
|
return platform;
|
||||||
}
|
}
|
||||||
|
@ -97,8 +112,8 @@ public class Template {
|
||||||
if (this == object) {
|
if (this == object) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (object instanceof Template) {
|
if (object instanceof ServerTemplate) {
|
||||||
final Template other = (Template) object;
|
final ServerTemplate other = (ServerTemplate) object;
|
||||||
return Objects.equal(name, other.name)
|
return Objects.equal(name, other.name)
|
||||||
&& Objects.equal(minDiskSize, other.minDiskSize)
|
&& Objects.equal(minDiskSize, other.minDiskSize)
|
||||||
&& Objects.equal(minMemSize, other.minMemSize)
|
&& Objects.equal(minMemSize, other.minMemSize)
|
|
@ -28,13 +28,16 @@ import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Represents an 'uptime' duration of server in a Glesys cloud
|
||||||
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
|
* @see ServerStatus
|
||||||
*/
|
*/
|
||||||
public class ServerUptime {
|
public class ServerUptime {
|
||||||
private final long time;
|
private final long time;
|
||||||
private final String timeString;
|
private final String timeString;
|
||||||
|
|
||||||
public ServerUptime(long time) {
|
private ServerUptime(long time) {
|
||||||
this.time = time;
|
this.time = time;
|
||||||
long days = TimeUnit.SECONDS.toDays(time);
|
long days = TimeUnit.SECONDS.toDays(time);
|
||||||
long hours = TimeUnit.SECONDS.toHours(time - TimeUnit.DAYS.toSeconds(days));
|
long hours = TimeUnit.SECONDS.toHours(time - TimeUnit.DAYS.toSeconds(days));
|
||||||
|
@ -65,14 +68,14 @@ public class ServerUptime {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param uptimeString a Glesys uptime string
|
* @param uptimeString a Glesys uptime string, ex. "0 0 0 0 0 10 1 1"
|
||||||
*/
|
*/
|
||||||
public static ServerUptime fromValue(String uptimeString) {
|
public static ServerUptime fromValue(String uptimeString) {
|
||||||
return new ServerUptime(uptimeString);
|
return new ServerUptime(uptimeString);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param time number of seconds
|
* @param time number of seconds the server has been up
|
||||||
*/
|
*/
|
||||||
public static ServerUptime fromValue(long time) {
|
public static ServerUptime fromValue(long time) {
|
||||||
return new ServerUptime(time);
|
return new ServerUptime(time);
|
||||||
|
@ -88,12 +91,12 @@ public class ServerUptime {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return object instanceof ServerUptime
|
return object instanceof ServerUptime
|
||||||
&& time == ((ServerUptime) object).time;
|
&& Objects.equal(time, ((ServerUptime) object).getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return 37 * (int) time;
|
return Objects.hashCode(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -101,5 +104,4 @@ public class ServerUptime {
|
||||||
return timeString;
|
return timeString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -36,6 +36,7 @@ import java.util.*;
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
* @author Adam Lowe
|
||||||
* @see ServerClient
|
* @see ServerClient
|
||||||
* @see <a href="https://customer.glesys.com/api.php" />
|
* @see <a href="https://customer.glesys.com/api.php" />
|
||||||
*/
|
*/
|
||||||
|
@ -110,7 +111,7 @@ public interface ServerAsyncClient {
|
||||||
@Path("/server/templates/format/json")
|
@Path("/server/templates/format/json")
|
||||||
@SelectJson("templates")
|
@SelectJson("templates")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
ListenableFuture<Map<String, Set<Template>>> getTemplates();
|
ListenableFuture<Map<String, Set<ServerTemplate>>> getTemplates();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ServerClient#stopServer
|
* @see ServerClient#stopServer
|
||||||
|
|
|
@ -18,17 +18,13 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.glesys.features;
|
package org.jclouds.glesys.features;
|
||||||
|
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
|
||||||
import org.jclouds.concurrent.Timeout;
|
import org.jclouds.concurrent.Timeout;
|
||||||
import org.jclouds.glesys.domain.*;
|
import org.jclouds.glesys.domain.*;
|
||||||
import org.jclouds.javax.annotation.Nullable;
|
import org.jclouds.javax.annotation.Nullable;
|
||||||
|
|
||||||
import javax.ws.rs.FormParam;
|
import javax.ws.rs.FormParam;
|
||||||
import javax.ws.rs.PathParam;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,6 +32,7 @@ import java.util.concurrent.TimeUnit;
|
||||||
* <p/>
|
* <p/>
|
||||||
*
|
*
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
|
* @author Adam Lowe
|
||||||
* @see ServerAsyncClient
|
* @see ServerAsyncClient
|
||||||
* @see <a href="https://customer.glesys.com/api.php" />
|
* @see <a href="https://customer.glesys.com/api.php" />
|
||||||
*/
|
*/
|
||||||
|
@ -86,8 +83,18 @@ public interface ServerClient {
|
||||||
*/
|
*/
|
||||||
ServerConsole getServerConsole(String id);
|
ServerConsole getServerConsole(String id);
|
||||||
|
|
||||||
// TODO should these be squished into single sets?
|
/**
|
||||||
Map<String, Set<Template>> getTemplates();
|
* Get information about the OS templates available
|
||||||
|
*
|
||||||
|
* @return a map of templates, keyed on platform
|
||||||
|
*/
|
||||||
|
Map<String, Set<ServerTemplate>> getTemplates();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get information about valid arguments to #createServer for each platform
|
||||||
|
*
|
||||||
|
* @return a map of argument lists, keyed on platform
|
||||||
|
*/
|
||||||
Map<String, ServerAllowedArguments> getAllowedArguments();
|
Map<String, ServerAllowedArguments> getAllowedArguments();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,5 +163,4 @@ public interface ServerClient {
|
||||||
void resetPassword(@FormParam("serverid") String id, @FormParam("newpassword") String password);
|
void resetPassword(@FormParam("serverid") String id, @FormParam("newpassword") String password);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -46,45 +46,45 @@ public class ServerClientLiveTest extends BaseGleSYSClientLiveTest {
|
||||||
private ServerClient client;
|
private ServerClient client;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCreateAndDestroyServer() throws Exception {
|
public void testAllowedArguments() throws Exception {
|
||||||
// ServerCreated server = client.createServer("Falkenberg", "Xen", "jclouds-test-host", "Debian-6 x64", 10, 512, 1, "password", 500, null, null);
|
Map<String,ServerAllowedArguments> templates = client.getAllowedArguments();
|
||||||
// System.out.println(server);
|
|
||||||
//
|
|
||||||
// boolean ready= false;
|
|
||||||
//
|
|
||||||
// for (int i=0; !ready && i<60; i++) {
|
|
||||||
// ServerStatus newStatus = client.getServerStatus(server.getId());
|
|
||||||
// if (newStatus.getState() == ServerState.RUNNING) {
|
|
||||||
// ready = true;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// System.out.println(newStatus);
|
|
||||||
// Thread.sleep(100);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// assertTrue(ready, "Server was not reported as running after 1 minute");
|
|
||||||
|
|
||||||
|
|
||||||
client.destroyServer("xm3054942", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testListTemplates() throws Exception {
|
|
||||||
Map<String,Set<Template>> templates = client.getTemplates();
|
|
||||||
|
|
||||||
assertTrue(templates.containsKey("OpenVZ"));
|
assertTrue(templates.containsKey("OpenVZ"));
|
||||||
assertTrue(templates.containsKey("Xen"));
|
assertTrue(templates.containsKey("Xen"));
|
||||||
|
|
||||||
for(Template template : templates.get("OpenVZ")) {
|
checkAllowedArguments(templates.get("OpenVZ"));
|
||||||
|
checkAllowedArguments(templates.get("Xen"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkAllowedArguments(ServerAllowedArguments t) {
|
||||||
|
assertNotNull(t);
|
||||||
|
|
||||||
|
assert t.getDataCenters().size() > 0 : t;
|
||||||
|
assert t.getCpuCores().size() > 0 : t;
|
||||||
|
assert t.getDiskSizes().size() > 0 : t;
|
||||||
|
assert t.getMemorySizes().size() > 0 : t;
|
||||||
|
assert t.getTemplates().size() > 0 : t;
|
||||||
|
assert t.getTransfers().size() > 0 : t;
|
||||||
|
assert t.getTransfers().size() > 0 : t;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testListTemplates() throws Exception {
|
||||||
|
Map<String,Set<ServerTemplate>> templates = client.getTemplates();
|
||||||
|
|
||||||
|
assertTrue(templates.containsKey("OpenVZ"));
|
||||||
|
assertTrue(templates.containsKey("Xen"));
|
||||||
|
|
||||||
|
for(ServerTemplate template : templates.get("OpenVZ")) {
|
||||||
checkTemplate(template, "OpenVZ");
|
checkTemplate(template, "OpenVZ");
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Template template : templates.get("Xen")) {
|
for(ServerTemplate template : templates.get("Xen")) {
|
||||||
checkTemplate(template, "Xen");
|
checkTemplate(template, "Xen");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkTemplate(Template t, String platform) {
|
private void checkTemplate(ServerTemplate t, String platform) {
|
||||||
assertNotNull(t);
|
assertNotNull(t);
|
||||||
assertNotNull(t.getName());
|
assertNotNull(t.getName());
|
||||||
assertNotNull(t.getOs());
|
assertNotNull(t.getOs());
|
||||||
|
|
|
@ -37,7 +37,7 @@ import org.testng.annotations.Test;
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
*/
|
*/
|
||||||
@Test(groups = "unit", testName = "ParseServerTemplatesTest")
|
@Test(groups = "unit", testName = "ParseServerTemplatesTest")
|
||||||
public class ParseServerTemplatesTest extends BaseItemParserTest<Map<String, Set<Template>>> {
|
public class ParseServerTemplatesTest extends BaseItemParserTest<Map<String, Set<ServerTemplate>>> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String resource() {
|
public String resource() {
|
||||||
|
@ -47,8 +47,8 @@ public class ParseServerTemplatesTest extends BaseItemParserTest<Map<String, Set
|
||||||
@Override
|
@Override
|
||||||
@SelectJson("templates")
|
@SelectJson("templates")
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
public Map<String, Set<Template>> expected() {
|
public Map<String, Set<ServerTemplate>> expected() {
|
||||||
Map<String, Set<Template>> result = new LinkedHashMap<String, Set<Template>>();
|
Map<String, Set<ServerTemplate>> result = new LinkedHashMap<String, Set<ServerTemplate>>();
|
||||||
|
|
||||||
String[] vzNames = new String[]{
|
String[] vzNames = new String[]{
|
||||||
"Centos 5", "Centos 5 64-bit", "Centos 6 32-bit", "Centos 6 64-bit",
|
"Centos 5", "Centos 5 64-bit", "Centos 6 32-bit", "Centos 6 64-bit",
|
||||||
|
@ -65,17 +65,17 @@ public class ParseServerTemplatesTest extends BaseItemParserTest<Map<String, Set
|
||||||
"Windows Server 2008 R2 x64 std", "Windows Server 2008 R2 x64 web", "Windows Server 2008 x64 web", "Windows Server 2008 x86 web"
|
"Windows Server 2008 R2 x64 std", "Windows Server 2008 R2 x64 web", "Windows Server 2008 x64 web", "Windows Server 2008 x86 web"
|
||||||
};
|
};
|
||||||
|
|
||||||
result.put("OpenVZ", new HashSet<Template>());
|
result.put("OpenVZ", new HashSet<ServerTemplate>());
|
||||||
for (String name : vzNames) {
|
for (String name : vzNames) {
|
||||||
result.get("OpenVZ").add(new Template(name, 5, 128, "linux", "OpenVZ"));
|
result.get("OpenVZ").add(new ServerTemplate(name, 5, 128, "linux", "OpenVZ"));
|
||||||
}
|
}
|
||||||
|
|
||||||
result.put("Xen", new HashSet<Template>());
|
result.put("Xen", new HashSet<ServerTemplate>());
|
||||||
for (String name : xenLinuxNames) {
|
for (String name : xenLinuxNames) {
|
||||||
result.get("Xen").add(new Template(name, 5, 512, name.startsWith("FreeBSD") ? "freebsd" : "linux", "Xen"));
|
result.get("Xen").add(new ServerTemplate(name, 5, 512, name.startsWith("FreeBSD") ? "freebsd" : "linux", "Xen"));
|
||||||
}
|
}
|
||||||
for (String name : xenWindowsNames) {
|
for (String name : xenWindowsNames) {
|
||||||
result.get("Xen").add(new Template(name, 20, 1024, "windows", "Xen"));
|
result.get("Xen").add(new ServerTemplate(name, 20, 1024, "windows", "Xen"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
Loading…
Reference in New Issue