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/10/05 01:28:44 UTC
[3/7] Remove savvis-symphonyvpdc,
which hasn't been published in over a year.
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b91fd46c/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingApiLiveTest.java
----------------------------------------------------------------------
diff --git a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingApiLiveTest.java b/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingApiLiveTest.java
deleted file mode 100644
index 5456069..0000000
--- a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingApiLiveTest.java
+++ /dev/null
@@ -1,191 +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.savvis.vpdc.features;
-
-import static org.jclouds.savvis.vpdc.options.GetVMOptions.Builder.withPowerState;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-
-import java.util.Iterator;
-import java.util.Set;
-
-import org.jclouds.savvis.vpdc.domain.FirewallRule;
-import org.jclouds.savvis.vpdc.domain.FirewallService;
-import org.jclouds.savvis.vpdc.domain.Network;
-import org.jclouds.savvis.vpdc.domain.NetworkConnectionSection;
-import org.jclouds.savvis.vpdc.domain.Org;
-import org.jclouds.savvis.vpdc.domain.Resource;
-import org.jclouds.savvis.vpdc.domain.VDC;
-import org.jclouds.savvis.vpdc.domain.VM;
-import org.jclouds.savvis.vpdc.reference.VCloudMediaType;
-import org.jclouds.util.InetAddresses2;
-import org.testng.annotations.BeforeGroups;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-import com.google.common.net.HostSpecifier;
-
-@Test(groups = "live")
-public class BrowsingApiLiveTest extends BaseVPDCApiLiveTest {
-
- private BrowsingApi api;
-
- @Override
- @BeforeGroups(groups = { "live" })
- public void setupContext() {
- super.setupContext();
- api = restContext.getApi().getBrowsingApi();
- }
-
- @Test
- public void testOrg() throws Exception {
- for (Resource org : restContext.getApi().listOrgs()) {
- Org response = api.getOrg(org.getId());
-
- assertNotNull(response);
- assertNotNull(response.getId());
- assertNotNull(response.getHref());
- assertNotNull(response.getName());
- // savvis leaves this null for some reason
- assertEquals(response.getType(), null);
- assert response.getImages().size() >= 0;
- assert response.getDescription() != null;
- assert response.getVDCs().size() >= 0;
- assertEquals(api.getOrg(response.getId()).toString(), response.toString());
- }
- }
-
- @Test
- public void testVDC() throws Exception {
- for (Resource org1 : restContext.getApi().listOrgs()) {
- Org org = api.getOrg(org1.getId());
- for (Resource vdc : org.getVDCs()) {
- VDC response = api.getVDCInOrg(org.getId(), vdc.getId());
- assertNotNull(response);
- assertNotNull(response.getId());
- assertNotNull(response.getHref());
- assertNotNull(response.getName());
- assertNotNull(response.getStatus());
- assertEquals(response.getType(), "application/vnd.vmware.vcloud.vdc+xml");
- assertNotNull(response.getDescription());
- assertNotNull(response.getResourceEntities());
- assertNotNull(response.getAvailableNetworks());
- assertEquals(api.getVDCInOrg(org.getId(), response.getId()).toString(), response.toString());
- }
- }
- }
-
- @Test
- public void testNetwork() throws Exception {
- for (Resource org1 : restContext.getApi().listOrgs()) {
- Org org = api.getOrg(org1.getId());
- for (Resource vdc : org.getVDCs()) {
- VDC VDC = api.getVDCInOrg(org.getId(), vdc.getId());
- for (Resource vApp : VDC.getAvailableNetworks()) {
- Network response = api.getNetworkInVDC(org.getId(), vdc.getId(), vApp.getId());
- assertNotNull(response);
- assertNotNull(response.getId());
- assertNotNull(response.getHref());
- assertNotNull(response.getName());
- assertEquals(response.getType(), VCloudMediaType.NETWORK_XML);
- assertNotNull(response.getNetmask());
- assertNotNull(response.getGateway());
- assertNotNull(response.getInternalToExternalNATRules());
- assertEquals(api.getNetworkInVDC(org.getId(), vdc.getId(), response.getId()).toString(), response
- .toString());
- }
- }
- }
- }
-
- // test for a single vm, as savvis response times are very slow. So if there are multiple vpdc's with numerous vm's,
- // test execution will invariably take a long time
- @Test
- public void testVM() throws Exception {
- for (Resource org1 : restContext.getApi().listOrgs()) {
- Org org = api.getOrg(org1.getId());
- VDC_LOOP : for (Resource vdc : org.getVDCs()) {
- VDC VDC = api.getVDCInOrg(org.getId(), vdc.getId());
- for (Resource vApp : Iterables.filter(VDC.getResourceEntities(), new Predicate<Resource>() {
-
- @Override
- public boolean apply(Resource arg0) {
- return VCloudMediaType.VAPP_XML.equals(arg0.getType());
- }
-
- })) {
- VM response = api.getVMInVDC(org.getId(), vdc.getId(), vApp.getId());
- assertNotNull(response);
- assertNotNull(response.getId());
- assertNotNull(response.getHref());
- assertNotNull(response.getName());
- assertEquals(response.getType(), "application/vnd.vmware.vcloud.vApp+xml");
- assert (response.getNetworkConnectionSections().size() > 0) : response;
- for (NetworkConnectionSection networkConnection : response.getNetworkConnectionSections())
- assertNotNull(networkConnection.getIpAddress());
- assertNotNull(response.getStatus());
- assertNotNull(response.getOperatingSystemSection().getDescription());
- assertNotNull(response.getOperatingSystemSection().getId());
- assertNotNull(response.getNetworkSection());
- assertNotNull(response.getVirtualHardwareSections());
- // power state is the only thing that should change
- assertEquals(api.getVMInVDC(org.getId(), vdc.getId(), response.getId(), withPowerState()).toString()
- .replaceFirst("status=[A-Z]+", ""), response.toString().replaceFirst("status=[A-Z]+", ""));
-
- // check one ip is valid
- String ip = Iterables.get(response.getNetworkConnectionSections(), 0).getIpAddress();
- assert HostSpecifier.isValid(ip) : response;
- if (InetAddresses2.isPrivateIPAddress(ip)) {
- // get public ip
- ip = Iterables.get(response.getNetworkConfigSections(), 0).getInternalToExternalNATRules().get(ip);
- // could be null
- if (ip != null){
- assert HostSpecifier.isValid(ip) : response;
- }
- }
- break VDC_LOOP;
- }
- }
- }
- }
-
- @Test
- public void testGetFirewallRules() throws Exception {
- for (Resource org1 : restContext.getApi().listOrgs()) {
- Org org = api.getOrg(org1.getId());
- for (Resource vdc : org.getVDCs()) {
- FirewallService response = api.listFirewallRules(org.getId(), vdc.getId());
- Set<FirewallRule> firewallRules = response.getFirewallRules();
- if (firewallRules != null) {
- Iterator<FirewallRule> iter = firewallRules.iterator();
- while (iter.hasNext()) {
- FirewallRule firewallRule = iter.next();
- assertNotNull(firewallRule);
- // these are null for firewall rules
- assertEquals(response.getHref(), null);
- assertEquals(response.getType(), null);
- assertNotNull(firewallRule.getFirewallType());
- assertNotNull(firewallRule.getProtocol());
- assertNotNull(firewallRule.getSource());
- assertNotNull(firewallRule.getDestination());
- }
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b91fd46c/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncApiTest.java
----------------------------------------------------------------------
diff --git a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncApiTest.java b/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncApiTest.java
deleted file mode 100644
index b38e667..0000000
--- a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/BrowsingAsyncApiTest.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.savvis.vpdc.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.rest.internal.GeneratedHttpRequest;
-import org.jclouds.savvis.vpdc.options.GetVMOptions;
-import org.jclouds.savvis.vpdc.xml.FirewallServiceHandler;
-import org.jclouds.savvis.vpdc.xml.NetworkHandler;
-import org.jclouds.savvis.vpdc.xml.OrgHandler;
-import org.jclouds.savvis.vpdc.xml.TaskHandler;
-import org.jclouds.savvis.vpdc.xml.VDCHandler;
-import org.jclouds.savvis.vpdc.xml.VMHandler;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-import com.google.common.reflect.Invokable;
-
-/**
- * Tests annotation parsing of {@code BrowsingAsyncApi}
- */
-@Test(groups = "unit", testName = "BrowsingAsyncApiTest")
-public class BrowsingAsyncApiTest extends BaseVPDCAsyncApiTest<BrowsingAsyncApi> {
-
- public void testOrg() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(BrowsingAsyncApi.class, "getOrg", String.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("11"));
-
- assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/11 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, OrgHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testOrgNull() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(BrowsingAsyncApi.class, "getOrg", String.class);
- GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null));
-
- assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, OrgHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testVDC() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(BrowsingAsyncApi.class, "getVDCInOrg", String.class, String.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("11", "22"));
-
- assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/11/vdc/22 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, VDCHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testVDCWhenOrgNull() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(BrowsingAsyncApi.class, "getVDCInOrg", String.class, String.class);
- GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null, "22"));
-
- assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/1/vdc/22 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, VDCHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testNetwork() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(BrowsingAsyncApi.class, "getNetworkInVDC", String.class, String.class, String.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("11", "22", "VM-Tier01"));
-
- assertRequestLineEquals(request,
- "GET https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/network/VM-Tier01 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, NetworkHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testNetworkWhenOrgNull() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(BrowsingAsyncApi.class, "getNetworkInVDC", String.class, String.class, String.class);
- GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null, "22", "VM-Tier01"));
-
- assertRequestLineEquals(request,
- "GET https://api.savvis.net/vpdc/v1.0/org/1/vdc/22/network/VM-Tier01 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, NetworkHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testVMVDC() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(BrowsingAsyncApi.class, "getVMInVDC", String.class, String.class, String.class,
- GetVMOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("11", "22", "33"));
-
- assertRequestLineEquals(request,
- "GET https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, VMHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testVM() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(BrowsingAsyncApi.class, "getVM", URI.class, GetVMOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33")));
-
- assertRequestLineEquals(request,
- "GET https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, VMHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testVMWithPowerState() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(BrowsingAsyncApi.class, "getVMInVDC", String.class, String.class, String.class,
- GetVMOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("11", "22", "VM-Tier01", GetVMOptions.Builder
- .withPowerState()));
-
- assertRequestLineEquals(request,
- "GET https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/VM-Tier01/withpowerstate HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, VMHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testVMWhenOrgNull() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(BrowsingAsyncApi.class, "getVMInVDC", String.class, String.class, String.class,
- GetVMOptions[].class);
- GeneratedHttpRequest request = processor.createRequest(method, Lists.<Object> newArrayList((String) null, "22", "VM-Tier01"));
-
- assertRequestLineEquals(request,
- "GET https://api.savvis.net/vpdc/v1.0/org/1/vdc/22/vApp/VM-Tier01 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, VMHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testGetTask() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(BrowsingAsyncApi.class, "getTask", String.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("1"));
-
- assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/task/1 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testListFirewallRules() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(BrowsingAsyncApi.class, "listFirewallRules", String.class, String.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("11", "22"));
-
- assertRequestLineEquals(request,
- "GET https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/FirewallService HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, FirewallServiceHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b91fd46c/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallApiLiveTest.java
----------------------------------------------------------------------
diff --git a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallApiLiveTest.java b/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallApiLiveTest.java
deleted file mode 100644
index 6c829ca..0000000
--- a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallApiLiveTest.java
+++ /dev/null
@@ -1,110 +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.savvis.vpdc.features;
-
-import org.jclouds.savvis.vpdc.domain.FirewallRule;
-import org.jclouds.savvis.vpdc.domain.Resource;
-import org.jclouds.savvis.vpdc.domain.Task;
-import org.testng.annotations.BeforeGroups;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
-public class FirewallApiLiveTest extends BaseVPDCApiLiveTest {
-
- private FirewallApi api;
- private String billingSiteId;
- private String vpdcId;
-
- @Override
- @BeforeGroups(groups = { "live" })
- public void setupContext() {
- super.setupContext();
- api = restContext.getApi().getFirewallApi();
- }
-
- @Test(groups = "live")
- public void testAddFirewallRule() throws Exception {
- billingSiteId = restContext.getApi().getBrowsingApi().getOrg(null).getId();// default
- vpdcId = Iterables.find(restContext.getApi().getBrowsingApi().getOrg(billingSiteId).getVDCs(),
- new Predicate<Resource>() {
-
- // try to find the first VDC owned by the current user
- // check here for what the email property might be, or in
- // the jclouds-wire.log
- @Override
- public boolean apply(Resource arg0) {
- String description = restContext.getApi().getBrowsingApi().getVDCInOrg(billingSiteId,
- arg0.getId()).getDescription();
- return description.indexOf(email) != -1;
- }
-
- }).getId();
-
- String networkTierName = Iterables.get(
- restContext.getApi().getBrowsingApi().getVDCInOrg(billingSiteId, vpdcId).getAvailableNetworks(), 0)
- .getName();
-
- FirewallRule firewallRule = FirewallRule.builder().firewallType("SERVER_TIER_FIREWALL").isEnabled(true).source("internet")
- .destination(networkTierName).port("10000").protocol("Tcp").policy("allow").description("Server Tier Firewall Rule").isLogged(false).build();
-
- System.out.printf("adding firewall rule:%s in vpdc %s %n", firewallRule.toString(), vpdcId);
-
- Task task = api.addFirewallRule(billingSiteId, vpdcId, firewallRule);
-
- // make sure there's no error
- assert task.getId() != null && task.getError() == null : task;
-
- assert this.taskTester.apply(task.getId());
- }
-
- @Test(groups = "live", dependsOnMethods = {"testAddFirewallRule"})
- public void testDeleteFirewallRule() throws Exception {
- billingSiteId = restContext.getApi().getBrowsingApi().getOrg(null).getId();// default
- vpdcId = Iterables.find(restContext.getApi().getBrowsingApi().getOrg(billingSiteId).getVDCs(),
- new Predicate<Resource>() {
-
- // try to find the first VDC owned by the current user
- // check here for what the email property might be, or in
- // the jclouds-wire.log
- @Override
- public boolean apply(Resource arg0) {
- String description = restContext.getApi().getBrowsingApi().getVDCInOrg(billingSiteId,
- arg0.getId()).getDescription();
- return description.indexOf(email) != -1;
- }
-
- }).getId();
-
- String networkTierName = Iterables.get(
- restContext.getApi().getBrowsingApi().getVDCInOrg(billingSiteId, vpdcId).getAvailableNetworks(), 0)
- .getName();
-
- FirewallRule firewallRule = FirewallRule.builder().firewallType("SERVER_TIER_FIREWALL").isEnabled(true).source("internet")
- .destination(networkTierName).port("10000").protocol("Tcp").policy("allow").description("Server Tier Firewall Rule").isLogged(false).build();
-
- System.out.printf("deleting firewall rule:%s in vpdc %s %n", firewallRule.toString(), vpdcId);
-
- Task task = api.deleteFirewallRule(billingSiteId, vpdcId, firewallRule);
-
- // make sure there's no error
- assert task.getId() != null && task.getError() == null : task;
-
- assert this.taskTester.apply(task.getId());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b91fd46c/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallAsyncApiTest.java
----------------------------------------------------------------------
diff --git a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallAsyncApiTest.java b/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallAsyncApiTest.java
deleted file mode 100644
index 0fe40e7..0000000
--- a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/FirewallAsyncApiTest.java
+++ /dev/null
@@ -1,77 +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.savvis.vpdc.features;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.jclouds.savvis.vpdc.domain.FirewallRule;
-import org.jclouds.savvis.vpdc.xml.TaskHandler;
-import org.jclouds.util.Strings2;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.reflect.Invokable;
-/**
- * Tests annotation parsing of {@code FirewallAsyncApi}
- */
-@Test(groups = "unit")
-public class FirewallAsyncApiTest extends BaseVPDCAsyncApiTest<FirewallAsyncApi> {
-
- public void testAddFirewallRule() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(FirewallAsyncApi.class, "addFirewallRule", String.class, String.class,
- FirewallRule.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("11", "22", FirewallRule.builder().firewallType(
- "SERVER_TIER_FIREWALL").isEnabled(true).source("internet").destination("VM Tier01").port("22").protocol(
- "Tcp").policy("allow").description("Server Tier Firewall Rule").isLogged(false).build()));
-
- assertRequestLineEquals(request,
- "PUT https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/FirewallService HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
- "/firewallService-default.xml")), "application/xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
-
- checkFilters(request);
- }
-
- public void testDeleteFirewallRule() throws NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(FirewallAsyncApi.class, "deleteFirewallRule", String.class, String.class,
- FirewallRule.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("11", "22", FirewallRule.builder().firewallType(
- "SERVER_TIER_FIREWALL").isEnabled(true).source("internet").destination("VM Tier01").port("22").protocol(
- "Tcp").policy("allow").description("Server Tier Firewall Rule").isLogged(false).build()));
-
- assertRequestLineEquals(request,
- "DELETE https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/FirewallService HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream(
- "/firewallService-default.xml")), "application/xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b91fd46c/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementApiLiveTest.java
----------------------------------------------------------------------
diff --git a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementApiLiveTest.java b/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementApiLiveTest.java
deleted file mode 100644
index e902673..0000000
--- a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementApiLiveTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.savvis.vpdc.features;
-
-import static org.jclouds.savvis.vpdc.options.GetVMOptions.Builder.withPowerState;
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
-
-import org.jclouds.savvis.vpdc.domain.Org;
-import org.jclouds.savvis.vpdc.domain.Resource;
-import org.jclouds.savvis.vpdc.domain.Task;
-import org.jclouds.savvis.vpdc.domain.VDC;
-import org.jclouds.savvis.vpdc.domain.VM;
-import org.jclouds.savvis.vpdc.reference.VCloudMediaType;
-import org.testng.annotations.BeforeGroups;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-
-@Test(groups = "live")
-public class ServiceManagementApiLiveTest extends BaseVPDCApiLiveTest {
-
- private ServiceManagementApi api;
-
- @Override
- @BeforeGroups(groups = { "live" })
- public void setupContext() {
- super.setupContext();
- api = restContext.getApi().getServiceManagementApi();
- }
-
- // test for a single vm, as savvis response times are very slow. So if there are multiple vpdc's with numerous vm's,
- // test execution will invariably take a long time
- public void testLifeCycle() throws InterruptedException, ExecutionException, TimeoutException, IOException {
- for (Resource org1 : restContext.getApi().listOrgs()) {
- Org org = restContext.getApi().getBrowsingApi().getOrg(org1.getId());
- VDC_LOOP : for (Resource vdc : org.getVDCs()) {
- VDC VDC = restContext.getApi().getBrowsingApi().getVDCInOrg(org.getId(), vdc.getId());
- for (Resource vmHandle : Iterables.filter(VDC.getResourceEntities(), new Predicate<Resource>() {
-
- @Override
- public boolean apply(Resource arg0) {
- return VCloudMediaType.VAPP_XML.equals(arg0.getType());
- }
-
- })) {
-
- Task powerOffTask = api.powerOffVM(vmHandle.getHref());
- assert taskTester.apply(powerOffTask.getId());
-
- VM vm = restContext.getApi().getBrowsingApi().getVM(vmHandle.getHref(), withPowerState());
- assertEquals(vm.getStatus(), VM.Status.OFF);
-
- Task powerOnTask = api.powerOnVM(vmHandle.getHref());
- assert taskTester.apply(powerOnTask.getId());
-
- vm = restContext.getApi().getBrowsingApi().getVM(vmHandle.getHref(), withPowerState());
-
- assertEquals(vm.getStatus(), VM.Status.ON);
-
- break VDC_LOOP;
- }
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b91fd46c/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementAsyncApiTest.java
----------------------------------------------------------------------
diff --git a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementAsyncApiTest.java b/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementAsyncApiTest.java
deleted file mode 100644
index fb0faf2..0000000
--- a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/ServiceManagementAsyncApiTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.savvis.vpdc.features;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-import java.net.URI;
-
-import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.jclouds.savvis.vpdc.xml.TaskHandler;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.reflect.Invokable;
-/**
- * Tests annotation parsing of {@code ServiceManagementAsyncApi}
- */
-@Test(groups = "unit")
-public class ServiceManagementAsyncApiTest extends BaseVPDCAsyncApiTest<ServiceManagementAsyncApi> {
-
- public void testPowerOnVMVDC() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ServiceManagementAsyncApi.class, "powerOnVMInVDC", String.class, String.class,
- String.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("11", "22", "33"));
-
- assertRequestLineEquals(request,
- "POST https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33/action/powerOn HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(request);
- }
-
- public void testPowerOnVM() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ServiceManagementAsyncApi.class, "powerOnVM", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33")));
-
- assertRequestLineEquals(request,
- "POST https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33/action/powerOn HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(request);
- }
-
- public void testPowerOffVMVDC() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ServiceManagementAsyncApi.class, "powerOffVMInVDC", String.class, String.class,
- String.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("11", "22", "33"));
-
- assertRequestLineEquals(request,
- "POST https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33/action/powerOff HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(request);
- }
-
- public void testPowerOffVM() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(ServiceManagementAsyncApi.class, "powerOffVM", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33")));
-
- assertRequestLineEquals(request,
- "POST https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33/action/powerOff HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(request);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b91fd46c/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMApiLiveTest.java
----------------------------------------------------------------------
diff --git a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMApiLiveTest.java b/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMApiLiveTest.java
deleted file mode 100644
index 2139d23..0000000
--- a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMApiLiveTest.java
+++ /dev/null
@@ -1,301 +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.savvis.vpdc.features;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.jclouds.util.Predicates2.retry;
-import static org.testng.Assert.assertEquals;
-
-import java.util.Set;
-
-import org.jclouds.cim.OSType;
-import org.jclouds.compute.domain.CIMOperatingSystem;
-import org.jclouds.compute.domain.ExecResponse;
-import org.jclouds.domain.LoginCredentials;
-import org.jclouds.predicates.SocketOpen;
-import org.jclouds.savvis.vpdc.domain.Network;
-import org.jclouds.savvis.vpdc.domain.Resource;
-import org.jclouds.savvis.vpdc.domain.Task;
-import org.jclouds.savvis.vpdc.domain.VDC;
-import org.jclouds.savvis.vpdc.domain.VM;
-import org.jclouds.savvis.vpdc.domain.VMSpec;
-import org.jclouds.savvis.vpdc.options.GetVMOptions;
-import org.jclouds.savvis.vpdc.reference.VCloudMediaType;
-import org.jclouds.ssh.SshClient;
-import org.testng.annotations.AfterGroups;
-import org.testng.annotations.BeforeGroups;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.ImmutableSet.Builder;
-import com.google.common.collect.Iterables;
-import com.google.common.net.HostAndPort;
-
-@Test(groups = "live")
-public class VMApiLiveTest extends BaseVPDCApiLiveTest {
-
- private VMApi api;
- private VM vm;
- private Predicate<HostAndPort> socketTester;
-
- private String username = checkNotNull(System.getProperty("test." + provider + ".loginUser"), "test." + provider
- + ".loginUser");
- private String password = checkNotNull(System.getProperty("test." + provider + ".loginPassword"), "test." + provider
- + ".loginPassword");
-
- @Override
- @BeforeGroups(groups = { "live" })
- public void setupContext() {
- super.setupContext();
- api = restContext.getApi().getVMApi();
- SocketOpen socketOpen = context.utils().injector().getInstance(SocketOpen.class);
- socketTester = retry(socketOpen, 130, 10, SECONDS);// make
- }
-
- private String billingSiteId;
- private String vpdcId;
-
- public void testCreateVirtualMachine() throws Exception {
- billingSiteId = restContext.getApi().getBrowsingApi().getOrg(null).getId();// default
- vpdcId = Iterables.find(restContext.getApi().getBrowsingApi().getOrg(billingSiteId).getVDCs(),
- new Predicate<Resource>() {
-
- // try to find the first VDC owned by the current user
- // check here for what the email property might be, or in
- // the jclouds-wire.log
- @Override
- public boolean apply(Resource arg0) {
- String description = restContext.getApi().getBrowsingApi().getVDCInOrg(billingSiteId,
- arg0.getId()).getDescription();
- return description.indexOf(email) != -1;
- }
-
- }).getId();
-
- String networkTierName = Iterables.get(
- restContext.getApi().getBrowsingApi().getVDCInOrg(billingSiteId, vpdcId).getAvailableNetworks(), 0)
- .getName();
- String name = prefix;
-
- VDC vpdc = restContext.getApi().getBrowsingApi().getVDCInOrg(billingSiteId, vpdcId);
-
- CIMOperatingSystem os = Iterables.find(restContext.getApi().listPredefinedOperatingSystems(),
- new Predicate<CIMOperatingSystem>() {
-
- @Override
- public boolean apply(CIMOperatingSystem arg0) {
- return arg0.getOsType() == OSType.RHEL_64;
- }
-
- });
- System.out.printf("Creating vm - vpdcId %s, vpdcName %s, networkName %s, name %s, os %s%n", vpdcId, vpdc.getName(), networkTierName, name, os);
-
- // TODO: determine the sizes available in the VDC, for example there's
- // a minimum size of boot disk, and also a preset combination of cpu count vs ram
- Task task = api.addVMIntoVDC(billingSiteId, vpdcId, VMSpec.builder().name(name).networkTierName(
- networkTierName).operatingSystem(os).memoryInGig(2).addDataDrive("/data01", 25).build());
-
- // make sure there's no error
- assert task.getId() != null && task.getError() == null : task;
-
- assert this.taskTester.apply(task.getId());
-
- // fetch the task again, in savvis, task.getOwner is populated with vApp after task has finished
- task = restContext.getApi().getBrowsingApi().getTask(task.getId());
-
- vm = restContext.getApi().getBrowsingApi().getVM(task.getOwner().getHref(), GetVMOptions.NONE);
- assert vm.getHref() != null : vm;
-
- // cannot ssh in savvis, as no public ip is assigned by default
-// conditionallyCheckSSH();
- }
-
- @Test(dependsOnMethods="testCloneVApp")
- public void testZCreateMultipleVMs() throws Exception {
- billingSiteId = restContext.getApi().getBrowsingApi().getOrg(null).getId();// default
- vpdcId = Iterables.find(restContext.getApi().getBrowsingApi().getOrg(billingSiteId).getVDCs(),
- new Predicate<Resource>() {
-
- // try to find the first VDC owned by the current user
- // check here for what the email property might be, or in
- // the jclouds-wire.log
- @Override
- public boolean apply(Resource arg0) {
- String description = restContext.getApi().getBrowsingApi().getVDCInOrg(billingSiteId,
- arg0.getId()).getDescription();
- return description.indexOf(email) != -1;
- }
-
- }).getId();
-
- String networkTierName = Iterables.get(
- restContext.getApi().getBrowsingApi().getVDCInOrg(billingSiteId, vpdcId).getAvailableNetworks(), 0)
- .getId();
- Network networkTier = restContext.getApi().getBrowsingApi().getNetworkInVDC(billingSiteId, vpdcId,
- networkTierName);
-
- String name = prefix;
-
- // delete any old VM
- VDC vpdc = restContext.getApi().getBrowsingApi().getVDCInOrg(billingSiteId, vpdcId);
- CIMOperatingSystem os = Iterables.find(restContext.getApi().listPredefinedOperatingSystems(),
- new Predicate<CIMOperatingSystem>() {
-
- @Override
- public boolean apply(CIMOperatingSystem arg0) {
- return arg0.getOsType() == OSType.RHEL_64;
- }
-
- });
-
- // TODO: Savvis returns network names with a - instead of space on getNetworkInVDC call,
- // fix this once savvis api starts returning correctly
- System.out.printf("Creating vm's - vpdcId %s, vpdcName %s, networkName %s, name %s, os %s%n", vpdcId, vpdc.getName(), networkTier
- .getName().replace("-", " "), name, os);
-
- Builder<VMSpec> vmSpecs = ImmutableSet.builder();
- int noOfVms = 2;
- for (int i = 0; i < noOfVms; i++) {
- // TODO: determine the sizes available in the VDC, for example there's
- // a minimum size of boot disk, and also a preset combination of cpu count vs ram
- VMSpec vmSpec = VMSpec.builder().name(name + i).operatingSystem(os).memoryInGig(2).networkTierName(
- networkTierName).addDataDrive("/data01", 25).build();
- vmSpecs.add(vmSpec);
- }
-
- Set<Task> tasks = api.addMultipleVMsIntoVDC(vpdc.getHref(), vmSpecs.build());
-
- for (Task task : tasks) {
- // make sure there's no error
- assert task.getId() != null && task.getError() == null : task;
- assert this.taskTester.apply(task.getId());
-
- // fetch the task again, in savvis, task.getOwner is populated with vApp after task has finished
- task = restContext.getApi().getBrowsingApi().getTask(task.getId());
-
- VM newVM = restContext.getApi().getBrowsingApi().getVM(task.getOwner().getHref(), GetVMOptions.NONE);
- assert newVM.getHref() != null : newVM;
- }
- }
-
- /**
- * disabled because it not currently supported by savvis. Planned for august release by savvis.
- * @throws Exception
- */
- @Test(enabled=false)
- public void testCaptureVAppTemplate() throws Exception {
- billingSiteId = restContext.getApi().getBrowsingApi().getOrg(null).getId();// default
- vpdcId = Iterables.find(restContext.getApi().getBrowsingApi().getOrg(billingSiteId).getVDCs(),
- new Predicate<Resource>() {
-
- // try to find the first VDC owned by the current user
- // check here for what the email property might be, or in
- // the jclouds-wire.log
- @Override
- public boolean apply(Resource arg0) {
- String description = restContext.getApi().getBrowsingApi().getVDCInOrg(billingSiteId,
- arg0.getId()).getDescription();
- return description.indexOf(email) != -1;
- }
-
- }).getId();
-
- VDC vpdc = restContext.getApi().getBrowsingApi().getVDCInOrg(billingSiteId, vpdcId);
-
- for (Resource vApp : Iterables.filter(vpdc.getResourceEntities(), new Predicate<Resource>() {
-
- @Override
- public boolean apply(Resource arg0) {
- return VCloudMediaType.VAPP_XML.equals(arg0.getType());
- }
-
- })) {
-
- System.out.printf("Capturing VAppTemplate for vApp - %s%n", vApp.getName());
- Task task = api.captureVApp(billingSiteId, vpdcId, vApp.getHref());
-
- // make sure there's no error
- assert task.getId() != null && task.getError() == null : task;
-
- assert this.taskTester.apply(task.getId());
- }
- }
-
- @Test(dependsOnMethods="testCreateVirtualMachine")
- public void testCloneVApp() throws Exception {
- billingSiteId = restContext.getApi().getBrowsingApi().getOrg(null).getId();// default
- vpdcId = Iterables.find(restContext.getApi().getBrowsingApi().getOrg(billingSiteId).getVDCs(),
- new Predicate<Resource>() {
-
- // try to find the first VDC owned by the current user
- // check here for what the email property might be, or in
- // the jclouds-wire.log
- @Override
- public boolean apply(Resource arg0) {
- String description = restContext.getApi().getBrowsingApi().getVDCInOrg(billingSiteId,
- arg0.getId()).getDescription();
- return description.indexOf(email) != -1;
- }
-
- }).getId();
-
- String networkTierName = Iterables.get(
- restContext.getApi().getBrowsingApi().getVDCInOrg(billingSiteId, vpdcId).getAvailableNetworks(), 0)
- .getId();
-
- String clonedVMName = vm.getName() + "clone";
-
- System.out.printf("Cloning vm - name %s in vpdcId %s in network %s, newVM name is %s%n", vm.getName(), vpdcId, networkTierName, clonedVMName);
-
- Task task = api.cloneVApp(vm.getHref(), clonedVMName, networkTierName);
-
- // make sure there's no error
- assert task.getId() != null && task.getError() == null : task;
- assert this.taskTester.apply(task.getId());
-
- // fetch the task again, in savvis, task.getOwner is populated with vApp after task has finished
- task = restContext.getApi().getBrowsingApi().getTask(task.getId());
-
- VM clonedVM = restContext.getApi().getBrowsingApi().getVM(task.getOwner().getHref(), GetVMOptions.NONE);
- assert clonedVM.getHref() != null : clonedVM;
- }
-
- protected void checkSSH(HostAndPort socket) {
- socketTester.apply(socket);
- SshClient api = view.utils().sshFactory()
- .create(socket, LoginCredentials.builder().user(username).password(password).build());
- try {
- api.connect();
- ExecResponse exec = api.exec("echo hello");
- System.out.println(exec);
- assertEquals(exec.getOutput().trim(), "hello");
- } finally {
- if (api != null)
- api.disconnect();
- }
- }
-
- @AfterGroups(groups = "live")
- protected void tearDownContext() {
- if (vm != null) {
- assert taskTester.apply(api.removeVMFromVDC(billingSiteId, vpdcId, vm.getId()).getId()) : vm;
- }
- super.tearDownContext();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b91fd46c/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncApiTest.java
----------------------------------------------------------------------
diff --git a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncApiTest.java b/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncApiTest.java
deleted file mode 100644
index 94487e0..0000000
--- a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/features/VMAsyncApiTest.java
+++ /dev/null
@@ -1,264 +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.savvis.vpdc.features;
-
-import static org.jclouds.reflect.Reflection2.method;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Set;
-
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.cim.OSType;
-import org.jclouds.compute.domain.CIMOperatingSystem;
-import org.jclouds.fallbacks.MapHttp4xxCodesToExceptions;
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.jclouds.savvis.vpdc.domain.VMSpec;
-import org.jclouds.savvis.vpdc.xml.TaskHandler;
-import org.jclouds.savvis.vpdc.xml.TasksListHandler;
-import org.jclouds.util.Strings2;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.reflect.Invokable;
-import com.google.inject.Key;
-import com.google.inject.TypeLiteral;
-/**
- * Tests annotation parsing of {@code VMAsyncApi}
- */
-@Test(groups = "unit")
-public class VMAsyncApiTest extends BaseVPDCAsyncApiTest<VMAsyncApi> {
-
- public void testAddVMIntoVDCURI() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VMAsyncApi.class, "addVMIntoVDC", URI.class, VMSpec.class);
-
- CIMOperatingSystem os = Iterables.find(injector.getInstance(Key.get(new TypeLiteral<Set<CIMOperatingSystem>>() {
- })), new Predicate<CIMOperatingSystem>() {
-
- @Override
- public boolean apply(CIMOperatingSystem arg0) {
- return arg0.getOsType() == OSType.RHEL_64;
- }
-
- });
-
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://api.savvis.net/rest/api/v0.8/org/11/vdc/22"), VMSpec.builder().name(
- "DemoHost-1").networkTierName("VM Tier01").operatingSystem(os).build()));
-
- assertRequestLineEquals(request,
- "GET https://api.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/ HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/vm-default.xml")),
- "application/xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(request);
- }
-
- public void testAddVMIntoVDC() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VMAsyncApi.class, "addVMIntoVDC", String.class, String.class, VMSpec.class);
-
- CIMOperatingSystem os = Iterables.find(injector.getInstance(Key.get(new TypeLiteral<Set<CIMOperatingSystem>>() {
- })), new Predicate<CIMOperatingSystem>() {
-
- @Override
- public boolean apply(CIMOperatingSystem arg0) {
- return arg0.getOsType() == OSType.RHEL_64;
- }
-
- });
-
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("11", "22", VMSpec.builder().operatingSystem(os).name(
- "DemoHost-1").networkTierName("VM Tier01").build()));
-
- assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/ HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/vm-default.xml")),
- "application/xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(request);
- }
-
- public void testCaptureVApp() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VMAsyncApi.class, "captureVApp", String.class, String.class, URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("100000.0", "2736", URI.create("https://api.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/vApp/1001")));
-
- assertRequestLineEquals(request,
- "POST https://api.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/action/captureVApp HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/capture-vapp-template-default.xml")),
- "application/xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
-
- checkFilters(request);
- }
-
- public void testCloneVApp() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VMAsyncApi.class, "cloneVApp", URI.class, String.class, String.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI.create("https://api.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/vApp/1001"), "clonedvm", "VM Tier01"));
-
- assertRequestLineEquals(request,
- "POST https://api.savvis.net/vpdc/v1.0/org/100000.0/vdc/2736/vApp/1001/action/cloneVApp HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/cloneVApp-default.xml")),
- "application/xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
-
- checkFilters(request);
- }
-
- public void testAddMultipleVMsIntoVDCURI() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VMAsyncApi.class, "addMultipleVMsIntoVDC", URI.class, Iterable.class);
-
- CIMOperatingSystem os = Iterables.find(injector.getInstance(Key.get(new TypeLiteral<Set<CIMOperatingSystem>>() {
- })), new Predicate<CIMOperatingSystem>() {
-
- @Override
- public boolean apply(CIMOperatingSystem arg0) {
- return arg0.getOsType() == OSType.RHEL_64;
- }
-
- });
-
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://api.savvis.net/rest/api/v0.8/org/11/vdc/22"), ImmutableSet.of(VMSpec
- .builder().name("Test VM").networkTierName("VM Tier01").operatingSystem(os).build())));
-
- assertRequestLineEquals(request,
- "GET https://api.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/ HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/vm-multiple-default.xml")),
- "application/xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TasksListHandler.class);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(request);
- }
-
- public void testAddMultipleVMsIntoVDC() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VMAsyncApi.class, "addMultipleVMsIntoVDC", String.class, String.class, Iterable.class);
-
- CIMOperatingSystem os = Iterables.find(injector.getInstance(Key.get(new TypeLiteral<Set<CIMOperatingSystem>>() {
- })), new Predicate<CIMOperatingSystem>() {
-
- @Override
- public boolean apply(CIMOperatingSystem arg0) {
- return arg0.getOsType() == OSType.RHEL_64;
- }
-
- });
-
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("11", "22", ImmutableSet.of(VMSpec.builder()
- .operatingSystem(os).name("Test VM").networkTierName("VM Tier01").build())));
-
- assertRequestLineEquals(request, "GET https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/ HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, Strings2.toStringAndClose(getClass().getResourceAsStream("/vm-multiple-default.xml")),
- "application/xml", false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TasksListHandler.class);
- assertFallbackClassEquals(method, MapHttp4xxCodesToExceptions.class);
-
- checkFilters(request);
- }
-
- public void testRemoveVMFromVDC() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VMAsyncApi.class, "removeVMFromVDC", String.class, String.class, String.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of("11", "22", "33"));
-
- assertRequestLineEquals(request,
- "DELETE https://api.savvis.net/vpdc/v1.0/org/11/vdc/22/vApp/33 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testRemoveVM() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VMAsyncApi.class, "removeVM", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://api.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/33")));
-
- assertRequestLineEquals(request,
- "DELETE https://api.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/33 HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testPowerOffVM() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VMAsyncApi.class, "powerOffVM", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://api.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/33")));
-
- assertRequestLineEquals(request,
- "POST https://api.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/33/action/powerOff HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-
- public void testPowerOnVM() throws SecurityException, NoSuchMethodException, IOException {
- Invokable<?, ?> method = method(VMAsyncApi.class, "powerOnVM", URI.class);
- GeneratedHttpRequest request = processor.createRequest(method, ImmutableList.<Object> of(URI
- .create("https://api.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/33")));
-
- assertRequestLineEquals(request,
- "POST https://api.savvis.net/rest/api/v0.8/org/11/vdc/22/vApp/33/action/powerOn HTTP/1.1");
- assertNonPayloadHeadersEqual(request, "");
- assertPayloadEquals(request, null, null, false);
-
- assertResponseParserClassEquals(method, request, ParseSax.class);
- assertSaxResponseParserClassEquals(method, TaskHandler.class);
- assertFallbackClassEquals(method, NullOnNotFoundOr404.class);
-
- checkFilters(request);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b91fd46c/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookieTest.java
----------------------------------------------------------------------
diff --git a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookieTest.java b/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookieTest.java
deleted file mode 100644
index 6281c8a..0000000
--- a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/filters/SetVCloudTokenCookieTest.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.savvis.vpdc.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
-public class SetVCloudTokenCookieTest {
-
- private SetVCloudTokenCookie filter;
-
- @BeforeTest
- void setUp() {
- filter = new SetVCloudTokenCookie(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(), 1);
- assertEquals(request.getFirstHeaderOrNull(HttpHeaders.COOKIE), "vcloud-token=token");
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b91fd46c/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandlerTest.java
----------------------------------------------------------------------
diff --git a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandlerTest.java b/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandlerTest.java
deleted file mode 100644
index a2ca5ff..0000000
--- a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/handlers/VPDCErrorHandlerTest.java
+++ /dev/null
@@ -1,124 +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.savvis.vpdc.handlers;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reportMatcher;
-import static org.easymock.EasyMock.verify;
-
-import java.net.URI;
-
-import org.easymock.IArgumentMatcher;
-import org.jclouds.http.HttpCommand;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.rest.AuthorizationException;
-import org.jclouds.rest.ResourceNotFoundException;
-import org.testng.annotations.Test;
-
-import com.google.inject.Guice;
-
-@Test(groups = { "unit" })
-public class VPDCErrorHandlerTest {
-
- @Test
- public void test400MakesIllegalArgumentException() {
- assertCodeMakes("GET", URI.create("https://savvis.com/foo"), 400, "", "Bad Request",
- IllegalArgumentException.class);
- }
-
- @Test
- public void test401MakesAuthorizationException() {
- assertCodeMakes("GET", URI.create("https://savvis.com/foo"), 401, "", "Unauthorized",
- AuthorizationException.class);
- }
-
- @Test
- public void test403MakesAuthorizationException() {
- assertCodeMakes(
- "GET",
- URI.create("https://savvis.com/foo"),
- 403,
- "HTTP/1.1 403 Forbidden",
- "With the User/login credentials provided, no privilege exists to process the current request. Please contact Savvis administrator for further information",
- AuthorizationException.class);
- }
-
- @Test
- public void test404MakesResourceNotFoundException() {
- assertCodeMakes("GET", URI.create("https://savvis.com/foo"), 404, "", "Not Found",
- ResourceNotFoundException.class);
- }
-
- @Test
- public void test405MakesIllegalArgumentException() {
- assertCodeMakes("GET", URI.create("https://savvis.com/foo"), 405, "", "Method Not Allowed",
- IllegalArgumentException.class);
- }
-
- @Test
- public void test409MakesIllegalStateException() {
- assertCodeMakes("GET", URI.create("https://savvis.com/foo"), 409, "", "Conflict", IllegalStateException.class);
- }
-
- private void assertCodeMakes(String method, URI uri, int statusCode, String message, String content,
- Class<? extends Exception> expected) {
- assertCodeMakes(method, uri, statusCode, message, "text/xml", content, expected);
- }
-
- private void assertCodeMakes(String method, URI uri, int statusCode, String message, String contentType,
- String content, Class<? extends Exception> expected) {
-
- VPDCErrorHandler function = Guice.createInjector().getInstance(VPDCErrorHandler.class);
-
- HttpCommand command = createMock(HttpCommand.class);
- HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build();
- HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build();
- response.getPayload().getContentMetadata().setContentType(contentType);
-
- expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
- command.setException(classEq(expected));
-
- replay(command);
-
- function.handleError(command, response);
-
- verify(command);
- }
-
- public static Exception classEq(final Class<? extends Exception> in) {
- reportMatcher(new IArgumentMatcher() {
-
- @Override
- public void appendTo(StringBuffer buffer) {
- buffer.append("classEq(");
- buffer.append(in);
- buffer.append(")");
- }
-
- @Override
- public boolean matches(Object arg) {
- return arg.getClass() == in;
- }
-
- });
- return null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b91fd46c/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/FirewallServiceHandlerTest.java
----------------------------------------------------------------------
diff --git a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/FirewallServiceHandlerTest.java b/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/FirewallServiceHandlerTest.java
deleted file mode 100644
index 606b608..0000000
--- a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/FirewallServiceHandlerTest.java
+++ /dev/null
@@ -1,60 +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.savvis.vpdc.xml;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.http.functions.ParseSax.Factory;
-import org.jclouds.http.functions.config.SaxParserModule;
-import org.jclouds.savvis.vpdc.domain.FirewallRule;
-import org.jclouds.savvis.vpdc.domain.FirewallService;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-/**
- * Tests behavior of {@code FirewallServiceHandler and @code FirewallRuleHandler}
- */
-@Test(groups = "unit")
-public class FirewallServiceHandlerTest {
-
- /*new FirewallRule(null, null, null, null, "SERVER_TIER_FIREWALL", true, "internet" , "VM Tier01" ,
- "22", "allow", "Server Tier Firewall Rule", false, "Tcp"),
- new FirewallRule(null, null, null, null, "SERVER_TIER_FIREWALL", true, "VM Tier03" , "VM Tier03" ,
- null, "allow", "Server Tier Firewall Rule", false, "Icmp-ping")));*/
-
- public void test() {
- InputStream is = getClass().getResourceAsStream("/firewallService.xml");
- Injector injector = Guice.createInjector(new SaxParserModule());
- Factory factory = injector.getInstance(ParseSax.Factory.class);
- FirewallService result = factory.create(injector.getInstance(FirewallServiceHandler.class)).parse(is);
- assertEquals(result.isEnabled(), false);
- assertEquals(
- result.getFirewallRules(),
- ImmutableSet.<FirewallRule> of(
- FirewallRule.builder().firewallType("SERVER_TIER_FIREWALL").isEnabled(false).source("internet")
- .destination("VM Tier01").port("22").protocol("Tcp").policy("allow").description("Server Tier Firewall Rule").isLogged(false).build(),
- FirewallRule.builder().firewallType("SERVER_TIER_FIREWALL").isEnabled(true).source("VM Tier03")
- .destination("VM Tier03").protocol("Icmp-ping").policy("allow").description("Server Tier Firewall Rule").isLogged(false).build()));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b91fd46c/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkConfigSectionHandlerTest.java
----------------------------------------------------------------------
diff --git a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkConfigSectionHandlerTest.java b/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkConfigSectionHandlerTest.java
deleted file mode 100644
index 7fd9da6..0000000
--- a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkConfigSectionHandlerTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.savvis.vpdc.xml;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.http.functions.ParseSax.Factory;
-import org.jclouds.http.functions.config.SaxParserModule;
-import org.jclouds.savvis.vpdc.domain.NetworkConfigSection;
-import org.testng.annotations.Test;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-/**
- * Tests behavior of {@code NetworkConfigSectionHandler}
- */
-@Test(groups = "unit")
-public class NetworkConfigSectionHandlerTest {
-
- public void test() {
- InputStream is = getClass().getResourceAsStream("/networkconfigsection.xml");
- Injector injector = Guice.createInjector(new SaxParserModule());
- Factory factory = injector.getInstance(ParseSax.Factory.class);
- NetworkConfigSection result = factory.create(injector.getInstance(NetworkConfigSectionHandler.class)).parse(is);
- assertEquals(result.toString(), NetworkConfigSection.builder().network("VM Tier01").gateway("0.0.0.0").netmask(
- "0.0.0.0").info("MAC=00:00:00:00:00:00").fenceMode("allowInOut").dhcp(true).internalToExternalNATRule(
- "10.76.2.4", "206.24.124.1").build().toString());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b91fd46c/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkConnectionSectionHandlerTest.java
----------------------------------------------------------------------
diff --git a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkConnectionSectionHandlerTest.java b/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkConnectionSectionHandlerTest.java
deleted file mode 100644
index a636d81..0000000
--- a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkConnectionSectionHandlerTest.java
+++ /dev/null
@@ -1,48 +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.savvis.vpdc.xml;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.http.functions.ParseSax.Factory;
-import org.jclouds.http.functions.config.SaxParserModule;
-import org.jclouds.savvis.vpdc.domain.NetworkConnectionSection;
-import org.testng.annotations.Test;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-/**
- * Tests behavior of {@code NetworkConnectionSectionHandler}
- */
-@Test(groups = "unit")
-public class NetworkConnectionSectionHandlerTest {
-
- public void test() {
- InputStream is = getClass().getResourceAsStream("/networkconnectionsection.xml");
- Injector injector = Guice.createInjector(new SaxParserModule());
- Factory factory = injector.getInstance(ParseSax.Factory.class);
- NetworkConnectionSection result = factory.create(injector.getInstance(NetworkConnectionSectionHandler.class))
- .parse(is);
- assertEquals(result.toString(), NetworkConnectionSection.builder().network("VM Tier01").info(
- "Read only description of a network connection to a deployed vApp").ipAddress("10.76.0.5").build()
- .toString());
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/b91fd46c/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkHandlerTest.java
----------------------------------------------------------------------
diff --git a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkHandlerTest.java b/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkHandlerTest.java
deleted file mode 100644
index 73e35f8..0000000
--- a/savvis-symphonyvpdc/src/test/java/org/jclouds/savvis/vpdc/xml/NetworkHandlerTest.java
+++ /dev/null
@@ -1,70 +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.savvis.vpdc.xml;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.InputStream;
-
-import org.jclouds.http.functions.ParseSax;
-import org.jclouds.http.functions.ParseSax.Factory;
-import org.jclouds.http.functions.config.SaxParserModule;
-import org.jclouds.savvis.vpdc.domain.Network;
-import org.jclouds.savvis.vpdc.reference.VCloudMediaType;
-import org.testng.annotations.Test;
-
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-/**
- * Tests behavior of {@code NetworkHandler}
- */
-@Test(groups = "unit")
-public class NetworkHandlerTest {
-
- public void test() {
- InputStream is = getClass().getResourceAsStream("/network.xml");
- Injector injector = Guice.createInjector(new SaxParserModule());
- Factory factory = injector.getInstance(ParseSax.Factory.class);
- Network result = factory.create(injector.getInstance(NetworkHandler.class)).parse(is);
- assertEquals(
- result.toString(),
- Network.builder().type(VCloudMediaType.NETWORK_XML).name("VM-Tier01").gateway("1.1.1.1")
- .netmask("255.255.255.240").build().toString());
- }
-
- public void testNat() {
- InputStream is = getClass().getResourceAsStream("/network-nat.xml");
- Injector injector = Guice.createInjector(new SaxParserModule());
- Factory factory = injector.getInstance(ParseSax.Factory.class);
- Network result = factory.create(injector.getInstance(NetworkHandler.class)).parse(is);
- assertEquals(result.toString(),
- Network.builder().type(VCloudMediaType.NETWORK_XML).name("VM Tier01").gateway("1.1.1.1").netmask("2.2.2.2")
- .internalToExternalNATRule("3.3.3.3", "4.4.4.4").internalToExternalNATRule("3.3.3.4", "4.4.4.5")
- .build().toString());
- }
-
- public void tesWhenNoVAppsInNetworkSetsAllZerosToGatewayAndNetmask() {
- InputStream is = getClass().getResourceAsStream("/network-unused.xml");
- Injector injector = Guice.createInjector(new SaxParserModule());
- Factory factory = injector.getInstance(ParseSax.Factory.class);
- Network result = factory.create(injector.getInstance(NetworkHandler.class)).parse(is);
- assertEquals(result.toString(),
- Network.builder().type(VCloudMediaType.NETWORK_XML).name("VM Tier01").gateway("0.0.0.0").netmask("0.0.0.0")
- .build().toString());
- }
-}