Finishing up live tests for Catalog and Query, and general tifying of domain objects and constants

This commit is contained in:
Andrew Donald Kennedy 2012-02-17 19:21:41 +00:00
parent 473126e7ec
commit 4e6bb27e9d
24 changed files with 259 additions and 761 deletions

View File

@ -28,4 +28,30 @@ public class VCloudDirectorConstants {
/** The XML namespace used by the clients. */ /** The XML namespace used by the clients. */
public static final String VCLOUD_1_5_NS = "http://www.vmware.com/vcloud/v1.5"; public static final String VCLOUD_1_5_NS = "http://www.vmware.com/vcloud/v1.5";
/** The property used to configure the timeout for task completion. */
public static final String PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED = "jclouds.vcloud-director.timeout.task-complete";
public static final String PROPERTY_VCLOUD_VERSION_SCHEMA = "jclouds.vcloud.version.schema";
/** Name of the default org that your vApp will join, if an org isn't explicitly specified. */
public static final String PROPERTY_VCLOUD_DEFAULT_ORG = "jclouds.vcloud.defaults.org";
/** Name of the default catalog to query, if it isn't explicitly specified. */
public static final String PROPERTY_VCLOUD_DEFAULT_CATALOG = "jclouds.vcloud.defaults.catalog";
/** Name of the VDC that your vApp will join, if a vDC isn't explicitly specified. */
public static final String PROPERTY_VCLOUD_DEFAULT_VDC = "jclouds.vcloud.defaults.vdc";
/** Name of the default network, in the default VDC that your vApp will join. */
public static final String PROPERTY_VCLOUD_DEFAULT_NETWORK = "jclouds.vcloud.defaults.network";
/** TODO javadoc */
// public static final String PROPERTY_VCLOUD_DEFAULT_FENCEMODE = "jclouds.vcloud.defaults.fencemode";
/** TODO javadoc */
public static final String PROPERTY_VCLOUD_XML_NAMESPACE = "jclouds.vcloud.xml.ns";
/** TODO javadoc */
public static final String PROPERTY_VCLOUD_XML_SCHEMA = "jclouds.vcloud.xml.schema";
} }

View File

@ -27,22 +27,33 @@ import org.jclouds.vcloud.director.v1_5.domain.Task;
public class VCloudDirectorException extends RuntimeException { public class VCloudDirectorException extends RuntimeException {
/** The serialVersionUID. */ /** The serialVersionUID. */
private static final long serialVersionUID = -3200853408568729058L; private static final long serialVersionUID = -5292516858598372960L;
private final Error error; private final Error error;
private final Task task;
public VCloudDirectorException(Error error) { public VCloudDirectorException(Error error) {
super("Error: " + error.getMessage()); super("Error: " + error.getMessage());
this.error = error; this.error = error;
this.task = null;
} }
public VCloudDirectorException(Task task) { public VCloudDirectorException(Task task) {
super("Task error: " + task.getError().getMessage()); super("Task error: " + task.getError().getMessage());
this.error = task.getError(); this.error = task.getError();
this.task = task;
} }
public Error getError() { public Error getError() {
return error; return error;
} }
public boolean hasTask() {
return task != null;
}
public Task getTask() {
return task;
}
} }

View File

@ -79,11 +79,19 @@ public class VCloudDirectorMediaType {
public static final String QUERY_RESULT_ID_RECORDS = "application/vnd.vmware.vcloud.query.idrecords+xml"; public static final String QUERY_RESULT_ID_RECORDS = "application/vnd.vmware.vcloud.query.idrecords+xml";
public static final String CONTROL_ACCESS = "application/vnd.vmware.vcloud.controlAccess+xml";
/**
* All acceptable media types.
*
* This list must be updated whenever a new media type constant is added.
*/
public static final List<String> ALL = Arrays.asList( public static final List<String> ALL = Arrays.asList(
SESSION, ERROR, ORG_LIST, METADATA, METADATA_ENTRY, SESSION, ERROR, ORG_LIST, METADATA, METADATA_ENTRY,
METADATA_VALUE, ORG, TASKS_LIST, TASK, ORG_NETWORK, METADATA_VALUE, ORG, TASKS_LIST, TASK, ORG_NETWORK,
CATALOG, CATALOG_ITEM, CATALOG_ITEMS, CATALOGS_LIST, PROPERTY, CATALOG, CATALOG_ITEM, CATALOG_ITEMS, CATALOGS_LIST, PROPERTY,
MEDIA, OWNER, VDC, ADMIN_USER, QUERY_RESULT_RECORDS, MEDIA, OWNER, VDC, ADMIN_USER, QUERY_RESULT_RECORDS,
QUERY_RESULT_REFERENCES, QUERY_RESULT_ID_RECORDS QUERY_RESULT_REFERENCES, QUERY_RESULT_ID_RECORDS,
CONTROL_ACCESS
); );
} }

View File

