mirror of https://github.com/apache/jclouds.git
Merge branch 'master' of github.com:jclouds/jclouds
This commit is contained in:
commit
362d79d879
|
@ -133,7 +133,7 @@ public class AMIClientLiveTest {
|
|||
}
|
||||
|
||||
public void testDescribeImagesCC() {
|
||||
Set<? extends Image> twoResults = client.describeImagesInRegion(Region.US_EAST_1, filters(
|
||||
Set<? extends Image> ccResults = client.describeImagesInRegion(Region.US_EAST_1, filters(
|
||||
ImmutableMultimap.<String, String> builder()//
|
||||
.put("virtualization-type", "hvm")//
|
||||
.put("architecture", "x86_64")//
|
||||
|
@ -143,8 +143,8 @@ public class AMIClientLiveTest {
|
|||
.put("image-type", "machine")//
|
||||
.put("root-device-type", "ebs")//
|
||||
.build()).ownedBy("137112412989", "099720109477"));
|
||||
assertNotNull(twoResults);
|
||||
assertEquals(twoResults.size(), 35);
|
||||
assertNotNull(ccResults);
|
||||
assert (ccResults.size() >= 34) : ccResults;
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
|
|
|
@ -54,27 +54,35 @@ public class BillingToken implements Comparable<BillingToken> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
BillingToken that = (BillingToken) o;
|
||||
|
||||
if (id != that.id) return false;
|
||||
if (Double.compare(that.price, price) != 0) return false;
|
||||
if (!name.equals(that.name)) return false;
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
BillingToken other = (BillingToken) obj;
|
||||
if (id != other.id)
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (Double.doubleToLongBits(price) != Double.doubleToLongBits(other.price))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result;
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + (int) (id ^ (id >>> 32));
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
long temp;
|
||||
result = (int) (id ^ (id >>> 32));
|
||||
result = 31 * result + name.hashCode();
|
||||
temp = price != +0.0d ? Double.doubleToLongBits(price) : 0L;
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(price);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -85,10 +93,6 @@ public class BillingToken implements Comparable<BillingToken> {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BillingToken{" +
|
||||
"id=" + id +
|
||||
", name='" + name + '\'' +
|
||||
", price=" + price +
|
||||
'}';
|
||||
return "BillingToken{" + "id=" + id + ", name='" + name + '\'' + ", price=" + price + '}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,29 +36,25 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
|
|||
public class GetImageListOptions extends BaseHttpRequestOptions {
|
||||
|
||||
public GetImageListOptions setType(ServerImageType imageType) {
|
||||
checkState(!queryParameters.containsKey(IMAGE_TYPE_KEY),
|
||||
"Can't have duplicate image type restrictions");
|
||||
checkState(!queryParameters.containsKey(IMAGE_TYPE_KEY), "Can't have duplicate image type restrictions");
|
||||
queryParameters.put(IMAGE_TYPE_KEY, imageType.toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
public GetImageListOptions setState(ServerImageState imageState) {
|
||||
checkState(!queryParameters.containsKey(IMAGE_STATE_KEY),
|
||||
"Can't have duplicate image state restrictions");
|
||||
checkState(!queryParameters.containsKey(IMAGE_STATE_KEY), "Can't have duplicate image state restrictions");
|
||||
queryParameters.put(IMAGE_STATE_KEY, imageState.toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
public GetImageListOptions onlyPublic() {
|
||||
checkState(!queryParameters.containsKey(IS_PUBLIC_KEY),
|
||||
"Can't have duplicate image visibility restrictions");
|
||||
checkState(!queryParameters.containsKey(IS_PUBLIC_KEY), "Can't have duplicate image visibility restrictions");
|
||||
queryParameters.put(IS_PUBLIC_KEY, "true");
|
||||
return this;
|
||||
}
|
||||
|
||||
public GetImageListOptions onlyPrivate() {
|
||||
checkState(!queryParameters.containsKey(IS_PUBLIC_KEY),
|
||||
"Can't have duplicate image visibility restrictions");
|
||||
checkState(!queryParameters.containsKey(IS_PUBLIC_KEY), "Can't have duplicate image visibility restrictions");
|
||||
queryParameters.put(IS_PUBLIC_KEY, "false");
|
||||
return this;
|
||||
}
|
||||
|
@ -70,26 +66,28 @@ public class GetImageListOptions extends BaseHttpRequestOptions {
|
|||
}
|
||||
|
||||
public GetImageListOptions maxItemsNumber(Integer maxNumber) {
|
||||
checkState(!queryParameters.containsKey(MAX_NUMBER_KEY),
|
||||
"Can't have duplicate parameter of max returned items");
|
||||
checkState(!queryParameters.containsKey(MAX_NUMBER_KEY), "Can't have duplicate parameter of max returned items");
|
||||
queryParameters.put(MAX_NUMBER_KEY, maxNumber.toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
public GetImageListOptions inDatacenter(String datacenterId) {
|
||||
GetImageListOptions getImageListOptions = new GetImageListOptions();
|
||||
return getImageListOptions.inDatacenter(checkNotNull(datacenterId));
|
||||
public static GetImageListOptions maxItems(int maxNumber) {
|
||||
return new GetImageListOptions().maxItemsNumber(maxNumber);
|
||||
}
|
||||
|
||||
public GetImageListOptions publicWebServers() {
|
||||
public static GetImageListOptions inDatacenter(String datacenterId) {
|
||||
return new GetImageListOptions().inDatacenter(checkNotNull(datacenterId, "datacenterId"));
|
||||
}
|
||||
|
||||
public static GetImageListOptions publicWebServers() {
|
||||
return new GetImageListOptions().setState(ServerImageState.AVAILABLE).setType(
|
||||
ServerImageType.WEB_APPLICATION_SERVER).onlyPublic();
|
||||
}
|
||||
|
||||
public GetImageListOptions publicDatabaseServers() {
|
||||
return new GetImageListOptions().setState(ServerImageState.AVAILABLE).setType(
|
||||
ServerImageType.DATABASE_SERVER).onlyPublic();
|
||||
public static GetImageListOptions publicDatabaseServers() {
|
||||
return new GetImageListOptions().setState(ServerImageState.AVAILABLE).setType(ServerImageType.DATABASE_SERVER)
|
||||
.onlyPublic();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,14 +18,20 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.options;
|
||||
|
||||
import org.jclouds.gogrid.domain.JobState;
|
||||
import org.jclouds.gogrid.domain.ObjectType;
|
||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.END_DATE_KEY;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.JOB_OBJECT_TYPE_KEY;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.JOB_STATE_KEY;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.MAX_NUMBER_KEY;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.OBJECT_KEY;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.OWNER_KEY;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.START_DATE_KEY;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static org.jclouds.gogrid.reference.GoGridQueryParams.*;
|
||||
import org.jclouds.gogrid.domain.JobState;
|
||||
import org.jclouds.gogrid.domain.ObjectType;
|
||||
import org.jclouds.http.options.BaseHttpRequestOptions;
|
||||
|
||||
/**
|
||||
* @author Oleksiy Yarmula
|
||||
|
@ -76,13 +82,19 @@ public class GetJobListOptions extends BaseHttpRequestOptions {
|
|||
return this;
|
||||
}
|
||||
|
||||
public GetJobListOptions latestJobForObjectByName(String serverName) {
|
||||
return maxItemsNumber(1).onlyForObjectName(serverName);
|
||||
}
|
||||
|
||||
/*
|
||||
* This method is intended for testing
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
GetJobListOptions options = (GetJobListOptions) o;
|
||||
|
||||
|
@ -90,14 +102,17 @@ public class GetJobListOptions extends BaseHttpRequestOptions {
|
|||
}
|
||||
|
||||
public static class Builder {
|
||||
public GetJobListOptions create() {
|
||||
return new GetJobListOptions();
|
||||
|
||||
public static GetJobListOptions maxItems(int maxNumber) {
|
||||
return new GetJobListOptions().maxItemsNumber(maxNumber);
|
||||
}
|
||||
|
||||
public GetJobListOptions latestJobForObjectByName(String serverName) {
|
||||
return new GetJobListOptions().
|
||||
maxItemsNumber(1).
|
||||
onlyForObjectName(serverName);
|
||||
public static GetJobListOptions startDate(Date startDate){
|
||||
return new GetJobListOptions().withStartDate(startDate);
|
||||
}
|
||||
|
||||
public static GetJobListOptions latestJobForObjectByName(String serverName) {
|
||||
return new GetJobListOptions().latestJobForObjectByName(serverName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,20 +18,21 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.predicates;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Inject;
|
||||
import org.jclouds.gogrid.domain.Job;
|
||||
import org.jclouds.gogrid.domain.JobState;
|
||||
import org.jclouds.gogrid.domain.LoadBalancer;
|
||||
import org.jclouds.gogrid.options.GetJobListOptions;
|
||||
import org.jclouds.gogrid.services.GridJobClient;
|
||||
import org.jclouds.logging.Logger;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.gogrid.options.GetJobListOptions.Builder.latestJobForObjectByName;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import org.jclouds.gogrid.domain.Job;
|
||||
import org.jclouds.gogrid.domain.JobState;
|
||||
import org.jclouds.gogrid.domain.LoadBalancer;
|
||||
import org.jclouds.gogrid.services.GridJobClient;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* @author Oleksiy Yarmula
|
||||
|
@ -53,9 +54,7 @@ public class LoadBalancerLatestJobCompleted implements Predicate<LoadBalancer> {
|
|||
public boolean apply(LoadBalancer loadBalancer) {
|
||||
checkNotNull(loadBalancer, "Load balancer must be a valid instance");
|
||||
checkNotNull(loadBalancer.getName(), "Load balancer must be a valid name");
|
||||
GetJobListOptions jobOptions = new GetJobListOptions.Builder().
|
||||
latestJobForObjectByName(loadBalancer.getName());
|
||||
Job latestJob = Iterables.getOnlyElement(jobClient.getJobList(jobOptions));
|
||||
Job latestJob = Iterables.getOnlyElement(jobClient.getJobList(latestJobForObjectByName(loadBalancer.getName())));
|
||||
return JobState.SUCCEEDED.equals(latestJob.getCurrentState());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,25 +18,26 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.predicates;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Inject;
|
||||
import org.jclouds.gogrid.domain.Job;
|
||||
import org.jclouds.gogrid.domain.JobState;
|
||||
import org.jclouds.gogrid.domain.Server;
|
||||
import org.jclouds.gogrid.options.GetJobListOptions;
|
||||
import org.jclouds.gogrid.services.GridJobClient;
|
||||
import org.jclouds.logging.Logger;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.gogrid.options.GetJobListOptions.Builder.latestJobForObjectByName;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import org.jclouds.gogrid.domain.Job;
|
||||
import org.jclouds.gogrid.domain.JobState;
|
||||
import org.jclouds.gogrid.domain.Server;
|
||||
import org.jclouds.gogrid.services.GridJobClient;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.inject.Inject;
|
||||
|
||||
/**
|
||||
* Checks if the latest job for the server is in "Succeeded" state.
|
||||
* To achieve meaningful results, this must be run in a sequential
|
||||
* environment when a server has only one job related to it at a time.
|
||||
* Checks if the latest job for the server is in "Succeeded" state. To achieve meaningful results,
|
||||
* this must be run in a sequential environment when a server has only one job related to it at a
|
||||
* time.
|
||||
*
|
||||
* The passed server instance must not be null and must have a name.
|
||||
*
|
||||
|
@ -59,9 +60,7 @@ public class ServerLatestJobCompleted implements Predicate<Server> {
|
|||
public boolean apply(Server server) {
|
||||
checkNotNull(server, "Server must be a valid instance");
|
||||
checkNotNull(server.getName(), "Server must be a valid name");
|
||||
GetJobListOptions jobOptions = new GetJobListOptions.Builder().
|
||||
latestJobForObjectByName(server.getName());
|
||||
Job latestJob = Iterables.getOnlyElement(jobClient.getJobList(jobOptions));
|
||||
Job latestJob = Iterables.getOnlyElement(jobClient.getJobList(latestJobForObjectByName(server.getName())));
|
||||
return JobState.SUCCEEDED.equals(latestJob.getCurrentState());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ public interface GridJobClient {
|
|||
*
|
||||
* @return jobs found by request
|
||||
*/
|
||||
@Timeout(duration = 90, timeUnit = TimeUnit.SECONDS)
|
||||
Set<Job> getJobList(GetJobListOptions... options);
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,12 +21,12 @@ package org.jclouds.gogrid.predicates;
|
|||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.jclouds.gogrid.options.GetJobListOptions.Builder.latestJobForObjectByName;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import org.jclouds.gogrid.domain.Job;
|
||||
import org.jclouds.gogrid.domain.JobState;
|
||||
import org.jclouds.gogrid.domain.Server;
|
||||
import org.jclouds.gogrid.options.GetJobListOptions;
|
||||
import org.jclouds.gogrid.services.GridJobClient;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -35,7 +35,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
/**
|
||||
* @author Oleksiy Yarmula
|
||||
*/
|
||||
//NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", testName = "ServerLatestJobCompletedTest")
|
||||
public class ServerLatestJobCompletedTest {
|
||||
|
||||
|
@ -45,15 +45,11 @@ public class ServerLatestJobCompletedTest {
|
|||
Server server = createMock(Server.class);
|
||||
expect(server.getName()).andStubReturn(serverName);
|
||||
|
||||
GetJobListOptions jobOptions = new GetJobListOptions.Builder().
|
||||
latestJobForObjectByName(serverName);
|
||||
|
||||
Job job = createMock(Job.class);
|
||||
expect(job.getCurrentState()).andReturn(JobState.SUCCEEDED);
|
||||
|
||||
GridJobClient client = createMock(GridJobClient.class);
|
||||
expect(client.getJobList(jobOptions)).
|
||||
andReturn(ImmutableSet.<Job>of(job));
|
||||
expect(client.getJobList(latestJobForObjectByName(serverName))).andReturn(ImmutableSet.<Job> of(job));
|
||||
|
||||
replay(job);
|
||||
replay(client);
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.gogrid.services;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.compute.ComputeServiceContext;
|
||||
import org.jclouds.compute.ComputeServiceContextFactory;
|
||||
import org.jclouds.gogrid.GoGridAsyncClient;
|
||||
import org.jclouds.gogrid.GoGridClient;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.sshj.config.SshjSshClientModule;
|
||||
import org.testng.annotations.AfterGroups;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code GoGridClient}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live")
|
||||
public class BaseGoGridClientLiveTest {
|
||||
|
||||
protected RestContext<GoGridClient, GoGridAsyncClient> restContext;
|
||||
protected String provider = "gogrid";
|
||||
protected String identity;
|
||||
protected String credential;
|
||||
protected String endpoint;
|
||||
protected String apiversion;
|
||||
protected ComputeServiceContext context;
|
||||
protected String prefix = System.getProperty("user.name");
|
||||
|
||||
protected void setupCredentials() {
|
||||
identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity");
|
||||
credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider
|
||||
+ ".credential");
|
||||
endpoint = System.getProperty("test." + provider + ".endpoint");
|
||||
apiversion = System.getProperty("test." + provider + ".apiversion");
|
||||
}
|
||||
|
||||
protected Properties setupProperties() {
|
||||
Properties overrides = new Properties();
|
||||
overrides.setProperty(provider + ".identity", identity);
|
||||
overrides.setProperty(provider + ".credential", credential);
|
||||
if (endpoint != null)
|
||||
overrides.setProperty(provider + ".endpoint", endpoint);
|
||||
if (apiversion != null)
|
||||
overrides.setProperty(provider + ".apiversion", apiversion);
|
||||
return overrides;
|
||||
}
|
||||
|
||||
@BeforeGroups(groups = { "live" })
|
||||
public void setupClient() {
|
||||
setupCredentials();
|
||||
Properties overrides = setupProperties();
|
||||
context = new ComputeServiceContextFactory().createContext(provider, ImmutableSet.<Module> of(
|
||||
new Log4JLoggingModule(), new SshjSshClientModule()), overrides);
|
||||
restContext = context.getProviderSpecificContext();
|
||||
}
|
||||
|
||||
@AfterGroups(groups = "live")
|
||||
protected void tearDown() {
|
||||
if (context != null)
|
||||
context.close();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.gogrid.services;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jclouds.gogrid.domain.ServerImage;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", testName = "GridImageClientLiveTest")
|
||||
public class GridImageClientLiveTest extends BaseGoGridClientLiveTest {
|
||||
|
||||
public void testListImages() throws Exception {
|
||||
Set<ServerImage> response = restContext.getApi().getImageServices().getImageList();
|
||||
assert null != response;
|
||||
for (ServerImage image : response) {
|
||||
assert image.getId() >= 0 : image;
|
||||
checkImage(image);
|
||||
|
||||
ServerImage query = Iterables.getOnlyElement(restContext.getApi().getImageServices().getImagesById(
|
||||
image.getId()));
|
||||
assertEquals(query.getId(), image.getId());
|
||||
|
||||
checkImage(query);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkImage(ServerImage image) {
|
||||
assert image.getArchitecture() != null : image;
|
||||
assert image.getBillingTokens() != null : image;
|
||||
if (image.getCreatedTime() == null)
|
||||
Logger.getAnonymousLogger().warning("image " + image.getId() + " is missing the createdon field");
|
||||
assert image.getDescription() != null : image;
|
||||
assert image.getFriendlyName() != null : image;
|
||||
assert image.getId() >= 0 : image;
|
||||
assert image.getLocation() != null : image;
|
||||
assert image.getName() != null : image;
|
||||
assert image.getOs() != null : image;
|
||||
assert image.getOwner() != null : image;
|
||||
assert image.getPrice() >= 0 : image;
|
||||
assert image.getState() != null : image;
|
||||
assert image.getType() != null : image;
|
||||
if (image.getUpdatedTime() == null)
|
||||
Logger.getAnonymousLogger().warning("image " + image.getId() + " is missing the updatedon field");
|
||||
}
|
||||
}
|
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
package org.jclouds.gogrid.services;
|
||||
|
||||
import static org.jclouds.gogrid.options.GetJobListOptions.Builder.startDate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
|
@ -45,10 +47,9 @@ public class GridJobAsyncClientTest extends BaseGoGridAsyncClientTest<GridJobAsy
|
|||
@Test
|
||||
public void testGetJobListWithOptions() throws NoSuchMethodException, IOException {
|
||||
Method method = GridJobAsyncClient.class.getMethod("getJobList", GetJobListOptions[].class);
|
||||
HttpRequest httpRequest = processor.createRequest(method,
|
||||
new GetJobListOptions.Builder().create().withStartDate(new Date(1267385381770L)).withEndDate(
|
||||
new Date(1267385382770L)).onlyForObjectType(ObjectType.VIRTUAL_SERVER).onlyForState(
|
||||
JobState.PROCESSING));
|
||||
HttpRequest httpRequest = processor
|
||||
.createRequest(method, startDate(new Date(1267385381770L)).withEndDate(new Date(1267385382770L))
|
||||
.onlyForObjectType(ObjectType.VIRTUAL_SERVER).onlyForState(JobState.PROCESSING));
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://api.gogrid.com/api/grid/job/list?v=1.5&startdate=1267385381770&"
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/**
|
||||
* Licensed to jclouds, Inc. (jclouds) under one or more
|
||||
* contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. jclouds licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.jclouds.gogrid.services;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.gogrid.domain.Job;
|
||||
import org.jclouds.gogrid.options.GetJobListOptions;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire
|
||||
@Test(groups = "unit", testName = "GridJobClientLiveTest")
|
||||
public class GridJobClientLiveTest extends BaseGoGridClientLiveTest {
|
||||
|
||||
public void testListJobs() throws Exception {
|
||||
Set<Job> response = restContext.getApi().getJobServices().getJobList(GetJobListOptions.Builder.maxItems(10));
|
||||
assert null != response;
|
||||
assert response.size() <= 10 : response;
|
||||
for (Job job : response) {
|
||||
assert job.getId() >= 0 : job;
|
||||
checkJob(job);
|
||||
|
||||
Job query = Iterables.getOnlyElement(restContext.getApi().getJobServices().getJobsById(job.getId()));
|
||||
assertEquals(query.getId(), job.getId());
|
||||
|
||||
checkJob(query);
|
||||
}
|
||||
}
|
||||
|
||||
private void checkJob(Job job) {
|
||||
assert job.getAttempts() >= 0 : job;
|
||||
assert job.getCommand() != null : job;
|
||||
assert job.getCreatedOn() != null : job;
|
||||
assert job.getCreatedOn() != null : job;
|
||||
assert job.getDetails() != null : job;
|
||||
assert job.getHistory() != null : job;
|
||||
assert job.getId() >= 0 : job;
|
||||
assert job.getLastUpdatedOn() != null : job;
|
||||
assert job.getObjectType() != null : job;
|
||||
assert job.getOwner() != null : job;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue