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:19:24 UTC
[08/19] jclouds git commit: JCLOUDS-780 Remove vcloud.
http://git-wip-us.apache.org/repos/asf/jclouds/blob/6f974f34/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppApiTest.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppApiTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppApiTest.java
deleted file mode 100644
index 73ca9a1..0000000
--- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppApiTest.java
+++ /dev/null
@@ -1,313 +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.features;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-import java.net.URI;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.Fallbacks.VoidOnNotFoundOr404;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.http.functions.ReleasePayloadAndReturn;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.jclouds.util.Strings2;
-import org.jclouds.vcloud.internal.BaseVCloudApiTest;
-import org.jclouds.vcloud.options.CloneVAppOptions;
-import org.jclouds.vcloud.xml.TaskHandler;
-import org.jclouds.vcloud.xml.VAppHandler;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code VAppApi}
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during
-// surefire
-@Test(groups = "unit", testName = "VAppApiTest")
-public class VAppApiTest extends BaseVCloudApiTest<VAppApi> {
-
- public void testopyVAppToVDCAndName() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppApi.class, "copyVAppToVDCAndName", URI.class, URI.class, String.class,
- CloneVAppOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "my-vapp"));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVApp-default.xml")),
- "application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testCopyVAppToVDCAndNameOptions() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppApi.class, "copyVAppToVDCAndName", URI.class, URI.class, String.class,
- CloneVAppOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", new CloneVAppOptions()
- .deploy().powerOn().description("The description of the new vApp")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVApp.xml")),
- "application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testMoveVAppToVDCAndRenameOptions() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppApi.class, "moveVAppToVDCAndRename", URI.class, URI.class, String.class,
- CloneVAppOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server", new CloneVAppOptions()
- .deploy().powerOn().description("The description of the new vApp")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVApp HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/moveVApp.xml")),
- "application/vnd.vmware.vcloud.cloneVAppParams+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testDeployVApp() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppApi.class, "deployVApp", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, "<DeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\"/>",
- "application/vnd.vmware.vcloud.deployVAppParams+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testDeployAndPowerOnVApp() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppApi.class, "deployAndPowerOnVApp", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, "<DeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\" powerOn=\"true\"/>",
- "application/vnd.vmware.vcloud.deployVAppParams+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testGetVApp() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppApi.class, "getVApp", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, VAppHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testRebootVApp() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppApi.class, "rebootVApp", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reboot HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testUndeployVApp() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppApi.class, "undeployVApp", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, "<UndeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\"/>",
- "application/vnd.vmware.vcloud.undeployVAppParams+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testUndeployAndSaveStateOfVAppSaveState() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppApi.class, "undeployAndSaveStateOfVApp", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request,
- "<UndeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\" saveState=\"true\"/>",
- "application/vnd.vmware.vcloud.undeployVAppParams+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testDeleteVApp() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppApi.class, "deleteVApp", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request, "DELETE https://vcenterprise.bluelock.com/api/v1.0/vApp/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, VoidOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testPowerOnVApp() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppApi.class, "powerOnVApp", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOn HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testPowerOffVApp() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppApi.class, "powerOffVApp", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOff HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testResetVApp() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppApi.class, "resetVApp", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reset HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testSuspendVApp() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppApi.class, "suspendVApp", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/suspend HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testShutdownVApp() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppApi.class, "shutdownVApp", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/shutdown HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/6f974f34/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiLiveTest.java
deleted file mode 100644
index e883235..0000000
--- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiLiveTest.java
+++ /dev/null
@@ -1,164 +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.features;
-
-import static com.google.common.collect.Iterables.getOnlyElement;
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.jclouds.util.Predicates2.retry;
-import static org.testng.Assert.assertEquals;
-
-import java.net.URI;
-
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.vcloud.VCloudMediaType;
-import org.jclouds.vcloud.domain.Catalog;
-import org.jclouds.vcloud.domain.CatalogItem;
-import org.jclouds.vcloud.domain.Org;
-import org.jclouds.vcloud.domain.ReferenceType;
-import org.jclouds.vcloud.domain.Status;
-import org.jclouds.vcloud.domain.Task;
-import org.jclouds.vcloud.domain.VApp;
-import org.jclouds.vcloud.domain.VAppTemplate;
-import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest;
-import org.jclouds.vcloud.options.CatalogItemOptions;
-import org.jclouds.vcloud.predicates.TaskSuccess;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableMap;
-
-@Test(groups = "live", enabled = true, singleThreaded = true, testName = "VAppTemplateApiLiveTest")
-public class VAppTemplateApiLiveTest extends BaseVCloudApiLiveTest {
- @Test
- public void testGetVAppTemplate() throws Exception {
- Org org = getVCloudApi().getOrgApi().findOrgNamed(null);
- for (ReferenceType cat : org.getCatalogs().values()) {
- Catalog response = getVCloudApi().getCatalogApi().getCatalog(cat.getHref());
- for (ReferenceType resource : response.values()) {
- if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
- CatalogItem item = getVCloudApi().getCatalogApi().getCatalogItem(resource.getHref());
- if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) {
- VAppTemplate template = getVCloudApi().getVAppTemplateApi().getVAppTemplate(item.getEntity().getHref());
- if (template != null) {
- // the UUID in the href is the only way to actually link templates
- assertEquals(template.getHref(), item.getEntity().getHref());
- } else {
- // null can be no longer available or auth exception
- }
- }
- }
- }
- }
- }
-
- @Test
- public void testGetOvfEnvelopeForVAppTemplate() throws Exception {
- Org org = getVCloudApi().getOrgApi().findOrgNamed(null);
- for (ReferenceType cat : org.getCatalogs().values()) {
- Catalog response = getVCloudApi().getCatalogApi().getCatalog(cat.getHref());
- for (ReferenceType resource : response.values()) {
- if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
- CatalogItem item = getVCloudApi().getCatalogApi().getCatalogItem(resource.getHref());
- if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) {
- getVCloudApi().getVAppTemplateApi().getOvfEnvelopeForVAppTemplate(item.getEntity().getHref());
- // null can be no longer available or auth exception
- }
- }
- }
- }
- }
-
- @Test
- public void testFindVAppTemplate() throws Exception {
- Org org = getVCloudApi().getOrgApi().findOrgNamed(null);
- for (ReferenceType cat : org.getCatalogs().values()) {
- Catalog response = getVCloudApi().getCatalogApi().getCatalog(cat.getHref());
- for (ReferenceType resource : response.values()) {
- if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
- CatalogItem item = getVCloudApi().getCatalogApi().getCatalogItem(resource.getHref());
- if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) {
- VAppTemplate template = getVCloudApi().getVAppTemplateApi().findVAppTemplateInOrgCatalogNamed(
- org.getName(), response.getName(), item.getEntity().getName());
- if (template != null) {
- // the UUID in the href is the only way to actually link templates
- assertEquals(template.getHref(), item.getEntity().getHref());
- } else {
- // null can be no longer available or auth exception
- }
- }
- }
- }
- }
- }
-
- @Test
- public void testCaptureVApp() throws Exception {
- String group = prefix + "cap";
- NodeMetadata node = null;
- VAppTemplate vappTemplate = null;
- CatalogItem item = null;
- try {
-
- node = getOnlyElement(client.createNodesInGroup(group, 1));
-
- Predicate<URI> taskTester = retry(new TaskSuccess(getVCloudApi()), 600, 5, SECONDS);
-
- // I have to undeploy first
- Task task = getVCloudApi().getVAppApi().undeployVApp(URI.create(node.getId()));
-
- // wait up to ten minutes per above
- assert taskTester.apply(task.getHref()) : node;
-
- VApp vApp = getVCloudApi().getVAppApi().getVApp(URI.create(node.getId()));
-
- // wait up to ten minutes per above
- assertEquals(vApp.getStatus(), Status.OFF);
-
- // vdc is equiv to the node's location
- // vapp uri is the same as the node's id
- vappTemplate = getVCloudApi().getVAppTemplateApi().captureVAppAsTemplateInVDC(URI.create(node.getId()),
- group, URI.create(node.getLocation().getId()));
-
- assertEquals(vappTemplate.getName(), group);
-
- task = vappTemplate.getTasks().get(0);
-
- // wait up to ten minutes per above
- assert taskTester.apply(task.getHref()) : vappTemplate;
-
- item = getVCloudApi().getCatalogApi().addVAppTemplateOrMediaImageToCatalogAndNameItem(
- vappTemplate.getHref(),
- getVCloudApi().getCatalogApi().findCatalogInOrgNamed(null, null).getHref(), "fooname",
- CatalogItemOptions.Builder.description("description").properties(ImmutableMap.of("foo", "bar")));
-
- assertEquals(item.getName(), "fooname");
- assertEquals(item.getDescription(), "description");
- assertEquals(item.getProperties(), ImmutableMap.of("foo", "bar"));
- assertEquals(item.getEntity().getName(), "fooname");
- assertEquals(item.getEntity().getHref(), vappTemplate.getHref());
- assertEquals(item.getEntity().getType(), vappTemplate.getType());
-
- } finally {
- if (item != null)
- getVCloudApi().getCatalogApi().deleteCatalogItem(item.getHref());
- if (vappTemplate != null)
- getVCloudApi().getVAppTemplateApi().deleteVAppTemplate(vappTemplate.getHref());
- if (node != null)
- client.destroyNode(node.getId());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/6f974f34/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiTest.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiTest.java
deleted file mode 100644
index 12bef2e..0000000
--- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VAppTemplateApiTest.java
+++ /dev/null
@@ -1,236 +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.features;
-
-import static org.jclouds.reflect.Reflection2.method;
-import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig;
-
-import java.io.IOException;
-import java.net.URI;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.ovf.xml.EnvelopeHandler;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.jclouds.util.Strings2;
-import org.jclouds.vcloud.domain.network.FenceMode;
-import org.jclouds.vcloud.domain.network.NetworkConfig;
-import org.jclouds.vcloud.internal.BaseVCloudApiTest;
-import org.jclouds.vcloud.options.CaptureVAppOptions;
-import org.jclouds.vcloud.options.CloneVAppTemplateOptions;
-import org.jclouds.vcloud.options.InstantiateVAppTemplateOptions;
-import org.jclouds.vcloud.xml.TaskHandler;
-import org.jclouds.vcloud.xml.VAppHandler;
-import org.jclouds.vcloud.xml.VAppTemplateHandler;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code VAppTemplateApi}
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during
-// surefire
-@Test(groups = "unit", testName = "VAppTemplateApiTest")
-public class VAppTemplateApiTest extends BaseVCloudApiTest<VAppTemplateApi> {
-
- public void testCreateVAppInVDCByInstantiatingTemplate() throws SecurityException, NoSuchMethodException,
- IOException {
- Invokable<?, ?> method = method(VAppTemplateApi.class, "createVAppInVDCByInstantiatingTemplate", String.class,
- URI.class, URI.class, InstantiateVAppTemplateOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("my-vapp", URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/3"),
- addNetworkConfig(new NetworkConfig("aloha", URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), FenceMode.NAT_ROUTED))));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/instantiateVAppTemplate HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vApp+xml\n");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
- "/instantiationparams-network.xml")), "application/vnd.vmware.vcloud.instantiateVAppTemplateParams+xml",
- false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, VAppHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testCreateVAppInVDCByInstantiatingTemplateOptionsIllegalName() throws SecurityException,
- NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppTemplateApi.class, "createVAppInVDCByInstantiatingTemplate", String.class,
- URI.class, URI.class, InstantiateVAppTemplateOptions[].class);
- processor.createRequest(method, ImmutableList.<Object> of("CentOS 01", URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), addNetworkConfig(new NetworkConfig(null,
- URI.create("https://vcenterprise.bluelock.com/api/v1.0/network/1991"), null))));
- }
-
- public void testcopyVAppTemplateToVDCAndName() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppTemplateApi.class, "copyVAppTemplateToVDCAndName", URI.class, URI.class,
- String.class, CloneVAppTemplateOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/4181"), URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "my-vapptemplate"));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVAppTemplate HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
- "/copyVAppTemplate-default.xml")), "application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testcopyVAppTemplateToVDCAndNameOptions() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppTemplateApi.class, "copyVAppTemplateToVDCAndName", URI.class, URI.class,
- String.class, CloneVAppTemplateOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"), URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server",
- new CloneVAppTemplateOptions().description("The description of the new vAppTemplate")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVAppTemplate HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/copyVAppTemplate.xml")),
- "application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testmoveVAppTemplateToVDCAndRenameOptions() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppTemplateApi.class, "moveVAppTemplateToVDCAndRename", URI.class, URI.class,
- String.class, CloneVAppTemplateOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/201"), URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), "new-linux-server",
- new CloneVAppTemplateOptions().description("The description of the new vAppTemplate")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/cloneVAppTemplate HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/moveVAppTemplate.xml")),
- "application/vnd.vmware.vcloud.cloneVAppTemplateParams+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testcaptureVAppAsTemplateInVDC() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppTemplateApi.class, "captureVAppAsTemplateInVDC", URI.class, String.class,
- URI.class, CaptureVAppOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/4181"), "my-template", URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/captureVApp HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
- assertPayloadEquals(request, Strings2
- .toStringAndClose(getClass().getResourceAsStream("/captureVApp-default.xml")),
- "application/vnd.vmware.vcloud.captureVAppParams+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testcaptureVAppAsTemplateInVDCOptions() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppTemplateApi.class, "captureVAppAsTemplateInVDC", URI.class, String.class,
- URI.class, CaptureVAppOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vapp/201"), "my-template", URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1"), new CaptureVAppOptions()
- .withDescription("The description of the new vApp Template")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vdc/1/action/captureVApp HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/captureVApp.xml")),
- "application/vnd.vmware.vcloud.captureVAppParams+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testFindVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppTemplateApi.class, "findVAppTemplateInOrgCatalogNamed", String.class,
- String.class, String.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("org", "catalog", "template"));
-
- assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testVAppTemplateURI() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppTemplateApi.class, "getVAppTemplate", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")));
-
- assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vAppTemplate+xml\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, VAppTemplateHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testGetOvfEnvelopeForVAppTemplate() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VAppTemplateApi.class, "getOvfEnvelopeForVAppTemplate", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")));
-
- assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2/ovf HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: text/xml\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, EnvelopeHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/6f974f34/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCApiLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCApiLiveTest.java
deleted file mode 100644
index be1efdc..0000000
--- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCApiLiveTest.java
+++ /dev/null
@@ -1,26 +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.features;
-
-import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest;
-import org.testng.annotations.Test;
-
-@Test(groups = "live", enabled = true, singleThreaded = true, testName = "VDCApiLiveTest")
-public class VDCApiLiveTest extends BaseVCloudApiLiveTest {
-
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/6f974f34/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCApiTest.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCApiTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCApiTest.java
deleted file mode 100644
index 0296453..0000000
--- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VDCApiTest.java
+++ /dev/null
@@ -1,100 +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.features;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.NoSuchElementException;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.jclouds.vcloud.internal.BaseVCloudApiTest;
-import org.jclouds.vcloud.xml.VDCHandler;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code VDCApi}
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during
-// surefire
-@Test(groups = "unit", testName = "VDCApiTest")
-public class VDCApiTest extends BaseVCloudApiTest<VDCApi> {
-
- @Test(expectedExceptions = NoSuchElementException.class)
- public void testFindVDCInOrgNamedBadVDC() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VDCApi.class, "findVDCInOrgNamed", String.class, String.class);
- processor.createRequest(method, ImmutableList.<Object> of("org", "vdc1"));
- }
-
- @Test(expectedExceptions = NoSuchElementException.class)
- public void testFindVDCInOrgNamedBadOrg() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VDCApi.class, "findVDCInOrgNamed", String.class, String.class);
- processor.createRequest(method, ImmutableList.<Object> of("org1", "vdc"));
- }
-
- public void testFindVDCInOrgNamedNullOrg() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VDCApi.class, "findVDCInOrgNamed", String.class, String.class);
- GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, "vdc"));
-
- assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, VDCHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testFindVDCInOrgNamedNullOrgAndVDC() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VDCApi.class, "findVDCInOrgNamed", String.class, String.class);
- GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList(null, null));
-
- assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, VDCHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testGetVDC() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VDCApi.class, "getVDC", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1")));
-
- assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vdc/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vdc+xml\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, VDCHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/6f974f34/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmApiLiveTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmApiLiveTest.java
deleted file mode 100644
index f6b3d92..0000000
--- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmApiLiveTest.java
+++ /dev/null
@@ -1,161 +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.features;
-
-import static com.google.common.base.Charsets.UTF_8;
-import static com.google.common.collect.Iterables.get;
-import static com.google.common.collect.Iterables.getOnlyElement;
-import static com.google.common.io.BaseEncoding.base64;
-import static org.jclouds.compute.options.RunScriptOptions.Builder.wrapInInitScript;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import org.jclouds.compute.domain.ExecResponse;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.options.TemplateOptions;
-import org.jclouds.vcloud.VCloudApi;
-import org.jclouds.vcloud.VCloudMediaType;
-import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
-import org.jclouds.vcloud.domain.Org;
-import org.jclouds.vcloud.domain.ReferenceType;
-import org.jclouds.vcloud.domain.VApp;
-import org.jclouds.vcloud.domain.VDC;
-import org.jclouds.vcloud.domain.Vm;
-import org.jclouds.vcloud.internal.BaseVCloudApiLiveTest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Iterables;
-import com.google.common.net.HostAndPort;
-
-/**
- * This tests that we can use guest customization as an alternative to bootstrapping with ssh. There
- * are a few advantages to this, including the fact that it can work inside google appengine where
- * network sockets (ssh:22) are prohibited.
- */
-@Test(groups = "live", enabled = true, singleThreaded = true, testName = "VmApiLiveTest")
-public class VmApiLiveTest extends BaseVCloudApiLiveTest {
-
- @Test
- public void testGetThumbnailOfVm() throws Exception {
- Org org = getVCloudApi().getOrgApi().findOrgNamed(null);
- for (ReferenceType vdc : org.getVDCs().values()) {
- VDC response = getVCloudApi().getVDCApi().getVDC(vdc.getHref());
- for (ReferenceType item : response.getResourceEntities().values()) {
- if (item.getType().equals(VCloudMediaType.VAPP_XML)) {
- try {
- VApp app = getVCloudApi().getVAppApi().getVApp(item.getHref());
- assertNotNull(app);
- for (Vm vm : app.getChildren()) {
- assert getVCloudApi().getVmApi().getScreenThumbnailForVm(vm.getHref()) != null;
- }
- } catch (RuntimeException e) {
-
- }
- }
- }
- }
- }
-
- @Test
- public void testGetVm() throws Exception {
- Org org = getVCloudApi().getOrgApi().findOrgNamed(null);
- for (ReferenceType vdc : org.getVDCs().values()) {
- VDC response = getVCloudApi().getVDCApi().getVDC(vdc.getHref());
- for (ReferenceType item : response.getResourceEntities().values()) {
- if (item.getType().equals(VCloudMediaType.VAPP_XML)) {
- try {
- VApp app = getVCloudApi().getVAppApi().getVApp(item.getHref());
- assertNotNull(app);
- for (Vm vm : app.getChildren()) {
- assertEquals(getVCloudApi().getVmApi().getVm(vm.getHref()).getHref(), vm.getHref());
- }
- } catch (RuntimeException e) {
-
- }
- }
- }
- }
- }
-
- @Test
- public void testExtendedOptionsWithCustomizationScript() throws Exception {
- String PARSE_VMTOOLSD = "vmtoolsd --cmd=\"info-get guestinfo.ovfenv\" |grep vCloud_CustomizationInfo|sed 's/.*value=\"\\(.*\\)\".*/\\1/g'";
-
- String group = prefix + "cus";
-
- NodeMetadata node = null;
- try {
-
- TemplateOptions options = client.templateOptions();
- options.blockOnPort(22, 180);
- options.as(VCloudTemplateOptions.class).customizationScript(script);
- options.as(VCloudTemplateOptions.class).description(group);
- node = getOnlyElement(client.createNodesInGroup(group, 1, options));
-
- VApp vapp = client.getContext().unwrapApi(VCloudApi.class).getVAppApi().getVApp(
- node.getUri());
- assertEquals(vapp.getDescription(), group);
-
- Vm vm = Iterables.get(vapp.getChildren(), 0);
- String apiOutput = vm.getGuestCustomizationSection().getCustomizationScript();
- checkApiOutput(apiOutput);
-
- ExecResponse vmTools = client.runScriptOnNode(node.getId(), PARSE_VMTOOLSD,
- wrapInInitScript(false).runAsRoot(false));
- checkApiOutput(new String(base64().decode(vmTools.getOutput().trim()), UTF_8));
-
- ExecResponse foo = client.runScriptOnNode(node.getId(), "cat /root/foo.txt", wrapInInitScript(false)
- .runAsRoot(false));
- checkCustomizationOccurred(foo);
-
- } finally {
- if (node != null)
- client.destroyNode(node.getId());
- }
- }
-
- protected void checkCustomizationOccurred(ExecResponse exec) {
- // note that vmwaretools throws in \r characters when executing scripts
- assert exec.getOutput().equals(iLoveAscii + "\r\n") : exec;
- }
-
- protected void checkApiOutput(String apiOutput) {
- checkApiOutput1_0_1(apiOutput);
- }
-
- // make sure the script has a lot of screwy characters, knowing our parser
- // throws-out \r
- protected String iLoveAscii = "I '\"love\"' {asc|!}*&";
-
- String script = "cat > /root/foo.txt<<EOF\n" + iLoveAscii + "\nEOF\n";
-
- protected void checkApiOutput1_0_1(String apiOutput) {
- // in 1.0.1, vcloud director seems to pass through characters via api
- // flawlessly
- assertEquals(apiOutput, script);
- }
-
- protected void checkApiOutput1_0_0(String apiOutput) {
- // in 1.0.0, vcloud director seems to remove all newlines
- assertEquals(apiOutput, script.replace("\n", ""));
- }
-
- protected HostAndPort getSocket(NodeMetadata node) {
- return HostAndPort.fromParts(get(node.getPublicAddresses(), 0), 22);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/6f974f34/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmApiTest.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmApiTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmApiTest.java
deleted file mode 100644
index b8e786c..0000000
--- a/apis/vcloud/src/test/java/org/jclouds/vcloud/features/VmApiTest.java
+++ /dev/null
@@ -1,318 +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.features;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-import java.net.URI;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.http.functions.ReleasePayloadAndReturn;
-import org.jclouds.http.functions.ReturnInputStream;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.jclouds.util.Strings2;
-import org.jclouds.vcloud.domain.GuestCustomizationSection;
-import org.jclouds.vcloud.internal.BaseVCloudApiTest;
-import org.jclouds.vcloud.utils.TestUtils;
-import org.jclouds.vcloud.xml.TaskHandler;
-import org.jclouds.vcloud.xml.VmHandler;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.reflect.Invokable;
-/**
- * Tests behavior of {@code VmApi}
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during
-// surefire
-@Test(groups = "unit", testName = "VmApiTest")
-public class VmApiTest extends BaseVCloudApiTest<VmApi> {
-
- public void testGetThumbnailOfVm() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VmApi.class, "getScreenThumbnailForVm", URI.class);
- GeneratedHttpRequest request = processor
- .createRequest(method, ImmutableList.<Object> of(URI.create("http://vcloud.example.com/api/v1.0/vApp/vm-12")));
-
- assertRequestLineEquals(request, "GET http://vcloud.example.com/api/v1.0/vApp/vm-12/screen HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: image/png\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReturnInputStream.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- @Test(dataProvider = "ignoreOnWindows", description = "see http://code.google.com/p/jclouds/issues/detail?id=402")
- public void testUpdateGuestConfiguration() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VmApi.class, "updateGuestCustomizationOfVm", GuestCustomizationSection.class,
- URI.class);
- GuestCustomizationSection guest = new GuestCustomizationSection(URI
- .create("http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection"));
- guest.setCustomizationScript("cat > /tmp/foo.txt<<EOF\nI love candy\nEOF");
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(guest, URI
- .create("http://vcloud.example.com/api/v1.0/vApp/vm-12")));
-
- assertRequestLineEquals(request,
- "PUT http://vcloud.example.com/api/v1.0/vApp/vm-12/guestCustomizationSection HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
- "/guestCustomizationSection.xml")), "application/vnd.vmware.vcloud.guestCustomizationSection+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testUpdateCPUCountOfVm() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VmApi.class, "updateCPUCountOfVm", int.class, URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(2, URI
- .create("http://vcloud.example.com/api/v1.0/vApp/vm-12")));
-
- assertRequestLineEquals(request,
- "PUT http://vcloud.example.com/api/v1.0/vApp/vm-12/virtualHardwareSection/cpu HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/cpuItem.xml")),
- "application/vnd.vmware.vcloud.rasdItem+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testUpdateMemoryMBOfVm() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VmApi.class, "updateMemoryMBOfVm", int.class, URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(512, URI
- .create("http://vcloud.example.com/api/v1.0/vApp/vm-12")));
-
- assertRequestLineEquals(request,
- "PUT http://vcloud.example.com/api/v1.0/vApp/vm-12/virtualHardwareSection/memory HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/memoryItem.xml")),
- "application/vnd.vmware.vcloud.rasdItem+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testDeployVm() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VmApi.class, "deployVm", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, "<DeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\"/>",
- "application/vnd.vmware.vcloud.deployVAppParams+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testDeployAndPowerOnVm() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VmApi.class, "deployAndPowerOnVm", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request, "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/deploy HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, "<DeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\" powerOn=\"true\"/>",
- "application/vnd.vmware.vcloud.deployVAppParams+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testGetVm() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VmApi.class, "getVm", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vm/1")));
-
- assertRequestLineEquals(request, "GET https://vcenterprise.bluelock.com/api/v1.0/vm/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.vm+xml\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, VmHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testRebootVm() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VmApi.class, "rebootVm", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reboot HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testUndeployVm() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VmApi.class, "undeployVm", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, "<UndeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\"/>",
- "application/vnd.vmware.vcloud.undeployVAppParams+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testUndeployAndSaveStateOfVmSaveState() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VmApi.class, "undeployAndSaveStateOfVm", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/action/undeploy HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request,
- "<UndeployVAppParams xmlns=\"http://www.vmware.com/vcloud/v1\" saveState=\"true\"/>",
- "application/vnd.vmware.vcloud.undeployVAppParams+xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testPowerOnVm() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VmApi.class, "powerOnVm", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOn HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testPowerOffVm() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VmApi.class, "powerOffVm", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/powerOff HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testResetVm() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VmApi.class, "resetVm", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/reset HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testSuspendVm() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VmApi.class, "suspendVm", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/suspend HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "Accept: application/vnd.vmware.vcloud.task+xml\n");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- public void testShutdownVm() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VmApi.class, "shutdownVm", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/1")));
-
- assertRequestLineEquals(request,
- "POST https://vcenterprise.bluelock.com/api/v1.0/vApp/1/power/action/shutdown HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ReleasePayloadAndReturn.class);
- assertSaxResponseParserClassEquals(method, null);
- assertFallbackClassEquals(method, null);
-
- checkFilters(request);
- }
-
- @DataProvider
- public Object[][] ignoreOnWindows() {
- return TestUtils.isWindowsOs() ? TestUtils.NO_INVOCATIONS
- : TestUtils.SINGLE_NO_ARG_INVOCATION;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/6f974f34/apis/vcloud/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java
deleted file mode 100644
index b2e4687..0000000
--- a/apis/vcloud/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java
+++ /dev/null
@@ -1,51 +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.filters;
-
-import static org.testng.Assert.assertEquals;
-
-import org.jclouds.http.HttpRequest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Supplier;
-import com.google.common.net.HttpHeaders;
-
-@Test(testName = "AddVCloudAuthorizationAndCookieToRequestTest")
-public class AddVCloudAuthorizationAndCookieToRequestTest {
-
- private AddVCloudAuthorizationAndCookieToRequest filter;
-
- @BeforeTest
- void setUp() {
- filter = new AddVCloudAuthorizationAndCookieToRequest(new Supplier<String>() {
- public String get() {
- return "token";
- }
- });
- }
-
- @Test
- public void testApply() {
- HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
- request = filter.filter(request);
- assertEquals(request.getHeaders().size(), 2);
- assertEquals(request.getFirstHeaderOrNull(HttpHeaders.COOKIE), "vcloud-token=token");
- assertEquals(request.getFirstHeaderOrNull("x-vcloud-authorization"), "token");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/6f974f34/apis/vcloud/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java
deleted file mode 100644
index 66a4f4a..0000000
--- a/apis/vcloud/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java
+++ /dev/null
@@ -1,145 +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.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import java.net.URI;
-
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.HttpResponseException;
-import org.jclouds.http.functions.BaseHandlerTest;
-import org.jclouds.vcloud.VCloudMediaType;
-import org.jclouds.vcloud.domain.VCloudSession;
-import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Tests behavior of {@code ParseLoginResponseFromHeaders}
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during
-// surefire
-@Test(groups = "unit", testName = "ParseLoginResponseFromHeadersTest")
-public class ParseLoginResponseFromHeadersTest extends BaseHandlerTest {
-
- private ParseLoginResponseFromHeaders parser;
-
- @BeforeTest
- void setUp() {
- parser = injector.getInstance(ParseLoginResponseFromHeaders.class);
- }
-
- @Test
- public void testApply() {
- HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
- .payload(getClass().getResourceAsStream("/orglist.xml"))
- .addHeader("x-vcloud-authorization", "vcloud-token=9er4d061-4bff-48fa-84b1-5da7166764d2; path=/").build();
- response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
- response.getPayload().getContentMetadata().setContentLength(307l);
-
- VCloudSession reply = parser.apply(response);
- assertEquals(reply.getVCloudToken(), "9er4d061-4bff-48fa-84b1-5da7166764d2");
- assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
- VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
-
- }
-
- @Test
- public void testApplyBlueLock() {
- HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
- .payload(getClass().getResourceAsStream("/orglist.xml"))
- .addHeader("x-vcloud-authorization", "MUKOJ2HoAfoMmLnHRp4esNb2MtWscCLLhVysnsIsCG0=").build();
- response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
- response.getPayload().getContentMetadata().setContentLength(307l);
-
- VCloudSession reply = parser.apply(response);
- assertEquals(reply.getVCloudToken(), "MUKOJ2HoAfoMmLnHRp4esNb2MtWscCLLhVysnsIsCG0=");
- assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
- VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
-
- }
-
- @Test
- public void testApplyTerremark() {
- HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
- .payload(getClass().getResourceAsStream("/orglist.xml"))
- .addHeader("Set-Cookie", "vcloud-token=37ce2715-9aba-4f48-8e45-2db8a8da702d; path=/").build();
- response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
- response.getPayload().getContentMetadata().setContentLength(307l);
-
- VCloudSession reply = parser.apply(response);
- assertEquals(reply.getVCloudToken(), "37ce2715-9aba-4f48-8e45-2db8a8da702d");
- assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
- VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
-
- }
-
- @Test
- public void testApplyTerremarkMultipleCookies() {
- HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
- .payload(getClass().getResourceAsStream("/orglist.xml"))
- .addHeader("Set-Cookie", "NSC_ESUO_21654_72.46.239.132_443=fooo;expires=Thu, 02-Jun-2011 17:19:26 GMT;path=/;secure;httponly")
- .addHeader("Set-Cookie", "vcloud-token=37ce2715-9aba-4f48-8e45-2db8a8da702d; path=/").build();
- response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
- response.getPayload().getContentMetadata().setContentLength(307l);
-
- VCloudSession reply = parser.apply(response);
- assertEquals(reply.getVCloudToken(), "37ce2715-9aba-4f48-8e45-2db8a8da702d");
- assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
- VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
-
- }
-
- @Test(expectedExceptions = HttpResponseException.class)
- public void testUnmatchedCookieThrowsHttpResponseException() {
- HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
- .payload(getClass().getResourceAsStream("/orglist.xml"))
- .addHeader("Set-Cookie", "NSC_ESUO_21654_72.46.239.132_443=fooo;expires=Thu, 02-Jun-2011 17:19:26 GMT;path=/;secure;httponly").build();
- response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
- response.getPayload().getContentMetadata().setContentLength(307l);
-
- parser.apply(response);
- }
-
- @Test(expectedExceptions = HttpResponseException.class)
- public void testNoThrowsHttpResponseException() {
- HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
- .payload(getClass().getResourceAsStream("/orglist.xml")).build();
- response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
- response.getPayload().getContentMetadata().setContentLength(307l);
-
- parser.apply(response);
- }
-
- @Test
- public void testApplyVirtacore() {
- HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
- .payload(getClass().getResourceAsStream("/orglist.xml"))
- .addHeader("x-vcloud-authorization", "vcloud-token=IPy0w7UGD4lwtdWAK/ZVzfuLK+dztxGRqsOhWqV0i48=").build();
- response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
- response.getPayload().getContentMetadata().setContentLength(307l);
-
- VCloudSession reply = parser.apply(response);
- assertEquals(reply.getVCloudToken(), "IPy0w7UGD4lwtdWAK/ZVzfuLK+dztxGRqsOhWqV0i48=");
- assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
- VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
-
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/6f974f34/apis/vcloud/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java
----------------------------------------------------------------------
diff --git a/apis/vcloud/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java b/apis/vcloud/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java
deleted file mode 100644
index 9466191..0000000
--- a/apis/vcloud/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java
+++ /dev/null
@@ -1,92 +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.handlers;
-
-import java.net.URI;
-
-import org.jclouds.http.BaseHttpErrorHandlerTest;
-import org.jclouds.http.HttpErrorHandler;
-import org.jclouds.http.HttpResponseException;
-import org.jclouds.rest.AuthorizationException;
-import org.jclouds.rest.ResourceNotFoundException;
-import org.jclouds.vcloud.VCloudMediaType;
-import org.testng.annotations.Test;
-
-@Test(groups = { "unit" })
-public class ParseVCloudErrorFromHttpResponseTest extends BaseHttpErrorHandlerTest {
-
- @Test
- public void testGet404SetsResourceNotFoundException() {
- assertCodeMakes("GET", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"), 404,
- "", "", ResourceNotFoundException.class);
- }
-
- @Test
- public void testGet403NoAcessToEntitySetsResourceNotFoundException() {
- assertCodeMakes(
- "GET",
- URI.create("https://zone01.bluelock.com/api/v1.0/vApp/vapp-1535788985"),
- 403,
- "HTTP/1.1 403",
- VCloudMediaType.ERROR_XML,
- "<Error xmlns=\"http://www.vmware.com/vcloud/v1\" minorErrorCode=\"ACCESS_TO_RESOURCE_IS_FORBIDDEN\" message=\"No access to entity "(com.vmware.vcloud.entity.vapp:1535788985)".\" majorErrorCode=\"403\" 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\"></Error>\n",
- ResourceNotFoundException.class);
- }
-
- @Test
- public void testGet403NoAcessToEntitySetsResourceNotFoundExceptionOnAPI1_0AgainstVCD1_5() {
- assertCodeMakes(
- "GET",
- URI.create("https://mycloud.greenhousedata.com/api/v1.0/vApp/vapp-d3a1f2cd-d07b-4ddc-bf7b-fb7468b4d95a"),
- 403,
- "HTTP/1.1 403",
- // NOTE VCD 1.5 appends the api version to the media type
- VCloudMediaType.ERROR_XML + ";1.0",
- "<Error xmlns=\"http://www.vmware.com/vcloud/v1\" minorErrorCode=\"ACCESS_TO_RESOURCE_IS_FORBIDDEN\" message=\"No access to entity "(com.vmware.vcloud.entity.vapp:d3a1f2cd-d07b-4ddc-bf7b-fb7468b4d95a)".\" majorErrorCode=\"403\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.vmware.com/vcloud/v1 http://mycloud.greenhousedata.com/api/v1.0/schema/master.xsd\"></Error>",
- ResourceNotFoundException.class);
- }
-
- @Test
- public void testDelete404SetsHttpResponseException() {
- assertCodeMakes("DELETE", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"),
- 404, "", "", HttpResponseException.class);
- }
-
- @Test
- public void testPOSTNotRunningSetsIllegalStateException() {
- assertCodeMakes(
- "POST",
- URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vapp-138351019/action/undeploy"),
- 400,
- "HTTP/1.1 400 Bad Request",
- VCloudMediaType.ERROR_XML,
- "<Error xmlns=\"http://www.vmware.com/vcloud/v1\" minorErrorCode=\"BAD_REQUEST\" message=\"The requested operation could not be executed since vApp "adriancolecap-78c" is not running"\" majorErrorCode=\"400\" 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\"></Error>\n",
- IllegalStateException.class);
- }
-
- @Test
- public void test401SetsAuthorizationException() {
- assertCodeMakes("GET", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"), 401,
- "", "", AuthorizationException.class);
- }
-
- @Override
- protected Class<? extends HttpErrorHandler> getHandlerClass() {
- return ParseVCloudErrorFromHttpResponse.class;
- }
-
-}