@ -18,9 +18,8 @@
*/ */
package org.jclouds.vcloud.director.v1_5; package org.jclouds.vcloud.director.v1_5;
import static org.jclouds.Constants.PROPERTY_API_VERSION; import static org.jclouds.Constants.*;
import static org.jclouds.Constants.PROPERTY_ENDPOINT; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
import java.util.Properties; import java.util.Properties;
@ -37,8 +36,20 @@ public class VCloudDirectorPropertiesBuilder extends PropertiesBuilder {
protected Properties defaultProperties() { protected Properties defaultProperties() {
Properties properties = super.defaultProperties(); Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_ENDPOINT, "https://vcloudbeta.bluelock.com/api"); properties.setProperty(PROPERTY_ENDPOINT, "https://vcloudbeta.bluelock.com/api");
properties.setProperty(PROPERTY_SESSION_INTERVAL, 30*60 + ""); properties.setProperty(PROPERTY_SESSION_INTERVAL, Integer.toString(30 * 60));
properties.setProperty(PROPERTY_API_VERSION, "1.5"); properties.setProperty(PROPERTY_API_VERSION, "1.5");
properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE,
String.format("http://www.vmware.com/vcloud/v${%s}", PROPERTY_VCLOUD_VERSION_SCHEMA));
properties.setProperty(PROPERTY_SESSION_INTERVAL, Integer.toString(8 * 60));
properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA, "https://vcloudbeta.bluelock.com/api/v1.5/schema/master.xsd");
properties.setProperty("jclouds.dns_name_length_min", "1");
properties.setProperty("jclouds.dns_name_length_max", "80");
// TODO integrate these with the {@link ComputeTimeouts} instead of having a single timeout for everything.
properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, Long.toString(1200l * 1000l));
properties.setProperty(PROPERTY_SESSION_INTERVAL, Integer.toString(300));
return properties; return properties;
} }

View File

@ -19,6 +19,7 @@ package org.jclouds.vcloud.director.v1_5.config;
import static com.google.common.base.Throwables.*; import static com.google.common.base.Throwables.*;
import static org.jclouds.rest.config.BinderUtils.*; import static org.jclouds.rest.config.BinderUtils.*;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
import java.net.URI; import java.net.URI;
import java.util.Map; import java.util.Map;
@ -35,6 +36,7 @@ import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError; import org.jclouds.http.annotation.ServerError;
import org.jclouds.location.Provider; import org.jclouds.location.Provider;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.config.RestClientModule; import org.jclouds.rest.config.RestClientModule;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorAsyncClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorAsyncClient;
@ -59,14 +61,17 @@ import org.jclouds.vcloud.director.v1_5.handlers.InvalidateSessionAndRetryOn401A
import org.jclouds.vcloud.director.v1_5.handlers.VCloudDirectorErrorHandler; import org.jclouds.vcloud.director.v1_5.handlers.VCloudDirectorErrorHandler;
import org.jclouds.vcloud.director.v1_5.login.SessionAsyncClient; import org.jclouds.vcloud.director.v1_5.login.SessionAsyncClient;
import org.jclouds.vcloud.director.v1_5.login.SessionClient; import org.jclouds.vcloud.director.v1_5.login.SessionClient;
import org.jclouds.vcloud.director.v1_5.predicates.TaskSuccess;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.base.Suppliers; import com.google.common.base.Suppliers;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader; import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.inject.Injector;
import com.google.inject.Provides; import com.google.inject.Provides;
import com.google.inject.Singleton; import com.google.inject.Singleton;
import com.google.inject.name.Named; import com.google.inject.name.Named;

View File

@ -56,10 +56,17 @@ public class Link extends ReferenceType<Link> {
public static final String PREVIOUS_PAGE = "previousPage"; public static final String PREVIOUS_PAGE = "previousPage";
public static final String LAST_PAGE = "lastPage"; public static final String LAST_PAGE = "lastPage";
public static final String FIRST_PAGE = "firstPage"; public static final String FIRST_PAGE = "firstPage";
public static final String CONTROL_ACCESS = "controlAccess";
/**
* All acceptable {@link Link#getRel()} values.
*
* This list must be updated whenever a new relationship is added.
*/
public static final List<String> ALL = Arrays.asList( public static final List<String> ALL = Arrays.asList(
UP, DOWN, EDIT, ADD, DELETE, REMOVE, CATALOG_ITEM, TASK_CANCEL, UP, DOWN, EDIT, ADD, DELETE, REMOVE, CATALOG_ITEM, TASK_CANCEL,
ALTERNATE, NEXT_PAGE, PREVIOUS_PAGE, LAST_PAGE, FIRST_PAGE ALTERNATE, NEXT_PAGE, PREVIOUS_PAGE, LAST_PAGE, FIRST_PAGE,
CONTROL_ACCESS
); );
} }

View File

@ -16,67 +16,37 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.*;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.VCLOUD_1_5_NS; import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
import java.net.URI; import java.net.URI;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects; import com.google.common.base.Objects;
/** /**
*
* Represents a media. * Represents a media.
* *
*
* <p>Java class for Media complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre> * <pre>
* &lt;complexType name="Media"> * &lt;complexType name="Media" /&gt;
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}ResourceEntityType">
* &lt;sequence>
* &lt;element name="Owner" type="{http://www.vmware.com/vcloud/v1.5}OwnerType" minOccurs="0"/>
* &lt;/sequence>
* &lt;attribute name="imageType" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
* &lt;attribute name="size" use="required" type="{http://www.w3.org/2001/XMLSchema}long" />
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre> * </pre>
*
*
*/ */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Media") @XmlRootElement(namespace = VCLOUD_1_5_NS, name = "Media")
@XmlType(propOrder = {"owner"}) public class Media extends ResourceEntityType<Media> {
public class Media
extends ResourceEntityType<Media>
{
public static final class ImageType { public static final class ImageType {
public static final String ISO = "iso"; public static final String ISO = "iso";
public static final String FLOPPY = "floppy"; public static final String FLOPPY = "floppy";
public static final List<String> ALL = Arrays.asList( public static final List<String> ALL = Arrays.asList(ISO, FLOPPY);
ISO, FLOPPY
);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -84,6 +54,7 @@ public class Media
return new Builder(); return new Builder();
} }
@Override
public Builder toBuilder() { public Builder toBuilder() {
return new Builder().fromMedia(this); return new Builder().fromMedia(this);
} }
@ -118,7 +89,7 @@ public class Media
return this; return this;
} }
@Override
public Media build() { public Media build() {
Media media = new Media(); Media media = new Media();
media.setOwner(owner); media.setOwner(owner);
@ -130,6 +101,7 @@ public class Media
/** /**
* @see ResourceEntityType#getFiles() * @see ResourceEntityType#getFiles()
*/ */
@Override
public Builder files(FilesList files) { public Builder files(FilesList files) {
super.files(files); super.files(files);
return this; return this;
@ -138,6 +110,7 @@ public class Media
/** /**
* @see ResourceEntityType#getStatus() * @see ResourceEntityType#getStatus()
*/ */
@Override
public Builder status(Integer status) { public Builder status(Integer status) {
super.status(status); super.status(status);
return this; return this;
@ -215,16 +188,13 @@ public class Media
return this; return this;
} }
@Override @Override
public Builder fromResourceEntityType(ResourceEntityType<Media> in) { public Builder fromResourceEntityType(ResourceEntityType<Media> in) {
return Builder.class.cast(super.fromResourceEntityType(in)); return Builder.class.cast(super.fromResourceEntityType(in));
} }
public Builder fromMedia(Media in) { public Builder fromMedia(Media in) {
return fromResourceEntityType(in) return fromResourceEntityType(in).owner(in.getOwner()).imageType(in.getImageType()).size(in.getSize());
.owner(in.getOwner())
.imageType(in.getImageType())
.size(in.getSize());
} }
} }
@ -241,64 +211,33 @@ public class Media
/** /**
* Gets the value of the owner property. * Gets the value of the owner property.
*
* @return
* possible object is
* {@link Owner }
*
*/ */
public Owner getOwner() { public Owner getOwner() {
return owner; return owner;
} }
/**
* Sets the value of the owner property.
*
* @param value
* allowed object is
* {@link Owner }
*
*/
public void setOwner(Owner value) { public void setOwner(Owner value) {
this.owner = value; this.owner = value;
} }
/** /**
* Gets the value of the imageType property. * Gets the value of the imageType property.
*
* @return
* possible object is
* {@link String }
*
*/ */
public String getImageType() { public String getImageType() {
return imageType; return imageType;
} }
/**
* Sets the value of the imageType property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setImageType(String value) { public void setImageType(String value) {
this.imageType = value; this.imageType = value;
} }
/** /**
* Gets the value of the size property. * Gets the value of the size property.
*
*/ */
public long getSize() { public long getSize() {
return size; return size;
} }
/**
* Sets the value of the size property.
*
*/
public void setSize(long value) { public void setSize(long value) {
this.size = value; this.size = value;
} }
@ -310,24 +249,18 @@ public class Media
if (o == null || getClass() != o.getClass()) if (o == null || getClass() != o.getClass())
return false; return false;
Media that = Media.class.cast(o); Media that = Media.class.cast(o);
return equal(owner, that.owner) && return super.equals(that) &&
equal(imageType, that.imageType) && equal(this.owner, that.owner) && equal(this.imageType, that.imageType) && equal(this.size, that.size);
equal(size, that.size);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(owner, return super.hashCode() + Objects.hashCode(owner, imageType, size);
imageType,
size);
} }
@Override @Override
public String toString() { public ToStringHelper string() {
return Objects.toStringHelper("") return super.string().add("owner", owner).add("imageType", imageType).add("size", size);
.add("owner", owner)
.add("imageType", imageType)
.add("size", size).toString();
} }
} }

View File

