Issue 280: updated catalog and org to 0.9+ spec

This commit is contained in:
Adrian Cole 2010-08-22 21:25:53 -07:00
parent 5015c169e4
commit ae5381d2bd
16 changed files with 462 additions and 221 deletions

View File

@ -19,8 +19,11 @@
package org.jclouds.vcloud.domain;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import org.jclouds.vcloud.domain.internal.CatalogImpl;
import com.google.inject.ImplementedBy;
@ -31,7 +34,35 @@ import com.google.inject.ImplementedBy;
@org.jclouds.vcloud.endpoints.Catalog
@ImplementedBy(CatalogImpl.class)
public interface Catalog extends NamedResource, Map<String, NamedResource> {
/**
* Reference to the org containing this vDC.
*
* @since vcloud api 1.0
* @return org, or null if this is a version before 1.0 where the org isn't present
*/
NamedResource getOrg();
/**
* optional description
*
* @since vcloud api 0.8
*/
@Nullable
String getDescription();
/**
* readonly element, true if the catalog is published
*
* @since vcloud api 1.0
*/
@Nullable
boolean isPublished();
/**
* readonly container for Task elements. Each element in the container represents a queued,
* running, or failed task owned by this object.
*
* @since vcloud api 1.0
*/
List<Task> getTasks();
}

View File

