You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ad...@apache.org on 2014/11/17 17:21:22 UTC
[15/32] jclouds-labs git commit: JCLOUDS-780 Remove vcloud-director.
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/EntityPredicates.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/EntityPredicates.java b/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/EntityPredicates.java
deleted file mode 100644
index 048ede7..0000000
--- a/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/EntityPredicates.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.net.URI;
-
-import org.jclouds.vcloud.director.v1_5.domain.Entity;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
-/**
- * Predicates for working with {@link EntityType} collections.
- */
-public class EntityPredicates {
-
- /**
- * Matches {@link EntityType entities} with the given id.
- *
- * @param T type of the entity, for example {@link Vm}
- * @param id value of the id attribute of the entity
- * @return predicate that will match entities of the given id
- */
- public static <T extends Entity> Predicate<T> idEquals(final String id) {
- checkNotNull(id, "id must be defined");
-
- return new Predicate<T>() {
- @Override
- public boolean apply(T entity) {
- return id.equals(entity.getId());
- }
-
- @Override
- public String toString() {
- return "idEquals(" + id + ")";
- }
- };
- }
-
- /**
- * Matches {@link EntityType entities} with the given name.
- *
- * @param T type of the entity, for example {@link Vm}
- * @param name value of the name attribute of the entity
- * @return predicate that will match entities of the given name
- */
- public static <T extends Entity> Predicate<T> nameEquals(final String name) {
- checkNotNull(name, "name must be defined");
-
- return new Predicate<T>() {
- @Override
- public boolean apply(T entity) {
- return name.equals(entity.getName());
- }
-
- @Override
- public String toString() {
- return "nameEquals(" + name + ")";
- }
- };
- }
-
- /**
- * Matches {@link EntityType entities} with names starting with the given prefix.
- *
- * @param T type of the entity, for example {@link Vm}
- * @param name prefix of the name attribute of the entity
- * @return predicate that will match entities with names starting with the given prefix
- */
- public static <T extends Entity> Predicate<T> nameStartsWith(final String prefix) {
- checkNotNull(prefix, "prefix must be defined");
-
- return new Predicate<T>() {
- @Override
- public boolean apply(T entity) {
- String name = entity.getName();
- return name != null && name.startsWith(prefix);
- }
-
- @Override
- public String toString() {
- return "nameStartsWith(" + prefix + ")";
- }
- };
- }
-
- /**
- * Matches {@link EntityType entities} with names in the given collection.
- *
- * @param T type of the entity, for example {@link Vm}
- * @param names collection of values for the name attribute of the entity
- * @return predicate that will match entities with names starting with the given prefix
- */
- public static <T extends Entity> Predicate<T> nameIn(final Iterable<String> names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<T>() {
- @Override
- public boolean apply(T entity) {
- String name = entity.getName();
- return Iterables.contains(names, name);
- }
-
- @Override
- public String toString() {
- return "nameIn(" + Iterables.toString(names) + ")";
- }
- };
- }
-
- /**
- * Matches {@link EntityType entities} of the given type.
- *
- * @param T type of the entity, for example {@link Vm}
- * @param type the media type string of the entity, for example {@link VCloudDirectorMediaType#CATALOG}
- * @return predicate that will match entities of the given type
- * @see VCloudDirectorMediaType
- */
- public static <T extends Entity> Predicate<T> typeEquals(final String type) {
- checkNotNull(type, "type must be defined");
-
- return new Predicate<T>() {
- @Override
- public boolean apply(T entity) {
- return type.equals(entity.getType());
- }
-
- @Override
- public String toString() {
- return "typeEquals(" + type + ")";
- }
- };
- }
-
- /**
- * Matches {@link EntityType entities} with the given {@link URI}.
- *
- * @param T type of the entity, for example {@link Vm}
- * @param href the URI of the entity
- * @return predicate that will match entities with the given URI
- * @see VCloudDirectorMediaType
- */
- public static <T extends Entity> Predicate<T> hrefEquals(final URI href) {
- checkNotNull(href, "href must be defined");
-
- return new Predicate<T>() {
- @Override
- public boolean apply(T entity) {
- return href.equals(entity.getHref());
- }
-
- @Override
- public String toString() {
- return "hrefEquals(" + href.toASCIIString() + ")";
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/LinkPredicates.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/LinkPredicates.java b/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/LinkPredicates.java
deleted file mode 100644
index 0eb0024..0000000
--- a/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/LinkPredicates.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.jclouds.vcloud.director.v1_5.VCloudDirectorMediaType;
-import org.jclouds.vcloud.director.v1_5.domain.Link;
-
-import com.google.common.base.Predicate;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
-
-/**
- * Predicates handy when working with Links
- */
-
-public class LinkPredicates {
-
- /**
- * matches links of the given relation
- *
- * @param rel from {@code context.getApi().getCurrentSession().get().getLinks()}
- * @return predicate that will match links of the given rel
- */
- public static Predicate<Link> relEquals(final String rel) {
- checkNotNull(rel, "rel must be defined");
-
- return relEquals(Link.Rel.fromValue(rel));
- }
-
- /** @see #relEquals(String) */
- public static Predicate<Link> relEquals(final Link.Rel rel) {
- return LINK_REL_SELECTORS.apply(checkNotNull(rel, "rel must be defined"));
- }
-
- private static final LoadingCache<Link.Rel, Predicate<Link>> LINK_REL_SELECTORS = CacheBuilder.newBuilder()
- .maximumSize(Link.Rel.ALL.size())
- .build(
- new CacheLoader<Link.Rel, Predicate<Link>>() {
- public Predicate<Link> load(final Link.Rel rel) {
- return new Predicate<Link>() {
- @Override
- public boolean apply(Link link) {
- return rel == link.getRel();
- }
-
- @Override
- public String toString() {
- return "relEquals(" + rel.value() + ")";
- }
- };
- }
- });
-
- /**
- * @see ReferenceTypePredicates#nameEquals
- */
- public static Predicate<Link> nameEquals(String name) {
- return MEDIA_NAME_SELECTORS.apply(name);
- }
-
- private static final LoadingCache<String, Predicate<Link>> MEDIA_NAME_SELECTORS = CacheBuilder.newBuilder()
- .maximumSize(VCloudDirectorMediaType.ALL.size())
- .build(
- new CacheLoader<String, Predicate<Link>>() {
- public Predicate<Link> load(String key) {
- return ReferencePredicates.nameEquals(key);
- }
- });
-
- /**
- * @see ReferenceTypePredicates#typeEquals
- */
- public static Predicate<Link> typeEquals(String type) {
- return MEDIA_TYPE_SELECTORS.apply(type);
- }
-
- private static final LoadingCache<String, Predicate<Link>> MEDIA_TYPE_SELECTORS = CacheBuilder.newBuilder()
- .maximumSize(VCloudDirectorMediaType.ALL.size())
- .build(
- new CacheLoader<String, Predicate<Link>>() {
- public Predicate<Link> load(String key) {
- return ReferencePredicates.typeEquals(key);
- }
- });
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/ReferencePredicates.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/ReferencePredicates.java b/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/ReferencePredicates.java
deleted file mode 100644
index 8f2d243..0000000
--- a/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/ReferencePredicates.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.net.URI;
-
-import org.jclouds.vcloud.director.v1_5.domain.Reference;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
-/**
- * Predicates for working with {@link Reference} collections.
- */
-public class ReferencePredicates {
-
- /**
- * Matches {@link Reference}s with the given name.
- *
- * @param T type of the reference, for example {@link Link}
- * @param name value of the name attribute of the referenced object
- * @return predicate that will match references of the given name
- */
- public static <T extends Reference> Predicate<T> nameEquals(final String name) {
- checkNotNull(name, "name must be defined");
-
- return new Predicate<T>() {
- @Override
- public boolean apply(T reference) {
- return name.equals(reference.getName());
- }
-
- @Override
- public String toString() {
- return "nameEquals(" + name + ")";
- }
- };
- }
-
- /**
- * Matches {@link Reference}s with names starting with the given prefix.
- *
- * @param T type of the reference, for example {@link Link}
- * @param name prefix of the name attribute of the referenced object
- * @return predicate that will match references with names starting with the given prefix
- */
- public static <T extends Reference> Predicate<T> nameStartsWith(final String prefix) {
- checkNotNull(prefix, "prefix must be defined");
-
- return new Predicate<T>() {
- @Override
- public boolean apply(T reference) {
- String name = reference.getName();
- return name != null && name.startsWith(prefix);
- }
-
- @Override
- public String toString() {
- return "nameStartsWith(" + prefix + ")";
- }
- };
- }
-
- /**
- * Matches {@link Reference}s with names in the given collection.
- *
- * @param T type of the reference, for example {@link Link}
- * @param names collection of values for the name attribute of the referenced object
- * @return predicate that will match references with names starting with the given prefix
- */
- public static <T extends Reference> Predicate<T> nameIn(final Iterable<String> names) {
- checkNotNull(names, "names must be defined");
-
- return new Predicate<T>() {
- @Override
- public boolean apply(T reference) {
- String name = reference.getName();
- return Iterables.contains(names, name);
- }
-
- @Override
- public String toString() {
- return "nameIn(" + Iterables.toString(names) + ")";
- }
- };
- }
-
- /**
- * Matches {@link Reference}s of the given type.
- *
- * @param T type of the reference, for example {@link Link}
- * @param type the media type string of the referenced object, for example {@link VCloudDirectorMediaType#CATALOG}
- * @return predicate that will match references of the given type
- * @see VCloudDirectorMediaType
- */
- public static <T extends Reference> Predicate<T> typeEquals(final String type) {
- checkNotNull(type, "type must be defined");
-
- return new Predicate<T>() {
- @Override
- public boolean apply(T reference) {
- return type.equals(reference.getType());
- }
-
- @Override
- public String toString() {
- return "typeEquals(" + type + ")";
- }
- };
- }
-
- /**
- * Matches {@link Reference}s with the given {@link URI}.
- *
- * @param T type of the reference, for example {@link Link}
- * @param href the URI of the reference
- * @return predicate that will match references with the given URI
- * @see VCloudDirectorMediaType
- */
- public static <T extends Reference> Predicate<T> hrefEquals(final URI href) {
- checkNotNull(href, "href must be defined");
-
- return new Predicate<T>() {
- @Override
- public boolean apply(T reference) {
- return href.equals(reference.getHref());
- }
-
- @Override
- public String toString() {
- return "hrefEquals(" + href.toASCIIString() + ")";
- }
- };
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java b/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java
deleted file mode 100644
index 724f7ac..0000000
--- a/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskStatusEquals.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Collection;
-import java.util.Set;
-
-import javax.annotation.Resource;
-
-import org.jclouds.logging.Logger;
-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.Status;
-import org.jclouds.vcloud.director.v1_5.features.TaskApi;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-
-/**
- * Test a {@link Task} status is in a particular set of {@link Task.Status statuses}.
- */
-public class TaskStatusEquals implements Predicate<Task> {
-
- private final TaskApi taskApi;
-
- @Resource
- protected Logger logger = Logger.NULL;
-
- private Collection<Status> expectedStatuses;
- private Collection<Status> failingStatuses;
-
- public TaskStatusEquals(TaskApi taskApi, Status expectedStatus, Set<Status> failingStatuses) {
- this(taskApi, ImmutableSet.of(expectedStatus), failingStatuses);
- }
-
- public TaskStatusEquals(TaskApi taskApi, Set<Status> expectedStatuses, Set<Status> failingStatuses) {
- this.taskApi = taskApi;
- this.expectedStatuses = expectedStatuses;
- this.failingStatuses = failingStatuses;
- }
-
- /** @see Predicate#apply(Object) */
- @Override
- public boolean apply(Task task) {
- checkNotNull(task, "task");
- logger.trace("looking for status on task %s", task);
-
- // TODO shouldn't we see if it's already done before getting it from API server?
- task = taskApi.get(task.getHref());
-
- // perhaps task isn't available, yet
- if (task == null) return false;
- logger.trace("%s: looking for status %s: currently: %s", task, expectedStatuses, task.getStatus());
-
- if (failingStatuses.contains(task.getStatus())) {
- throw new VCloudDirectorException(task);
- }
- if (expectedStatuses.contains(task.getStatus())) {
- return true;
- }
- return false;
- }
-
- @Override
- public String toString() {
- return "taskStatusEquals(" + Iterables.toString(expectedStatuses) + ")";
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskSuccess.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskSuccess.java b/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskSuccess.java
deleted file mode 100644
index 52373ce..0000000
--- a/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/predicates/TaskSuccess.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5.predicates;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.EnumSet;
-
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.logging.Logger;
-import org.jclouds.vcloud.director.v1_5.VCloudDirectorException;
-import org.jclouds.vcloud.director.v1_5.domain.Task;
-import org.jclouds.vcloud.director.v1_5.features.TaskApi;
-
-import com.google.common.base.Predicate;
-
-/**
- * Test a {@link Task} to see if it has {@link Task.Status#SUCCESS succeeded}.
- */
-@Singleton
-public class TaskSuccess implements Predicate<Task> {
-
- private final TaskApi taskApi;
-
- @Resource
- protected Logger logger = Logger.NULL;
-
- @Inject
- public TaskSuccess(TaskApi taskApi) {
- this.taskApi = taskApi;
- }
-
- /** @see Predicate#apply(Object) */
- @Override
- public boolean apply(Task task) {
- checkNotNull(task, "task");
- logger.trace("looking for status on task %s", task.getOperationName());
-
- // TODO shouldn't we see if it's already done before getting it from API server?
- task = taskApi.get(task.getHref());
-
- // perhaps task isn't available, yet
- if (task == null) return false;
-
- logger.trace("%s: looking for status %s: currently: %s", task.getOperationName(), Task.Status.SUCCESS, task.getStatus());
- if (EnumSet.of(Task.Status.ERROR, Task.Status.CANCELED, Task.Status.ABORTED).contains(task.getStatus())) {
- throw new VCloudDirectorException(task);
- } else return task.getStatus().equals(Task.Status.SUCCESS);
- }
-
- @Override
- public String toString() {
- return "checkTaskSuccess()";
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorApi.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorApi.java b/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorApi.java
deleted file mode 100644
index 85bb25f..0000000
--- a/vcloud-director/src/main/java/org/jclouds/vcloud/director/v1_5/user/VCloudDirectorApi.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5.user;
-
-import static org.jclouds.Fallbacks.NullOnNotFoundOr404;
-
-import java.io.Closeable;
-import java.net.URI;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-
-import org.jclouds.rest.annotations.Delegate;
-import org.jclouds.rest.annotations.EndpointParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.JAXBResponseParser;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.vcloud.director.v1_5.domain.Entity;
-import org.jclouds.vcloud.director.v1_5.domain.Session;
-import org.jclouds.vcloud.director.v1_5.features.CatalogApi;
-import org.jclouds.vcloud.director.v1_5.features.MediaApi;
-import org.jclouds.vcloud.director.v1_5.features.MetadataApi;
-import org.jclouds.vcloud.director.v1_5.features.NetworkApi;
-import org.jclouds.vcloud.director.v1_5.features.OrgApi;
-import org.jclouds.vcloud.director.v1_5.features.QueryApi;
-import org.jclouds.vcloud.director.v1_5.features.TaskApi;
-import org.jclouds.vcloud.director.v1_5.features.UploadApi;
-import org.jclouds.vcloud.director.v1_5.features.VAppApi;
-import org.jclouds.vcloud.director.v1_5.features.VAppTemplateApi;
-import org.jclouds.vcloud.director.v1_5.features.VdcApi;
-import org.jclouds.vcloud.director.v1_5.features.VmApi;
-import org.jclouds.vcloud.director.v1_5.filters.AddVCloudAuthorizationAndCookieToRequest;
-
-import com.google.inject.Provides;
-
-@RequestFilters(AddVCloudAuthorizationAndCookieToRequest.class)
-public interface VCloudDirectorApi extends Closeable {
-
- /**
- * Redirects to the URL of an entity with the given VCD ID.
- *
- * <pre>
- * GET /entity/{id}
- * </pre>
- */
- @GET
- @Path("/entity/{id}")
- @Consumes
- @JAXBResponseParser
- @Fallback(NullOnNotFoundOr404.class)
- Entity resolveEntity(@PathParam("id") String id);
-
- /**
- * @return the current login session
- */
- @Provides
- Session getCurrentSession();
-
- /**
- * @return synchronous access to query features
- */
- @Delegate
- QueryApi getQueryApi();
-
- /**
- * @return synchronous access to {@link Org} features
- */
- @Delegate
- OrgApi getOrgApi();
-
- /**
- * @return synchronous access to {@link Task} features
- */
- @Delegate
- TaskApi getTaskApi();
-
- /**
- * @return synchronous access to {@link Network} features
- */
- @Delegate
- NetworkApi getNetworkApi();
-
- /**
- * @return synchronous access to {@link Catalog} features
- */
- @Delegate
- CatalogApi getCatalogApi();
-
- /**
- * @return synchronous access to {@link Media} features
- */
- @Delegate
- MediaApi getMediaApi();
-
- /**
- * @return synchronous access to {@link Vdc} features
- */
- @Delegate
- VdcApi getVdcApi();
-
- /**
- * @return synchronous access to upload features
- */
- @Delegate
- UploadApi getUploadApi();
-
- /**
- * @return synchronous access to {@link VApp} features
- */
- @Delegate
- VAppApi getVAppApi();
-
- /**
- * @return synchronous access to {@link VAppTemplate} features
- */
- @Delegate
- VAppTemplateApi getVAppTemplateApi();
-
- /**
- * @return synchronous access to {@link Vm} features
- */
- @Delegate
- VmApi getVmApi();
-
- @Delegate
- MetadataApi getMetadataApi(@EndpointParam URI href);
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
----------------------------------------------------------------------
diff --git a/vcloud-director/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata b/vcloud-director/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
deleted file mode 100644
index 262e987..0000000
--- a/vcloud-director/src/main/resources/META-INF/services/org.jclouds.apis.ApiMetadata
+++ /dev/null
@@ -1 +0,0 @@
-org.jclouds.vcloud.director.v1_5.VCloudDirectorApiMetadata
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/test/java/org/jclouds/vcloud/director/testng/FormatApiResultsListener.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/test/java/org/jclouds/vcloud/director/testng/FormatApiResultsListener.java b/vcloud-director/src/test/java/org/jclouds/vcloud/director/testng/FormatApiResultsListener.java
deleted file mode 100644
index 0aee156..0000000
--- a/vcloud-director/src/test/java/org/jclouds/vcloud/director/testng/FormatApiResultsListener.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.testng;
-
-import java.text.SimpleDateFormat;
-import java.util.Arrays;
-import java.util.Set;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.ITestResult;
-import org.testng.TestListenerAdapter;
-
-import com.google.common.base.Joiner;
-import com.google.common.base.Optional;
-import com.google.common.base.Predicates;
-import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-
-/**
- * Outputs test status to the {@code jclouds.vcloud.api} logger.
- *
- * Adapted from {@link org.jclouds.test.testng.UnitTestTestNGListener}.
- */
-public class FormatApiResultsListener extends TestListenerAdapter {
-
- public static final Logger logger = LoggerFactory.getLogger("jclouds.vcloud.api");
-
- private static final SimpleDateFormat timestamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- private static final Set<String> apis = ImmutableSet.of("admin", "user");
-
- @Override
- public synchronized void onTestSuccess(ITestResult res) {
- if (methodInApiGroup(res)) {
- String statusLine = resultForState(res, "succeeded");
- logger.info(statusLine);
- }
- }
-
- @Override
- public synchronized void onTestFailure(ITestResult res) {
- if (methodInApiGroup(res)) {
- String statusLine = resultForState(res, "failed");
- logger.info(statusLine);
- }
- }
-
- @Override
- public synchronized void onTestSkipped(ITestResult res) {
- if (methodInApiGroup(res)) {
- String statusLine = resultForState(res, "skipped");
- logger.info(statusLine);
- }
- }
-
- private boolean methodInApiGroup(ITestResult res) {
- return Iterables.any(Arrays.asList(res.getMethod().getGroups()), Predicates.in(apis));
- }
-
- private String resultForState(ITestResult res, String state) {
- return Joiner.on(',').join(getApi(res), getOperation(res), getStart(res), getTest(res), getDuration(res), state);
- }
-
- private String getApi(ITestResult res) {
- Optional<String> found = Iterables.tryFind(Arrays.asList(res.getMethod().getGroups()), Predicates.in(apis));
- return found.isPresent() ? found.get() : "";
- }
-
- private String getOperation(ITestResult res) {
- return Strings.nullToEmpty(res.getMethod().getDescription());
- }
-
- private String getTest(ITestResult res) {
- return Strings.nullToEmpty(res.getName());
- }
-
- private String getStart(ITestResult res) {
- return timestamp.format(res.getStartMillis());
- }
-
- private String getDuration(ITestResult res) {
- return Long.toString(res.getEndMillis() - res.getStartMillis());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppApiLiveTest.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppApiLiveTest.java b/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppApiLiveTest.java
deleted file mode 100644
index 9ecd55a..0000000
--- a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/AbstractVAppApiLiveTest.java
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5;
-
-import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.ENTITY_NON_NULL;
-import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.OBJ_FIELD_EQ;
-import static org.jclouds.vcloud.director.v1_5.VCloudDirectorLiveTestConstants.TASK_COMPLETE_TIMELY;
-import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkGuestCustomizationSection;
-import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkNetworkConnectionSection;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.io.IOException;
-import java.math.BigInteger;
-import java.net.URI;
-import java.util.List;
-import java.util.Set;
-
-import org.jclouds.dmtf.cim.CimBoolean;
-import org.jclouds.dmtf.cim.CimString;
-import org.jclouds.dmtf.cim.CimUnsignedInt;
-import org.jclouds.dmtf.cim.CimUnsignedLong;
-import org.jclouds.vcloud.director.v1_5.domain.AbstractVApp;
-import org.jclouds.vcloud.director.v1_5.domain.RasdItemsList;
-import org.jclouds.vcloud.director.v1_5.domain.Reference;
-import org.jclouds.vcloud.director.v1_5.domain.ResourceEntity.Status;
-import org.jclouds.vcloud.director.v1_5.domain.Task;
-import org.jclouds.vcloud.director.v1_5.domain.VApp;
-import org.jclouds.vcloud.director.v1_5.domain.VAppTemplate;
-import org.jclouds.vcloud.director.v1_5.domain.Vdc;
-import org.jclouds.vcloud.director.v1_5.domain.Vm;
-import org.jclouds.vcloud.director.v1_5.domain.dmtf.RasdItem;
-import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConnection;
-import org.jclouds.vcloud.director.v1_5.domain.network.NetworkConnection.IpAddressAllocationMode;
-import org.jclouds.vcloud.director.v1_5.domain.network.VAppNetworkConfiguration;
-import org.jclouds.vcloud.director.v1_5.domain.params.UndeployVAppParams;
-import org.jclouds.vcloud.director.v1_5.domain.section.GuestCustomizationSection;
-import org.jclouds.vcloud.director.v1_5.domain.section.NetworkConnectionSection;
-import org.jclouds.vcloud.director.v1_5.features.CatalogApi;
-import org.jclouds.vcloud.director.v1_5.features.MetadataApi;
-import org.jclouds.vcloud.director.v1_5.features.QueryApi;
-import org.jclouds.vcloud.director.v1_5.features.VAppApi;
-import org.jclouds.vcloud.director.v1_5.features.VAppTemplateApi;
-import org.jclouds.vcloud.director.v1_5.features.VdcApi;
-import org.jclouds.vcloud.director.v1_5.features.VmApi;
-import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorApiLiveTest;
-import org.jclouds.vcloud.director.v1_5.predicates.ReferencePredicates;
-import org.jclouds.xml.internal.JAXBParser;
-import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-
-import com.google.common.base.Function;
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.base.Strings;
-import com.google.common.base.Throwables;
-import com.google.common.collect.Iterables;
-
-/**
- * Shared code to test the behaviour of {@link VAppApi} and {@link VAppTemplateApi}.
- */
-public abstract class AbstractVAppApiLiveTest extends BaseVCloudDirectorApiLiveTest {
-
- public static final String VAPP = "VApp";
- public static final String VAPP_TEMPLATE = "VAppTemplate";
- public static final String VDC = "Vdc";
- public static final String VM = "Vm";
-
- /*
- * Convenience reference to API apis.
- */
-
- protected CatalogApi catalogApi;
- protected QueryApi queryApi;
- protected VAppApi vAppApi;
- protected VAppTemplateApi vAppTemplateApi;
- protected VdcApi vdcApi;
- protected VmApi vmApi;
- protected MetadataApi metadataApi;
-
- /*
- * Objects shared between tests.
- */
-
- protected Vdc vdc;
- protected Vm vm;
- protected VApp vApp;
- protected VAppTemplate vAppTemplate;
- protected String vmId;
- protected String vAppId;
-
- /**
- * Retrieves the required apis from the REST API context
- *
- * @see BaseVCloudDirectorApiLiveTest#setupRequiredApis()
- */
- @Override
- protected void setupRequiredApis() {
- assertNotNull(context.getApi());
-
- catalogApi = context.getApi().getCatalogApi();
- queryApi = context.getApi().getQueryApi();
- vAppApi = context.getApi().getVAppApi();
- vAppTemplateApi = context.getApi().getVAppTemplateApi();
- vdcApi = context.getApi().getVdcApi();
- vmApi = context.getApi().getVmApi();
- }
-
- /**
- * Sets up the environment. Retrieves the test {@link Vdc} and {@link VAppTemplate} from their
- * configured {@link URI}s. Instantiates a new test VApp.
- */
- @BeforeClass(alwaysRun = true, description = "Retrieves the required apis from the REST API context")
- protected void setupEnvironment() {
- // Get the configured Vdc for the tests
- vdc = lazyGetVdc();
-
- // Get the configured VAppTemplate for the tests
- vAppTemplate = vAppTemplateApi.get(context.resolveIdToHref(vAppTemplateId));
- assertNotNull(vAppTemplate, String.format(ENTITY_NON_NULL, VAPP_TEMPLATE));
-
- // Instantiate a new VApp
- VApp vAppInstantiated = instantiateVApp();
- assertNotNull(vAppInstantiated, String.format(ENTITY_NON_NULL, VAPP));
- vAppId = vAppInstantiated.getId();
-
- // Wait for the task to complete
- Task instantiateTask = Iterables.getOnlyElement(vAppInstantiated.getTasks());
- assertTrue(retryTaskSuccessLong.apply(instantiateTask), String.format(TASK_COMPLETE_TIMELY, "instantiateTask"));
-
- // Get the instantiated VApp
- vApp = vAppApi.get(vApp.getHref());
-
- // Get the Vm
- List<Vm> vms = vApp.getChildren().getVms();
- vm = Iterables.getOnlyElement(vms);
- vmId = vm.getId();
- assertFalse(vms.isEmpty(), "The VApp must have a Vm");
- }
-
- protected void getGuestCustomizationSection(final Function<URI, GuestCustomizationSection> getGuestCustomizationSection) {
- // Get URI for child VM
- URI vmHref = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
-
- // The method under test
- try {
- GuestCustomizationSection section = getGuestCustomizationSection.apply(vmHref);
-
- // Check the retrieved object is well formed
- checkGuestCustomizationSection(section);
- } catch (Exception e) {
- Throwables.propagate(e);
- }
- }
-
- protected void getNetworkConnectionSection(final Function<URI, NetworkConnectionSection> getNetworkConnectionSection) {
- // Get URI for child VM
- URI vmHref = Iterables.getOnlyElement(vApp.getChildren().getVms()).getHref();
-
- // The method under test
- try {
- NetworkConnectionSection section = getNetworkConnectionSection.apply(vmHref);
-
- // Check the retrieved object is well formed
- checkNetworkConnectionSection(section);
- } catch (Exception e) {
- Throwables.propagate(e);
- }
- }
-
- @AfterClass(alwaysRun = true, description = "Cleans up the environment by deleting addd VApps")
- protected void cleanUpEnvironment() {
- vdc = vdcApi.get(context.resolveIdToHref(vdcId)); // Refresh
-
- // Find references in the Vdc with the VApp type and in the list of instantiated VApp names
- Iterable<Reference> vApps = Iterables.filter(vdc.getResourceEntities(),
- Predicates.and(ReferencePredicates.<Reference> typeEquals(VCloudDirectorMediaType.VAPP), ReferencePredicates.<Reference> nameIn(vAppNames)));
-
- // If we found any references, remove the VApp they point to
- if (!Iterables.isEmpty(vApps)) {
- for (Reference ref : vApps) {
- cleanUpVApp(context.getApi().getVAppApi().get(ref.getHref())); // NOTE may fail, but should continue deleting
- }
- } else {
- logger.warn("No VApps in list found in Vdc %s (%s)", vdc.getName(), Iterables.toString(vAppNames));
- }
- }
-
- protected static CimBoolean cimBoolean(boolean val) {
- CimBoolean result = new CimBoolean();
- result.setValue(val);
- return result;
- }
-
- protected static CimUnsignedInt cimUnsignedInt(long val) {
- CimUnsignedInt result = new CimUnsignedInt();
- result.setValue(val);
- return result;
- }
-
- protected static CimUnsignedLong cimUnsignedLong(BigInteger val) {
- CimUnsignedLong result = new CimUnsignedLong();
- result.setValue(val);
- return result;
- }
-
- protected static CimString cimString(String value) {
- return new CimString(value);
- }
-
- protected void checkHasMatchingItem(final String context, final RasdItemsList items, final String instanceId, final String elementName) {
- Optional<RasdItem> found = Iterables.tryFind(items.getItems(), new Predicate<RasdItem>() {
- @Override
- public boolean apply(RasdItem item) {
- String itemInstanceId = item.getInstanceID();
- if (itemInstanceId.equals(instanceId)) {
- Assert.assertEquals(item.getElementName(), elementName,
- String.format(OBJ_FIELD_EQ, VAPP, context + "/" + instanceId + "/elementName", elementName, item.getElementName()));
- return true;
- }
- return false;
- }
- });
- assertTrue(found.isPresent(), "no " + context + " item found with id " + instanceId + "; only found " + items);
- }
-
- /**
- * Power on a {@link VApp}.
- */
- protected VApp powerOnVApp(URI vAppHref) {
- VApp test = vAppApi.get(vAppHref);
- Status status = test.getStatus();
- if (status != Status.POWERED_ON) {
- Task powerOn = vAppApi.powerOn(vAppHref);
- assertTaskSucceedsLong(powerOn);
- }
- test = vAppApi.get(vAppHref);
- assertStatus(VAPP, test, Status.POWERED_ON);
- return test;
- }
-
- /**
- * Power on a {@link Vm}.
- */
- protected Vm powerOnVm(URI vmHref) {
- Vm test = vmApi.get(vmHref);
- Status status = test.getStatus();
- if (status != Status.POWERED_ON) {
- Task powerOn = vmApi.powerOn(vmHref);
- assertTaskSucceedsLong(powerOn);
- }
- test = vmApi.get(vmHref);
- assertStatus(VM, test, Status.POWERED_ON);
- return test;
- }
-
- /**
- * Power off a {@link VApp}.
- */
- protected VApp powerOffVApp(URI vAppHref) {
- VApp test = vAppApi.get(vAppHref);
- Status status = test.getStatus();
- if (status != Status.POWERED_OFF) {
- Task powerOff = vAppApi.powerOff(vAppHref);
- assertTaskSucceedsLong(powerOff);
- }
- test = vAppApi.get(vAppHref);
- assertStatus(VAPP, test, Status.POWERED_OFF);
- return test;
- }
-
- /**
- * Power off a {@link Vm}.
- */
- protected Vm powerOffVm(URI vmHref) {
- Vm test = vmApi.get(vmHref);
- Status status = test.getStatus();
- if (status != Status.POWERED_OFF || test.isDeployed()) {
- UndeployVAppParams undeployParams = UndeployVAppParams.builder().build();
- Task shutdownVapp = vmApi.undeploy(vmHref, undeployParams);
- assertTaskSucceedsLong(shutdownVapp);
- }
- test = vmApi.get(vmHref);
- assertStatus(VM, test, Status.POWERED_OFF);
- return test;
- }
-
- /**
- * Suspend a {@link VApp}.
- */
- protected VApp suspendVApp(URI vAppHref) {
- VApp test = vAppApi.get(vAppHref);
- Status status = test.getStatus();
- if (status != Status.SUSPENDED) {
- Task suspend = vAppApi.suspend(vAppHref);
- assertTaskSucceedsLong(suspend);
- }
- test = vAppApi.get(vAppHref);
- assertStatus(VAPP, test, Status.SUSPENDED);
- return test;
- }
-
- /**
- * Suspend a {@link Vm}.
- */
- protected Vm suspendVm(URI vmHref) {
- Vm test = vmApi.get(vmHref);
- Status status = test.getStatus();
- if (status != Status.SUSPENDED) {
- Task suspend = vmApi.suspend(vmHref);
- assertTaskSucceedsLong(suspend);
- }
- test = vmApi.get(vmHref);
- assertStatus(VM, test, Status.SUSPENDED);
- return test;
- }
-
- /**
- * Check the {@link VApp}s current status.
- */
- protected void assertVAppStatus(URI vAppHref, final Status status) {
- VApp testVApp = vAppApi.get(vAppHref);
- assertStatus(VAPP, testVApp, status);
- }
-
- /**
- * Check the {@link Vm}s current status.
- */
- protected void assertVmStatus(URI vmHref, final Status status) {
- Vm testVm = vmApi.get(vmHref);
- assertStatus(VM, testVm, status);
- }
-
- /**
- * Check a {@link VApp} or {@link Vm}s status.
- */
- protected static void assertStatus(final String type, final AbstractVApp testVApp, final Status status) {
- assertEquals(testVApp.getStatus(), status, String.format(OBJ_FIELD_EQ, type, "status", status.toString(), testVApp.getStatus().toString()));
- }
-
- protected void debug(final Object object) {
- JAXBParser parser = new JAXBParser("true");
- try {
- String xml = parser.toXML(object);
- logger.debug(Strings.padStart(Strings.padEnd(" " + object.getClass().toString() + " ", 70, '-'), 80, '-'));
- logger.debug(xml);
- logger.debug(Strings.repeat("-", 80));
- } catch (IOException ioe) {
- Throwables.propagate(ioe);
- }
- }
-
- protected VAppNetworkConfiguration getVAppNetworkConfig(VApp vApp) {
- Set<VAppNetworkConfiguration> vAppNetworkConfigs = vAppApi.getNetworkConfigSection(vApp.getHref()).getNetworkConfigs();
- return Iterables.tryFind(vAppNetworkConfigs, Predicates.notNull()).orNull();
- }
-
- protected boolean vAppHasNetworkConfigured(VApp vApp) {
- return getVAppNetworkConfig(vApp) != null;
- }
-
- protected boolean vmHasNetworkConnectionConfigured(Vm vm) {
- return listNetworkConnections(vm).size() > 0;
- }
-
- protected Set<NetworkConnection> listNetworkConnections(Vm vm) {
- return vmApi.getNetworkConnectionSection(vm.getHref()).getNetworkConnections();
- }
-
- protected Set<VAppNetworkConfiguration> listVappNetworkConfigurations(VApp vApp) {
- Set<VAppNetworkConfiguration> vAppNetworkConfigs = vAppApi.getNetworkConfigSection(vApp.getHref()).getNetworkConfigs();
- return vAppNetworkConfigs;
- }
-
- protected void attachVmToVAppNetwork(Vm vm, String vAppNetworkName) {
- Set<NetworkConnection> networkConnections = vmApi.getNetworkConnectionSection(vm.getHref())
- .getNetworkConnections();
-
- NetworkConnectionSection section = NetworkConnectionSection.builder()
- .info("info")
- .primaryNetworkConnectionIndex(0)
- .build();
-
- for (NetworkConnection networkConnection : networkConnections) {
- NetworkConnection newNetworkConnection = networkConnection.toBuilder()
- .network(vAppNetworkName)
- .isConnected(true)
- .networkConnectionIndex(0)
- .ipAddressAllocationMode(IpAddressAllocationMode.POOL)
- .build();
-
- section = section.toBuilder().networkConnection(newNetworkConnection).build();
- }
- Task configureNetwork = vmApi.editNetworkConnectionSection(vm.getHref(), section);
- assertTaskSucceedsLong(configureNetwork);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiExpectTest.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiExpectTest.java b/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiExpectTest.java
deleted file mode 100644
index c058ba6..0000000
--- a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiExpectTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.vcloud.director.v1_5.internal.VCloudDirectorAdminApiExpectTest;
-import org.jclouds.vcloud.director.v1_5.login.SessionApiExpectTest;
-import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorApi;
-import org.testng.annotations.Test;
-
-@Test(groups = "unit", testName = "VCloudDirectorApi")
-public class VCloudDirectorApiExpectTest extends VCloudDirectorAdminApiExpectTest {
-
- //TODO: this inheritance is all wrong!! the base client shouldn't inherit from the admin client tests!!
-
- public void testRestClientModuleWorksProperly() throws Exception {
-
- VCloudDirectorApi apiWhenSessionsExist = requestSendsResponse(loginRequest, sessionResponse);
-
- assertEquals(apiWhenSessionsExist.getCurrentSession(), SessionApiExpectTest.SESSION);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiExperimentLiveTest.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiExperimentLiveTest.java b/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiExperimentLiveTest.java
deleted file mode 100644
index e98ab80..0000000
--- a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiExperimentLiveTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.vcloud.director.v1_5.domain.Session;
-import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorApiLiveTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-@Test(groups = "live", testName = "VCloudDirectorApiExperimentLiveTest")
-public class VCloudDirectorApiExperimentLiveTest extends BaseVCloudDirectorApiLiveTest {
-
- public void testImplicitSession() {
- Session session = context.getApi().getCurrentSession();
- assertEquals(session.getHref().toASCIIString(), context.getProviderMetadata().getEndpoint() + "/session/");
- }
-
- /**
- * No operation.
- *
- * @see BaseVCloudDirectorApiLiveTest#setupRequiredApis()
- */
- @Override
- @BeforeClass(alwaysRun = true)
- public void setupRequiredApis() { }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiLiveTest.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiLiveTest.java b/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiLiveTest.java
deleted file mode 100644
index 253ff26..0000000
--- a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiLiveTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5;
-
-import static org.jclouds.vcloud.director.v1_5.domain.Checks.checkEntityType;
-
-import org.jclouds.vcloud.director.v1_5.domain.Entity;
-import org.jclouds.vcloud.director.v1_5.domain.Reference;
-import org.jclouds.vcloud.director.v1_5.domain.org.Org;
-import org.jclouds.vcloud.director.v1_5.internal.BaseVCloudDirectorApiLiveTest;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-/**
- * Tests live behavior of {@link VCloudDirectorApi}.
- */
-@Test(groups = { "live", "user" }, singleThreaded = true, testName = "VCloudDirectorApiLiveTest")
-public class VCloudDirectorApiLiveTest extends BaseVCloudDirectorApiLiveTest {
-
- @Test(description = "GET /entity/{id}")
- public void testResolveEntity() {
- for (Reference orgRef : context.getApi().getOrgApi().list()) {
- Org org = context.getApi().getOrgApi().get(orgRef.getHref());
- Entity entity = context.getApi().resolveEntity(org.getId());
- checkEntityType(entity);
- }
- }
-
- @Override
- @BeforeClass(alwaysRun = true)
- public void setupRequiredApis() {
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java b/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java
deleted file mode 100644
index 201b1db..0000000
--- a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorApiMetadataTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5;
-
-import org.jclouds.View;
-import org.jclouds.apis.internal.BaseApiMetadataTest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.reflect.TypeToken;
-
-@Test(groups = "unit", testName = "VCloudDirectorApiMetadataTest")
-//TODO: BaseComputeServiceApiMetadataTest
-public class VCloudDirectorApiMetadataTest extends BaseApiMetadataTest {
-
- public VCloudDirectorApiMetadataTest() {
- super(new VCloudDirectorApiMetadata(), ImmutableSet.<TypeToken<? extends View>>of());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java b/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java
deleted file mode 100644
index f713d8b..0000000
--- a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/VCloudDirectorLiveTestConstants.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5;
-
-public final class VCloudDirectorLiveTestConstants {
-
- /* regular expressions for pattern matching */
-
- public static final String MAC_ADDRESS_PATTERN = "^([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})$";
-
- /* Error code 200 indicates success. */
-
- public static final String OK = "ERR-200: ok";
-
- /* Error codes from 100 to 199 reflect parsing and other errors in domain object fields and attributes. */
-
- public static final String URN_REQ_LIVE = "ERR-101: %s urn required to perform live tests";
-
- public static final String OBJ_REQ_LIVE = "ERR-102: %s instance required to perform live tests";
-
- public static final String OBJ_FIELD_REQ_LIVE = "ERR-103: %s must have a non-null \"%s\" to perform live tests";
-
- public static final String OBJ_FIELD_REQ = "ERR-103: %s must always have a non-null field \"%s\"";
-
- public static final String OBJ_FIELD_ATTRB_REQ = "ERR-105: %s %s (%s) must always have a non-null field \"%s\"";
-
- public static final String OBJ_FIELD_EQ = "ERR-106: %s %s must have the value \"%s\" (%s)";
-
- public static final String OBJ_FIELD_CONTAINS = "ERR-107: %s %s must contain the values \"%s\" (%s)";
-
- public static final String OBJ_FIELD_GTE_0 = "ERR-108: %s field %s must be greater than to equal to 0 (%d)";
-
- public static final String OBJ_FIELD_GTE_1 = "ERR-108: %s field %s must be greater than to equal to 0 (%d)";
-
- public static final String OBJ_FIELD_GTE = "ERR-108: %s field %s must be greater than to equal to %d (%d)";
-
- public static final String GETTER_RETURNS_SAME_OBJ = "ERR-109: %s should return the same %s as %s (%s, %s)";
-
- public static final String OBJ_FIELD_UPDATABLE = "ERR-110: %s field %s should be updatable";
-
- public static final String OBJ_FIELD_ATTRB_DEL = "ERR-111: %s %s (%s) should have deleted field \"%s\" (%s)";
-
- public static final String OBJ_DEL = "ERR-112: %s (%s) should have been deleted";
-
- public static final String TASK_COMPLETE_TIMELY = "ERR-113: Task %s should complete in a timely fashion";
-
- public static final String NOT_NULL_OBJ_FIELD_FMT = "ERR-114: The %s field of the %s must not be null";
-
- public static final String NOT_EMPTY_OBJECT_FMT = "ERR-115: One or more %s fields of the %s must be present";
-
- public static final String REQUIRED_VALUE_OBJECT_FMT = "ERR-116: The %s field of the %s must not be '%s'; allowed values: %s";
-
- public static final String REQUIRED_VALUE_FMT = "ERR-117: The %s field must not be '%s'; allowed values: %s";
-
- public static final String MUST_BE_WELL_FORMED_FMT = "ERR-118: The %s field must be well formed: '%s'";
-
- public static final String MUST_EXIST_FMT = "ERR-119: The '%s' %s must exist";
-
- public static final String MUST_CONTAIN_FMT = "ERR-120: The %s field must contain '%s': '%s'";
-
- public static final String CONDITION_FMT = "ERR-121: The %s field must be %s: '%s'";
-
- public static final String CORRECT_VALUE_OBJECT_FMT = "ERR-122: The %s field of the %s must be '%s': '%s'";
-
- public static final String OBJ_FIELD_CLONE = "ERR-123: %s %s must be a clone of \"%s\" (%s)";
-
- public static final String OBJ_FIELD_EMPTY_TO_DELETE = "ERR-124: %s must have no %s to be deleted (%s)";
-
- public static final String NOT_NULL_OBJ_FMT = "ERR-125: The %s object must not be null";
-
- public static final String NOT_EMPTY_STRING_FMT = "ERR-126: The %s field must not be an empty string";
-
- public static final String MATCHES_STRING_FMT = "ERR-127: The %s field must match the pattern \"%s\" (%s)";
-
- public static final String OBJ_FIELD_LIST_EMPTY = "ERR-128: %s %s must be empty (%d members)";
-
- public static final String OBJ_FIELD_LIST_SIZE_EQ = "ERR-129: %s %s must have %d members (%d members)";
-
- public static final String OBJ_FIELD_LIST_SIZE_GE = "ERR-130: %s %s must have at least %d members (%d members)";
-
- /* Error codes from 300 to 399 reflect entities and their links and relationship errors. */
-
- public static final String ENTITY_NON_NULL = "ERR-301: The %s entity must not be null";
-
- public static final String ENTITY_EQUAL = "ERR-302: The two %s entities must be equal";
-
- public static final String ENTITY_CONDITION = "ERR-303: The %s entity must %s (%s)";
-
- private VCloudDirectorLiveTestConstants() {
- throw new AssertionError("intentionally unimplemented");
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/binders/BindMapAsMetadataTest.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/binders/BindMapAsMetadataTest.java b/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/binders/BindMapAsMetadataTest.java
deleted file mode 100644
index 1bb41c8..0000000
--- a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/binders/BindMapAsMetadataTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5.binders;
-
-import static org.testng.Assert.assertEquals;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.xml.XMLParser;
-import org.jclouds.xml.internal.JAXBParser;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Tests behavior of {@code BindMapAsMetadata}.
- */
-@Test(groups = "unit", testName = "BindMapAsMetadataTest")
-public class BindMapAsMetadataTest {
- XMLParser xml = new JAXBParser("true");
-
- @Test
- public void testBindMap() {
- BindMapAsMetadata binder = new BindMapAsMetadata(xml);
-
- HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
- request = binder.bindToRequest(request, ImmutableMap.of("foo", "bar"));
- assertEquals(request.getPayload().getRawContent(),
- XMLParser.DEFAULT_XML_HEADER + "\n" +
- "<Metadata xmlns=\"http://www.vmware.com/vcloud/v1.5\">" + "\n" +
- " <MetadataEntry>" + "\n" +
- " <Key>foo</Key>" + "\n" +
- " <Value>bar</Value>" + "\n" +
- " </MetadataEntry>" + "\n" +
- "</Metadata>" + "\n");
- assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.APPLICATION_XML);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/775b89fd/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/binders/BindStringAsMetadataValueTest.java
----------------------------------------------------------------------
diff --git a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/binders/BindStringAsMetadataValueTest.java b/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/binders/BindStringAsMetadataValueTest.java
deleted file mode 100644
index 4f28366..0000000
--- a/vcloud-director/src/test/java/org/jclouds/vcloud/director/v1_5/binders/BindStringAsMetadataValueTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.vcloud.director.v1_5.binders;
-
-import static org.testng.Assert.assertEquals;
-
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.xml.XMLParser;
-import org.jclouds.xml.internal.JAXBParser;
-import org.testng.annotations.Test;
-
-/**
- * Tests behavior of {@code BindStringAsMetadataValue}.
- */
-@Test(groups = "unit", testName = "BindStringAsMetadataValueTest")
-public class BindStringAsMetadataValueTest {
- XMLParser xml = new JAXBParser("true");
-
- @Test
- public void testBindMap() {
- BindStringAsMetadataValue binder = new BindStringAsMetadataValue(xml);
-
- HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
- request = binder.bindToRequest(request, "foo");
- assertEquals(request.getPayload().getRawContent(),
- XMLParser.DEFAULT_XML_HEADER + "\n" +
- "<MetadataValue xmlns=\"http://www.vmware.com/vcloud/v1.5\">" + "\n" +
- " <Value>foo</Value>" + "\n" +
- "</MetadataValue>" + "\n");
- assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.APPLICATION_XML);
- }
-
-}