@ -1,256 +0,0 @@
/*
* 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.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.*;
import static com.google.common.base.Preconditions.*;
import java.net.URI;
import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects;
import com.google.common.collect.Sets;
/**
*
* Base type that represents a resource entity such as a vApp
* template or virtual media.
*
*
* <p>Java class for ResourceEntity complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType name="ResourceEntity">
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}EntityType">
* &lt;sequence>
* &lt;element name="Files" type="{http://www.vmware.com/vcloud/v1.5}FilesListType" minOccurs="0"/>
* &lt;/sequence>
* &lt;attribute name="status" type="{http://www.w3.org/2001/XMLSchema}int" />
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ResourceEntity", propOrder = {
"files"
})
public class ResourceEntity extends EntityType<ResourceEntity> {
@SuppressWarnings("unchecked")
public static Builder builder() {
return new Builder();
}
public Builder toBuilder() {
return new Builder().fromResourceEntity(this);
}
public static class Builder extends EntityType.Builder<ResourceEntity> {
private Object /* FilesList */ files;
private Integer status;
/**
* @see ResourceEntity#getFiles()
*/
public Builder files(Object /* FilesList */ files) {
this.files = files;
return this;
}
/**
* @see ResourceEntity#getStatus()
*/
public Builder status(Integer status) {
this.status = status;
return this;
}
public ResourceEntity build() {
ResourceEntity resourceEntity = new ResourceEntity();
resourceEntity.setFiles(files);
resourceEntity.setStatus(status);
return resourceEntity;
}
/**
* @see EntityType#getId()
*/
@Override
public Builder id(String id) {
this.id = id;
return this;
}
/**
* @see EntityType#getTasksInProgress()
*/
@Override
public Builder tasksInProgress(TasksInProgress tasksInProgress) {
this.tasksInProgress = tasksInProgress;
return this;
}
/**
* @see ReferenceType#getHref()
*/
@Override
public Builder href(URI href) {
this.href = href;
return this;
}
/**
* @see ReferenceType#getType()
*/
@Override
public Builder type(String type) {
this.type = type;
return this;
}
/**
* @see ReferenceType#getLinks()
*/
@Override
public Builder links(Set<Link> links) {
this.links = Sets.newLinkedHashSet(checkNotNull(links, "links"));
return this;
}
/**
* @see ReferenceType#getLinks()
*/
@Override
public Builder link(Link link) {
this.links.add(checkNotNull(link, "link"));
return this;
}
@Override
public Builder fromEntityType(EntityType<ResourceEntity> in) {
return Builder.class.cast(super.fromEntityType(in));
}
public Builder fromResourceEntity(ResourceEntity in) {
return fromEntityType(in)
.files(in.getFiles())
.status(in.getStatus());
}
}
protected ResourceEntity() {
// For JAXB and builder use
}
@XmlElement(name = "Files")
protected Object /* FilesList */ files;
@XmlAttribute
protected Integer status;
/**
* Gets the value of the files property.
*
* @return
* possible object is
* {@link FilesList }
*
*/
public Object /* FilesList */ getFiles() {
return files;
}
/**
* Sets the value of the files property.
*
* @param value
* allowed object is
* {@link FilesList }
*
*/
public void setFiles(Object /* FilesList */ value) {
this.files = value;
}
/**
* Gets the value of the status property.
*
* @return
* possible object is
* {@link Integer }
*
*/
public Integer getStatus() {
return status;
}
/**
* Sets the value of the status property.
*
* @param value
* allowed object is
* {@link Integer }
*
*/
public void setStatus(Integer value) {
this.status = value;
}
@Override
public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
ResourceEntity that = ResourceEntity.class.cast(o);
return equal(files, that.files) &&
equal(status, that.status);
}
@Override
public int hashCode() {
return Objects.hashCode(files,
status);
}
@Override
public String toString() {
return Objects.toStringHelper("")
.add("files", files)
.add("status", status).toString();
}
}

View File

@ -19,58 +19,28 @@
package org.jclouds.vcloud.director.v1_5.domain; package org.jclouds.vcloud.director.v1_5.domain;
import static com.google.common.base.Objects.equal; import static com.google.common.base.Objects.*;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.*;
import java.net.URI; import java.net.URI;
import java.util.Set; import java.util.Set;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import com.google.common.base.Objects; import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
/** /**
* * Base type that represents a resource entity such as a vApp template or virtual media.
* Base type that represents a resource entity such as a vApp
* template or virtual media.
*
*
* <p>Java class for ResourceEntity complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* *
* <pre> * <pre>
* &lt;complexType name="ResourceEntity"> * &lt;complexType name="ResourceEntity" &gt;
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}EntityType">
* &lt;sequence>
* &lt;element name="Files" type="{http://www.vmware.com/vcloud/v1.5}FilesListType" minOccurs="0"/>
* &lt;/sequence>
* &lt;attribute name="status" type="{http://www.w3.org/2001/XMLSchema}int" />
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre> * </pre>
* *
* * @author danikov
*/ */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ResourceEntity", propOrder = {
"files"
})
//@XmlSeeAlso({
// MediaType.class,
// VAppTemplateType.class,
// AbstractVAppType.class,
// NetworkPoolType.class
//})
public class ResourceEntityType<T extends ResourceEntityType<T>> extends EntityType<T> { public class ResourceEntityType<T extends ResourceEntityType<T>> extends EntityType<T> {
public static <T extends ResourceEntityType<T>> Builder<T> builder() { public static <T extends ResourceEntityType<T>> Builder<T> builder() {
@ -103,7 +73,7 @@ public class ResourceEntityType<T extends ResourceEntityType<T>> extends EntityT
return this; return this;
} }
@Override
public ResourceEntityType<T> build() { public ResourceEntityType<T> build() {
ResourceEntityType<T> resourceEntity = new ResourceEntityType<T>(); ResourceEntityType<T> resourceEntity = new ResourceEntityType<T>();
resourceEntity.setFiles(files); resourceEntity.setFiles(files);
@ -111,7 +81,6 @@ public class ResourceEntityType<T extends ResourceEntityType<T>> extends EntityT
return resourceEntity; return resourceEntity;
} }
/** /**
* @see EntityType#getId() * @see EntityType#getId()
*/ */
@ -166,23 +135,18 @@ public class ResourceEntityType<T extends ResourceEntityType<T>> extends EntityT
return this; return this;
} }
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override @Override
public Builder<T> fromResourceType(ResourceType<T> in) { public Builder<T> fromResourceType(ResourceType<T> in) {
return Builder.class.cast(super.fromResourceType(in)); return Builder.class.cast(super.fromResourceType(in));
} }
public Builder<T> fromResourceEntityType(ResourceEntityType<T> in) { public Builder<T> fromResourceEntityType(ResourceEntityType<T> in) {
return fromResourceType(in) return fromResourceType(in).files(in.getFiles()).status(in.getStatus());
.files(in.getFiles())
.status(in.getStatus());
} }
} }
public ResourceEntityType() { public ResourceEntityType() {
// for JAXB
} }
@XmlElement(name = "Files") @XmlElement(name = "Files")
@ -192,48 +156,22 @@ public class ResourceEntityType<T extends ResourceEntityType<T>> extends EntityT
/** /**
* Gets the value of the files property. * Gets the value of the files property.
*
* @return
* possible object is
* {@link FilesList }
*
*/ */
public FilesList getFiles() { public FilesList getFiles() {
return files; return files;
} }
/**
* Sets the value of the files property.
*
* @param value
* allowed object is
* {@link FilesList }
*
*/
public void setFiles(FilesList value) { public void setFiles(FilesList value) {
this.files = value; this.files = value;
} }
/** /**
* Gets the value of the status property. * Gets the value of the status property.
*
* @return
* possible object is
* {@link Integer }
*
*/ */
public Integer getStatus() { public Integer getStatus() {
return status; return status;
} }
/**
* Sets the value of the status property.
*
* @param value
* allowed object is
* {@link Integer }
*
*/
public void setStatus(Integer value) { public void setStatus(Integer value) {
this.status = value; this.status = value;
} }
@ -245,21 +183,17 @@ public class ResourceEntityType<T extends ResourceEntityType<T>> extends EntityT
if (o == null || getClass() != o.getClass()) if (o == null || getClass() != o.getClass())
return false; return false;
ResourceEntityType<?> that = ResourceEntityType.class.cast(o); ResourceEntityType<?> that = ResourceEntityType.class.cast(o);
return equal(files, that.files) && return super.equals(that) && equal(this.files, that.files) && equal(this.status, that.status);
equal(status, that.status);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hashCode(files, return super.hashCode() + Objects.hashCode(files, status);
status);
} }
@Override @Override
public String toString() { public ToStringHelper string() {
return Objects.toStringHelper("") return super.string().add("files", files).add("status", status);
.add("files", files)
.add("status", status).toString();
} }
} }

