mirror of https://github.com/apache/jclouds.git
fixed bug in computservice types and Issue 230: added instance support for ibm cloud.
This commit is contained in:
parent
3bc448e35c
commit
f624dbe3f8
|
@ -64,8 +64,8 @@ public abstract class ComputeServiceContextBuilder<S, A> extends RestContextBuil
|
|||
public ComputeServiceContext buildComputeServiceContext() {
|
||||
// need the generic type information
|
||||
return (ComputeServiceContext) buildInjector().getInstance(
|
||||
Key.get(Types.newParameterizedType(ComputeServiceContextImpl.class, asyncClientType,
|
||||
syncClientType)));
|
||||
Key.get(Types.newParameterizedType(ComputeServiceContextImpl.class, syncClientType,
|
||||
asyncClientType)));
|
||||
}
|
||||
|
||||
protected void addImageResolutionModuleIfNotPresent() {
|
||||
|
|
|
@ -37,7 +37,7 @@ public enum OsFamily {
|
|||
/**
|
||||
* Oracle Enterprise Linux
|
||||
*/
|
||||
OEL, RHEL, FEDORA, DEBIAN, UBUNTU, TTYLINUX, ARCH, GENTOO, WINDOWS;
|
||||
OEL, RHEL, FEDORA, DEBIAN, UBUNTU, TTYLINUX, ARCH, SUSE, GENTOO, WINDOWS;
|
||||
public String value() {
|
||||
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_HYPHEN, name());
|
||||
}
|
||||
|
|
|
@ -149,6 +149,22 @@ public class ParserModule extends AbstractModule {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class LongDateAdapter implements DateAdapter {
|
||||
|
||||
public JsonElement serialize(Date src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
return new JsonPrimitive(src.getTime());
|
||||
}
|
||||
|
||||
public Date deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
|
||||
throws JsonParseException {
|
||||
long toParse = json.getAsJsonPrimitive().getAsLong();
|
||||
Date toReturn = new Date(toParse);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class GsonAdapterBindings {
|
||||
|
|
|
@ -36,8 +36,11 @@ import javax.ws.rs.core.MediaType;
|
|||
import org.jclouds.http.filters.BasicAuthentication;
|
||||
import org.jclouds.ibmdev.binders.BindImageVisibilityToJsonPayload;
|
||||
import org.jclouds.ibmdev.domain.Image;
|
||||
import org.jclouds.ibmdev.domain.Instance;
|
||||
import org.jclouds.ibmdev.functions.ParseImageFromJson;
|
||||
import org.jclouds.ibmdev.functions.ParseImagesFromJson;
|
||||
import org.jclouds.ibmdev.functions.ParseInstanceFromJson;
|
||||
import org.jclouds.ibmdev.functions.ParseInstancesFromJson;
|
||||
import org.jclouds.rest.annotations.BinderParam;
|
||||
import org.jclouds.rest.annotations.Endpoint;
|
||||
import org.jclouds.rest.annotations.ExceptionParser;
|
||||
|
@ -96,4 +99,29 @@ public interface IBMDeveloperCloudAsyncClient {
|
|||
ListenableFuture<Image> setImageVisibility(@PathParam("imageId") long id,
|
||||
@BinderParam(BindImageVisibilityToJsonPayload.class) Image.Visibility visibility);
|
||||
|
||||
/**
|
||||
* @see IBMDeveloperCloudClient#listInstances()
|
||||
*/
|
||||
@GET
|
||||
@Path("/instances")
|
||||
@ResponseParser(ParseInstancesFromJson.class)
|
||||
ListenableFuture<Set<? extends Instance>> listInstances();
|
||||
|
||||
/**
|
||||
* @see IBMDeveloperCloudClient#getInstance(long)
|
||||
*/
|
||||
@GET
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
||||
@Path("/instances/{instanceId}")
|
||||
@ResponseParser(ParseInstanceFromJson.class)
|
||||
ListenableFuture<Instance> getInstance(@PathParam("instanceId") long id);
|
||||
|
||||
/**
|
||||
* @see IBMDeveloperCloudClient#deleteInstance
|
||||
*/
|
||||
@DELETE
|
||||
@Path("/instances/{instanceId}")
|
||||
@ExceptionParser(ReturnVoidOnNotFoundOr404.class)
|
||||
ListenableFuture<Void> deleteInstance(@PathParam("instanceId") long id);
|
||||
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
import org.jclouds.ibmdev.domain.Image;
|
||||
import org.jclouds.ibmdev.domain.Instance;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
|
||||
/**
|
||||
|
@ -95,4 +96,33 @@ public interface IBMDeveloperCloudClient {
|
|||
* code 412 if the image is in an invalid state to perform this operation
|
||||
*/
|
||||
Image setImageVisibility(long id, Image.Visibility visibility);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the list of Instances that the authenticated user manages.
|
||||
* @throws AuthorizationException
|
||||
* code 401 if the currently authenticated user is not authorized to view this
|
||||
* information
|
||||
*/
|
||||
Set<? extends Instance> listInstances();
|
||||
|
||||
/**
|
||||
* Returns the Instance that the authenticated user manages with the specified {@code id}
|
||||
*
|
||||
* @return null if instance is not found
|
||||
* @throws AuthorizationException
|
||||
* code 401 if the currently authenticated user is not authorized to view this
|
||||
* instance
|
||||
*/
|
||||
Instance getInstance(long id);
|
||||
|
||||
/**
|
||||
* Deletes the Instance that the authenticated user manages with the specified {@code id}
|
||||
*
|
||||
* @throws AuthorizationException
|
||||
* code 401 if the user is not authorized to delete this instance
|
||||
* @throws IllegalStateException
|
||||
* code 412 if the instance is in an invalid state to perform this operation
|
||||
*/
|
||||
void deleteInstance(long id);
|
||||
}
|
||||
|
|
|
@ -31,6 +31,8 @@ import org.jclouds.http.annotation.ClientError;
|
|||
import org.jclouds.http.annotation.Redirection;
|
||||
import org.jclouds.http.annotation.ServerError;
|
||||
import org.jclouds.http.filters.BasicAuthentication;
|
||||
import org.jclouds.http.functions.config.ParserModule.DateAdapter;
|
||||
import org.jclouds.http.functions.config.ParserModule.LongDateAdapter;
|
||||
import org.jclouds.ibmdev.IBMDeveloperCloud;
|
||||
import org.jclouds.ibmdev.IBMDeveloperCloudAsyncClient;
|
||||
import org.jclouds.ibmdev.IBMDeveloperCloudClient;
|
||||
|
@ -82,4 +84,10 @@ public class IBMDeveloperCloudRestClientModule extends
|
|||
IBMDeveloperCloudErrorHandler.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(LongDateAdapter.class);
|
||||
super.configure();
|
||||
}
|
||||
|
||||
}
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.ibmdev.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
@ -48,7 +49,7 @@ public class Image {
|
|||
private String owner;
|
||||
private String architecture;
|
||||
private String platform;
|
||||
private long createdTime;
|
||||
private Date createdTime;
|
||||
private long location;
|
||||
private Set<String> supportedInstanceTypes = Sets.newLinkedHashSet();
|
||||
private Set<String> productCodes = Sets.newLinkedHashSet();
|
||||
|
@ -115,11 +116,11 @@ public class Image {
|
|||
this.platform = platform;
|
||||
}
|
||||
|
||||
public long getCreatedTime() {
|
||||
public Date getCreatedTime() {
|
||||
return createdTime;
|
||||
}
|
||||
|
||||
public void setCreatedTime(long createdTime) {
|
||||
public void setCreatedTime(Date createdTime) {
|
||||
this.createdTime = createdTime;
|
||||
}
|
||||
|
||||
|
@ -176,7 +177,7 @@ public class Image {
|
|||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((architecture == null) ? 0 : architecture.hashCode());
|
||||
result = prime * result + (int) (createdTime ^ (createdTime >>> 32));
|
||||
result = prime * result + ((createdTime == null) ? 0 : createdTime.hashCode());
|
||||
result = prime * result + ((description == null) ? 0 : description.hashCode());
|
||||
result = prime * result + ((documentation == null) ? 0 : documentation.hashCode());
|
||||
result = prime * result + (int) (id ^ (id >>> 32));
|
||||
|
@ -207,7 +208,10 @@ public class Image {
|
|||
return false;
|
||||
} else if (!architecture.equals(other.architecture))
|
||||
return false;
|
||||
if (createdTime != other.createdTime)
|
||||
if (createdTime == null) {
|
||||
if (other.createdTime != null)
|
||||
return false;
|
||||
} else if (!createdTime.equals(other.createdTime))
|
||||
return false;
|
||||
if (description == null) {
|
||||
if (other.description != null)
|
||||
|
|
|
@ -0,0 +1,395 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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
|
||||
*
|
||||
* 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.ibmdev.domain;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
/**
|
||||
*
|
||||
* The current state of the instance.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class Instance {
|
||||
public static class Software {
|
||||
private String version;
|
||||
private String type;
|
||||
private String name;
|
||||
|
||||
public Software(String version, String type, String name) {
|
||||
this.version = version;
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Software() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((type == null) ? 0 : type.hashCode());
|
||||
result = prime * result + ((version == null) ? 0 : version.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Software other = (Software) obj;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (type == null) {
|
||||
if (other.type != null)
|
||||
return false;
|
||||
} else if (!type.equals(other.type))
|
||||
return false;
|
||||
if (version == null) {
|
||||
if (other.version != null)
|
||||
return false;
|
||||
} else if (!version.equals(other.version))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Software [name=" + name + ", type=" + type + ", version=" + version + "]";
|
||||
}
|
||||
}
|
||||
|
||||
private Date launchTime;
|
||||
private Set<Software> software = Sets.newLinkedHashSet();
|
||||
private String ip;
|
||||
private long requestId;
|
||||
private String keyName;
|
||||
private String name;
|
||||
private String instanceType;
|
||||
private int status;
|
||||
private String owner;
|
||||
private String hostname;
|
||||
private int location;
|
||||
private long imageId;
|
||||
private Set<String> productCodes;
|
||||
private String requestName;
|
||||
private long id;
|
||||
private Date expirationTime;
|
||||
|
||||
public Instance(Date launchTime, Set<Software> software, String ip, long requestId,
|
||||
String keyName, String name, String instanceType, int status, String owner,
|
||||
String hostname, int location, long imageId, Set<String> productCodes,
|
||||
String requestName, long id, Date expirationTime) {
|
||||
this.launchTime = launchTime;
|
||||
this.software = software;
|
||||
this.ip = ip;
|
||||
this.requestId = requestId;
|
||||
this.keyName = keyName;
|
||||
this.name = name;
|
||||
this.instanceType = instanceType;
|
||||
this.status = status;
|
||||
this.owner = owner;
|
||||
this.hostname = hostname;
|
||||
this.location = location;
|
||||
this.imageId = imageId;
|
||||
this.productCodes = productCodes;
|
||||
this.requestName = requestName;
|
||||
this.id = id;
|
||||
this.expirationTime = expirationTime;
|
||||
}
|
||||
|
||||
public Instance() {
|
||||
}
|
||||
|
||||
public Date getLaunchTime() {
|
||||
return launchTime;
|
||||
}
|
||||
|
||||
public void setLaunchTime(Date launchTime) {
|
||||
this.launchTime = launchTime;
|
||||
}
|
||||
|
||||
public Set<Software> getSoftware() {
|
||||
return software;
|
||||
}
|
||||
|
||||
public void setSoftware(Set<Software> software) {
|
||||
this.software = software;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public long getRequestId() {
|
||||
return requestId;
|
||||
}
|
||||
|
||||
public void setRequestId(long requestId) {
|
||||
this.requestId = requestId;
|
||||
}
|
||||
|
||||
public String getKeyName() {
|
||||
return keyName;
|
||||
}
|
||||
|
||||
public void setKeyName(String keyName) {
|
||||
this.keyName = keyName;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getInstanceType() {
|
||||
return instanceType;
|
||||
}
|
||||
|
||||
public void setInstanceType(String instanceType) {
|
||||
this.instanceType = instanceType;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public String getHostname() {
|
||||
return hostname;
|
||||
}
|
||||
|
||||
public void setHostname(String hostname) {
|
||||
this.hostname = hostname;
|
||||
}
|
||||
|
||||
public int getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(int location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public long getImageId() {
|
||||
return imageId;
|
||||
}
|
||||
|
||||
public void setImageId(long imageId) {
|
||||
this.imageId = imageId;
|
||||
}
|
||||
|
||||
public Set<String> getProductCodes() {
|
||||
return productCodes;
|
||||
}
|
||||
|
||||
public void setProductCodes(Set<String> productCodes) {
|
||||
this.productCodes = productCodes;
|
||||
}
|
||||
|
||||
public String getRequestName() {
|
||||
return requestName;
|
||||
}
|
||||
|
||||
public void setRequestName(String requestName) {
|
||||
this.requestName = requestName;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Date getExpirationTime() {
|
||||
return expirationTime;
|
||||
}
|
||||
|
||||
public void setExpirationTime(Date expirationTime) {
|
||||
this.expirationTime = expirationTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((expirationTime == null) ? 0 : expirationTime.hashCode());
|
||||
result = prime * result + ((hostname == null) ? 0 : hostname.hashCode());
|
||||
result = prime * result + (int) (id ^ (id >>> 32));
|
||||
result = prime * result + (int) imageId;
|
||||
result = prime * result + ((instanceType == null) ? 0 : instanceType.hashCode());
|
||||
result = prime * result + ((ip == null) ? 0 : ip.hashCode());
|
||||
result = prime * result + ((keyName == null) ? 0 : keyName.hashCode());
|
||||
result = prime * result + ((launchTime == null) ? 0 : launchTime.hashCode());
|
||||
result = prime * result + location;
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((owner == null) ? 0 : owner.hashCode());
|
||||
result = prime * result + ((productCodes == null) ? 0 : productCodes.hashCode());
|
||||
result = prime * result + (int) (requestId ^ (requestId >>> 32));
|
||||
result = prime * result + ((requestName == null) ? 0 : requestName.hashCode());
|
||||
result = prime * result + ((software == null) ? 0 : software.hashCode());
|
||||
result = prime * result + status;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Instance other = (Instance) obj;
|
||||
if (expirationTime == null) {
|
||||
if (other.expirationTime != null)
|
||||
return false;
|
||||
} else if (!expirationTime.equals(other.expirationTime))
|
||||
return false;
|
||||
if (hostname == null) {
|
||||
if (other.hostname != null)
|
||||
return false;
|
||||
} else if (!hostname.equals(other.hostname))
|
||||
return false;
|
||||
if (id != other.id)
|
||||
return false;
|
||||
if (imageId != other.imageId)
|
||||
return false;
|
||||
if (instanceType == null) {
|
||||
if (other.instanceType != null)
|
||||
return false;
|
||||
} else if (!instanceType.equals(other.instanceType))
|
||||
return false;
|
||||
if (ip == null) {
|
||||
if (other.ip != null)
|
||||
return false;
|
||||
} else if (!ip.equals(other.ip))
|
||||
return false;
|
||||
if (keyName == null) {
|
||||
if (other.keyName != null)
|
||||
return false;
|
||||
} else if (!keyName.equals(other.keyName))
|
||||
return false;
|
||||
if (launchTime == null) {
|
||||
if (other.launchTime != null)
|
||||
return false;
|
||||
} else if (!launchTime.equals(other.launchTime))
|
||||
return false;
|
||||
if (location != other.location)
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
return false;
|
||||
if (owner == null) {
|
||||
if (other.owner != null)
|
||||
return false;
|
||||
} else if (!owner.equals(other.owner))
|
||||
return false;
|
||||
if (productCodes == null) {
|
||||
if (other.productCodes != null)
|
||||
return false;
|
||||
} else if (!productCodes.equals(other.productCodes))
|
||||
return false;
|
||||
if (requestId != other.requestId)
|
||||
return false;
|
||||
if (requestName == null) {
|
||||
if (other.requestName != null)
|
||||
return false;
|
||||
} else if (!requestName.equals(other.requestName))
|
||||
return false;
|
||||
if (software == null) {
|
||||
if (other.software != null)
|
||||
return false;
|
||||
} else if (!software.equals(other.software))
|
||||
return false;
|
||||
if (status != other.status)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Instance [id=" + id + ", name=" + name + ", ip=" + ip + ", hostname=" + hostname
|
||||
+ ", status=" + status + ", instanceType=" + instanceType + ", location=" + location
|
||||
+ ", imageId=" + imageId + ", software=" + software + ", keyName=" + keyName
|
||||
+ ", launchTime=" + launchTime + ", expirationTime=" + expirationTime + ", owner="
|
||||
+ owner + ", productCodes=" + productCodes + ", requestId=" + requestId
|
||||
+ ", requestName=" + requestName + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.
|
||||
* ====================================================================
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.ibmdev.functions;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
import org.jclouds.ibmdev.domain.Instance;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class ParseInstanceFromJson extends ParseJson<Instance> {
|
||||
@Inject
|
||||
public ParseInstanceFromJson(Gson gson) {
|
||||
super(gson);
|
||||
}
|
||||
|
||||
private static final Set<String> emptyString = ImmutableSet.of("");
|
||||
|
||||
@Override
|
||||
protected Instance apply(InputStream stream) {
|
||||
try {
|
||||
Instance returnVal = gson.fromJson(new InputStreamReader(stream, "UTF-8"), Instance.class);
|
||||
if (emptyString.equals(returnVal.getProductCodes()))
|
||||
returnVal.getProductCodes().clear();
|
||||
return returnVal;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException("jclouds requires UTF-8 encoding", e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2009 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.
|
||||
* ====================================================================
|
||||
*/
|
||||
/**
|
||||
*
|
||||
* Copyright (C) 2009 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*/
|
||||
package org.jclouds.ibmdev.functions;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
import org.jclouds.ibmdev.domain.Instance;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
/**
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class ParseInstancesFromJson extends ParseJson<Set<? extends Instance>> {
|
||||
@Inject
|
||||
public ParseInstancesFromJson(Gson gson) {
|
||||
super(gson);
|
||||
}
|
||||
|
||||
private static class InstanceListResponse {
|
||||
Set<Instance> instances = Sets.newLinkedHashSet();
|
||||
}
|
||||
|
||||
private static final Set<String> emptyString = ImmutableSet.of("");
|
||||
|
||||
@Override
|
||||
protected Set<? extends Instance> apply(InputStream stream) {
|
||||
try {
|
||||
Set<Instance> list = gson.fromJson(new InputStreamReader(stream, "UTF-8"),
|
||||
InstanceListResponse.class).instances;
|
||||
for (Instance instance : list)
|
||||
if (emptyString.equals(instance.getProductCodes()))
|
||||
instance.getProductCodes().clear();
|
||||
return list;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException("jclouds requires UTF-8 encoding", e);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,34 +26,28 @@ package org.jclouds.ibmdev;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.encryption.EncryptionService;
|
||||
import org.jclouds.http.filters.BasicAuthentication;
|
||||
import org.jclouds.http.functions.CloseContentAndReturn;
|
||||
import org.jclouds.ibmdev.config.IBMDeveloperCloudRestClientModule;
|
||||
import org.jclouds.ibmdev.domain.Image;
|
||||
import org.jclouds.ibmdev.functions.ParseImageFromJson;
|
||||
import org.jclouds.ibmdev.functions.ParseImagesFromJson;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.logging.Logger.LoggerFactory;
|
||||
import org.jclouds.ibmdev.functions.ParseInstanceFromJson;
|
||||
import org.jclouds.ibmdev.functions.ParseInstancesFromJson;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.RestClientTest;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import com.google.inject.name.Names;
|
||||
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;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
/**
|
||||
* Tests annotation parsing of {@code IBMDeveloperCloudAsyncClient}
|
||||
|
@ -84,7 +78,6 @@ public class IBMDeveloperCloudAsyncClientTest extends RestClientTest<IBMDevelope
|
|||
"Accept: application/json\nAuthorization: Basic Zm9vOmJhcg==\n");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
// TODO: insert expected response class, which probably extends ParseJson
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseImagesFromJson.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
@ -103,10 +96,8 @@ public class IBMDeveloperCloudAsyncClientTest extends RestClientTest<IBMDevelope
|
|||
assertHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
// TODO: insert expected response class, which probably extends ParseJson
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseImageFromJson.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
// note that get methods should convert 404's to null
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
|
@ -152,6 +143,60 @@ public class IBMDeveloperCloudAsyncClientTest extends RestClientTest<IBMDevelope
|
|||
|
||||
}
|
||||
|
||||
public void testListInstances() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = IBMDeveloperCloudAsyncClient.class.getMethod("listInstances");
|
||||
GeneratedHttpRequest<IBMDeveloperCloudAsyncClient> httpRequest = processor
|
||||
.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://www-180.ibm.com/cloud/enterprise/beta/api/rest/20090403/instances HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseInstancesFromJson.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, null);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
|
||||
}
|
||||
|
||||
public void testGetInstance() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = IBMDeveloperCloudAsyncClient.class.getMethod("getInstance", long.class);
|
||||
GeneratedHttpRequest<IBMDeveloperCloudAsyncClient> httpRequest = processor.createRequest(
|
||||
method, 1);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"GET https://www-180.ibm.com/cloud/enterprise/beta/api/rest/20090403/instances/1 HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseInstanceFromJson.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, ReturnNullOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
|
||||
}
|
||||
|
||||
public void testDeleteInstance() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = IBMDeveloperCloudAsyncClient.class.getMethod("deleteInstance", long.class);
|
||||
GeneratedHttpRequest<IBMDeveloperCloudAsyncClient> httpRequest = processor.createRequest(
|
||||
method, 1);
|
||||
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"DELETE https://www-180.ibm.com/cloud/enterprise/beta/api/rest/20090403/instances/1 HTTP/1.1");
|
||||
assertHeadersEqual(httpRequest, "Accept: application/json\n");
|
||||
assertPayloadEquals(httpRequest, null);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, CloseContentAndReturn.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
assertExceptionParserClassEquals(method, ReturnVoidOnNotFoundOr404.class);
|
||||
|
||||
checkFilters(httpRequest);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void checkFilters(GeneratedHttpRequest<IBMDeveloperCloudAsyncClient> httpRequest) {
|
||||
assertEquals(httpRequest.getFilters().size(), 1);
|
||||
|
@ -166,26 +211,13 @@ public class IBMDeveloperCloudAsyncClientTest extends RestClientTest<IBMDevelope
|
|||
|
||||
@Override
|
||||
protected Module createModule() {
|
||||
return new AbstractModule() {
|
||||
return new IBMDeveloperCloudRestClientModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
Names.bindProperties(binder(),
|
||||
new IBMDeveloperCloudPropertiesBuilder(new Properties()).build());
|
||||
bind(URI.class).annotatedWith(IBMDeveloperCloud.class).toInstance(
|
||||
URI.create("https://www-180.ibm.com/cloud/enterprise/beta/api/rest/20090403"));
|
||||
bind(Logger.LoggerFactory.class).toInstance(new LoggerFactory() {
|
||||
public Logger getLogger(String category) {
|
||||
return Logger.NULL;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
@Singleton
|
||||
public BasicAuthentication provideBasicAuthentication(EncryptionService encryptionService)
|
||||
throws UnsupportedEncodingException {
|
||||
return new BasicAuthentication("foo", "bar", encryptionService);
|
||||
Names.bindProperties(binder(), new IBMDeveloperCloudPropertiesBuilder("foo", "bar")
|
||||
.build());
|
||||
install(new NullLoggingModule());
|
||||
super.configure();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -30,6 +30,7 @@ import static org.testng.Assert.assertNotNull;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jclouds.ibmdev.domain.Image;
|
||||
import org.jclouds.ibmdev.domain.Instance;
|
||||
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -71,4 +72,19 @@ public class IBMDeveloperCloudClientLiveTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListInstances() throws Exception {
|
||||
Set<? extends Instance> response = connection.listInstances();
|
||||
assertNotNull(response);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetInstance() throws Exception {
|
||||
Set<? extends Instance> response = connection.listInstances();
|
||||
assertNotNull(response);
|
||||
if (response.size() > 0) {
|
||||
Instance instance = Iterables.get(response, 0);
|
||||
assertEquals(connection.getInstance(instance.getId()).getId(), instance.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ package org.jclouds.ibmdev.functions;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.config.ParserModule;
|
||||
|
@ -46,7 +47,13 @@ public class ParseImageFromJsonTest {
|
|||
|
||||
@BeforeTest
|
||||
protected void setUpInjector() throws IOException {
|
||||
Injector injector = Guice.createInjector(new ParserModule());
|
||||
Injector injector = Guice.createInjector(new ParserModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(LongDateAdapter.class);
|
||||
super.configure();
|
||||
}
|
||||
});
|
||||
handler = injector.getInstance(ParseImageFromJson.class);
|
||||
}
|
||||
|
||||
|
@ -61,7 +68,7 @@ public class ParseImageFromJsonTest {
|
|||
image.setOwner("mutdosch@us.ibm.com");
|
||||
image.setArchitecture("i386");
|
||||
image.setPlatform("Redhat Enterprise Linux (32-bit)/5.4");
|
||||
image.setCreatedTime(1265647398000l);
|
||||
image.setCreatedTime(new Date(1265647398000l));
|
||||
image.setLocation(1);
|
||||
image.setSupportedInstanceTypes(ImmutableSet.of("LARGE", "MEDIUM"));
|
||||
// image.setProductCodes();
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
package org.jclouds.ibmdev.functions;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.http.HttpResponse;
|
||||
|
@ -44,7 +45,13 @@ public class ParseImagesFromJsonTest {
|
|||
|
||||
@BeforeTest
|
||||
protected void setUpInjector() throws IOException {
|
||||
Injector injector = Guice.createInjector(new ParserModule());
|
||||
Injector injector = Guice.createInjector(new ParserModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(LongDateAdapter.class);
|
||||
super.configure();
|
||||
}
|
||||
});
|
||||
handler = injector.getInstance(ParseImagesFromJson.class);
|
||||
}
|
||||
|
||||
|
@ -59,7 +66,7 @@ public class ParseImagesFromJsonTest {
|
|||
image1.setOwner("SYSTEM");
|
||||
image1.setArchitecture("i386");
|
||||
image1.setPlatform("SUSE Linux Enterprise/10 SP2");
|
||||
image1.setCreatedTime(1240632000000l);
|
||||
image1.setCreatedTime(new Date(1240632000000l));
|
||||
image1.setLocation(1);
|
||||
image1.setSupportedInstanceTypes(ImmutableSet.of("SMALL", "MEDIUM", "LARGE"));
|
||||
image1.setProductCodes(ImmutableSet.of("fd2d0478b132490897526b9b4433a334"));
|
||||
|
@ -78,7 +85,7 @@ public class ParseImagesFromJsonTest {
|
|||
image2.setOwner("mutdosch@us.ibm.com");
|
||||
image2.setArchitecture("i386");
|
||||
image2.setPlatform("Redhat Enterprise Linux (32-bit)/5.4");
|
||||
image2.setCreatedTime(1265647398869l);
|
||||
image2.setCreatedTime(new Date(1265647398869l));
|
||||
image2.setLocation(1);
|
||||
image2.setSupportedInstanceTypes(ImmutableSet.of("LARGE", "MEDIUM"));
|
||||
// image.setProductCodes();
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/**
|
||||
*
|
||||
* 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.ibmdev.functions;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.config.ParserModule;
|
||||
import org.jclouds.ibmdev.domain.Instance;
|
||||
import org.jclouds.ibmdev.domain.Instance.Software;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ParseInstanceFromJson}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", sequential = true, testName = "ibmdev.ParseInstanceFromJsonTest")
|
||||
public class ParseInstanceFromJsonTest {
|
||||
|
||||
private ParseInstanceFromJson handler;
|
||||
|
||||
@BeforeTest
|
||||
protected void setUpInjector() throws IOException {
|
||||
Injector injector = Guice.createInjector(new ParserModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(LongDateAdapter.class);
|
||||
super.configure();
|
||||
}
|
||||
});
|
||||
handler = injector.getInstance(ParseInstanceFromJson.class);
|
||||
}
|
||||
|
||||
public void test() {
|
||||
Instance instance = new Instance(new Date(1260472231726l), ImmutableSet.of(new Software(
|
||||
"10 SP2", "OS", "SUSE Linux Enterprise")), "129.33.197.78", 7430l, "DEFAULT", "ABC",
|
||||
"MEDIUM", 5, "aadelucc@us.ibm.com", "vm723.developer.ihost.com", 1, 3l, ImmutableSet
|
||||
.<String> of(), "ABC", 7430l, new Date(1263064240837l));
|
||||
|
||||
Instance compare = handler.apply(new HttpResponse(ParseInstanceFromJsonTest.class
|
||||
.getResourceAsStream("/instance.json")));
|
||||
assertEquals(compare, instance);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
/**
|
||||
*
|
||||
* 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.ibmdev.functions;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.config.ParserModule;
|
||||
import org.jclouds.ibmdev.domain.Instance;
|
||||
import org.jclouds.ibmdev.domain.Instance.Software;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ParseInstancesFromJson}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "unit", sequential = true, testName = "ibmdev.ParseInstancesFromJsonTest")
|
||||
public class ParseInstancesFromJsonTest {
|
||||
|
||||
private ParseInstancesFromJson handler;
|
||||
|
||||
@BeforeTest
|
||||
protected void setUpInjector() throws IOException {
|
||||
Injector injector = Guice.createInjector(new ParserModule() {
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(DateAdapter.class).to(LongDateAdapter.class);
|
||||
super.configure();
|
||||
}
|
||||
});
|
||||
handler = injector.getInstance(ParseInstancesFromJson.class);
|
||||
}
|
||||
|
||||
public void test() {
|
||||
Instance instance1 = new Instance(new Date(1260472231726l), ImmutableSet.of(new Software(
|
||||
"10 SP2", "OS", "SUSE Linux Enterprise")), "129.33.197.78", 7430l, "DEFAULT", "ABC",
|
||||
"MEDIUM", 5, "aadelucc@us.ibm.com", "vm723.developer.ihost.com", 1, 3l, ImmutableSet
|
||||
.<String> of(), "ABC", 7430l, new Date(1263064240837l));
|
||||
|
||||
Instance instance2 = new Instance(new Date(1260472231727l), ImmutableSet.of(new Software(
|
||||
"10 SP3", "OS", "SUSE Linux Enterprise")), "129.33.197.79", 7431l, "DEFAULT", "ABC",
|
||||
"MEDIUM", 6, "aadelucc@us.ibm.com", "vm723.developer.ihost.com", 2, 4l, ImmutableSet
|
||||
.<String> of(), "ABC", 7431l, new Date(1263064240838l));
|
||||
|
||||
Set<? extends Instance> compare = handler.apply(new HttpResponse(ParseInstancesFromJsonTest.class
|
||||
.getResourceAsStream("/instances.json")));
|
||||
assert (compare.contains(instance1));
|
||||
assert (compare.contains(instance2));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"launchTime":1260472231726,
|
||||
"software":
|
||||
[
|
||||
{ "version":"10 SP2", "type":"OS", "name":"SUSE Linux Enterprise" }
|
||||
],
|
||||
"ip":"129.33.197.78",
|
||||
"requestId":"7430",
|
||||
"keyName":"DEFAULT",
|
||||
"name":"ABC",
|
||||
"instanceType":"MEDIUM",
|
||||
"status":5,
|
||||
"owner":"aadelucc@us.ibm.com",
|
||||
"hostname":"vm723.developer.ihost.com",
|
||||
"location":"1",
|
||||
"imageId":"3",
|
||||
"productCodes":[],
|
||||
"requestName":"ABC",
|
||||
"id":"7430",
|
||||
"expirationTime":1263064240837
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"instances":[
|
||||
{
|
||||
"launchTime":1260472231726,
|
||||
"software":
|
||||
[
|
||||
{ "version":"10 SP2", "type":"OS", "name":"SUSE Linux Enterprise" }
|
||||
],
|
||||
"ip":"129.33.197.78",
|
||||
"requestId":"7430",
|
||||
"keyName":"DEFAULT",
|
||||
"name":"ABC",
|
||||
"instanceType":"MEDIUM",
|
||||
"status":5,
|
||||
"owner":"aadelucc@us.ibm.com",
|
||||
"hostname":"vm723.developer.ihost.com",
|
||||
"location":"1",
|
||||
"imageId":"3",
|
||||
"productCodes":[],
|
||||
"requestName":"ABC",
|
||||
"id":"7430",
|
||||
"expirationTime":1263064240837
|
||||
},
|
||||
{
|
||||
"launchTime":1260472231727,
|
||||
"software":
|
||||
[
|
||||
{ "version":"10 SP3", "type":"OS", "name":"SUSE Linux Enterprise" }
|
||||
],
|
||||
"ip":"129.33.197.79",
|
||||
"requestId":"7431",
|
||||
"keyName":"DEFAULT",
|
||||
"name":"ABC",
|
||||
"instanceType":"MEDIUM",
|
||||
"status":6,
|
||||
"owner":"aadelucc@us.ibm.com",
|
||||
"hostname":"vm723.developer.ihost.com",
|
||||
"location":"2",
|
||||
"imageId":"4",
|
||||
"productCodes":[],
|
||||
"requestName":"ABC",
|
||||
"id":"7431",
|
||||
"expirationTime":1263064240838
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue