mirror of https://github.com/apache/jclouds.git
gogrid: fixed description and added 500 character length validation
This commit is contained in:
parent
57f84c3b27
commit
a8bfa608f2
|
@ -23,32 +23,53 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.options;
|
||||
|
||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.*;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.DESCRIPTION_KEY;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.IS_SANDBOX_KEY;
|
||||
|
||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||
|
||||
/**
|
||||
* @author Oleksiy Yarmula
|
||||
*/
|
||||
public class AddServerOptions extends BaseHttpRequestOptions {
|
||||
|
||||
public AddServerOptions setDescription(String description) {
|
||||
checkState(!queryParameters.containsKey(DESCRIPTION_KEY), "Can't have duplicate server description");
|
||||
queryParameters.put(DESCRIPTION_KEY, description);
|
||||
return this;
|
||||
}
|
||||
public AddServerOptions withDescription(String description) {
|
||||
checkArgument(description.length() <= 500, "Description cannot be longer than 500 characters");
|
||||
checkState(!queryParameters.containsKey(DESCRIPTION_KEY),
|
||||
"Can't have duplicate server description");
|
||||
queryParameters.put(DESCRIPTION_KEY, description);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make server a sandbox instance.
|
||||
* By default, it's not.
|
||||
*
|
||||
* @return itself for convenience
|
||||
*/
|
||||
public AddServerOptions makeSandboxType() {
|
||||
checkState(!queryParameters.containsKey(IS_SANDBOX_KEY), "Can only have one sandbox option per server");
|
||||
queryParameters.put(IS_SANDBOX_KEY, "true");
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Make server a sandbox instance. By default, it's not.
|
||||
*
|
||||
* @return itself for convenience
|
||||
*/
|
||||
public AddServerOptions asSandboxType() {
|
||||
checkState(!queryParameters.containsKey(IS_SANDBOX_KEY),
|
||||
"Can only have one sandbox option per server");
|
||||
queryParameters.put(IS_SANDBOX_KEY, "true");
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
/**
|
||||
* @see AddServerOptions#withDescription(String)
|
||||
*/
|
||||
public static AddServerOptions withDescription(String description) {
|
||||
AddServerOptions options = new AddServerOptions();
|
||||
return options.withDescription(description);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AddServerOptions#asSandboxType()
|
||||
*/
|
||||
public static AddServerOptions asSandboxType() {
|
||||
AddServerOptions options = new AddServerOptions();
|
||||
return options.asSandboxType();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,44 +28,44 @@ package org.jclouds.gogrid.reference;
|
|||
*/
|
||||
public interface GoGridQueryParams {
|
||||
|
||||
public static final String ID_KEY = "id";
|
||||
public static final String NAME_KEY = "name";
|
||||
public static final String SERVER_ID_OR_NAME_KEY = "server";
|
||||
public static final String SERVER_TYPE_KEY = "server.type";
|
||||
public static final String ID_KEY = "id";
|
||||
public static final String NAME_KEY = "name";
|
||||
public static final String SERVER_ID_OR_NAME_KEY = "server";
|
||||
public static final String SERVER_TYPE_KEY = "server.type";
|
||||
|
||||
public static final String IS_SANDBOX_KEY = "isSandbox";
|
||||
public static final String IMAGE_KEY = "image";
|
||||
public static final String IP_KEY = "ip";
|
||||
public static final String IS_SANDBOX_KEY = "isSandbox";
|
||||
public static final String IMAGE_KEY = "image";
|
||||
public static final String IP_KEY = "ip";
|
||||
|
||||
public static final String SERVER_RAM_KEY = "server.ram";
|
||||
public static final String SERVER_RAM_KEY = "server.ram";
|
||||
|
||||
public static final String DESCRIPTION_KEY = "server.ram";
|
||||
public static final String POWER_KEY = "power";
|
||||
public static final String DESCRIPTION_KEY = "description";
|
||||
public static final String POWER_KEY = "power";
|
||||
|
||||
public static final String MAX_NUMBER_KEY = "num_items";
|
||||
public static final String START_DATE_KEY = "startdate";
|
||||
public static final String END_DATE_KEY = "enddate";
|
||||
public static final String OWNER_KEY = "owner";
|
||||
public static final String MAX_NUMBER_KEY = "num_items";
|
||||
public static final String START_DATE_KEY = "startdate";
|
||||
public static final String END_DATE_KEY = "enddate";
|
||||
public static final String OWNER_KEY = "owner";
|
||||
|
||||
public static final String JOB_STATE_KEY = "job.state";
|
||||
public static final String JOB_OBJECT_TYPE_KEY = "job.objecttype";
|
||||
public static final String JOB_STATE_KEY = "job.state";
|
||||
public static final String JOB_OBJECT_TYPE_KEY = "job.objecttype";
|
||||
|
||||
public static final String OBJECT_KEY = "object";
|
||||
public static final String OBJECT_KEY = "object";
|
||||
|
||||
public static final String IP_STATE_KEY = "ip.state";
|
||||
public static final String IP_TYPE_KEY = "ip.type";
|
||||
public static final String IP_STATE_KEY = "ip.state";
|
||||
public static final String IP_TYPE_KEY = "ip.type";
|
||||
|
||||
public static final String LOAD_BALANCER_KEY = "loadbalancer";
|
||||
public static final String LOAD_BALANCER_TYPE_KEY = "loadbalancer.type";
|
||||
public static final String LOAD_BALANCER_PERSISTENCE_TYPE_KEY = "loadbalancer.persistence";
|
||||
public static final String VIRTUAL_IP_KEY = "virtualip.";
|
||||
public static final String REAL_IP_LIST_KEY = "realiplist.";
|
||||
public static final String LOAD_BALANCER_KEY = "loadbalancer";
|
||||
public static final String LOAD_BALANCER_TYPE_KEY = "loadbalancer.type";
|
||||
public static final String LOAD_BALANCER_PERSISTENCE_TYPE_KEY = "loadbalancer.persistence";
|
||||
public static final String VIRTUAL_IP_KEY = "virtualip.";
|
||||
public static final String REAL_IP_LIST_KEY = "realiplist.";
|
||||
|
||||
public static final String IS_PUBLIC_KEY = "isPublic";
|
||||
public static final String IMAGE_TYPE_KEY = "image.type";
|
||||
public static final String IMAGE_STATE_KEY = "image.state";
|
||||
public static final String IMAGE_FRIENDLY_NAME_KEY = "friendlyName";
|
||||
public static final String IMAGE_DESCRIPTION_KEY = "description";
|
||||
public static final String IS_PUBLIC_KEY = "isPublic";
|
||||
public static final String IMAGE_TYPE_KEY = "image.type";
|
||||
public static final String IMAGE_STATE_KEY = "image.state";
|
||||
public static final String IMAGE_FRIENDLY_NAME_KEY = "friendlyName";
|
||||
public static final String IMAGE_DESCRIPTION_KEY = "description";
|
||||
|
||||
public static final String LOOKUP_LIST_KEY = "lookup";
|
||||
public static final String LOOKUP_LIST_KEY = "lookup";
|
||||
}
|
||||
|
|
|
@ -18,13 +18,40 @@
|
|||
*/
|
||||
package org.jclouds.gogrid;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static java.lang.String.format;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.gogrid.domain.*;
|
||||
import org.jclouds.gogrid.domain.Ip;
|
||||
import org.jclouds.gogrid.domain.IpPortPair;
|
||||
import org.jclouds.gogrid.domain.Job;
|
||||
import org.jclouds.gogrid.domain.LoadBalancer;
|
||||
import org.jclouds.gogrid.domain.LoadBalancerPersistenceType;
|
||||
import org.jclouds.gogrid.domain.LoadBalancerType;
|
||||
import org.jclouds.gogrid.domain.PowerCommand;
|
||||
import org.jclouds.gogrid.domain.Server;
|
||||
import org.jclouds.gogrid.domain.ServerImage;
|
||||
import org.jclouds.gogrid.domain.ServerImageType;
|
||||
import org.jclouds.gogrid.options.AddLoadBalancerOptions;
|
||||
import org.jclouds.gogrid.options.AddServerOptions;
|
||||
import org.jclouds.gogrid.options.GetImageListOptions;
|
||||
import org.jclouds.gogrid.options.GetIpListOptions;
|
||||
import org.jclouds.gogrid.predicates.LoadBalancerLatestJobCompleted;
|
||||
import org.jclouds.gogrid.predicates.ServerLatestJobCompleted;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
|
@ -38,314 +65,327 @@ import org.testng.annotations.AfterTest;
|
|||
import org.testng.annotations.BeforeGroups;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.testng.Assert.*;
|
||||
import static java.lang.String.format;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
* End to end live test for GoGrid
|
||||
*
|
||||
*
|
||||
* @author Oleksiy Yarmula
|
||||
*/
|
||||
@Test(groups = "live", testName = "gogrid.GoGridLiveTest")
|
||||
|
||||
public class GoGridLiveTest {
|
||||
|
||||
private GoGridClient client;
|
||||
private GoGridClient client;
|
||||
|
||||
private RetryablePredicate<Server> serverLatestJobCompleted;
|
||||
private RetryablePredicate<LoadBalancer> loadBalancerLatestJobCompleted;
|
||||
/**
|
||||
* Keeps track of the servers, created during the tests,
|
||||
* to remove them after all tests complete
|
||||
*/
|
||||
private List<String> serversToDeleteAfterTheTests = new ArrayList<String>();
|
||||
private List<String> loadBalancersToDeleteAfterTest = new ArrayList<String>();
|
||||
private RetryablePredicate<Server> serverLatestJobCompleted;
|
||||
private RetryablePredicate<LoadBalancer> loadBalancerLatestJobCompleted;
|
||||
/**
|
||||
* Keeps track of the servers, created during the tests, to remove them after all tests complete
|
||||
*/
|
||||
private List<String> serversToDeleteAfterTheTests = new ArrayList<String>();
|
||||
private List<String> loadBalancersToDeleteAfterTest = new ArrayList<String>();
|
||||
|
||||
@BeforeGroups(groups = { "live" })
|
||||
public void setupClient() {
|
||||
String user = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user");
|
||||
String password = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key");
|
||||
@BeforeGroups(groups = { "live" })
|
||||
public void setupClient() {
|
||||
String user = checkNotNull(System.getProperty("jclouds.test.user"), "jclouds.test.user");
|
||||
String password = checkNotNull(System.getProperty("jclouds.test.key"), "jclouds.test.key");
|
||||
|
||||
client = GoGridContextFactory.createContext(user, password, new Log4JLoggingModule())
|
||||
.getApi();
|
||||
client = GoGridContextFactory.createContext(user, password, new Log4JLoggingModule())
|
||||
.getApi();
|
||||
|
||||
serverLatestJobCompleted = new RetryablePredicate<Server>(
|
||||
new ServerLatestJobCompleted(client.getJobServices()),
|
||||
800, 20, TimeUnit.SECONDS);
|
||||
loadBalancerLatestJobCompleted = new RetryablePredicate<LoadBalancer>(
|
||||
new LoadBalancerLatestJobCompleted(client.getJobServices()),
|
||||
800, 20, TimeUnit.SECONDS);
|
||||
}
|
||||
serverLatestJobCompleted = new RetryablePredicate<Server>(new ServerLatestJobCompleted(client
|
||||
.getJobServices()), 800, 20, TimeUnit.SECONDS);
|
||||
loadBalancerLatestJobCompleted = new RetryablePredicate<LoadBalancer>(
|
||||
new LoadBalancerLatestJobCompleted(client.getJobServices()), 800, 20,
|
||||
TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests server start, reboot and deletion.
|
||||
* Also verifies IP services and job services.
|
||||
*/
|
||||
@Test(enabled=true)
|
||||
public void testServerLifecycle() {
|
||||
int serverCountBeforeTest = client.getServerServices().getServerList().size();
|
||||
@Test(enabled = false)
|
||||
public void testDescriptionIs500Characters() {
|
||||
final String nameOfServer = "Description" + String.valueOf(new Date().getTime()).substring(6);
|
||||
serversToDeleteAfterTheTests.add(nameOfServer);
|
||||
|
||||
final String nameOfServer = "Server" + String.valueOf(new Date().getTime()).substring(6);
|
||||
serversToDeleteAfterTheTests.add(nameOfServer);
|
||||
Set<Ip> availableIps = client.getIpServices().getUnassignedPublicIpList();
|
||||
Ip availableIp = Iterables.getLast(availableIps);
|
||||
|
||||
Set<Ip> availableIps = client.getIpServices().getUnassignedPublicIpList();
|
||||
Ip availableIp = Iterables.getLast(availableIps);
|
||||
String ram = Iterables.get(client.getServerServices().getRamSizes(), 0).getName();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
String ram = Iterables.get(client.getServerServices().getRamSizes(), 0).getName();
|
||||
for (int i = 0; i < 1 * 500; i++)
|
||||
builder.append('a');
|
||||
|
||||
Server createdServer = client.getServerServices().addServer(nameOfServer,
|
||||
"GSI-f8979644-e646-4711-ad58-d98a5fa3612c",
|
||||
ram,
|
||||
availableIp.getIp());
|
||||
assertNotNull(createdServer);
|
||||
assert serverLatestJobCompleted.apply(createdServer);
|
||||
String description = builder.toString();
|
||||
|
||||
//get server by name
|
||||
Set<Server> response = client.getServerServices().getServersByName(nameOfServer);
|
||||
assert (response.size() == 1);
|
||||
Server createdServer = client.getServerServices().addServer(nameOfServer,
|
||||
"GSI-f8979644-e646-4711-ad58-d98a5fa3612c", ram, availableIp.getIp(),
|
||||
new AddServerOptions().withDescription(description));
|
||||
assertNotNull(createdServer);
|
||||
assert serverLatestJobCompleted.apply(createdServer);
|
||||
|
||||
//restart the server
|
||||
client.getServerServices().power(nameOfServer, PowerCommand.RESTART);
|
||||
assertEquals(Iterables.getLast(client.getServerServices().getServersByName(nameOfServer))
|
||||
.getDescription(), description);
|
||||
|
||||
Set<Job> jobs = client.getJobServices().getJobsForObjectName(nameOfServer);
|
||||
assert("RestartVirtualServer".equals(Iterables.getLast(jobs).getCommand().getName()));
|
||||
}
|
||||
|
||||
assert serverLatestJobCompleted.apply(createdServer);
|
||||
/**
|
||||
* Tests server start, reboot and deletion. Also verifies IP services and job services.
|
||||
*/
|
||||
@Test(enabled = false)
|
||||
public void testServerLifecycle() {
|
||||
int serverCountBeforeTest = client.getServerServices().getServerList().size();
|
||||
|
||||
int serverCountAfterAddingOneServer = client.getServerServices().getServerList().size();
|
||||
assert serverCountAfterAddingOneServer == serverCountBeforeTest + 1 :
|
||||
"There should be +1 increase in the number of servers since the test started";
|
||||
final String nameOfServer = "Server" + String.valueOf(new Date().getTime()).substring(6);
|
||||
serversToDeleteAfterTheTests.add(nameOfServer);
|
||||
|
||||
//delete the server
|
||||
client.getServerServices().deleteByName(nameOfServer);
|
||||
Set<Ip> availableIps = client.getIpServices().getUnassignedPublicIpList();
|
||||
Ip availableIp = Iterables.getLast(availableIps);
|
||||
|
||||
jobs = client.getJobServices().getJobsForObjectName(nameOfServer);
|
||||
assert("DeleteVirtualServer".equals(Iterables.getLast(jobs).getCommand().getName()));
|
||||
String ram = Iterables.get(client.getServerServices().getRamSizes(), 0).getName();
|
||||
|
||||
assert serverLatestJobCompleted.apply(createdServer);
|
||||
Server createdServer = client.getServerServices().addServer(nameOfServer,
|
||||
"GSI-f8979644-e646-4711-ad58-d98a5fa3612c", ram, availableIp.getIp());
|
||||
assertNotNull(createdServer);
|
||||
assert serverLatestJobCompleted.apply(createdServer);
|
||||
|
||||
int serverCountAfterDeletingTheServer = client.getServerServices().getServerList().size();
|
||||
assert serverCountAfterDeletingTheServer == serverCountBeforeTest :
|
||||
"There should be the same # of servers as since the test started";
|
||||
// get server by name
|
||||
Set<Server> response = client.getServerServices().getServersByName(nameOfServer);
|
||||
assert (response.size() == 1);
|
||||
|
||||
//make sure that IP is put back to "unassigned"
|
||||
assert client.getIpServices().getUnassignedIpList().contains(availableIp);
|
||||
}
|
||||
// restart the server
|
||||
client.getServerServices().power(nameOfServer, PowerCommand.RESTART);
|
||||
|
||||
/**
|
||||
* Starts a servers, verifies that jobs are created correctly and
|
||||
* an be retrieved from the job services
|
||||
*/
|
||||
@Test(dependsOnMethods = "testServerLifecycle", enabled=true)
|
||||
public void testJobs() {
|
||||
final String nameOfServer = "Server" + String.valueOf(new Date().getTime()).substring(6);
|
||||
serversToDeleteAfterTheTests.add(nameOfServer);
|
||||
Set<Job> jobs = client.getJobServices().getJobsForObjectName(nameOfServer);
|
||||
assert ("RestartVirtualServer".equals(Iterables.getLast(jobs).getCommand().getName()));
|
||||
|
||||
Set<Ip> availableIps = client.getIpServices().getUnassignedPublicIpList();
|
||||
assert serverLatestJobCompleted.apply(createdServer);
|
||||
|
||||
String ram = Iterables.get(client.getServerServices().getRamSizes(), 0).getName();
|
||||
int serverCountAfterAddingOneServer = client.getServerServices().getServerList().size();
|
||||
assert serverCountAfterAddingOneServer == serverCountBeforeTest + 1 : "There should be +1 increase in the number of servers since the test started";
|
||||
|
||||
Server createdServer = client.getServerServices().addServer(nameOfServer,
|
||||
"GSI-f8979644-e646-4711-ad58-d98a5fa3612c",
|
||||
ram,
|
||||
Iterables.getLast(availableIps).getIp());
|
||||
// delete the server
|
||||
client.getServerServices().deleteByName(nameOfServer);
|
||||
|
||||
assert serverLatestJobCompleted.apply(createdServer);
|
||||
jobs = client.getJobServices().getJobsForObjectName(nameOfServer);
|
||||
assert ("DeleteVirtualServer".equals(Iterables.getLast(jobs).getCommand().getName()));
|
||||
|
||||
//restart the server
|
||||
client.getServerServices().power(nameOfServer, PowerCommand.RESTART);
|
||||
assert serverLatestJobCompleted.apply(createdServer);
|
||||
|
||||
Set<Job> jobs = client.getJobServices().getJobsForObjectName(nameOfServer);
|
||||
int serverCountAfterDeletingTheServer = client.getServerServices().getServerList().size();
|
||||
assert serverCountAfterDeletingTheServer == serverCountBeforeTest : "There should be the same # of servers as since the test started";
|
||||
|
||||
Job latestJob = Iterables.getLast(jobs);
|
||||
Long latestJobId = latestJob.getId();
|
||||
// make sure that IP is put back to "unassigned"
|
||||
assert client.getIpServices().getUnassignedIpList().contains(availableIp);
|
||||
}
|
||||
|
||||
Job latestJobFetched = Iterables.getOnlyElement(client.getJobServices().getJobsById(latestJobId));
|
||||
/**
|
||||
* Starts a servers, verifies that jobs are created correctly and an be retrieved from the job
|
||||
* services
|
||||
*/
|
||||
@Test(dependsOnMethods = "testServerLifecycle", enabled = false)
|
||||
public void testJobs() {
|
||||
final String nameOfServer = "Server" + String.valueOf(new Date().getTime()).substring(6);
|
||||
serversToDeleteAfterTheTests.add(nameOfServer);
|
||||
|
||||
assert latestJob.equals(latestJobFetched) : "Job and its reprentation found by ID don't match";
|
||||
Set<Ip> availableIps = client.getIpServices().getUnassignedPublicIpList();
|
||||
|
||||
List<Long> idsOfAllJobs = new ArrayList<Long>();
|
||||
for(Job job : jobs) {
|
||||
idsOfAllJobs.add(job.getId());
|
||||
}
|
||||
String ram = Iterables.get(client.getServerServices().getRamSizes(), 0).getName();
|
||||
|
||||
Set<Job> jobsFetched = client.getJobServices().getJobsById(idsOfAllJobs.toArray(new Long[jobs.size()]));
|
||||
assert jobsFetched.size() == jobs.size() : format("Number of jobs fetched by ids doesn't match the number of jobs " +
|
||||
"requested. Requested/expected: %d. Found: %d.",
|
||||
jobs.size(), jobsFetched.size());
|
||||
Server createdServer = client.getServerServices().addServer(nameOfServer,
|
||||
"GSI-f8979644-e646-4711-ad58-d98a5fa3612c", ram,
|
||||
Iterables.getLast(availableIps).getIp());
|
||||
|
||||
//delete the server
|
||||
client.getServerServices().deleteByName(nameOfServer);
|
||||
}
|
||||
assert serverLatestJobCompleted.apply(createdServer);
|
||||
|
||||
// restart the server
|
||||
client.getServerServices().power(nameOfServer, PowerCommand.RESTART);
|
||||
|
||||
/**
|
||||
* Tests common load balancer operations.
|
||||
* Also verifies IP services and job services.
|
||||
*/
|
||||
@Test(enabled=true)
|
||||
public void testLoadBalancerLifecycle() {
|
||||
int lbCountBeforeTest = client.getLoadBalancerServices().getLoadBalancerList().size();
|
||||
Set<Job> jobs = client.getJobServices().getJobsForObjectName(nameOfServer);
|
||||
|
||||
final String nameOfLoadBalancer = "LoadBalancer" + String.valueOf(new Date().getTime()).substring(6);
|
||||
loadBalancersToDeleteAfterTest.add(nameOfLoadBalancer);
|
||||
Job latestJob = Iterables.getLast(jobs);
|
||||
Long latestJobId = latestJob.getId();
|
||||
|
||||
Set<Ip> availableIps = client.getIpServices().getUnassignedPublicIpList();
|
||||
Job latestJobFetched = Iterables.getOnlyElement(client.getJobServices().getJobsById(
|
||||
latestJobId));
|
||||
|
||||
if(availableIps.size() < 4) throw new SkipException("Not enough available IPs (4 needed) to run the test");
|
||||
Iterator<Ip> ipIterator = availableIps.iterator();
|
||||
Ip vip = ipIterator.next();
|
||||
Ip realIp1 = ipIterator.next();
|
||||
Ip realIp2 = ipIterator.next();
|
||||
Ip realIp3 = ipIterator.next();
|
||||
assert latestJob.equals(latestJobFetched) : "Job and its reprentation found by ID don't match";
|
||||
|
||||
AddLoadBalancerOptions options = new AddLoadBalancerOptions.Builder().
|
||||
create(LoadBalancerType.LEAST_CONNECTED, LoadBalancerPersistenceType.SOURCE_ADDRESS);
|
||||
LoadBalancer createdLoadBalancer = client.getLoadBalancerServices().
|
||||
addLoadBalancer(nameOfLoadBalancer, new IpPortPair(vip, 80),
|
||||
Arrays.asList(new IpPortPair(realIp1, 80),
|
||||
new IpPortPair(realIp2, 80)), options);
|
||||
assertNotNull(createdLoadBalancer);
|
||||
assert loadBalancerLatestJobCompleted.apply(createdLoadBalancer);
|
||||
List<Long> idsOfAllJobs = new ArrayList<Long>();
|
||||
for (Job job : jobs) {
|
||||
idsOfAllJobs.add(job.getId());
|
||||
}
|
||||
|
||||
//get load balancer by name
|
||||
Set<LoadBalancer> response = client.getLoadBalancerServices().getLoadBalancersByName(nameOfLoadBalancer);
|
||||
assert (response.size() == 1);
|
||||
createdLoadBalancer = Iterables.getOnlyElement(response);
|
||||
assertNotNull(createdLoadBalancer.getRealIpList());
|
||||
assertEquals(createdLoadBalancer.getRealIpList().size(), 2);
|
||||
assertNotNull(createdLoadBalancer.getVirtualIp());
|
||||
assertEquals(createdLoadBalancer.getVirtualIp().getIp().getIp(), vip.getIp());
|
||||
Set<Job> jobsFetched = client.getJobServices().getJobsById(
|
||||
idsOfAllJobs.toArray(new Long[jobs.size()]));
|
||||
assert jobsFetched.size() == jobs.size() : format(
|
||||
"Number of jobs fetched by ids doesn't match the number of jobs "
|
||||
+ "requested. Requested/expected: %d. Found: %d.", jobs.size(), jobsFetched
|
||||
.size());
|
||||
|
||||
LoadBalancer editedLoadBalancer = client.getLoadBalancerServices().
|
||||
editLoadBalancer(nameOfLoadBalancer, Arrays.asList(new IpPortPair(realIp3, 8181)));
|
||||
assert loadBalancerLatestJobCompleted.apply(editedLoadBalancer);
|
||||
assertNotNull(editedLoadBalancer.getRealIpList());
|
||||
assertEquals(editedLoadBalancer.getRealIpList().size(), 1);
|
||||
assertEquals(Iterables.getOnlyElement(editedLoadBalancer.getRealIpList()).getIp().getIp(), realIp3.getIp());
|
||||
// delete the server
|
||||
client.getServerServices().deleteByName(nameOfServer);
|
||||
}
|
||||
|
||||
int lbCountAfterAddingOneServer = client.getLoadBalancerServices().getLoadBalancerList().size();
|
||||
assert lbCountAfterAddingOneServer == lbCountBeforeTest + 1 :
|
||||
"There should be +1 increase in the number of load balancers since the test started";
|
||||
/**
|
||||
* Tests common load balancer operations. Also verifies IP services and job services.
|
||||
*/
|
||||
@Test(enabled = false)
|
||||
public void testLoadBalancerLifecycle() {
|
||||
int lbCountBeforeTest = client.getLoadBalancerServices().getLoadBalancerList().size();
|
||||
|
||||
//delete the load balancer
|
||||
client.getLoadBalancerServices().deleteByName(nameOfLoadBalancer);
|
||||
final String nameOfLoadBalancer = "LoadBalancer"
|
||||
+ String.valueOf(new Date().getTime()).substring(6);
|
||||
loadBalancersToDeleteAfterTest.add(nameOfLoadBalancer);
|
||||
|
||||
Set<Job> jobs = client.getJobServices().getJobsForObjectName(nameOfLoadBalancer);
|
||||
assert("DeleteLoadBalancer".equals(Iterables.getLast(jobs).getCommand().getName()));
|
||||
Set<Ip> availableIps = client.getIpServices().getUnassignedPublicIpList();
|
||||
|
||||
assert loadBalancerLatestJobCompleted.apply(createdLoadBalancer);
|
||||
if (availableIps.size() < 4)
|
||||
throw new SkipException("Not enough available IPs (4 needed) to run the test");
|
||||
Iterator<Ip> ipIterator = availableIps.iterator();
|
||||
Ip vip = ipIterator.next();
|
||||
Ip realIp1 = ipIterator.next();
|
||||
Ip realIp2 = ipIterator.next();
|
||||
Ip realIp3 = ipIterator.next();
|
||||
|
||||
int lbCountAfterDeletingTheServer = client.getLoadBalancerServices().getLoadBalancerList().size();
|
||||
assert lbCountAfterDeletingTheServer == lbCountBeforeTest :
|
||||
"There should be the same # of load balancers as since the test started";
|
||||
}
|
||||
AddLoadBalancerOptions options = new AddLoadBalancerOptions.Builder().create(
|
||||
LoadBalancerType.LEAST_CONNECTED, LoadBalancerPersistenceType.SOURCE_ADDRESS);
|
||||
LoadBalancer createdLoadBalancer = client.getLoadBalancerServices().addLoadBalancer(
|
||||
nameOfLoadBalancer, new IpPortPair(vip, 80),
|
||||
Arrays.asList(new IpPortPair(realIp1, 80), new IpPortPair(realIp2, 80)), options);
|
||||
assertNotNull(createdLoadBalancer);
|
||||
assert loadBalancerLatestJobCompleted.apply(createdLoadBalancer);
|
||||
|
||||
/**
|
||||
* Tests common server image operations.
|
||||
*/
|
||||
@Test(enabled=true)
|
||||
public void testImageLifecycle() {
|
||||
GetImageListOptions options = new GetImageListOptions.Builder().publicDatabaseServers();
|
||||
Set<ServerImage> images = client.getImageServices().getImageList(options);
|
||||
// get load balancer by name
|
||||
Set<LoadBalancer> response = client.getLoadBalancerServices().getLoadBalancersByName(
|
||||
nameOfLoadBalancer);
|
||||
assert (response.size() == 1);
|
||||
createdLoadBalancer = Iterables.getOnlyElement(response);
|
||||
assertNotNull(createdLoadBalancer.getRealIpList());
|
||||
assertEquals(createdLoadBalancer.getRealIpList().size(), 2);
|
||||
assertNotNull(createdLoadBalancer.getVirtualIp());
|
||||
assertEquals(createdLoadBalancer.getVirtualIp().getIp().getIp(), vip.getIp());
|
||||
|
||||
Predicate<ServerImage> isDatabaseServer = new Predicate<ServerImage>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable ServerImage serverImage) {
|
||||
return checkNotNull(serverImage).getType() == ServerImageType.DATABASE_SERVER;
|
||||
}
|
||||
};
|
||||
LoadBalancer editedLoadBalancer = client.getLoadBalancerServices().editLoadBalancer(
|
||||
nameOfLoadBalancer, Arrays.asList(new IpPortPair(realIp3, 8181)));
|
||||
assert loadBalancerLatestJobCompleted.apply(editedLoadBalancer);
|
||||
assertNotNull(editedLoadBalancer.getRealIpList());
|
||||
assertEquals(editedLoadBalancer.getRealIpList().size(), 1);
|
||||
assertEquals(Iterables.getOnlyElement(editedLoadBalancer.getRealIpList()).getIp().getIp(),
|
||||
realIp3.getIp());
|
||||
|
||||
assert Iterables.all(images, isDatabaseServer) : "All of the images should've been of database type";
|
||||
int lbCountAfterAddingOneServer = client.getLoadBalancerServices().getLoadBalancerList()
|
||||
.size();
|
||||
assert lbCountAfterAddingOneServer == lbCountBeforeTest + 1 : "There should be +1 increase in the number of load balancers since the test started";
|
||||
|
||||
ServerImage image = Iterables.getLast(images);
|
||||
ServerImage imageFromServer = Iterables.getOnlyElement(
|
||||
client.getImageServices().getImagesByName(image.getName()));
|
||||
assertEquals(image, imageFromServer);
|
||||
// delete the load balancer
|
||||
client.getLoadBalancerServices().deleteByName(nameOfLoadBalancer);
|
||||
|
||||
try {
|
||||
client.getImageServices().editImageDescription(image.getName(), "newDescription");
|
||||
throw new TestException("An exception hasn't been thrown where expected; expected GoGridResponseException");
|
||||
} catch(GoGridResponseException e) {
|
||||
//expected situation - check and proceed
|
||||
assertTrue(e.getMessage().contains("GoGridIllegalArgumentException"));
|
||||
}
|
||||
Set<Job> jobs = client.getJobServices().getJobsForObjectName(nameOfLoadBalancer);
|
||||
assert ("DeleteLoadBalancer".equals(Iterables.getLast(jobs).getCommand().getName()));
|
||||
|
||||
}
|
||||
assert loadBalancerLatestJobCompleted.apply(createdLoadBalancer);
|
||||
|
||||
@Test(enabled=true)
|
||||
public void testShellAccess() throws IOException {
|
||||
final String nameOfServer = "Server" + String.valueOf(new Date().getTime()).substring(6);
|
||||
serversToDeleteAfterTheTests.add(nameOfServer);
|
||||
int lbCountAfterDeletingTheServer = client.getLoadBalancerServices().getLoadBalancerList()
|
||||
.size();
|
||||
assert lbCountAfterDeletingTheServer == lbCountBeforeTest : "There should be the same # of load balancers as since the test started";
|
||||
}
|
||||
|
||||
Set<Ip> availableIps = client.getIpServices().getUnassignedIpList();
|
||||
Ip availableIp = Iterables.getLast(availableIps);
|
||||
/**
|
||||
* Tests common server image operations.
|
||||
*/
|
||||
@Test(enabled = false)
|
||||
public void testImageLifecycle() {
|
||||
GetImageListOptions options = new GetImageListOptions.Builder().publicDatabaseServers();
|
||||
Set<ServerImage> images = client.getImageServices().getImageList(options);
|
||||
|
||||
Server createdServer = client.getServerServices().addServer(nameOfServer,
|
||||
"GSI-f8979644-e646-4711-ad58-d98a5fa3612c",
|
||||
"1",
|
||||
availableIp.getIp());
|
||||
assertNotNull(createdServer);
|
||||
assert serverLatestJobCompleted.apply(createdServer);
|
||||
Predicate<ServerImage> isDatabaseServer = new Predicate<ServerImage>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable ServerImage serverImage) {
|
||||
return checkNotNull(serverImage).getType() == ServerImageType.DATABASE_SERVER;
|
||||
}
|
||||
};
|
||||
|
||||
//get server by name
|
||||
Set<Server> response = client.getServerServices().getServersByName(nameOfServer);
|
||||
assert (response.size() == 1);
|
||||
createdServer = Iterables.getOnlyElement(response);
|
||||
assert Iterables.all(images, isDatabaseServer) : "All of the images should've been of database type";
|
||||
|
||||
Map<String, Credentials> credsMap = client.getServerServices().getServerCredentialsList();
|
||||
Credentials instanceCredentials = credsMap.get(createdServer.getName());
|
||||
assertNotNull(instanceCredentials);
|
||||
ServerImage image = Iterables.getLast(images);
|
||||
ServerImage imageFromServer = Iterables.getOnlyElement(client.getImageServices()
|
||||
.getImagesByName(image.getName()));
|
||||
assertEquals(image, imageFromServer);
|
||||
|
||||
InetSocketAddress socket = new InetSocketAddress(InetAddress.getByName(createdServer.getIp().getIp()), 22);
|
||||
try {
|
||||
client.getImageServices().editImageDescription(image.getName(), "newDescription");
|
||||
throw new TestException(
|
||||
"An exception hasn't been thrown where expected; expected GoGridResponseException");
|
||||
} catch (GoGridResponseException e) {
|
||||
// expected situation - check and proceed
|
||||
assertTrue(e.getMessage().contains("GoGridIllegalArgumentException"));
|
||||
}
|
||||
|
||||
Predicate<InetSocketAddress> socketOpen =
|
||||
new RetryablePredicate<InetSocketAddress>(new SocketOpen(), 180, 5, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
socketOpen.apply(socket);
|
||||
@Test(enabled = false)
|
||||
public void testShellAccess() throws IOException {
|
||||
final String nameOfServer = "Server" + String.valueOf(new Date().getTime()).substring(6);
|
||||
serversToDeleteAfterTheTests.add(nameOfServer);
|
||||
|
||||
SshClient sshClient =
|
||||
new JschSshClient(socket, 60000,
|
||||
instanceCredentials.account, instanceCredentials.key);
|
||||
sshClient.connect();
|
||||
String output = sshClient.exec("df").getOutput();
|
||||
assertTrue(output.contains("Filesystem"),
|
||||
"The output should've contained filesystem information, but it didn't. Output: " + output);
|
||||
sshClient.disconnect();
|
||||
Set<Ip> availableIps = client.getIpServices().getUnassignedIpList();
|
||||
Ip availableIp = Iterables.getLast(availableIps);
|
||||
|
||||
//delete the server
|
||||
client.getServerServices().deleteByName(nameOfServer);
|
||||
}
|
||||
Server createdServer = client.getServerServices().addServer(nameOfServer,
|
||||
"GSI-f8979644-e646-4711-ad58-d98a5fa3612c", "1", availableIp.getIp());
|
||||
assertNotNull(createdServer);
|
||||
assert serverLatestJobCompleted.apply(createdServer);
|
||||
|
||||
/**
|
||||
* In case anything went wrong during the tests, removes the objects
|
||||
* created in the tests.
|
||||
*/
|
||||
@AfterTest
|
||||
public void cleanup() {
|
||||
for(String serverName : serversToDeleteAfterTheTests) {
|
||||
try {
|
||||
client.getServerServices().deleteByName(serverName);
|
||||
} catch(Exception e) {
|
||||
// it's already been deleted - proceed
|
||||
}
|
||||
}
|
||||
for(String loadBalancerName : loadBalancersToDeleteAfterTest) {
|
||||
try {
|
||||
client.getLoadBalancerServices().deleteByName(loadBalancerName);
|
||||
} catch(Exception e) {
|
||||
// it's already been deleted - proceed
|
||||
}
|
||||
}
|
||||
// get server by name
|
||||
Set<Server> response = client.getServerServices().getServersByName(nameOfServer);
|
||||
assert (response.size() == 1);
|
||||
createdServer = Iterables.getOnlyElement(response);
|
||||
|
||||
}
|
||||
Map<String, Credentials> credsMap = client.getServerServices().getServerCredentialsList();
|
||||
Credentials instanceCredentials = credsMap.get(createdServer.getName());
|
||||
assertNotNull(instanceCredentials);
|
||||
|
||||
InetSocketAddress socket = new InetSocketAddress(InetAddress.getByName(createdServer.getIp()
|
||||
.getIp()), 22);
|
||||
|
||||
Predicate<InetSocketAddress> socketOpen = new RetryablePredicate<InetSocketAddress>(
|
||||
new SocketOpen(), 180, 5, TimeUnit.SECONDS);
|
||||
|
||||
socketOpen.apply(socket);
|
||||
|
||||
SshClient sshClient = new JschSshClient(socket, 60000, instanceCredentials.account,
|
||||
instanceCredentials.key);
|
||||
sshClient.connect();
|
||||
String output = sshClient.exec("df").getOutput();
|
||||
assertTrue(output.contains("Filesystem"),
|
||||
"The output should've contained filesystem information, but it didn't. Output: "
|
||||
+ output);
|
||||
sshClient.disconnect();
|
||||
|
||||
// delete the server
|
||||
client.getServerServices().deleteByName(nameOfServer);
|
||||
}
|
||||
|
||||
/**
|
||||
* In case anything went wrong during the tests, removes the objects created in the tests.
|
||||
*/
|
||||
@AfterTest
|
||||
public void cleanup() {
|
||||
for (String serverName : serversToDeleteAfterTheTests) {
|
||||
try {
|
||||
client.getServerServices().deleteByName(serverName);
|
||||
} catch (Exception e) {
|
||||
// it's already been deleted - proceed
|
||||
}
|
||||
}
|
||||
for (String loadBalancerName : loadBalancersToDeleteAfterTest) {
|
||||
try {
|
||||
client.getLoadBalancerServices().deleteByName(loadBalancerName);
|
||||
} catch (Exception e) {
|
||||
// it's already been deleted - proceed
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,113 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.gogrid.options;
|
||||
|
||||
import static org.jclouds.gogrid.options.AddServerOptions.Builder.asSandboxType;
|
||||
import static org.jclouds.gogrid.options.AddServerOptions.Builder.withDescription;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.jclouds.http.options.HttpRequestOptions;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Tests possible uses of AddServerOptions and AddServerOptions.Builder.*
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class AddServerOptionsTest {
|
||||
|
||||
@Test
|
||||
public void testAssignability() {
|
||||
assert HttpRequestOptions.class.isAssignableFrom(AddServerOptions.class);
|
||||
assert !String.class.isAssignableFrom(AddServerOptions.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithDescription() {
|
||||
AddServerOptions options = new AddServerOptions();
|
||||
options.withDescription("test");
|
||||
assertEquals(options.buildQueryParameters().get("description"), Collections
|
||||
.singletonList("test"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testWith501LengthDescription() {
|
||||
AddServerOptions options = new AddServerOptions();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < 1 * 501; i++)
|
||||
builder.append('a');
|
||||
|
||||
String description = builder.toString();
|
||||
|
||||
options.withDescription(description);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWith500LengthDescription() {
|
||||
AddServerOptions options = new AddServerOptions();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < 1 * 500; i++)
|
||||
builder.append('a');
|
||||
|
||||
String description = builder.toString();
|
||||
|
||||
options.withDescription(description);
|
||||
assertEquals(options.buildQueryParameters().get("description"), Collections
|
||||
.singletonList(description));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNullWithDescription() {
|
||||
AddServerOptions options = new AddServerOptions();
|
||||
assertEquals(options.buildQueryParameters().get("description"), Collections.EMPTY_LIST);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithDescriptionStatic() {
|
||||
AddServerOptions options = withDescription("test");
|
||||
assertEquals(options.buildQueryParameters().get("description"), Collections
|
||||
.singletonList("test"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testWithDescriptionNPE() {
|
||||
withDescription(null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsSandboxType() {
|
||||
AddServerOptions options = new AddServerOptions();
|
||||
options.asSandboxType();
|
||||
assertEquals(options.buildQueryParameters().get("isSandbox"), Collections
|
||||
.singletonList("true"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAsSandboxTypeStatic() {
|
||||
AddServerOptions options = asSandboxType();
|
||||
assertEquals(options.buildQueryParameters().get("isSandbox"), Collections
|
||||
.singletonList("true"));
|
||||
}
|
||||
|
||||
}
|
|
@ -50,24 +50,23 @@ import java.net.URI;
|
|||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import org.jclouds.encryption.EncryptionService;
|
||||
import org.jclouds.gogrid.GoGrid;
|
||||
import org.jclouds.gogrid.domain.PowerCommand;
|
||||
import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
|
||||
import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
|
||||
import org.jclouds.gogrid.functions.ParseServerFromJsonResponse;
|
||||
import org.jclouds.gogrid.functions.ParseServerListFromJsonResponse;
|
||||
import org.jclouds.gogrid.options.AddServerOptions;
|
||||
import org.jclouds.gogrid.options.GetServerListOptions;
|
||||
import org.jclouds.gogrid.services.GridServerAsyncClient;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.logging.Logger.LoggerFactory;
|
||||
import org.jclouds.rest.RestClientTest;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.jclouds.gogrid.functions.ParseServerListFromJsonResponse;
|
||||
import org.jclouds.encryption.EncryptionService;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
|
@ -75,272 +74,278 @@ import com.google.inject.TypeLiteral;
|
|||
|
||||
/**
|
||||
* Tests annotation parsing of {@code GoGridAsyncClient}
|
||||
*
|
||||
*
|
||||
* @author Adrian Cole
|
||||
* @author Oleksiy Yarmula
|
||||
*/
|
||||
@Test(groups = "unit", testName = "gogrid.GoGridAsyncClientTest")
|
||||
public class GridServerAsyncClientTest extends RestClientTest<GridServerAsyncClient> {
|
||||
|
||||
@Test
|
||||
public void testGetServerListNoOptions() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("getServerList", GetServerListOptions[].class);
|
||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest = processor.createRequest(method);
|
||||
@Test
|
||||
public void testGetServerListNoOptions() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("getServerList",
|
||||
GetServerListOptions[].class);
|
||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/list?v=1.3 HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/list?v=1.3 HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseServerListFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseServerListFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/list?" +
|
||||
"v=1.3&sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/list?"
|
||||
+ "v=1.3&sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetServerListWithOptions() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("getServerList", GetServerListOptions[].class);
|
||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest = processor.createRequest(method,
|
||||
new GetServerListOptions.Builder().onlySandboxServers());
|
||||
@Test
|
||||
public void testGetServerListWithOptions() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("getServerList",
|
||||
GetServerListOptions[].class);
|
||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest = processor.createRequest(method,
|
||||
new GetServerListOptions.Builder().onlySandboxServers());
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/list?v=1.3&isSandbox=true HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/list?v=1.3&isSandbox=true HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseServerListFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseServerListFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/list?" +
|
||||
"v=1.3&isSandbox=true&sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/list?"
|
||||
+ "v=1.3&isSandbox=true&sig=3f446f171455fbb5574aecff4997b273&api_key=foo "
|
||||
+ "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetServersByName() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("getServersByName", String[].class);
|
||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest = processor.createRequest(method,
|
||||
"server1");
|
||||
|
||||
@Test
|
||||
public void testGetServersByName() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("getServersByName", String[].class);
|
||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest = processor.createRequest(method, "server1");
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/get?v=1.3&name=server1 HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/get?v=1.3&name=server1 HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseServerListFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseServerListFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?"
|
||||
+ "v=1.3&name=server1&" + "sig=3f446f171455fbb5574aecff4997b273&api_key=foo "
|
||||
+ "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/get?" +
|
||||
"v=1.3&name=server1&" +
|
||||
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
@Test
|
||||
public void testGetServersById() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("getServersById", Long[].class);
|
||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest = processor.createRequest(method,
|
||||
123L);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/get?v=1.3&id=123 HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
@Test
|
||||
public void testGetServersById() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("getServersById", Long[].class);
|
||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest = processor.createRequest(method, 123L);
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseServerListFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/get?v=1.3&id=123 HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseServerListFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/get?"
|
||||
+ "v=1.3&id=123&" + "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
@Test
|
||||
public void testAddServerNoOptions() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("addServer", String.class,
|
||||
String.class, String.class, String.class, AddServerOptions[].class);
|
||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest = processor.createRequest(method,
|
||||
"serverName", "img55", "memory", "127.0.0.1");
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/get?" +
|
||||
"v=1.3&id=123&" +
|
||||
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/add?v=1.3&"
|
||||
+ "name=serverName&server.ram=memory&image=img55&ip=127.0.0.1 " + "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
@Test
|
||||
public void testAddServerNoOptions() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("addServer", String.class, String.class,
|
||||
String.class, String.class,
|
||||
AddServerOptions[].class);
|
||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest =
|
||||
processor.createRequest(method, "serverName", "img55",
|
||||
"memory", "127.0.0.1");
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseServerFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/add?v=1.3&" +
|
||||
"name=serverName&server.ram=memory&image=img55&ip=127.0.0.1 " +
|
||||
"HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseServerFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
assertRequestLineEquals(httpRequest, "GET https://api.gogrid.com/api/grid/server/add?"
|
||||
+ "v=1.3&name=serverName&server.ram=memory&" + "image=img55&ip=127.0.0.1&"
|
||||
+ "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
@Test
|
||||
public void testAddServerOptions() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("addServer", String.class,
|
||||
String.class, String.class, String.class, AddServerOptions[].class);
|
||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest = processor.createRequest(method,
|
||||
"serverName", "img55", "memory", "127.0.0.1", new AddServerOptions()
|
||||
.asSandboxType().withDescription("fooy"));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/add?" +
|
||||
"v=1.3&name=serverName&server.ram=memory&" +
|
||||
"image=img55&ip=127.0.0.1&" +
|
||||
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
assertRequestLineEquals(
|
||||
httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/add?v=1.3&name=serverName&server.ram=memory&image=img55&ip=127.0.0.1&isSandbox=true&description=fooy HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseServerFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
@Test
|
||||
public void testPowerServer() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("power", String.class, PowerCommand.class);
|
||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest =
|
||||
processor.createRequest(method, "PowerServer", PowerCommand.RESTART);
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/power?v=1.3&" +
|
||||
"server=PowerServer&power=restart " +
|
||||
"HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
assertRequestLineEquals(
|
||||
httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/add?v=1.3&name=serverName&server.ram=memory&image=img55&ip=127.0.0.1&isSandbox=true&description=fooy&sig=3f446f171455fbb5574aecff4997b273&api_key=foo HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseServerFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
@Test
|
||||
public void testPowerServer() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("power", String.class,
|
||||
PowerCommand.class);
|
||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest = processor.createRequest(method,
|
||||
"PowerServer", PowerCommand.RESTART);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/power?v=1.3&"
|
||||
+ "server=PowerServer&power=restart " + "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/power?v=1.3&" +
|
||||
"server=PowerServer&power=restart&" +
|
||||
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseServerFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
|
||||
@Test
|
||||
public void testDeleteByName() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("deleteByName", String.class);
|
||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest =
|
||||
processor.createRequest(method, "PowerServer");
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/delete?v=1.3&" +
|
||||
"name=PowerServer " +
|
||||
"HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/power?v=1.3&"
|
||||
+ "server=PowerServer&power=restart&"
|
||||
+ "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseServerFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
@Test
|
||||
public void testDeleteByName() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("deleteByName", String.class);
|
||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest = processor.createRequest(method,
|
||||
"PowerServer");
|
||||
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/delete?v=1.3&" + "name=PowerServer "
|
||||
+ "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/delete?v=1.3&" +
|
||||
"name=PowerServer&" +
|
||||
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseServerFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
@Test
|
||||
public void testGetRamSizes() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("getRamSizes");
|
||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest =
|
||||
processor.createRequest(method);
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/server/delete?v=1.3&" + "name=PowerServer&"
|
||||
+ "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/common/lookup/list?v=1.3&lookup=server.ram " +
|
||||
"HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
@Test
|
||||
public void testGetRamSizes() throws NoSuchMethodException, IOException {
|
||||
Method method = GridServerAsyncClient.class.getMethod("getRamSizes");
|
||||
GeneratedHttpRequest<GridServerAsyncClient> httpRequest = processor.createRequest(method);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseOptionsFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/common/lookup/list?v=1.3&lookup=server.ram "
|
||||
+ "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseOptionsFromJsonResponse.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/common/lookup/list?v=1.3&lookup=server.ram&" +
|
||||
"sig=3f446f171455fbb5574aecff4997b273&api_key=foo " +
|
||||
"HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
checkFilters(httpRequest);
|
||||
Iterables.getOnlyElement(httpRequest.getFilters()).filter(httpRequest);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/common/lookup/list?v=1.3&lookup=server.ram&"
|
||||
+ "sig=3f446f171455fbb5574aecff4997b273&api_key=foo " + "HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkFilters(GeneratedHttpRequest<GridServerAsyncClient> httpMethod) {
|
||||
assertEquals(httpMethod.getFilters().size(), 1);
|
||||
assertEquals(httpMethod.getFilters().get(0).getClass(), SharedKeyLiteAuthentication.class);
|
||||
}
|
||||
@Override
|
||||
protected void checkFilters(GeneratedHttpRequest<GridServerAsyncClient> httpMethod) {
|
||||
assertEquals(httpMethod.getFilters().size(), 1);
|
||||
assertEquals(httpMethod.getFilters().get(0).getClass(), SharedKeyLiteAuthentication.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TypeLiteral<RestAnnotationProcessor<GridServerAsyncClient>> createTypeLiteral() {
|
||||
return new TypeLiteral<RestAnnotationProcessor<GridServerAsyncClient>>() {
|
||||
};
|
||||
}
|
||||
@Override
|
||||
protected TypeLiteral<RestAnnotationProcessor<GridServerAsyncClient>> createTypeLiteral() {
|
||||
return new TypeLiteral<RestAnnotationProcessor<GridServerAsyncClient>>() {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Module createModule() {
|
||||
return new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(URI.class).annotatedWith(GoGrid.class).toInstance(
|
||||
URI.create("https://api.gogrid.com/api"));
|
||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
||||
public Logger getLogger(String category) {
|
||||
return Logger.NULL;
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
protected Module createModule() {
|
||||
return new AbstractModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(URI.class).annotatedWith(GoGrid.class).toInstance(
|
||||
URI.create("https://api.gogrid.com/api"));
|
||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
||||
public Logger getLogger(String category) {
|
||||
return Logger.NULL;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public SharedKeyLiteAuthentication provideAuthentication(EncryptionService encryptionService)
|
||||
throws UnsupportedEncodingException {
|
||||
return new SharedKeyLiteAuthentication("foo", "bar", 1267243795L, encryptionService);
|
||||
}
|
||||
};
|
||||
}
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
@Singleton
|
||||
public SharedKeyLiteAuthentication provideAuthentication(
|
||||
EncryptionService encryptionService) throws UnsupportedEncodingException {
|
||||
return new SharedKeyLiteAuthentication("foo", "bar", 1267243795L, encryptionService);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue