http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VmApiTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VmApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/features/VmApiTest.java deleted file mode 100644 index b8e786c..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/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/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/filters/AddVCloudAuthorizationAndCookieToRequestTest.java deleted file mode 100644 index 40d1fd5..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/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"; - } - }, "1.0"); - } - - @Test - public void testApply() { - HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build(); - request = filter.filter(request); - assertEquals(request.getHeaders().size(), 3); - assertEquals(request.getFirstHeaderOrNull(HttpHeaders.COOKIE), "vcloud-token=token"); - assertEquals(request.getFirstHeaderOrNull("x-vcloud-authorization"), "token"); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/functions/ParseLoginResponseFromHeadersTest.java deleted file mode 100644 index 66a4f4a..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/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("[email protected]", new ReferenceTypeImpl("[email protected]", - 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("[email protected]", new ReferenceTypeImpl("[email protected]", - 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("[email protected]", new ReferenceTypeImpl("[email protected]", - 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("[email protected]", new ReferenceTypeImpl("[email protected]", - 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("[email protected]", new ReferenceTypeImpl("[email protected]", - VCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48")))); - - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/handlers/ParseVCloudErrorFromHttpResponseTest.java deleted file mode 100644 index 9466191..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/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; - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.java deleted file mode 100644 index 4ffe512..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BasePayloadTest.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.internal; - -import static org.jclouds.reflect.Reflection2.method; - -import java.net.URI; -import java.util.List; - -import org.jclouds.reflect.Invocation; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.VCloudApiMetadata; -import org.nnsoft.guice.rocoto.Rocoto; -import org.nnsoft.guice.rocoto.configuration.ConfigurationModule; - -import com.google.common.base.Throwables; -import com.google.inject.Guice; -import com.google.inject.Injector; - -public class BasePayloadTest { - - protected Injector injector = Guice.createInjector(Rocoto.expandVariables(new ConfigurationModule() { - protected void bindConfigurations() { - bindProperties(new VCloudApiMetadata().getDefaultProperties()); - } - })); - - protected GeneratedHttpRequest requestForArgs(List<Object> args) { - try { - Invocation invocation = Invocation.create(method(String.class, "toString"), args); - return GeneratedHttpRequest.builder().method("POST").endpoint(URI.create("http://localhost/key")) - .invocation(invocation).build(); - } catch (SecurityException e) { - throw Throwables.propagate(e); - } - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiLiveTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiLiveTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiLiveTest.java deleted file mode 100644 index a4db473..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiLiveTest.java +++ /dev/null @@ -1,55 +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.internal; - -import org.jclouds.compute.ComputeService; -import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest; -import org.jclouds.sshj.config.SshjSshClientModule; -import org.jclouds.vcloud.VCloudApi; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -import com.google.inject.Module; - -@Test(groups = "live", enabled = true, singleThreaded = true) -public abstract class BaseVCloudApiLiveTest extends BaseComputeServiceContextLiveTest { - - // username is too long for name constraints - protected String prefix = "vcd"; - - protected ComputeService client; - - public BaseVCloudApiLiveTest() { - provider = "vcloud"; - } - - protected VCloudApi getVCloudApi() { - return view.unwrapApi(VCloudApi.class); - } - - @Override - @BeforeClass(groups = { "integration", "live" }) - public void setupContext() { - super.setupContext(); - client = view.getComputeService(); - } - - @Override - protected Module getSshModule() { - return new SshjSshClientModule(); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiTest.java deleted file mode 100644 index feeec7c..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/BaseVCloudApiTest.java +++ /dev/null @@ -1,270 +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.internal; - -import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL; -import static org.testng.Assert.assertEquals; - -import java.net.URI; -import java.util.Map; -import java.util.concurrent.atomic.AtomicReference; - -import javax.inject.Inject; -import javax.inject.Named; -import javax.inject.Singleton; - -import org.jclouds.http.HttpRequest; -import org.jclouds.ovf.Envelope; -import org.jclouds.ovf.xml.EnvelopeHandlerTest; -import org.jclouds.providers.AnonymousProviderMetadata; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.AuthorizationException; -import org.jclouds.rest.ConfiguresHttpApi; -import org.jclouds.rest.internal.BaseRestAnnotationProcessingTest; -import org.jclouds.vcloud.VCloudApiMetadata; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.VCloudVersionsApi; -import org.jclouds.vcloud.config.VCloudHttpApiModule; -import org.jclouds.vcloud.domain.AllocationModel; -import org.jclouds.vcloud.domain.CatalogItem; -import org.jclouds.vcloud.domain.Org; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.VAppTemplate; -import org.jclouds.vcloud.domain.VCloudSession; -import org.jclouds.vcloud.domain.VDC; -import org.jclouds.vcloud.domain.VDCStatus; -import org.jclouds.vcloud.domain.internal.CatalogImpl; -import org.jclouds.vcloud.domain.internal.CatalogItemImpl; -import org.jclouds.vcloud.domain.internal.OrgImpl; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.jclouds.vcloud.domain.internal.VDCImpl; -import org.jclouds.vcloud.filters.AddVCloudAuthorizationAndCookieToRequest; -import org.jclouds.vcloud.xml.VAppTemplateHandlerTest; -import org.testng.annotations.Test; - -import com.google.common.base.Functions; -import com.google.common.base.Supplier; -import com.google.common.base.Suppliers; -import com.google.common.cache.CacheLoader; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; -import com.google.inject.AbstractModule; -import com.google.inject.Module; -import com.google.inject.TypeLiteral; - -/** - * Tests behavior of {@code VCloudApi} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "BaseVCloudApiTest") -public abstract class BaseVCloudApiTest<T> extends BaseRestAnnotationProcessingTest<T> { - - @Override - protected void checkFilters(HttpRequest request) { - assertEquals(request.getFilters().size(), 1); - assertEquals(request.getFilters().get(0).getClass(), AddVCloudAuthorizationAndCookieToRequest.class); - } - - @Override - protected Module createModule() { - return new VCloudHttpApiModuleExtension(); - } - - @Override - protected ProviderMetadata createProviderMetadata() { - return AnonymousProviderMetadata.forApiWithEndpoint(new VCloudApiMetadata(), "https://vcenterprise.bluelock.com/api/v1.0"); - } - - protected static final ReferenceTypeImpl ORG_REF = new ReferenceTypeImpl("org", VCloudMediaType.ORG_XML, - URI.create("https://vcenterprise.bluelock.com/api/v1.0/org/1")); - - protected static final ReferenceTypeImpl CATALOG_REF = new ReferenceTypeImpl("catalog", VCloudMediaType.CATALOG_XML, - URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalog/1")); - - protected static final ReferenceTypeImpl TASKSLIST_REF = new ReferenceTypeImpl("tasksList", - VCloudMediaType.TASKSLIST_XML, URI.create("https://vcenterprise.bluelock.com/api/v1.0/tasksList/1")); - - protected static final ReferenceTypeImpl VDC_REF = new ReferenceTypeImpl("vdc", VCloudMediaType.VDC_XML, - URI.create("https://vcenterprise.bluelock.com/api/v1.0/vdc/1")); - - protected static final ReferenceTypeImpl NETWORK_REF = new ReferenceTypeImpl("network", VCloudMediaType.NETWORK_XML, - URI.create("https://vcloud.safesecureweb.com/network/1990")); - - protected static final Org ORG = new OrgImpl(ORG_REF.getName(), ORG_REF.getType(), ORG_REF.getHref(), "org", null, - ImmutableMap.<String, ReferenceType> of(CATALOG_REF.getName(), CATALOG_REF), - ImmutableMap.<String, ReferenceType> of(VDC_REF.getName(), VDC_REF), ImmutableMap.<String, ReferenceType> of( - NETWORK_REF.getName(), NETWORK_REF), TASKSLIST_REF, ImmutableList.<Task> of()); - - protected static final VDC VDC = new VDCImpl(VDC_REF.getName(), VDC_REF.getType(), VDC_REF.getHref(), - VDCStatus.READY, null, "description", ImmutableSet.<Task> of(), AllocationModel.ALLOCATION_POOL, null, null, - null, ImmutableMap.<String, ReferenceType> of( - "vapp", - new ReferenceTypeImpl("vapp", "application/vnd.vmware.vcloud.vApp+xml", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/188849-1")), - "network", - new ReferenceTypeImpl("network", "application/vnd.vmware.vcloud.vAppTemplate+xml", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vdcItem/2"))), - ImmutableMap.<String, ReferenceType> of(NETWORK_REF.getName(), NETWORK_REF), 0, 0, 0, false); - - @ConfiguresHttpApi - public static class VCloudHttpApiModuleExtension extends VCloudHttpApiModule { - - @Override - protected Supplier<URI> provideAuthenticationURI(VCloudVersionsApi versionService, String version) { - return Suppliers.ofInstance(URI.create("https://vcenterprise.bluelock.com/api/v1.0/login")); - } - - @Override - protected Supplier<Org> provideOrg(Supplier<Map<String, Org>> orgSupplier, - @org.jclouds.vcloud.endpoints.Org Supplier<ReferenceType> defaultOrg) { - return Suppliers.ofInstance(ORG); - } - - @Override - protected void installDefaultVCloudEndpointsModule() { - install(new AbstractModule() { - - @Override - protected void configure() { - TypeLiteral<Supplier<ReferenceType>> refTypeSupplier = new TypeLiteral<Supplier<ReferenceType>>() { - }; - bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.Org.class).toInstance( - Suppliers.<ReferenceType> ofInstance(ORG_REF)); - bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.Catalog.class).toInstance( - Suppliers.<ReferenceType> ofInstance(CATALOG_REF)); - bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.TasksList.class).toInstance( - Suppliers.<ReferenceType> ofInstance(TASKSLIST_REF)); - bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.VDC.class).toInstance( - Suppliers.<ReferenceType> ofInstance(VDC_REF)); - bind(refTypeSupplier).annotatedWith(org.jclouds.vcloud.endpoints.Network.class).toInstance( - Suppliers.<ReferenceType> ofInstance(NETWORK_REF)); - } - - }); - } - - @Override - protected Supplier<VCloudSession> provideVCloudTokenCache(@Named(PROPERTY_SESSION_INTERVAL) long seconds, - AtomicReference<AuthorizationException> authException, final VCloudLoginApi login) { - return Suppliers.<VCloudSession> ofInstance(new VCloudSession() { - - @Override - public Map<String, ReferenceType> getOrgs() { - return ImmutableMap.<String, ReferenceType> of(ORG_REF.getName(), ORG_REF); - } - - @Override - public String getVCloudToken() { - return "token"; - } - - }); - - } - - @Override - protected void configure() { - super.configure(); - bind(OrgMapSupplier.class).to(TestOrgMapSupplier.class); - bind(OrgCatalogSupplier.class).to(TestOrgCatalogSupplier.class); - bind(OrgCatalogItemSupplier.class).to(TestOrgCatalogItemSupplier.class); - } - - @SuppressWarnings("unchecked") - @Override - protected void bindCacheLoaders() { - bind(new TypeLiteral<CacheLoader<URI, VAppTemplate>>() { - }).toInstance(CacheLoader.class.cast(CacheLoader.from(Functions.constant(VAppTemplateHandlerTest.parseTemplate())))); - - bind(new TypeLiteral<CacheLoader<URI, Envelope>>() { - }).toInstance(CacheLoader.class.cast(CacheLoader.from(Functions.constant(EnvelopeHandlerTest.parseEnvelope())))); - } - - @Override - protected Supplier<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> provideOrgVDCSupplierCache( - @Named(PROPERTY_SESSION_INTERVAL) long seconds, AtomicReference<AuthorizationException> authException, - OrgVDCSupplier supplier) { - return Suppliers.<Map<String, Map<String, org.jclouds.vcloud.domain.VDC>>> ofInstance(ImmutableMap - .<String, Map<String, org.jclouds.vcloud.domain.VDC>> of(ORG_REF.getName(), - ImmutableMap.<String, org.jclouds.vcloud.domain.VDC> of(VDC.getName(), VDC))); - } - - @Singleton - public static class TestOrgMapSupplier extends OrgMapSupplier { - - @Inject - protected TestOrgMapSupplier() { - super(null, null); - } - - @Override - public Map<String, Org> get() { - return ImmutableMap.<String, Org> of(ORG.getName(), ORG); - } - } - - @Singleton - public static class TestOrgCatalogSupplier extends OrgCatalogSupplier { - @Inject - protected TestOrgCatalogSupplier() { - super(null, null); - } - - @Override - public Map<String, Map<String, org.jclouds.vcloud.domain.Catalog>> get() { - return ImmutableMap.<String, Map<String, org.jclouds.vcloud.domain.Catalog>> of( - ORG_REF.getName(), ImmutableMap.<String, org.jclouds.vcloud.domain.Catalog> of( - CATALOG_REF.getName(), - new CatalogImpl(CATALOG_REF.getName(), CATALOG_REF.getType(), CATALOG_REF.getHref(), null, - "description", ImmutableMap.<String, ReferenceType> of( - "item", - new ReferenceTypeImpl("item", "application/vnd.vmware.vcloud.catalogItem+xml", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/1")), - "template", - new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", - URI.create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"))), - ImmutableList.<Task> of(), true, false))); - } - } - - @Singleton - public static class TestOrgCatalogItemSupplier extends OrgCatalogItemSupplier { - protected TestOrgCatalogItemSupplier() { - super(null, null); - } - - @Override - public Map<String, Map<String, Map<String, CatalogItem>>> get() { - return ImmutableMap.<String, Map<String, Map<String, CatalogItem>>> of( - ORG_REF.getName(), ImmutableMap - .<String, Map<String, CatalogItem>> of(CATALOG_REF - .getName(), ImmutableMap.<String, CatalogItem> of( - "template", - new CatalogItemImpl("template", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalogItem/2"), "description", - new ReferenceTypeImpl("template", "application/vnd.vmware.vcloud.vAppTemplate+xml", - URI.create("https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/2")), - ImmutableMap.<String, String> of())))); - - } - } - - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/VCloudLoginApiTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/VCloudLoginApiTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/VCloudLoginApiTest.java deleted file mode 100644 index b97cdf0..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/internal/VCloudLoginApiTest.java +++ /dev/null @@ -1,95 +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.internal; - -import static org.jclouds.reflect.Reflection2.method; -import static org.testng.Assert.assertEquals; - -import java.io.IOException; -import java.net.URI; - -import org.jclouds.http.HttpRequest; -import org.jclouds.http.filters.BasicAuthentication; -import org.jclouds.location.Provider; -import org.jclouds.providers.AnonymousProviderMetadata; -import org.jclouds.providers.ProviderMetadata; -import org.jclouds.rest.internal.BaseRestAnnotationProcessingTest; -import org.jclouds.rest.internal.GeneratedHttpRequest; -import org.jclouds.vcloud.endpoints.VCloudLogin; -import org.jclouds.vcloud.functions.ParseLoginResponseFromHeaders; -import org.jclouds.vcloud.http.filters.VCloudBasicAuthentication; -import org.testng.annotations.Test; - -import com.google.common.base.Supplier; -import com.google.common.collect.ImmutableList; -import com.google.common.net.HttpHeaders; -import com.google.common.reflect.Invokable; -import com.google.inject.Binder; -import com.google.inject.Module; -import com.google.inject.Provides; -/** - * Tests behavior of {@code VCloudLoginApi} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "VCloudLoginApiTest") -public class VCloudLoginApiTest extends BaseRestAnnotationProcessingTest<VCloudLoginApi> { - - public void testLogin() throws SecurityException, NoSuchMethodException, IOException { - Invokable<?, ?> method = method(VCloudLoginApi.class, "login"); - GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.of()); - - assertEquals(request.getRequestLine(), "POST http://localhost:8080/login HTTP/1.1"); - assertNonPayloadHeadersEqual(request, HttpHeaders.ACCEPT + ": application/vnd.vmware.vcloud.orgList+xml\n" + HttpHeaders.ACCEPT + ": application/vnd.vmware.vcloud.session+xml\n"); - assertPayloadEquals(request, null, null, false); - - assertResponseParserClassEquals(method, request, ParseLoginResponseFromHeaders.class); - assertSaxResponseParserClassEquals(method, null); - assertFallbackClassEquals(method, null); - - checkFilters(request); - } - - @Override - protected void checkFilters(HttpRequest request) { - assertEquals(request.getFilters().size(), 1); - assertEquals(request.getFilters().get(0).getClass(), VCloudBasicAuthentication.class); - } - - @Override - protected Module createModule() { - return new Module() { - - @Override - public void configure(Binder binder) { - } - - @Provides - @VCloudLogin - Supplier<URI> provideURI(@Provider Supplier<URI> uri) { - return uri; - } - - }; - } - - @Override - protected ProviderMetadata createProviderMetadata() { - return AnonymousProviderMetadata.forApiOnEndpoint(VCloudLoginApi.class, - "http://localhost:8080/login"); - } - -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.java deleted file mode 100644 index 8994284..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/options/InstantiateVAppTemplateOptionsTest.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.options; - -import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.addNetworkConfig; -import static org.jclouds.vcloud.options.InstantiateVAppTemplateOptions.Builder.description; -import static org.testng.Assert.assertEquals; - -import java.net.URI; - -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.vcloud.domain.network.FenceMode; -import org.jclouds.vcloud.domain.network.NetworkConfig; -import org.testng.annotations.Test; - -import com.google.common.collect.Iterables; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code InstantiateVAppTemplateOptions} - */ -@Test(groups = "unit") -public class InstantiateVAppTemplateOptionsTest { - - Injector injector = Guice.createInjector(new SaxParserModule()); - - @Test - public void testAddNetworkConfig() { - InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions(); - options.addNetworkConfig(new NetworkConfig("default", URI.create("http://localhost"), FenceMode.BRIDGED)); - assertEquals(Iterables.get(options.getNetworkConfig(), 0).getNetworkName(), "default"); - assertEquals(Iterables.get(options.getNetworkConfig(), 0).getParentNetwork(), URI.create("http://localhost")); - assertEquals(Iterables.get(options.getNetworkConfig(), 0).getFenceMode(), FenceMode.BRIDGED); - } - - @Test - public void testAddNetworkConfigStatic() { - InstantiateVAppTemplateOptions options = addNetworkConfig(new NetworkConfig("default", - URI.create("http://localhost"), FenceMode.BRIDGED)); - assertEquals(Iterables.get(options.getNetworkConfig(), 0).getNetworkName(), "default"); - assertEquals(Iterables.get(options.getNetworkConfig(), 0).getParentNetwork(), URI.create("http://localhost")); - assertEquals(Iterables.get(options.getNetworkConfig(), 0).getFenceMode(), FenceMode.BRIDGED); - } - - @Test - public void testDescription() { - InstantiateVAppTemplateOptions options = new InstantiateVAppTemplateOptions(); - options.description("foo"); - assertEquals(options.getDescription(), "foo"); - } - - @Test - public void testDescriptionStatic() { - InstantiateVAppTemplateOptions options = description("foo"); - assertEquals(options.getDescription(), "foo"); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java deleted file mode 100644 index 4bdb5b8..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/suppliers/OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest.java +++ /dev/null @@ -1,113 +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.suppliers; - -import static org.easymock.EasyMock.createMock; -import static org.testng.Assert.assertEquals; - -import java.util.NoSuchElementException; - -import org.jclouds.config.ValueOfConfigurationKeyOrNull; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.testng.annotations.Test; - -import com.google.common.base.Predicates; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; -import com.google.inject.AbstractModule; -import com.google.inject.Guice; -import com.google.inject.name.Names; - -/** - * Tests behavior of - * {@code OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during -// surefire -@Test(groups = "unit", testName = "OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest") -public class OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefaultTest { - ValueOfConfigurationKeyOrNull valueOfConfigurationKeyOrNull = Guice.createInjector().getInstance( - ValueOfConfigurationKeyOrNull.class); - - @Test(expectedExceptions = IllegalArgumentException.class) - public void testIllegalArgumentWhenResourcesEmpty() { - new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(valueOfConfigurationKeyOrNull, "foo", - Predicates.<ReferenceType> alwaysTrue()).apply(ImmutableSet.<ReferenceType> of()); - } - - @Test - public void testReturnsOnlyResource() { - ReferenceType reference = createMock(ReferenceType.class); - - assertEquals(new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(valueOfConfigurationKeyOrNull, - "foo", Predicates.<ReferenceType> alwaysTrue()).apply(ImmutableSet.<ReferenceType> of(reference)), - reference); - - } - - @Test - public void testReturnsFirstResourceWhenConfigurationUnspecified() { - ReferenceType reference1 = createMock(ReferenceType.class); - ReferenceType reference2 = createMock(ReferenceType.class); - - assertEquals(new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(valueOfConfigurationKeyOrNull, - "foo", Predicates.<ReferenceType> alwaysTrue()).apply(ImmutableList.<ReferenceType> of(reference1, - reference2)), reference1); - - } - - @Test - public void testReturnsResourceMatchingDefaultPredicateWhenConfigurationUnspecified() { - ReferenceType reference1 = createMock(ReferenceType.class); - ReferenceType reference2 = createMock(ReferenceType.class); - - assertEquals(new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(valueOfConfigurationKeyOrNull, - "foo", Predicates.equalTo(reference2)).apply(ImmutableList.<ReferenceType> of(reference1, reference2)), - reference2); - - } - - @Test - public void testReturnsResourceWithNameMatchingConfigurationKey() { - ReferenceType reference1 = new ReferenceTypeImpl("travis tritt", null, null); - ReferenceType reference2 = new ReferenceTypeImpl("hail mary", null, null); - - assertEquals( - new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(Guice.createInjector( - new AbstractModule() { - protected void configure() { - bindConstant().annotatedWith(Names.named("foo")).to(".*mary.*"); - } - }).getInstance(ValueOfConfigurationKeyOrNull.class), "foo", Predicates.<ReferenceType> alwaysTrue()).apply(ImmutableList - .<ReferenceType> of(reference1, reference2)), reference2); - - } - - @Test(expectedExceptions = NoSuchElementException.class) - public void testThrowsNoSuchElementWhenNoneMatchConfigurationKey() { - ReferenceType reference1 = new ReferenceTypeImpl("travis tritt", null, null); - ReferenceType reference2 = new ReferenceTypeImpl("hail mary", null, null); - - new OnlyReferenceTypeFirstWithNameMatchingConfigurationKeyOrDefault(Guice.createInjector(new AbstractModule() { - protected void configure() { - bindConstant().annotatedWith(Names.named("foo")).to(".*happy.*"); - } - }).getInstance(ValueOfConfigurationKeyOrNull.class), "foo", Predicates.<ReferenceType> alwaysTrue()) - .apply(ImmutableList.<ReferenceType> of(reference1, reference2)); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/utils/TestUtils.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/utils/TestUtils.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/utils/TestUtils.java deleted file mode 100644 index 9a844ed..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/utils/TestUtils.java +++ /dev/null @@ -1,30 +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.utils; - - -/** - * Utility class for test - */ -public class TestUtils { - public static final Object[][] NO_INVOCATIONS = new Object[0][0]; - public static final Object[][] SINGLE_NO_ARG_INVOCATION = { new Object[0] }; - - public static boolean isWindowsOs() { - return System.getProperty("os.name", "").toLowerCase().contains("windows"); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java deleted file mode 100644 index 2a883e6..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogHandlerTest.java +++ /dev/null @@ -1,133 +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.xml; - -import static org.jclouds.vcloud.VCloudMediaType.CATALOGITEM_XML; -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.vcloud.domain.Catalog; -import org.jclouds.vcloud.domain.ReferenceType; -import org.jclouds.vcloud.domain.Task; -import org.jclouds.vcloud.domain.internal.CatalogImpl; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code CatalogHandler} - */ -@Test(groups = "unit") -public class CatalogHandlerTest { - - private Injector injector; - - private Factory factory; - - public void testVCloud1_0() { - InputStream is = getClass().getResourceAsStream("/catalog-blank.xml"); - injector = Guice.createInjector(new SaxParserModule()); - factory = injector.getInstance(ParseSax.Factory.class); - Catalog result = factory.create(injector.getInstance(CatalogHandler.class)).parse(is); - assertEquals(result, new CatalogImpl("Jclouds-private", "application/vnd.vmware.vcloud.catalog+xml", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/catalog/921222081"), new ReferenceTypeImpl(null, - "application/vnd.vmware.vcloud.org+xml", URI - .create("https://vcenterprise.bluelock.com/api/v1.0/org/9566014")), null, ImmutableMap - .<String, ReferenceType> of(), ImmutableList.<Task> of(), false, false)); - } - - public void testTerremark() { - InputStream is = getClass().getResourceAsStream("/catalog.xml"); - injector = Guice.createInjector(new SaxParserModule()); - factory = injector.getInstance(ParseSax.Factory.class); - Catalog result = factory.create(injector.getInstance(CatalogHandler.class)).parse(is); - assertEquals(result.getName(), "Miami Environment 1"); - assert result.getDescription() == null; - - assertEquals(result.getHref(), URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/vdc/32/catalog")); - assertEquals(result.get("CentOS 5.3 (32-bit)"), new ReferenceTypeImpl("CentOS 5.3 (32-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/5"))); - assertEquals(result.get("CentOS 5.3 (64-bit)"), new ReferenceTypeImpl("CentOS 5.3 (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/6"))); - assertEquals(result.get("RHEL 5.3 (32-bit)"), new ReferenceTypeImpl("RHEL 5.3 (32-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/7"))); - assertEquals(result.get("RHEL 5.3 (64-bit)"), new ReferenceTypeImpl("RHEL 5.3 (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/8"))); - assertEquals(result.get("Ubuntu JeOS 9.04 (32-bit)"), new ReferenceTypeImpl("Ubuntu JeOS 9.04 (32-bit)", - CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/11"))); - assertEquals(result.get("Ubuntu JeOS 9.04 (64-bit)"), new ReferenceTypeImpl("Ubuntu JeOS 9.04 (64-bit)", - CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/12"))); - assertEquals(result.get("Ubuntu Server 9.04 (32-bit)"), new ReferenceTypeImpl("Ubuntu Server 9.04 (32-bit)", - CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/9"))); - assertEquals(result.get("Ubuntu Server 9.04 (64-bit)"), new ReferenceTypeImpl("Ubuntu Server 9.04 (64-bit)", - CATALOGITEM_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/10"))); - assertEquals(result.get("Windows 2003 Enterprise R2 (32-bit)"), new ReferenceTypeImpl( - "Windows 2003 Enterprise R2 (32-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/1"))); - assertEquals(result.get("Windows 2003 Enterprise R2 (64-bit)"), new ReferenceTypeImpl( - "Windows 2003 Enterprise R2 (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/2"))); - assertEquals(result.get("Windows 2003 Standard R2 (32-bit)"), new ReferenceTypeImpl( - "Windows 2003 Standard R2 (32-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/3"))); - assertEquals(result.get("Windows 2003 Standard R2 (64-bit)"), new ReferenceTypeImpl( - "Windows 2003 Standard R2 (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/4"))); - assertEquals(result.get("Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)"), new ReferenceTypeImpl( - "Windows 2003 Standard R2 w.SQL 2008 Web (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/23"))); - assertEquals(result.get("Windows Server 2008 Enterprise (32-bit)"), new ReferenceTypeImpl( - "Windows Server 2008 Enterprise (32-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/13"))); - assertEquals(result.get("Windows Server 2008 Enterprise (64-bit)"), new ReferenceTypeImpl( - "Windows Server 2008 Enterprise (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/15"))); - assertEquals(result.get("Windows Server 2008 Enterprise R2 (64-bit)"), new ReferenceTypeImpl( - "Windows Server 2008 Enterprise R2 (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/16"))); - assertEquals(result.get("Windows Server 2008 Standard (32-bit)"), new ReferenceTypeImpl( - "Windows Server 2008 Standard (32-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/17"))); - assertEquals(result.get("Windows Server 2008 Standard (64-bit)"), new ReferenceTypeImpl( - "Windows Server 2008 Standard (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/18"))); - assertEquals(result.get("Windows Server 2008 Standard R2 (64-bit)"), new ReferenceTypeImpl( - "Windows Server 2008 Standard R2 (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/19"))); - assertEquals(result.get("Windows Server 2008 Standard w.SQL 2008 Web (64-bit)"), new ReferenceTypeImpl( - "Windows Server 2008 Standard w.SQL 2008 Web (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/14"))); - assertEquals(result.get("Windows Web Server 2008 (32-bit)"), new ReferenceTypeImpl( - "Windows Web Server 2008 (32-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/20"))); - assertEquals(result.get("Windows Web Server 2008 (64-bit)"), new ReferenceTypeImpl( - "Windows Web Server 2008 (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/21"))); - assertEquals(result.get("Windows Web Server 2008 R2 (64-bit)"), new ReferenceTypeImpl( - "Windows Web Server 2008 R2 (64-bit)", CATALOGITEM_XML, URI - .create("https://services.vcloudexpress.terremark.com/api/v0.8/catalogItem/22"))); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogItemHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogItemHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogItemHandlerTest.java deleted file mode 100644 index 6f2b100..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/CatalogItemHandlerTest.java +++ /dev/null @@ -1,84 +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.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; - -import org.jclouds.http.functions.ParseSax; -import org.jclouds.http.functions.ParseSax.Factory; -import org.jclouds.http.functions.config.SaxParserModule; -import org.jclouds.vcloud.domain.CatalogItem; -import org.jclouds.vcloud.domain.internal.CatalogItemImpl; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.testng.annotations.Test; - -import com.google.common.collect.ImmutableSortedMap; -import com.google.inject.Guice; -import com.google.inject.Injector; - -/** - * Tests behavior of {@code CatalogItemHandler} - */ -@Test(groups = "unit") -public class CatalogItemHandlerTest { - - public void testApplyInputStream() { - InputStream is = getClass().getResourceAsStream("/catalogItem-hosting.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - CatalogItem result = factory.create(injector.getInstance(CatalogItemHandler.class)).parse(is); - - assertEquals(result, new CatalogItemImpl("Windows 2008 Datacenter 64 Bit", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/catalogItem/2"), "Windows 2008 Datacenter 64 Bit", - new ReferenceTypeImpl("Windows 2008 Datacenter 64 Bit", - "application/vnd.vmware.vcloud.vAppTemplate+xml", URI - .create("https://vcloud.safesecureweb.com/api/v0.8/vAppTemplate/2")), - ImmutableSortedMap.of("Foo", "Bar", "Hello", "World" - - ))); - - } - - public void testApplyInputStreamWithNamespaceUsingVcloud() { - InputStream is = getClass().getResourceAsStream("/catalogItem-carrenza-with-vcloud-namespace.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - CatalogItem result = factory.create(injector.getInstance(CatalogItemHandler.class)).parse(is); - - assertEquals(result, new CatalogItemImpl("ubuntu10.10x64", - URI.create("https://myvdc.carrenza.net/api/v1.0/catalogItem/ecd4d3a0-0d12-4195-a6d2-14cdf9f925a3"), - null, new ReferenceTypeImpl("ubuntu10.10x64", "application/vnd.vmware.vcloud.vAppTemplate+xml", - URI.create("https://myvdc.carrenza.net/api/v1.0/vAppTemplate/vappTemplate-123766ea-2b55-482c-8adf-735ab1952834")), - ImmutableSortedMap.<String, String>of())); - } - - public void testApplyInputStreamWithNamespaceUsingDefault() { - InputStream is = getClass().getResourceAsStream("/catalogItem-carrenza-with-default-namespace.xml"); - Injector injector = Guice.createInjector(new SaxParserModule()); - Factory factory = injector.getInstance(ParseSax.Factory.class); - CatalogItem result = factory.create(injector.getInstance(CatalogItemHandler.class)).parse(is); - - assertEquals(result, new CatalogItemImpl("ubuntu10.10x64", - URI.create("https://myvdc.carrenza.net/api/v1.0/catalogItem/ecd4d3a0-0d12-4195-a6d2-14cdf9f925a3"), - null, new ReferenceTypeImpl("ubuntu10.10x64", "application/vnd.vmware.vcloud.vAppTemplate+xml", - URI.create("https://myvdc.carrenza.net/api/v1.0/vAppTemplate/vappTemplate-123766ea-2b55-482c-8adf-735ab1952834")), - ImmutableSortedMap.<String, String>of())); - } -} http://git-wip-us.apache.org/repos/asf/stratos/blob/295c545c/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandlerTest.java ---------------------------------------------------------------------- diff --git a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandlerTest.java b/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandlerTest.java deleted file mode 100644 index 503611e..0000000 --- a/dependencies/jclouds/apis/vcloud/1.8.1-stratos/src/test/java/org/jclouds/vcloud/xml/GuestCustomizationSectionHandlerTest.java +++ /dev/null @@ -1,73 +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.xml; - -import static org.testng.Assert.assertEquals; - -import java.io.InputStream; -import java.net.URI; -import java.net.UnknownHostException; - -import org.jclouds.http.functions.BaseHandlerTest; -import org.jclouds.vcloud.VCloudMediaType; -import org.jclouds.vcloud.domain.GuestCustomizationSection; -import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl; -import org.testng.annotations.Test; - -/** - * Tests behavior of {@code GuestCustomizationSectionHandler} - */ -// NOTE:without testName, this will not call @Before* and fail w/NPE during surefire -@Test(groups = "unit", testName = "GuestCustomizationSectionHandlerTest") -public class GuestCustomizationSectionHandlerTest extends BaseHandlerTest { - - public void testDefault() throws UnknownHostException { - InputStream is = getClass().getResourceAsStream("/guestCustomization.xml"); - - GuestCustomizationSection result = factory.create(injector.getInstance(GuestCustomizationSectionHandler.class)) - .parse(is); - - checkGuestCustomization(result); - - } - - @Test(enabled = false) - public static void checkGuestCustomization(GuestCustomizationSection result) { - assertEquals(result.getType(), VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML); - assertEquals(result.getHref(), - URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/guestCustomizationSection/")); - assertEquals(result.getInfo(), "Specifies Guest OS Customization Settings"); - assertEquals(result.isEnabled(), Boolean.TRUE); - assertEquals(result.shouldChangeSid(), Boolean.FALSE); - assertEquals(result.getVirtualMachineId(), "2087535248"); - assertEquals(result.isJoinDomainEnabled(), Boolean.FALSE); - assertEquals(result.useOrgSettings(), Boolean.FALSE); - assertEquals(result.getDomainName(), null); - assertEquals(result.getDomainUserName(), null); - assertEquals(result.getDomainUserPassword(), null); - assertEquals(result.isAdminPasswordEnabled(), Boolean.TRUE); - assertEquals(result.isAdminPasswordAuto(), Boolean.TRUE); - assertEquals(result.getAdminPassword(), null); - assertEquals(result.isResetPasswordRequired(), Boolean.FALSE); - assertEquals(result.getCustomizationScript(), "cat > /root/foo.txt<<EOF\nI '\"love\"' {asc|!}*&\nEOF\n"); - assertEquals(result.getComputerName(), "RHEL5"); - assertEquals( - result.getEdit(), - new ReferenceTypeImpl(null, VCloudMediaType.GUESTCUSTOMIZATIONSECTION_XML, URI - .create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vm-2087535248/guestCustomizationSection/"))); - } -}