View File

@ -148,13 +148,6 @@ public class Task extends EntityType<Task> {
return this; return this;
} }
/**
* @see Task#getStatus()
*/
public Builder status(TaskStatus status) {
return this.status(status.toString());
}
/** /**
* @see Task#getOperation() * @see Task#getOperation()
*/ */
@ -418,12 +411,8 @@ public class Task extends EntityType<Task> {
* <li>aborted - The task was aborted by an administrative action. * <li>aborted - The task was aborted by an administrative action.
* </ul> * </ul>
*/ */
public TaskStatus getStatus() { public String getStatus() {
return TaskStatus.fromValue(status); return status;
}
public void setStatus(TaskStatus status) {
this.setStatus(status.toString());
} }
public void setStatus(String status) { public void setStatus(String status) {

View File

@ -1,41 +0,0 @@
/**
* 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.vcloud.director.v1_5.domain;
/**
*
* @author Adrian Cole
*
*/
public class TaskInErrorStateException extends RuntimeException {
private static final long serialVersionUID = 1L;
private final Task task;
public TaskInErrorStateException(Task task) {
super("error on task: " + task + " error: " + task.getError());
this.task = task;
}
public Task getTask() {
return task;
}
}

View File

@ -1,73 +0,0 @@
/**
* 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.vcloud.director.v1_5.domain;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* @author Adrian Cole
*/
public enum TaskStatus {
/**
* The task has completed and returned a value indicating success.
*/
SUCCESS,
/**
* The task is running.
*/
RUNNING,
/**
* The task has been queued for execution.
*/
QUEUED,
/**
* The task has completed and returned a value indicating an error.
*/
ERROR,
/**
* not an official status, temporarily in.
*/
CANCELLED, UNRECOGNIZED;
public String value() {
return name().toLowerCase();
}
@Override
public String toString() {
return value();
}
public static TaskStatus fromValue(String status) {
if ("CANCELED".equals(status.toUpperCase())) {
// TODO: ecloud hack
status = "CANCELLED";
} else if ("FAILED".equals(status.toUpperCase())) {
status = "ERROR";
} else if ("COMPLETED".equals(status.toUpperCase())) {
status = "SUCCESS";
}
try {
return valueOf(checkNotNull(status, "status").toUpperCase());
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
}
}
}

View File

@ -18,54 +18,19 @@
*/ */
package org.jclouds.vcloud.director.v1_5.domain.vapp; package org.jclouds.vcloud.director.v1_5.domain.vapp;
import java.util.ArrayList; import org.jclouds.vcloud.director.v1_5.domain.ResourceEntityType;
import java.util.List;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity;
/** /**
*
* Represents a base type for VAppType and VmType. * Represents a base type for VAppType and VmType.
* *
*
* <p>Java class for AbstractVAppType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre> * <pre>
* &lt;complexType name="AbstractVAppType"> * &lt;complexType name="AbstractVAppType" &gt;
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}ResourceEntityType">
* &lt;sequence>
* &lt;element name="VAppParent" type="{http://www.vmware.com/vcloud/v1.5}ReferenceType" minOccurs="0"/>
* &lt;element ref="{http://schemas.dmtf.org/ovf/envelope/1}Section" maxOccurs="unbounded" minOccurs="0"/>
* &lt;/sequence>
* &lt;attribute name="deployed" type="{http://www.w3.org/2001/XMLSchema}boolean" />
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre> * </pre>
* *
* * @author grkvlt@apache.org
*/ */
@XmlAccessorType(XmlAccessType.FIELD) public abstract class AbstractVAppType extends ResourceEntityType<AbstractVAppType> {
@XmlType(name = "AbstractVAppType", propOrder = {
"vAppParent",
"section"
})
public abstract class AbstractVAppType extends ResourceEntity {
// @XmlElement(name = "VAppParent") // @XmlElement(name = "VAppParent")
// protected ReferenceType vAppParent; // protected ReferenceType vAppParent;

View File

@ -18,51 +18,15 @@
*/ */
package org.jclouds.vcloud.director.v1_5.domain.vapp; package org.jclouds.vcloud.director.v1_5.domain.vapp;
import static com.google.common.base.Objects.*;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import org.jclouds.vcloud.director.v1_5.domain.Owner;
import com.google.common.base.Objects;
/** /**
*
* Represents a vApp. * Represents a vApp.
* *
*
* <p>Java class for VApp complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre> * <pre>
* &lt;complexType name="VApp"> * &lt;complexType name="VApp" /&gt;
* &lt;complexContent>
* &lt;extension base="{http://www.vmware.com/vcloud/v1.5}AbstractVApp">
* &lt;sequence>
* &lt;element name="Owner" type="{http://www.vmware.com/vcloud/v1.5}OwnerType" minOccurs="0"/>
* &lt;element name="InMaintenanceMode" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
* &lt;element name="Children" type="{http://www.vmware.com/vcloud/v1.5}VAppChildrenType" minOccurs="0"/>
* &lt;/sequence>
* &lt;attribute name="ovfDescriptorUploaded" type="{http://www.w3.org/2001/XMLSchema}boolean" />
* &lt;anyAttribute processContents='lax' namespace='##other'/>
* &lt;/extension>
* &lt;/complexContent>
* &lt;/complexType>
* </pre> * </pre>
* *
* * @author grkvlt@apache.org
*/ */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "VApp", propOrder = {
"owner",
"inMaintenanceMode",
"children"
})
public class VApp extends AbstractVAppType { public class VApp extends AbstractVAppType {
// //
// @SuppressWarnings("unchecked") // @SuppressWarnings("unchecked")

View File

@ -18,53 +18,64 @@
*/ */
package org.jclouds.vcloud.director.v1_5.predicates; package org.jclouds.vcloud.director.v1_5.predicates;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants.*;
import java.net.URI; import java.net.URI;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.inject.Named;
import javax.inject.Singleton; import javax.inject.Singleton;
import org.jclouds.logging.Logger; import org.jclouds.logging.Logger;
import org.jclouds.predicates.RetryablePredicate;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorAsyncClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorAsyncClient;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.TaskInErrorStateException;
import org.jclouds.vcloud.director.v1_5.domain.TaskStatus;
import org.jclouds.vcloud.director.v1_5.features.TaskClient; import org.jclouds.vcloud.director.v1_5.features.TaskClient;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.inject.Inject; import com.google.inject.Inject;
/** /**
* Keeps testing {@link Task} to see if it has succeeded before a time limit has elapsed.
* *
* Tests to see if a task succeeds. * @author grkvlt@apache.org
*
* @author Adrian Cole
*/ */
@Singleton @Singleton
public class TaskSuccess implements Predicate<URI> { public class TaskSuccess implements Predicate<URI> {
private final TaskClient taskClient; private final TaskClient taskClient;
private final RetryablePredicate<URI> retry;
@Resource private final Predicate<URI> checkSuccess = new Predicate<URI>() {
protected Logger logger = Logger.NULL; @Override
@Inject
public TaskSuccess(RestContext<VCloudDirectorClient, VCloudDirectorAsyncClient> context) {
this.taskClient = context.getApi().getTaskClient();
}
public boolean apply(URI taskUri) { public boolean apply(URI taskUri) {
logger.trace("looking for status on task %s", taskUri); logger.trace("looking for status on task %s", taskUri);
Task task = taskClient.getTask(taskUri); Task task = taskClient.getTask(taskUri);
// perhaps task isn't available, yet // perhaps task isn't available, yet
if (task == null) if (task == null) return false;
return false; logger.trace("%s: looking for status %s: currently: %s", task, Task.Status.SUCCESS, task.getStatus());
logger.trace("%s: looking for status %s: currently: %s", task, TaskStatus.SUCCESS, task.getStatus()); if (task.getStatus().equals(Task.Status.ERROR))
if (task.getStatus() == TaskStatus.ERROR) throw new VCloudDirectorException(task);
throw new TaskInErrorStateException(task); return task.getStatus().equals(Task.Status.SUCCESS);
return task.getStatus() == TaskStatus.SUCCESS; }
};
@Resource
protected Logger logger = Logger.NULL;
@Inject
public TaskSuccess(RestContext<VCloudDirectorClient, VCloudDirectorAsyncClient> context,
@Named(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED) long maxWait) {
this.taskClient = context.getApi().getTaskClient();
this.retry = new RetryablePredicate<URI>(checkSuccess, maxWait);
} }
/** @see Predicate#apply(Object) */
@Override
public boolean apply(URI input) {
return retry.apply(input);
}
} }

View File

@ -18,7 +18,7 @@
*/ */
package org.jclouds.vcloud.director.v1_5; package org.jclouds.vcloud.director.v1_5;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.*;
import org.jclouds.vcloud.director.v1_5.domain.Session; import org.jclouds.vcloud.director.v1_5.domain.Session;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;

View File

@ -47,7 +47,7 @@ public class VCloudDirectorLiveTestConstants {
public static final String REQUIRED_VALUE_OBJECT_FMT = "ERR-03: The %s field of the %s must not be '%s'; allowed values: %s"; public static final String REQUIRED_VALUE_OBJECT_FMT = "ERR-03: The %s field of the %s must not be '%s'; allowed values: %s";
public static final String REQUIRED_VALUE_FMT = "ERR-04: The %s field must not be '%sr'; allowed values: %s"; public static final String REQUIRED_VALUE_FMT = "ERR-04: The %s field must not be '%s'; allowed values: %s";
public static final String MUST_BE_WELL_FORMED_FMT = "ERR-05: The %s field must be well formed: '%s'"; public static final String MUST_BE_WELL_FORMED_FMT = "ERR-05: The %s field must be well formed: '%s'";

View File

@ -129,7 +129,7 @@ public class Checks {
public static void checkTask(Task task) { public static void checkTask(Task task) {
// Check required fields // Check required fields
assertNotNull(task.getStatus(), String.format(NOT_NULL_OBJECT_FMT, "Status", "Task")); assertNotNull(task.getStatus(), String.format(NOT_NULL_OBJECT_FMT, "Status", "Task"));
assertTrue(Task.Status.ALL.contains(task.getStatus()), String.format(REQUIRED_VALUE_OBJECT_FMT, "Status", "Task", task.getStatus(), Iterables.toString(Link.Rel.ALL))); assertTrue(Task.Status.ALL.contains(task.getStatus()), String.format(REQUIRED_VALUE_OBJECT_FMT, "Status", "Task", task.getStatus(), Iterables.toString(Task.Status.ALL)));
// Check optional fields // Check optional fields
// NOTE operation cannot be checked // NOTE operation cannot be checked

View File

@ -34,7 +34,7 @@ import org.jclouds.vcloud.director.v1_5.domain.ReferenceType;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences; import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
@ -54,6 +54,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
private CatalogClient catalogClient; private CatalogClient catalogClient;
private QueryClient queryClient; private QueryClient queryClient;
private MediaClient mediaClient;
/* /*
* Shared state between dependant tests. * Shared state between dependant tests.
@ -67,11 +68,13 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
private CatalogItem newCatalogItem; private CatalogItem newCatalogItem;
private Metadata catalogMetadata; private Metadata catalogMetadata;
@BeforeGroups(groups = { "live" }) @BeforeClass(inheritGroups = true)
public void setupClients() { public void setupRequiredClients() {
catalogClient = context.getApi().getCatalogClient(); catalogClient = context.getApi().getCatalogClient();
queryClient = context.getApi().getQueryClient(); queryClient = context.getApi().getQueryClient();
mediaClient = context.getApi().getMediaClient();
} }
private Metadata catalogItemMetadata; private Metadata catalogItemMetadata;
@Test(testName = "GET /catalog/{id}") @Test(testName = "GET /catalog/{id}")
@ -152,9 +155,8 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
} }
}); });
MetadataValue metadataValue = catalogClient.getCatalogMetadataValue(catalogRef, "KEY"); MetadataValue metadataValue = catalogClient.getCatalogMetadataValue(catalogRef, "KEY");
// XXX
assertEquals(metadataValue.getValue(), existingMetadataEntry.getValue(), assertEquals(metadataValue.getValue(), existingMetadataEntry.getValue(),
"The MetadataValue for KEY should have the same Value as the existing MetadataEntry"); String.format(CORRECT_VALUE_OBJECT_FMT, "Value", "MetadataValue", existingMetadataEntry.getValue(), metadataValue.getValue()));
checkMetadataValue(metadataValue); checkMetadataValue(metadataValue);
} }
@ -162,8 +164,7 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
public void testGetCatalogItemMetadata() { public void testGetCatalogItemMetadata() {
resetCatalogItemMetadata(catalogItemRef); resetCatalogItemMetadata(catalogItemRef);
catalogItemMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef); catalogItemMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef);
// XXX assertEquals(catalogItemMetadata.getMetadataEntries().size(), 1, String.format(MUST_EXIST_FMT, "MetadataEntry", "CatalogItem"));
assertEquals(catalogItemMetadata.getMetadataEntries().size(), 1, "There should be a single MetadataEntry");
checkMetadata(catalogItemMetadata); checkMetadata(catalogItemMetadata);
} }
@ -176,9 +177,8 @@ public class CatalogClientLiveTest extends BaseVCloudDirectorClientLiveTest {
Task mergeCatalogItemMetadata = catalogClient.mergeCatalogItemMetadata(catalogItemRef, newMetadata); Task mergeCatalogItemMetadata = catalogClient.mergeCatalogItemMetadata(catalogItemRef, newMetadata);
checkTask(mergeCatalogItemMetadata); checkTask(mergeCatalogItemMetadata);
// TODO requires code from dan to be merged assertTrue(successTester.apply(mergeCatalogItemMetadata.getHref()),
// assertTrue(taskTester.apply(mergeCatalogItemMetadata.getHref()), String.format(TASK_COMPLETE_TIMELY, "mergeCatalogItemMetadata"));
// String.format(TASK_COMPLETE_TIMELY, "mergeCatalogItemMetadata"));
Metadata mergedCatalogItemMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef); Metadata mergedCatalogItemMetadata = catalogClient.getCatalogItemMetadata(catalogItemRef);
// XXX // XXX

View File

@ -29,7 +29,7 @@ import org.jclouds.vcloud.director.v1_5.domain.MetadataEntry;
import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork; import org.jclouds.vcloud.director.v1_5.domain.OrgNetwork;
import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
@ -46,8 +46,8 @@ public class NetworkClientLiveTest extends BaseVCloudDirectorClientLiveTest {
private NetworkClient networkClient; private NetworkClient networkClient;
@BeforeGroups(groups = { "live" }) @BeforeClass(inheritGroups = true)
public void setupClients() { public void setupRequiredClients() {
networkClient = context.getApi().getNetworkClient(); networkClient = context.getApi().getNetworkClient();
} }

View File

@ -29,7 +29,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Org;
import org.jclouds.vcloud.director.v1_5.domain.OrgList; import org.jclouds.vcloud.director.v1_5.domain.OrgList;
import org.jclouds.vcloud.director.v1_5.domain.Reference; import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@ -48,8 +48,8 @@ public class OrgClientLiveTest extends BaseVCloudDirectorClientLiveTest {
private OrgClient orgClient; private OrgClient orgClient;
@BeforeGroups(groups = { "live" }) @BeforeClass(inheritGroups = true)
public void setupClients() { public void setupRequiredClients() {
orgClient = context.getApi().getOrgClient(); orgClient = context.getApi().getOrgClient();
} }

View File

@ -18,16 +18,13 @@
*/ */
package org.jclouds.vcloud.director.v1_5.features; package org.jclouds.vcloud.director.v1_5.features;
import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.*;
import static org.testng.Assert.*; import static org.testng.Assert.*;
import java.net.URI; import org.jclouds.vcloud.director.v1_5.domain.query.CatalogReferences;
import org.jclouds.vcloud.director.v1_5.domain.query.QueryResultRecords;
import org.jclouds.vcloud.director.v1_5.domain.OrgList;
import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.TasksList;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
@ -45,8 +42,8 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
private CatalogClient catalogClient; private CatalogClient catalogClient;
private QueryClient queryClient; private QueryClient queryClient;
@BeforeGroups(groups = { "live" }) @BeforeClass(inheritGroups = true)
public void setupClients() { public void setupRequiredClients() {
catalogClient = context.getApi().getCatalogClient(); catalogClient = context.getApi().getCatalogClient();
queryClient = context.getApi().getQueryClient(); queryClient = context.getApi().getQueryClient();
} }
@ -55,14 +52,18 @@ public class QueryClientLiveTest extends BaseVCloudDirectorClientLiveTest {
* Shared state between dependant tests. * Shared state between dependant tests.
*/ */
private OrgList orgList; private QueryResultRecords<?> catalogRecords;
private Reference orgRef; private CatalogReferences catalogReferences;
private TasksList taskList;
private Task task;
private URI taskUri;
@Test(testName = "GET /catalogs/query/") @Test(testName = "GET /catalogs/query")
public void testQueryCatalogNoParam() { public void testQueryAllCatalogs() {
assertTrue(true); catalogRecords = queryClient.catalogsQueryAll();
assertFalse(catalogRecords.getRecords().isEmpty(), String.format(NOT_EMPTY_OBJECT_FMT, "CatalogRecord", "QueryResultRecords"));
}
@Test(testName = "GET /catalogs/query?format=references", dependsOnMethods = { "testQueryAllCatalogs" })
public void testQueryAllCatalogReferences() {
catalogReferences = queryClient.catalogReferencesQueryAll();
assertFalse(catalogReferences.getReferences().isEmpty(), String.format(NOT_EMPTY_OBJECT_FMT, "CatalogReference", "CatalogReferences"));
} }
} }

View File

@ -29,7 +29,7 @@ import org.jclouds.vcloud.director.v1_5.domain.Reference;
import org.jclouds.vcloud.director.v1_5.domain.Task; import org.jclouds.vcloud.director.v1_5.domain.Task;
import org.jclouds.vcloud.director.v1_5.domain.TasksList; import org.jclouds.vcloud.director.v1_5.domain.TasksList;
import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest; import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorClientLiveTest;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
@ -49,8 +49,8 @@ public class TaskClientLiveTest extends BaseVCloudDirectorClientLiveTest {
private OrgClient orgClient; private OrgClient orgClient;
private TaskClient taskClient; private TaskClient taskClient;
@BeforeGroups(groups = { "live" }) @BeforeClass(inheritGroups = true)
public void setupClients() { public void setupRequiredClients() {
orgClient = context.getApi().getOrgClient(); orgClient = context.getApi().getOrgClient();
taskClient = context.getApi().getTaskClient(); taskClient = context.getApi().getTaskClient();
} }

View File

@ -27,8 +27,8 @@ import org.jclouds.rest.RestContextFactory;
import org.jclouds.sshj.config.SshjSshClientModule; import org.jclouds.sshj.config.SshjSshClientModule;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorAsyncClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorAsyncClient;
import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient; import org.jclouds.vcloud.director.v1_5.VCloudDirectorClient;
import org.testng.annotations.AfterGroups; import org.jclouds.vcloud.director.v1_5.predicates.TaskSuccess;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
@ -41,21 +41,24 @@ import com.google.inject.Module;
*/ */
@Test(groups = "live") @Test(groups = "live")
public class BaseVCloudDirectorClientLiveTest extends BaseVersionedServiceLiveTest { public class BaseVCloudDirectorClientLiveTest extends BaseVersionedServiceLiveTest {
public BaseVCloudDirectorClientLiveTest() {
protected BaseVCloudDirectorClientLiveTest() {
provider = "vcloud-director"; provider = "vcloud-director";
} }
protected TaskSuccess successTester;
protected RestContext<VCloudDirectorClient, VCloudDirectorAsyncClient> context; protected RestContext<VCloudDirectorClient, VCloudDirectorAsyncClient> context;
@BeforeGroups(groups = { "live" }) @BeforeClass(groups = { "live" })
public void setupClient() { public void setupContext() {
setupCredentials(); setupCredentials();
Properties overrides = setupProperties(); Properties overrides = setupProperties();
context = new RestContextFactory().createContext(provider, identity, credential, context = new RestContextFactory().createContext(provider, identity, credential,
ImmutableSet.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides); ImmutableSet.<Module> of(new Log4JLoggingModule(), new SshjSshClientModule()), overrides);
successTester = new TaskSuccess(context, 1000L);
} }
@AfterGroups(groups = "live")
protected void tearDown() { protected void tearDown() {
if (context != null) if (context != null)
context.close(); context.close();