@ -19,6 +19,7 @@
package org.jclouds.vcloud.domain;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
@ -46,6 +47,14 @@ public interface Org extends NamedResource {
@Nullable
String getDescription();
/**
* full name of the organization
*
* @since vcloud api 1.0
*/
@Nullable
String getFullName();
/**
* @since vcloud api 0.8
*/
@ -70,4 +79,12 @@ public interface Org extends NamedResource {
*/
Map<String, NamedResource> getNetworks();
/**
* readonly container for Task elements. Each element in the container represents a queued,
* running, or failed task owned by this object.
*
* @since vcloud api 1.0
*/
List<Task> getTasks();
}

View File

@ -23,12 +23,15 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.jclouds.vcloud.VCloudExpressMediaType;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Task;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.inject.internal.Nullable;
/**
@ -42,26 +45,81 @@ public class CatalogImpl extends LinkedHashMap<String, NamedResource> implements
/** The serialVersionUID */
private static final long serialVersionUID = 8464716396538298809L;
private final String name;
private final String description;
private final String type;
private final URI id;
private final NamedResource org;
@Nullable
private final String description;
private final List<Task> tasks = Lists.newArrayList();
private final boolean published;
public CatalogImpl(String name, URI id, @Nullable String description, Map<String, NamedResource> contents) {
public CatalogImpl(String name, String type, URI id, NamedResource org, @Nullable String description,
Map<String, NamedResource> contents, Iterable<Task> tasks, boolean published) {
this.name = checkNotNull(name, "name");
this.type = checkNotNull(type, "type");
this.org = org;// TODO: once <1.0 is killed check not null
this.description = description;
this.id = checkNotNull(id, "id");
putAll(checkNotNull(contents, "contents"));
Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks"));
this.published = published;
}
/**
* {@inheritDoc}
*/
@Override
public URI getId() {
return id;
}
/**
* {@inheritDoc}
*/
@Override
public String getName() {
return name;
}
/**
* {@inheritDoc}
*/
@Override
public NamedResource getOrg() {
return org;
}
/**
* {@inheritDoc}
*/
public String getDescription() {
return description;
}
/**
* {@inheritDoc}
*/
@Override
public String getType() {
return type;
}
/**
* {@inheritDoc}
*/
@Override
public List<Task> getTasks() {
return tasks;
}
/**
* {@inheritDoc}
*/
@Override
public boolean isPublished() {
return published;
}
@Override
public int hashCode() {
final int prime = 31;
@ -69,6 +127,9 @@ public class CatalogImpl extends LinkedHashMap<String, NamedResource> implements
result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((name == null) ? 0 : name.hashCode());
result = prime * result + ((org == null) ? 0 : org.hashCode());
result = prime * result + ((tasks == null) ? 0 : tasks.hashCode());
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
}
@ -96,18 +157,24 @@ public class CatalogImpl extends LinkedHashMap<String, NamedResource> implements
return false;
} else if (!name.equals(other.name))
return false;
if (org == null) {
if (other.org != null)
return false;
} else if (!org.equals(other.org))
return false;
if (tasks == null) {
if (other.tasks != null)
return false;
} else if (!tasks.equals(other.tasks))
return false;
if (type == null) {
if (other.type != null)
return false;
} else if (!type.equals(other.type))
return false;
return true;
}
public String getDescription() {
return description;
}
@Override
public String getType() {
return VCloudExpressMediaType.CATALOG_XML;
}
@Override
public int compareTo(NamedResource o) {
return (this == o) ? 0 : getId().compareTo(o.getId());

View File

@ -19,13 +19,21 @@
package org.jclouds.vcloud.domain.internal;
import static com.google.common.base.Preconditions.checkNotNull;
import java.net.URI;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.Task;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
/**
* Locations of resources in vCloud
@ -34,21 +42,36 @@ import org.jclouds.vcloud.domain.Org;
*
*/
public class OrgImpl extends NamedResourceImpl implements Org {
private final String fullName;
@Nullable
private final String description;
private final Map<String, NamedResource> catalogs;
private final Map<String, NamedResource> vdcs;
private final Map<String, NamedResource> networks;
private final Map<String, NamedResource> catalogs = Maps.newLinkedHashMap();
private final Map<String, NamedResource> vdcs = Maps.newLinkedHashMap();
private final Map<String, NamedResource> networks = Maps.newLinkedHashMap();
private final NamedResource tasksList;
private final List<Task> tasks = Lists.newArrayList();
public OrgImpl(String name, String type, URI id, String description, Map<String, NamedResource> catalogs,
Map<String, NamedResource> vdcs, Map<String, NamedResource> networks, @Nullable NamedResource tasksList) {
public OrgImpl(String name, String type, URI id, String fullName, String description,
Map<String, NamedResource> catalogs, Map<String, NamedResource> vdcs, Map<String, NamedResource> networks,
@Nullable NamedResource tasksList, Iterable<Task> tasks) {
super(name, type, id);
this.fullName = checkNotNull(fullName, "fullName");
this.description = description;
this.catalogs = catalogs;
this.vdcs = vdcs;
this.networks = networks;
this.catalogs.putAll(checkNotNull(catalogs, "catalogs"));
this.vdcs.putAll(checkNotNull(vdcs, "vdcs"));
this.networks.putAll(checkNotNull(networks, "networks"));
this.tasksList = tasksList;
Iterables.addAll(this.tasks, checkNotNull(tasks, "tasks"));
}
@Override
public String getFullName() {
return fullName;
}
@Override
public String getDescription() {
return description;
}
@Override
@ -61,18 +84,30 @@ public class OrgImpl extends NamedResourceImpl implements Org {
return vdcs;
}
@Override
public Map<String, NamedResource> getNetworks() {
return networks;
}
@Override
public NamedResource getTasksList() {
return tasksList;
}
@Override
public List<Task> getTasks() {
return tasks;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((catalogs == null) ? 0 : catalogs.hashCode());
result = prime * result + ((description == null) ? 0 : description.hashCode());
result = prime * result + ((fullName == null) ? 0 : fullName.hashCode());
result = prime * result + ((networks == null) ? 0 : networks.hashCode());
result = prime * result + ((tasks == null) ? 0 : tasks.hashCode());
result = prime * result + ((tasksList == null) ? 0 : tasksList.hashCode());
result = prime * result + ((vdcs == null) ? 0 : vdcs.hashCode());
return result;
@ -97,11 +132,21 @@ public class OrgImpl extends NamedResourceImpl implements Org {
return false;
} else if (!description.equals(other.description))
return false;
if (fullName == null) {
if (other.fullName != null)
return false;
} else if (!fullName.equals(other.fullName))
return false;
if (networks == null) {
if (other.networks != null)
return false;
} else if (!networks.equals(other.networks))
return false;
if (tasks == null) {
if (other.tasks != null)
return false;
} else if (!tasks.equals(other.tasks))
return false;
if (tasksList == null) {
if (other.tasksList != null)
return false;
@ -125,13 +170,4 @@ public class OrgImpl extends NamedResourceImpl implements Org {
return "[id=" + getId() + ", name=" + getName() + ", type=" + getType() + "]";
}
@Override
public Map<String, NamedResource> getNetworks() {
return networks;
}
@Override
public String getDescription() {
return description;
}
}

View File

@ -19,31 +19,50 @@
package org.jclouds.vcloud.xml;
import static org.jclouds.vcloud.util.Utils.newNamedResource;
import java.util.List;
import java.util.SortedMap;
import javax.inject.Inject;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.internal.CatalogImpl;
import org.jclouds.vcloud.util.Utils;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
/**
* @author Adrian Cole
*/
public class CatalogHandler extends ParseSax.HandlerWithResult<Catalog> {
protected final TaskHandler taskHandler;
@Inject
public CatalogHandler(TaskHandler taskHandler) {
this.taskHandler = taskHandler;
}
private StringBuilder currentText = new StringBuilder();
private NamedResource catalog;
private SortedMap<String, NamedResource> contents = Maps.newTreeMap();
protected List<Task> tasks = Lists.newArrayList();
private String description;
private NamedResource org;
private boolean published = true;
public Catalog getResult() {
return new CatalogImpl(catalog.getName(), catalog.getId(), description, contents);
return new CatalogImpl(catalog.getName(), catalog.getType(), catalog.getId(), org, description, contents, tasks,
published);
}
@Override
@ -52,12 +71,21 @@ public class CatalogHandler extends ParseSax.HandlerWithResult<Catalog> {
catalog = Utils.newNamedResource(attributes);
} else if (qName.equals("CatalogItem")) {
Utils.putNamedResource(contents, attributes);
} else if (qName.equals("Link") && "up".equals(Utils.attrOrNull(attributes, "rel"))) {
org = newNamedResource(attributes);
} else {
taskHandler.startElement(uri, localName, qName, attributes);
}
}
public void endElement(String uri, String name, String qName) {
if (qName.equals("Description")) {
taskHandler.endElement(uri, name, qName);
if (qName.equals("Task")) {
this.tasks.add(taskHandler.getResult());
} else if (qName.equals("Description")) {
description = currentOrNull();
} else if (qName.equals("IsPublished")) {
published = Boolean.parseBoolean(currentOrNull());
}
currentText = new StringBuilder();
}

View File

@ -22,21 +22,34 @@ package org.jclouds.vcloud.xml;
import static org.jclouds.vcloud.util.Utils.newNamedResource;
import static org.jclouds.vcloud.util.Utils.putNamedResource;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.internal.OrgImpl;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
/**
* @author Adrian Cole
*/
public class OrgHandler extends ParseSax.HandlerWithResult<Org> {
protected final TaskHandler taskHandler;
@Inject
public OrgHandler(TaskHandler taskHandler) {
this.taskHandler = taskHandler;
}
private StringBuilder currentText = new StringBuilder();
protected NamedResource org;
@ -44,11 +57,14 @@ public class OrgHandler extends ParseSax.HandlerWithResult<Org> {
protected NamedResource tasksList;
protected Map<String, NamedResource> catalogs = Maps.newLinkedHashMap();
protected Map<String, NamedResource> networks = Maps.newLinkedHashMap();
protected List<Task> tasks = Lists.newArrayList();
protected String description;
protected String fullName;
public Org getResult() {
return new OrgImpl(org.getName(), org.getType(), org.getId(), description, catalogs, vdcs, networks, tasksList);
return new OrgImpl(org.getName(), org.getType(), org.getId(), fullName != null ? fullName : org.getName(),
description, catalogs, vdcs, networks, tasksList, tasks);
}
@Override
@ -68,12 +84,20 @@ public class OrgHandler extends ParseSax.HandlerWithResult<Org> {
putNamedResource(networks, attributes);
}
}
} else {
taskHandler.startElement(uri, localName, qName, attributes);
}
}
public void endElement(String uri, String name, String qName) {
if (qName.equals("Description")) {
taskHandler.endElement(uri, name, qName);
if (qName.equals("Task")) {
this.tasks.add(taskHandler.getResult());
} else if (qName.equals("Description")) {
description = currentOrNull();
} else if (qName.equals("FullName")) {
fullName = currentOrNull();
}
currentText = new StringBuilder();
}

View File

@ -24,6 +24,7 @@ import static org.testng.Assert.assertNotNull;
import java.util.Properties;
import org.jclouds.Constants;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.RestContext;
@ -68,17 +69,20 @@ public abstract class CommonVCloudClientLiveTest<S extends CommonVCloudClient, A
@Test
public void testCatalog() throws Exception {
Catalog response = connection.findCatalogInOrgNamed(null, null);
assertNotNull(response);
assertNotNull(response.getName());
assertNotNull(response.getId());
assertEquals(connection.findCatalogInOrgNamed(null, response.getName()), response);
Org org = connection.findOrgNamed(null);
for (NamedResource cat : org.getCatalogs().values()) {
Catalog response = connection.getCatalog(cat.getId());
assertNotNull(response);
assertNotNull(response.getName());
assertNotNull(response.getId());
assertEquals(connection.findCatalogInOrgNamed(null, response.getName()), response);
}
}
@Test
public void testGetNetwork() throws Exception {
VDC response = connection.findVDCInOrgNamed(null, null);
for (NamedResource resource : response.getAvailableNetworks().values()) {
public void testGetOrgNetwork() throws Exception {
Org org = connection.findOrgNamed(null);
for (NamedResource resource : org.getNetworks().values()) {
if (resource.getType().equals(VCloudMediaType.NETWORK_XML)) {
OrgNetwork item = connection.getNetwork(resource.getId());
assertNotNull(item);
@ -86,29 +90,49 @@ public abstract class CommonVCloudClientLiveTest<S extends CommonVCloudClient, A
}
}
@Test
public void testGetVDCNetwork() throws Exception {
Org org = connection.findOrgNamed(null);
for (NamedResource vdc : org.getVDCs().values()) {
VDC response = connection.getVDC(vdc.getId());
for (NamedResource resource : response.getAvailableNetworks().values()) {
if (resource.getType().equals(VCloudMediaType.NETWORK_XML)) {
OrgNetwork item = connection.getNetwork(resource.getId());
assertNotNull(item);
}
}
}
}
@Test
public void testGetCatalogItem() throws Exception {
Catalog response = connection.findCatalogInOrgNamed(null, null);
for (NamedResource resource : response.values()) {
if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
CatalogItem item = connection.findCatalogItemInOrgCatalogNamed(null, null, resource.getName());
assertNotNull(item);
assertNotNull(item.getEntity());
assertNotNull(item.getId());
assertNotNull(item.getProperties());
assertNotNull(item.getType());
Org org = connection.findOrgNamed(null);
for (NamedResource cat : org.getCatalogs().values()) {
Catalog response = connection.getCatalog(cat.getId());
for (NamedResource resource : response.values()) {
if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
CatalogItem item = connection.findCatalogItemInOrgCatalogNamed(null, null, resource.getName());
assertNotNull(item);
assertNotNull(item.getEntity());
assertNotNull(item.getId());
assertNotNull(item.getProperties());
assertNotNull(item.getType());
}
}
}
}
@Test
public void testGetVAppTemplate() throws Exception {
Catalog response = connection.findCatalogInOrgNamed(null, null);
for (NamedResource resource : response.values()) {
if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
CatalogItem item = connection.getCatalogItem(resource.getId());
if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) {
assertNotNull(connection.findVAppTemplateInOrgCatalogNamed(null, null, item.getEntity().getName()));
Org org = connection.findOrgNamed(null);
for (NamedResource cat : org.getCatalogs().values()) {
Catalog response = connection.getCatalog(cat.getId());
for (NamedResource resource : response.values()) {
if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
CatalogItem item = connection.getCatalogItem(resource.getId());
if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) {
assertNotNull(connection.findVAppTemplateInOrgCatalogNamed(null, null, item.getEntity().getName()));
}
}
}
}
@ -116,13 +140,16 @@ public abstract class CommonVCloudClientLiveTest<S extends CommonVCloudClient, A
@Test
public void testDefaultVDC() throws Exception {
VDC response = connection.findVDCInOrgNamed(null, null);
assertNotNull(response);
assertNotNull(response.getName());
assertNotNull(response.getId());
assertNotNull(response.getResourceEntities());
assertNotNull(response.getAvailableNetworks());
assertEquals(connection.getVDC(response.getId()), response);
Org org = connection.findOrgNamed(null);
for (NamedResource vdc : org.getVDCs().values()) {
VDC response = connection.getVDC(vdc.getId());
assertNotNull(response);
assertNotNull(response.getName());
assertNotNull(response.getId());
assertNotNull(response.getResourceEntities());
assertNotNull(response.getAvailableNetworks());
assertEquals(connection.getVDC(response.getId()), response);
}
}
@Test
@ -148,11 +175,14 @@ public abstract class CommonVCloudClientLiveTest<S extends CommonVCloudClient, A
@Test
public void testGetVApp() throws Exception {
VDC response = connection.findVDCInOrgNamed(null, null);
for (NamedResource item : response.getResourceEntities().values()) {
if (item.getType().equals(VCloudMediaType.VAPP_XML)) {
VApp app = connection.getVApp(item.getId());
assertNotNull(app);
Org org = connection.findOrgNamed(null);
for (NamedResource vdc : org.getVDCs().values()) {
VDC response = connection.getVDC(vdc.getId());
for (NamedResource item : response.getResourceEntities().values()) {
if (item.getType().equals(VCloudMediaType.VAPP_XML)) {
VApp app = connection.getVApp(item.getId());
assertNotNull(app);
}
}
}
}
@ -163,6 +193,8 @@ public abstract class CommonVCloudClientLiveTest<S extends CommonVCloudClient, A
public void setupClient() {
setupCredentials();
Properties props = new Properties();
props.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true");
props.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true");
context = new ComputeServiceContextFactory().createContext(provider, identity, credential,
ImmutableSet.<Module> of(new Log4JLoggingModule()), props).getProviderSpecificContext();

View File

@ -51,6 +51,7 @@ import org.jclouds.util.Utils;
import org.jclouds.vcloud.config.VCloudRestClientModule;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VCloudSession;
import org.jclouds.vcloud.domain.internal.CatalogImpl;
import org.jclouds.vcloud.domain.internal.CatalogItemImpl;
@ -73,6 +74,7 @@ import org.testng.annotations.Test;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Module;
import com.google.inject.TypeLiteral;
@ -721,9 +723,12 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
"vdc",
new VDCImpl(
"vdc",
null, URI
null,
URI
.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"),
null, null, "description",
null,
null,
"description",
null,
null,
null,
@ -757,7 +762,7 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
@Override
public Map<String, Org> get() {
return ImmutableMap.<String, Org> of("org", new OrgImpl("org", null, URI
.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"), "description", ImmutableMap
.create("https://vcenterprise.bluelock.com/api/v1.0/org/1"), "org", "description", ImmutableMap
.<String, NamedResource> of("catalog", new NamedResourceImpl("catalog",
VCloudMediaType.CATALOG_XML, URI
.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"))), ImmutableMap
@ -767,7 +772,8 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
VCloudMediaType.NETWORK_XML, URI
.create("https://vcenterprise.bluelock.com/api/v1.0/network/1"))),
new NamedResourceImpl("tasksList", VCloudMediaType.TASKSLIST_XML, URI
.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1"))));
.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1")), ImmutableList
.<Task> of()));
}
}
@ -780,32 +786,17 @@ public class VCloudAsyncClientTest extends RestClientTest<VCloudAsyncClient> {
@Override
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
return ImmutableMap
.<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> of(
"org",
return ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> of("org",
ImmutableMap
.<String, org.jclouds.vcloud.domain.Catalog> of(
"catalog",
new CatalogImpl(
"catalog",
URI
.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"),
"description",
ImmutableMap
.<String, NamedResource> of(
"item",
new NamedResourceImpl(
"item",
"application/vnd.vmware.vcloud.catalogItem+xml",
URI
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1")),
"template",
new NamedResourceImpl(
"template",
"application/vnd.vmware.vcloud.vAppTemplate+xml",
URI
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"))))));
ImmutableMap.<String, org.jclouds.vcloud.domain.Catalog> of("catalog", new CatalogImpl("catalog", "type",
URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1"), null, "description",
ImmutableMap.<String, NamedResource> of("item", new NamedResourceImpl("item",
"application/vnd.vmware.vcloud.catalogItem+xml", URI
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1")),
"template", new NamedResourceImpl("template",
"application/vnd.vmware.vcloud.vAppTemplate+xml", URI
.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"))),
ImmutableList.<Task> of(), true)));
}
}

View File

@ -51,6 +51,7 @@ import org.jclouds.util.Utils;
import org.jclouds.vcloud.config.VCloudExpressRestClientModule;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.VCloudSession;
import org.jclouds.vcloud.domain.internal.CatalogImpl;
import org.jclouds.vcloud.domain.internal.CatalogItemImpl;
@ -74,6 +75,7 @@ import org.testng.annotations.Test;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Module;
import com.google.inject.TypeLiteral;
@ -741,14 +743,15 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
@Override
public Map<String, Org> get() {
return ImmutableMap.<String, Org> of("org", new OrgImpl("org", null, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), null, ImmutableMap
.create("https://vcloud.safesecureweb.com/api/v0.8/org/1"), "org", null, ImmutableMap
.<String, NamedResource> of("catalog", new NamedResourceImpl("catalog",
VCloudExpressMediaType.CATALOG_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))), ImmutableMap
.<String, NamedResource> of("vdc", new NamedResourceImpl("vdc", VCloudExpressMediaType.VDC_XML,
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vdc/1"))), null,
new NamedResourceImpl("tasksList", VCloudExpressMediaType.TASKSLIST_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1"))));
.create("https://vcloud.safesecureweb.com/api/v0.8/tasksList/1")), ImmutableList
.<Task> of()));
}
}
@ -763,13 +766,14 @@ public class VCloudExpressAsyncClientTest extends RestClientTest<VCloudExpressAs
public Map<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> get() {
return ImmutableMap.<String, Map<String, ? extends org.jclouds.vcloud.domain.Catalog>> of("org",
ImmutableMap.<String, org.jclouds.vcloud.domain.Catalog> of("catalog", new CatalogImpl("catalog", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"), "description", ImmutableMap
.<String, NamedResource> of("item", new NamedResourceImpl("item",
ImmutableMap.<String, org.jclouds.vcloud.domain.Catalog> of("catalog", new CatalogImpl("catalog", "type",
URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"), null, "description",
ImmutableMap.<String, NamedResource> of("item", new NamedResourceImpl("item",
"application/vnd.vmware.vcloud.catalogItem+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1")), "template",
new NamedResourceImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"))))));
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"))),
ImmutableList.<Task> of(), true)));
}
}

View File

@ -19,6 +19,7 @@
package org.jclouds.vcloud.xml;
import static org.jclouds.vcloud.VCloudMediaType.CATALOGITEM_XML;
import static org.testng.Assert.assertEquals;
import java.io.InputStream;
@ -27,12 +28,15 @@ import java.net.URI;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.http.functions.config.SaxParserModule;
import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.domain.internal.CatalogItemImpl;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.internal.CatalogImpl;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSortedMap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.inject.Guice;
import com.google.inject.Injector;
@ -44,19 +48,91 @@ import com.google.inject.Injector;
@Test(groups = "unit", testName = "vcloud.CatalogHandlerTest")
public class CatalogHandlerTest {
public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/catalogItem-hosting.xml");
Injector injector = Guice.createInjector(new SaxParserModule());
Factory factory = injector.getInstance(ParseSax.Factory.class);
CatalogItem result = factory.create(injector.getInstance(CatalogItemHandler.class)).parse(is);
private Injector injector;
assertEquals(result, new CatalogItemImpl("Windows 2008 Datacenter 64 Bit", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"), "Windows 2008 Datacenter 64 Bit",
new NamedResourceImpl("Windows 2008 Datacenter 64 Bit", "application/vnd.vmware.vcloud.vAppTemplate+xml",
URI.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2")), ImmutableSortedMap.of("Foo",
"Bar", "Hello", "World"
private Factory factory;
)));
public void testVCloud1_0() {
InputStream is = getClass().getResourceAsStream("/catalog-blank.xml");
injector = Guice.createInjector(new SaxParserModule());
factory = injector.getInstance(ParseSax.Factory.class);
Catalog result = (Catalog) factory.create(injector.getInstance(CatalogHandler.class)).parse(is);
assertEquals(result, new CatalogImpl("Jclouds-private", "application/vnd.vmware.vcloud.catalog+xml", URI
.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/921222081"), new NamedResourceImpl(null,
"application/vnd.vmware.vcloud.org+xml", URI
.create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014")), null, ImmutableMap
.<String, NamedResource> of(), ImmutableList.<Task> of(), false));
}
public void testTerremark() {
InputStream is = getClass().getResourceAsStream("/express/catalog.xml");
injector = Guice.createInjector(new SaxParserModule());
factory = injector.getInstance(ParseSax.Factory.class);
Catalog result = (Catalog) factory.create(injector.getInstance(CatalogHandler.class)).parse(is);
assertEquals(result.getName(), "Miami Environment 1");
assert result.getDescription() == null;
assertEquals(result.getId(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"));
assertEquals(result.get("CentOS 5.3 (32-bit)"), new NamedResourceImpl("CentOS 5.3 (32-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/5")));
assertEquals(result.get("CentOS 5.3 (64-bit)"), new NamedResourceImpl("CentOS 5.3 (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/6")));
assertEquals(result.get("RHEL 5.3 (32-bit)"), new NamedResourceImpl("RHEL 5.3 (32-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/7")));
assertEquals(result.get("RHEL 5.3 (64-bit)"), new NamedResourceImpl("RHEL 5.3 (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/8")));
assertEquals(result.get("Ubuntu JeOS 9.04 (32-bit)"), new NamedResourceImpl("Ubuntu JeOS 9.04 (32-bit)",
CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/11")));
assertEquals(result.get("Ubuntu JeOS 9.04 (64-bit)"), new NamedResourceImpl("Ubuntu JeOS 9.04 (64-bit)",
CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/12")));
assertEquals(result.get("Ubuntu Server 9.04 (32-bit)"), new NamedResourceImpl("Ubuntu Server 9.04 (32-bit)",
CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/9")));
assertEquals(result.get("Ubuntu Server 9.04 (64-bit)"), new NamedResourceImpl("Ubuntu Server 9.04 (64-bit)",
CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/10")));
assertEquals(result.get("Windows 2003 Enterprise R2 (32-bit)"), new NamedResourceImpl(
"Windows 2003 Enterprise R2 (32-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/1")));
assertEquals(result.get("Windows 2003 Enterprise R2 (64-bit)"), new NamedResourceImpl(
"Windows 2003 Enterprise R2 (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/2")));
assertEquals(result.get("Windows 2003 Standard R2 (32-bit)"), new NamedResourceImpl(
"Windows 2003 Standard R2 (32-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/3")));
assertEquals(result.get("Windows 2003 Standard R2 (64-bit)"), new NamedResourceImpl(
"Windows 2003 Standard R2 (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/4")));
assertEquals(result.get("Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)"), new NamedResourceImpl(
"Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/23")));
assertEquals(result.get("Windows Server 2008 Enterprise (32-bit)"), new NamedResourceImpl(
"Windows Server 2008 Enterprise (32-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/13")));
assertEquals(result.get("Windows Server 2008 Enterprise (64-bit)"), new NamedResourceImpl(
"Windows Server 2008 Enterprise (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/15")));
assertEquals(result.get("Windows Server 2008 Enterprise R2 (64-bit)"), new NamedResourceImpl(
"Windows Server 2008 Enterprise R2 (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/16")));
assertEquals(result.get("Windows Server 2008 Standard (32-bit)"), new NamedResourceImpl(
"Windows Server 2008 Standard (32-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/17")));
assertEquals(result.get("Windows Server 2008 Standard (64-bit)"), new NamedResourceImpl(
"Windows Server 2008 Standard (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/18")));
assertEquals(result.get("Windows Server 2008 Standard R2 (64-bit)"), new NamedResourceImpl(
"Windows Server 2008 Standard R2 (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/19")));
assertEquals(result.get("Windows Server 2008 Standard w.SQL 2008 Web (64-bit)"), new NamedResourceImpl(
"Windows Server 2008 Standard w.SQL 2008 Web (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/14")));
assertEquals(result.get("Windows Web Server 2008 (32-bit)"), new NamedResourceImpl(
"Windows Web Server 2008 (32-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/20")));
assertEquals(result.get("Windows Web Server 2008 (64-bit)"), new NamedResourceImpl(
"Windows Web Server 2008 (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/21")));
assertEquals(result.get("Windows Web Server 2008 R2 (64-bit)"), new NamedResourceImpl(
"Windows Web Server 2008 R2 (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/22")));
}
}

View File

@ -19,7 +19,6 @@
package org.jclouds.vcloud.xml;
import static org.jclouds.vcloud.VCloudExpressMediaType.CATALOGITEM_XML;
import static org.testng.Assert.assertEquals;
import java.io.InputStream;
@ -28,121 +27,37 @@ import java.net.URI;
import org.jclouds.http.functions.ParseSax;
import org.jclouds.http.functions.ParseSax.Factory;
import org.jclouds.http.functions.config.SaxParserModule;
import org.jclouds.vcloud.domain.Catalog;
import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.domain.internal.CatalogItemImpl;
import org.jclouds.vcloud.domain.internal.NamedResourceImpl;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSortedMap;
import com.google.inject.Guice;
import com.google.inject.Injector;
/**
* Tests behavior of {@code CatalogHandler}
* Tests behavior of {@code CatalogItemHandler}
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "vcloud.CatalogHandlerTest")
@Test(groups = "unit", testName = "vcloud.CatalogItemHandlerTest")
public class CatalogItemHandlerTest {
private Injector injector;
private Factory factory;
public void testApplyInputStream() {
InputStream is = getClass().getResourceAsStream("/catalog.xml");
injector = Guice.createInjector(new SaxParserModule());
factory = injector.getInstance(ParseSax.Factory.class);
Catalog result = (Catalog) factory.create(injector.getInstance(CatalogHandler.class)).parse(is);
assertEquals(result.getName(), "Miami Environment 1");
assert result.getDescription() == null;
InputStream is = getClass().getResourceAsStream("/catalogItem-hosting.xml");
Injector injector = Guice.createInjector(new SaxParserModule());
Factory factory = injector.getInstance(ParseSax.Factory.class);
CatalogItem result = factory.create(injector.getInstance(CatalogItemHandler.class)).parse(is);
assertEquals(result.getId(), URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog"));
assertEquals(result, new CatalogItemImpl("Windows 2008 Datacenter 64 Bit", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"), "Windows 2008 Datacenter 64 Bit",
new NamedResourceImpl("Windows 2008 Datacenter 64 Bit",
"application/vnd.vmware.vcloud.vAppTemplate+xml", URI
.create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2")),
ImmutableSortedMap.of("Foo", "Bar", "Hello", "World"
assertEquals(result.get("CentOS 5.3 (32-bit)"), new NamedResourceImpl("CentOS 5.3 (32-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/5")));
assertEquals(result.get("CentOS 5.3 (64-bit)"), new NamedResourceImpl("CentOS 5.3 (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/6")));
assertEquals(result.get("RHEL 5.3 (32-bit)"), new NamedResourceImpl("RHEL 5.3 (32-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/7")));
assertEquals(result.get("RHEL 5.3 (64-bit)"), new NamedResourceImpl("RHEL 5.3 (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/8")));
assertEquals(result.get("Ubuntu JeOS 9.04 (32-bit)"), new NamedResourceImpl("Ubuntu JeOS 9.04 (32-bit)",
CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/11")));
assertEquals(result.get("Ubuntu JeOS 9.04 (64-bit)"), new NamedResourceImpl("Ubuntu JeOS 9.04 (64-bit)",
CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/12")));
assertEquals(result.get("Ubuntu Server 9.04 (32-bit)"), new NamedResourceImpl("Ubuntu Server 9.04 (32-bit)",
CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/9")));
assertEquals(result.get("Ubuntu Server 9.04 (64-bit)"), new NamedResourceImpl("Ubuntu Server 9.04 (64-bit)",
CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/10")));
assertEquals(result.get("Windows 2003 Enterprise R2 (32-bit)"), new NamedResourceImpl(
"Windows 2003 Enterprise R2 (32-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/1")));
assertEquals(result.get("Windows 2003 Enterprise R2 (64-bit)"), new NamedResourceImpl(
"Windows 2003 Enterprise R2 (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/2")));
assertEquals(result.get("Windows 2003 Standard R2 (32-bit)"), new NamedResourceImpl(
"Windows 2003 Standard R2 (32-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/3")));
assertEquals(result.get("Windows 2003 Standard R2 (64-bit)"), new NamedResourceImpl(
"Windows 2003 Standard R2 (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/4")));
assertEquals(result.get("Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)"), new NamedResourceImpl(
"Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/23")));
assertEquals(result.get("Windows Server 2008 Enterprise (32-bit)"), new NamedResourceImpl(
"Windows Server 2008 Enterprise (32-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/13")));
assertEquals(result.get("Windows Server 2008 Enterprise (64-bit)"), new NamedResourceImpl(
"Windows Server 2008 Enterprise (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/15")));
assertEquals(result.get("Windows Server 2008 Enterprise R2 (64-bit)"), new NamedResourceImpl(
"Windows Server 2008 Enterprise R2 (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/16")));
assertEquals(result.get("Windows Server 2008 Standard (32-bit)"), new NamedResourceImpl(
"Windows Server 2008 Standard (32-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/17")));
assertEquals(result.get("Windows Server 2008 Standard (64-bit)"), new NamedResourceImpl(
"Windows Server 2008 Standard (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/18")));
assertEquals(result.get("Windows Server 2008 Standard R2 (64-bit)"), new NamedResourceImpl(
"Windows Server 2008 Standard R2 (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/19")));
assertEquals(result.get("Windows Server 2008 Standard w.SQL 2008 Web (64-bit)"), new NamedResourceImpl(
"Windows Server 2008 Standard w.SQL 2008 Web (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/14")));
assertEquals(result.get("Windows Web Server 2008 (32-bit)"), new NamedResourceImpl(
"Windows Web Server 2008 (32-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/20")));
assertEquals(result.get("Windows Web Server 2008 (64-bit)"), new NamedResourceImpl(
"Windows Web Server 2008 (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/21")));
assertEquals(result.get("Windows Web Server 2008 R2 (64-bit)"), new NamedResourceImpl(
"Windows Web Server 2008 R2 (64-bit)", CATALOGITEM_XML, URI
.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/22")));
)));
}
public void testHosting() {
InputStream is = getClass().getResourceAsStream("/catalog-hosting.xml");
injector = Guice.createInjector(new SaxParserModule());
factory = injector.getInstance(ParseSax.Factory.class);
Catalog result = (Catalog) factory.create(injector.getInstance(CatalogHandler.class)).parse(is);
assertEquals(result.getName(), "HMSCatalog");
assertEquals(result.getDescription(), "HMS Shared Catalog");
assertEquals(result.getId(), URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"));
assertEquals(result.get("Plesk (Linux) 64-bit Template"), new NamedResourceImpl("Plesk (Linux) 64-bit Template",
CATALOGITEM_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/1")));
assertEquals(result.get("Windows 2008 Datacenter 64 Bit Template"), new NamedResourceImpl(
"Windows 2008 Datacenter 64 Bit Template", CATALOGITEM_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2")));
assertEquals(result.get("Cent OS 64 Bit Template"), new NamedResourceImpl("Cent OS 64 Bit Template",
CATALOGITEM_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/3")));
assertEquals(result.get("cPanel (Linux) 64 Bit Template"), new NamedResourceImpl(
"cPanel (Linux) 64 Bit Template", CATALOGITEM_XML, URI
.create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/4")));
}
}

View File

@ -55,6 +55,7 @@ public class OrgHandlerTest {
Org result = (Org) factory.create(injector.getInstance(OrgHandler.class)).parse(is);
assertEquals(result.getName(), "ExampleOrg");
assertEquals(result.getFullName(), "ExampleOrg");
assertEquals(result.getDescription(), "Example Corp's Primary Organization.");
assertEquals(result.getId(), URI.create("http://vcloud.example.com/api/v1.0/org/5"));
assertEquals(result.getCatalogs(), ImmutableMap.of("Main Catalog", new NamedResourceImpl("Main Catalog",
@ -79,6 +80,7 @@ public class OrgHandlerTest {
Org result = (Org) factory.create(injector.getInstance(OrgHandler.class)).parse(is);
assertEquals(result.getName(), "adrian@jclouds.org");
assertEquals(result.getFullName(), "adrian@jclouds.org");
assertEquals(result.getId(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"));
assertEquals(result.getCatalogs(), ImmutableMap.of("Miami Environment 1 Catalog", new NamedResourceImpl(
"Miami Environment 1 Catalog", CATALOG_XML, URI
@ -96,6 +98,7 @@ public class OrgHandlerTest {
Factory factory = injector.getInstance(ParseSax.Factory.class);
Org result = (Org) factory.create(injector.getInstance(OrgHandler.class)).parse(is);
assertEquals(result.getName(), "Customer 188849");
assertEquals(result.getFullName(), "Customer 188849");
assertEquals(result.getId(), URI.create("https://vcloud.safesecureweb.com/api/v0.8/org/188849"));
assertEquals(result.getCatalogs(), ImmutableMap.of("HMS Shared Catalog", new NamedResourceImpl(
"HMS Shared Catalog", CATALOG_XML, URI.create("https://vcloud.safesecureweb.com/api/v0.8/catalog/1"))));

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Catalog xmlns="http://www.vmware.com/vcloud/v1" name="Jclouds-private" type="application/vnd.vmware.vcloud.catalog+xml" href="https://vcenterprise.bluelock.com/api/v1.0/catalog/921222081" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1 http://vcenterprise.bluelock.com/api/v1.0/schema/master.xsd">
<Link rel="up" type="application/vnd.vmware.vcloud.org+xml" href="https://vcenterprise.bluelock.com/api/v1.0/org/9566014"/>
<Link rel="add" type="application/vnd.vmware.vcloud.catalogItem+xml" href="https://vcenterprise.bluelock.com/api/v1.0/catalog/921222081/catalogItems"/>
<CatalogItems/>
<IsPublished>false</IsPublished>
</Catalog>

View File

@ -25,9 +25,12 @@ import java.util.Map;
import javax.annotation.Nullable;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.domain.Task;
import org.jclouds.vcloud.domain.internal.OrgImpl;
import org.jclouds.vcloud.terremark.domain.TerremarkOrg;
import com.google.common.collect.ImmutableList;
/**
* Locations of resources in a Terremark vCloud
*
@ -41,7 +44,7 @@ public class TerremarkOrgImpl extends OrgImpl implements TerremarkOrg {
public TerremarkOrgImpl(String name, String type, URI id, String description, Map<String, NamedResource> catalogs,
Map<String, NamedResource> vdcs, Map<String, NamedResource> networks, @Nullable NamedResource tasksList,
NamedResource keysList) {
super(name, type, id, description, catalogs, vdcs, networks, tasksList);
super(name, type, id, name, description, catalogs, vdcs, networks, tasksList, ImmutableList.<Task> of());
this.keysList = keysList;
}

View File

@ -22,10 +22,13 @@ package org.jclouds.vcloud.terremark.xml;
import static org.jclouds.vcloud.terremark.TerremarkVCloudExpressMediaType.KEYSLIST_XML;
import static org.jclouds.vcloud.util.Utils.newNamedResource;
import javax.inject.Inject;
import org.jclouds.vcloud.domain.NamedResource;
import org.jclouds.vcloud.terremark.domain.TerremarkOrg;
import org.jclouds.vcloud.terremark.domain.internal.TerremarkOrgImpl;
import org.jclouds.vcloud.xml.OrgHandler;
import org.jclouds.vcloud.xml.TaskHandler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
@ -33,6 +36,10 @@ import org.xml.sax.SAXException;
* @author Adrian Cole
*/
public class TerremarkOrgHandler extends OrgHandler {
@Inject
public TerremarkOrgHandler(TaskHandler taskHandler) {
super(taskHandler);
}
private NamedResource keysList;