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 2013/09/30 18:15:28 UTC
[08/17] JCLOUDS-304. Remove broken terremark providers
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindNodeConfigurationToXmlPayloadTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindNodeConfigurationToXmlPayloadTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindNodeConfigurationToXmlPayloadTest.java
deleted file mode 100644
index b216c7e..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindNodeConfigurationToXmlPayloadTest.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.trmk.vcloud_0_8.binders;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.jclouds.Constants.PROPERTY_API_VERSION;
-import static org.jclouds.Constants.PROPERTY_ENDPOINT;
-import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NAME;
-import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_VERSION;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Map;
-import java.util.Properties;
-
-import org.jclouds.http.HttpRequest;
-import org.jclouds.trmk.vcloud_0_8.internal.TerremarkVCloudApiMetadata;
-import org.nnsoft.guice.rocoto.Rocoto;
-import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-/**
- * Tests behavior of {@code BindNodeConfigurationToXmlPayload}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class BindNodeConfigurationToXmlPayloadTest {
- Injector injector = Guice.createInjector(Rocoto.expandVariables(new ConfigurationModule() {
-
- @Override
- protected void bindConfigurations() {
- Properties properties = TerremarkVCloudApiMetadata.defaultProperties();
- properties.setProperty(PROPERTY_API_VERSION, "0.8a-ext1.6");
- properties.setProperty(PROPERTY_TERREMARK_EXTENSION_NAME, "vCloudExpressExtensions");
- properties.setProperty(PROPERTY_TERREMARK_EXTENSION_VERSION, "1.6");
- properties.setProperty(PROPERTY_ENDPOINT, "https://services.vcloudexpress.terremark.com/api");
- bindProperties(properties);
- }
- }));
-
- public void testChangeDescription() throws IOException {
- String expectedPayload = "<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Name>willie</Name><Enabled>true</Enabled><Description>description</Description></NodeService>";
- assertConfigMakesPayload(ImmutableMap.<String, Object> of("name", "willie", "enabled", "true", "description",
- "description"), expectedPayload);
- }
-
- public void testDisableTraffic() throws IOException {
- String expectedPayload = "<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Name>willie</Name><Enabled>false</Enabled></NodeService>";
- assertConfigMakesPayload(ImmutableMap.<String, Object> of("name", "willie", "enabled", "false"), expectedPayload);
- }
-
- public void testTwoOptions() throws IOException {
- String expectedPayload = "<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Name>willie</Name><Enabled>true</Enabled></NodeService>";
- assertConfigMakesPayload(ImmutableMap.<String, Object> of("name", "willie", "enabled", "true"), expectedPayload);
- }
-
- @Test(expectedExceptions = NullPointerException.class)
- public void testNoOptions() throws IOException {
- String expectedPayload = "<NodeService xmlns=\"urn:tmrk:vCloudExpressExtensions-1.6\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Name>willie</Name><Enabled>false</Enabled></NodeService>";
- assertConfigMakesPayload(ImmutableMap.<String, Object> of(), expectedPayload);
- }
-
- private void assertConfigMakesPayload(Map<String, Object> config, String expectedPayload) {
- BindNodeConfigurationToXmlPayload binder = injector.getInstance(BindNodeConfigurationToXmlPayload.class);
- HttpRequest request = createMock(HttpRequest.class);
- expect(request.getEndpoint()).andReturn(URI.create("http://localhost/key")).anyTimes();
- request.setPayload(expectedPayload);
- replay(request);
- binder.bindToRequest(request, config);
- verify(request);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindVAppConfigurationToXmlPayloadTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindVAppConfigurationToXmlPayloadTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindVAppConfigurationToXmlPayloadTest.java
deleted file mode 100644
index 116d0c1..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/binders/BindVAppConfigurationToXmlPayloadTest.java
+++ /dev/null
@@ -1,186 +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.trmk.vcloud_0_8.binders;
-
-import static org.jclouds.trmk.vcloud_0_8.domain.VAppConfiguration.Builder.changeNameTo;
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.net.URI;
-import java.util.Map;
-
-import org.jclouds.cim.ResourceAllocationSettingData;
-import org.jclouds.cim.ResourceAllocationSettingData.ResourceType;
-import org.jclouds.rest.annotations.ApiVersion;
-import org.jclouds.rest.internal.GeneratedHttpRequest;
-import org.jclouds.trmk.vcloud_0_8.domain.Status;
-import org.jclouds.trmk.vcloud_0_8.domain.VAppConfiguration;
-import org.jclouds.trmk.vcloud_0_8.domain.internal.VAppImpl;
-import org.jclouds.trmk.vcloud_0_8.internal.BasePayloadTest;
-import org.jclouds.trmk.vcloud_0_8.internal.TerremarkVCloudApiMetadata;
-import org.jclouds.util.Strings2;
-import org.nnsoft.guice.rocoto.Rocoto;
-import org.nnsoft.guice.rocoto.configuration.ConfigurationModule;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableListMultimap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Maps;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-/**
- * Tests behavior of {@code BindVAppConfigurationToXmlPayload}
- *
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class BindVAppConfigurationToXmlPayloadTest extends BasePayloadTest {
- Injector injector = Guice.createInjector(Rocoto.expandVariables(new ConfigurationModule() {
-
- @Override
- protected void bindConfigurations() {
- bind(String.class).annotatedWith(ApiVersion.class).toInstance("0.8");
- bindProperties(TerremarkVCloudApiMetadata.defaultProperties());
- }
- }));
-
- public void testChangeName() throws IOException {
- VAppImpl vApp = new VAppImpl("MyAppServer6", URI
- .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null,
- ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(
- ResourceAllocationSettingData.builder().instanceID("1").elementName("foo").resourceType(
- ResourceType.PROCESSOR).virtualQuantity(2l).build(), ResourceAllocationSettingData
- .builder().instanceID("2").elementName("foo").resourceType(ResourceType.MEMORY)
- .virtualQuantity(1024l).build(), ResourceAllocationSettingData.builder().instanceID(
- "9").elementName("foo").addressOnParent("0").hostResource("1048576").resourceType(
- ResourceType.DISK_DRIVE).virtualQuantity(209152l).build()));
-
- String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/configureVApp.xml"))
- .replace("eduardo", "roberto");
-
- VAppConfiguration config = new VAppConfiguration().changeNameTo("roberto");
-
- GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(vApp, config));
- BindVAppConfigurationToXmlPayload binder = injector.getInstance(BindVAppConfigurationToXmlPayload.class);
-
- Map<String, Object> map = Maps.newHashMap();
- assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
- }
-
- public void testRemoveDisk() throws IOException {
- VAppImpl vApp = new VAppImpl("MyAppServer6", URI
- .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null,
- ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(
- ResourceAllocationSettingData.builder().instanceID("1").elementName("foo").resourceType(
- ResourceType.PROCESSOR).virtualQuantity(2l).build(),//
- ResourceAllocationSettingData.builder().instanceID("2").elementName("foo").resourceType(
- ResourceType.MEMORY).virtualQuantity(1024l).build(), //
- ResourceAllocationSettingData.builder().instanceID("9").elementName("foo").addressOnParent("0")
- .hostResource("1048576").resourceType(ResourceType.DISK_DRIVE)
- .virtualQuantity(209152l).build(),//
- ResourceAllocationSettingData.builder().instanceID("9").elementName("foo").addressOnParent("1")
- .hostResource("1048576").resourceType(ResourceType.DISK_DRIVE)
- .virtualQuantity(209152l).build()//
- )
-
- );
-
- String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/configureVApp.xml"))
- .replace("eduardo", "MyAppServer6");
-
- VAppConfiguration config = new VAppConfiguration().deleteDiskWithAddressOnParent(1);
-
- GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(vApp, config));
-
- BindVAppConfigurationToXmlPayload binder = injector.getInstance(BindVAppConfigurationToXmlPayload.class);
-
- Map<String, Object> map = Maps.newHashMap();
- assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
- }
-
- public void testChangeAll() throws IOException {
- VAppImpl vApp = new VAppImpl("MyAppServer6", URI
- .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null,
- ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(
- ResourceAllocationSettingData.builder().instanceID("1").elementName("foo").resourceType(
- ResourceType.PROCESSOR).virtualQuantity(2l).build(), ResourceAllocationSettingData
- .builder().instanceID("2").elementName("foo").resourceType(ResourceType.MEMORY)
- .virtualQuantity(1024l).build(), ResourceAllocationSettingData.builder().instanceID(
- "9").elementName("foo").addressOnParent("0").hostResource("1048576").resourceType(
- ResourceType.DISK_DRIVE).virtualQuantity(209152l).build()));
-
- String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/configureVAppAll.xml"));
-
- VAppConfiguration config = changeNameTo("eduardo").changeMemoryTo(1536).changeProcessorCountTo(1).addDisk(
- 25 * 1048576).addDisk(25 * 1048576);
-
- GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(vApp, config));
-
- BindVAppConfigurationToXmlPayload binder = injector.getInstance(BindVAppConfigurationToXmlPayload.class);
-
- Map<String, Object> map = Maps.newHashMap();
- assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
- }
-
- public void testChangeCPUCountTo4() throws IOException {
- VAppImpl vApp = new VAppImpl("eduardo", URI
- .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null,
- ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(
- ResourceAllocationSettingData.builder().instanceID("1").elementName("foo").resourceType(
- ResourceType.PROCESSOR).virtualQuantity(4l).build(), ResourceAllocationSettingData
- .builder().instanceID("2").elementName("foo").resourceType(ResourceType.MEMORY)
- .virtualQuantity(1024l).build(), ResourceAllocationSettingData.builder().instanceID(
- "9").elementName("foo").addressOnParent("0").hostResource("1048576").resourceType(
- ResourceType.DISK_DRIVE).virtualQuantity(209152l).build()));
- String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/configureVApp4.xml"));
-
- VAppConfiguration config = new VAppConfiguration().changeProcessorCountTo(4);
-
- GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(vApp, config));
-
- BindVAppConfigurationToXmlPayload binder = injector.getInstance(BindVAppConfigurationToXmlPayload.class);
-
- Map<String, Object> map = Maps.newHashMap();
- assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
- }
-
- public void testChangeMemoryTo1536() throws IOException {
- VAppImpl vApp = new VAppImpl("MyAppServer6", URI
- .create("https://services.vcloudexpress/terremark.com/api/v0.8/vapp/4213"), Status.OFF, 4194304l, null,
- ImmutableListMultimap.<String, String> of(), null, null, null, ImmutableSet.of(
- ResourceAllocationSettingData.builder().instanceID("1").elementName("foo").resourceType(
- ResourceType.PROCESSOR).virtualQuantity(2l).build(), ResourceAllocationSettingData
- .builder().instanceID("2").elementName("foo").resourceType(ResourceType.MEMORY)
- .virtualQuantity(1536l).build(), ResourceAllocationSettingData.builder().instanceID(
- "9").elementName("foo").addressOnParent("0").hostResource("1048576").resourceType(
- ResourceType.DISK_DRIVE).virtualQuantity(209152l).build()));
-
- String expected = Strings2.toStringAndClose(getClass().getResourceAsStream("/configureVApp.xml"))
- .replace("eduardo", "MyAppServer6").replace("1024", "1536");
-
- VAppConfiguration config = new VAppConfiguration().changeMemoryTo(1536);
-
- GeneratedHttpRequest request = requestForArgs(ImmutableList.<Object> of(vApp, config));
-
- BindVAppConfigurationToXmlPayload binder = injector.getInstance(BindVAppConfigurationToXmlPayload.class);
-
- Map<String, Object> map = Maps.newHashMap();
- assertEquals(binder.bindToRequest(request, map).getPayload().getRawContent(), expected);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudComputeClientTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudComputeClientTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudComputeClientTest.java
deleted file mode 100644
index c2f364b..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudComputeClientTest.java
+++ /dev/null
@@ -1,123 +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.trmk.vcloud_0_8.compute;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.Map;
-
-import javax.inject.Provider;
-
-import org.jclouds.compute.ComputeServiceAdapter.NodeAndInitialCredentials;
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.domain.Credentials;
-import org.jclouds.domain.LoginCredentials;
-import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudApi;
-import org.jclouds.trmk.vcloud_0_8.domain.Status;
-import org.jclouds.trmk.vcloud_0_8.domain.Task;
-import org.jclouds.trmk.vcloud_0_8.domain.VApp;
-import org.jclouds.trmk.vcloud_0_8.domain.VAppTemplate;
-import org.jclouds.trmk.vcloud_0_8.domain.VDC;
-import org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions;
-import org.jclouds.trmk.vcloud_0_8.suppliers.InternetServiceAndPublicIpAddressSupplier;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.Maps;
-import com.google.common.io.ByteStreams;
-
-/**
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class TerremarkVCloudComputeClientTest {
- @SuppressWarnings("unchecked")
- @Test
- public void testStartWindows() throws IOException {
- Map<String, Credentials> credentialStore = Maps.newHashMap();
- InputStream is = getClass().getResourceAsStream("/windows_description.txt");
- String description = new String(ByteStreams.toByteArray(is));
- VAppTemplate template = createMock(VAppTemplate.class);
- VDC vdc = createMock(VDC.class);
- URI templateURI = URI.create("template");
- URI vdcURI = URI.create("vdc");
-
- expect(template.getDescription()).andReturn(description).atLeastOnce();
- TerremarkVCloudApi client = createMock(TerremarkVCloudApi.class);
- VApp vApp = createMock(VApp.class);
- InternetServiceAndPublicIpAddressSupplier supplier = createMock(InternetServiceAndPublicIpAddressSupplier.class);
- expect(client.getVAppTemplate(templateURI)).andReturn(template);
- expect(
- client.instantiateVAppTemplateInVDC(vdcURI, templateURI, "name",
- new InstantiateVAppTemplateOptions().productProperty("password", "password"))).andReturn(vApp);
- Task task = createMock(Task.class);
- URI vappLocation = URI.create("vapp");
- URI taskLocation = URI.create("task");
-
- expect(vApp.getHref()).andReturn(vappLocation).atLeastOnce();
- expect(vApp.getName()).andReturn("name").atLeastOnce();
- expect(client.deployVApp(vappLocation)).andReturn(task);
- expect(task.getHref()).andReturn(taskLocation).atLeastOnce();
- Predicate<URI> successTester = createMock(Predicate.class);
- expect(successTester.apply(taskLocation)).andReturn(true).atLeastOnce();
- expect(client.powerOnVApp(vappLocation)).andReturn(task);
-
- Predicate<VApp> notFoundTester = createMock(Predicate.class);
- Map<Status, NodeMetadata.Status> vAppStatusToNodeStatus = createMock(Map.class);
-
- TerremarkVCloudComputeClient computeClient = new TerremarkVCloudComputeClient(client,
- new Provider<String>() {
-
- @Override
- public String get() {
- return "password";
- }
-
- }, successTester, vAppStatusToNodeStatus, credentialStore, supplier);
-
- replay(vdc);
- replay(template);
- replay(vApp);
- replay(task);
- replay(client);
- replay(successTester);
- replay(notFoundTester);
- replay(vAppStatusToNodeStatus);
-
- NodeAndInitialCredentials<VApp> response = computeClient.startAndReturnCredentials(vdcURI, templateURI, "name", new InstantiateVAppTemplateOptions());
-
- assertEquals(response.getNodeId(), "vapp");
- assertEquals(response.getNode(),vApp);
- assertEquals(response.getCredentials(), LoginCredentials.builder().password("password").build());
-
- verify(vdc);
- verify(template);
- verify(vApp);
- verify(task);
- verify(client);
- verify(successTester);
- verify(notFoundTester);
- verify(vAppStatusToNodeStatus);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudTemplateOptionsTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudTemplateOptionsTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudTemplateOptionsTest.java
deleted file mode 100644
index d494955..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/TerremarkVCloudTemplateOptionsTest.java
+++ /dev/null
@@ -1,229 +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.trmk.vcloud_0_8.compute;
-
-import static org.jclouds.trmk.vcloud_0_8.compute.options.TerremarkVCloudTemplateOptions.Builder.authorizePublicKey;
-import static org.jclouds.trmk.vcloud_0_8.compute.options.TerremarkVCloudTemplateOptions.Builder.blockOnPort;
-import static org.jclouds.trmk.vcloud_0_8.compute.options.TerremarkVCloudTemplateOptions.Builder.inboundPorts;
-import static org.jclouds.trmk.vcloud_0_8.compute.options.TerremarkVCloudTemplateOptions.Builder.installPrivateKey;
-import static org.jclouds.trmk.vcloud_0_8.compute.options.TerremarkVCloudTemplateOptions.Builder.noKeyPair;
-import static org.jclouds.trmk.vcloud_0_8.compute.options.TerremarkVCloudTemplateOptions.Builder.sshKeyFingerprint;
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-
-import org.jclouds.compute.options.TemplateOptions;
-import org.jclouds.trmk.vcloud_0_8.compute.options.TerremarkVCloudTemplateOptions;
-import org.testng.annotations.Test;
-
-/**
- * Tests possible uses of TerremarkVCloudTemplateOptions and
- * TerremarkVCloudTemplateOptions.Builder.*
- *
- * @author Adrian Cole
- */
-public class TerremarkVCloudTemplateOptionsTest {
-
- public void testAs() {
- TemplateOptions options = new TerremarkVCloudTemplateOptions();
- assertEquals(options.as(TerremarkVCloudTemplateOptions.class), options);
- }
-
- @Test(expectedExceptions = NullPointerException.class, expectedExceptionsMessageRegExp = "use noKeyPair option to request boot without a keypair")
- public void testkeyPairBadFormat() {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- options.sshKeyFingerprint("");
- }
-
- @Test(expectedExceptions = IllegalStateException.class)
- public void testkeyPairAndNoKeyPair() {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- options.sshKeyFingerprint("mykeypair");
- options.noKeyPair();
- }
-
- @Test(expectedExceptions = IllegalStateException.class)
- public void testNoKeyPairAndKeyPair() {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- options.noKeyPair();
- options.sshKeyFingerprint("mykeypair");
- }
-
- @Test
- public void testkeyPair() {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- options.sshKeyFingerprint("mykeypair");
- assertEquals(options.getSshKeyFingerprint(), "mykeypair");
- }
-
- @Test
- public void testNullkeyPair() {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- assertEquals(options.getSshKeyFingerprint(), null);
- }
-
- @Test
- public void testkeyPairStatic() {
- TerremarkVCloudTemplateOptions options = sshKeyFingerprint("mykeypair");
- assertEquals(options.getSshKeyFingerprint(), "mykeypair");
- }
-
- @Test(expectedExceptions = NullPointerException.class)
- public void testkeyPairNPE() {
- sshKeyFingerprint(null);
- }
-
- @Test
- public void testnoKeyPair() {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- options.noKeyPair();
- assertEquals(options.getSshKeyFingerprint(), null);
- assert !options.shouldAutomaticallyCreateKeyPair();
- }
-
- @Test
- public void testFalsenoKeyPair() {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- assertEquals(options.getSshKeyFingerprint(), null);
- assert options.shouldAutomaticallyCreateKeyPair();
- }
-
- @Test
- public void testnoKeyPairStatic() {
- TerremarkVCloudTemplateOptions options = noKeyPair();
- assertEquals(options.getSshKeyFingerprint(), null);
- assert !options.shouldAutomaticallyCreateKeyPair();
- }
-
- // superclass tests
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testinstallPrivateKeyBadFormat() {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- options.installPrivateKey("whompy");
- }
-
- @Test
- public void testinstallPrivateKey() throws IOException {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- options.installPrivateKey("-----BEGIN RSA PRIVATE KEY-----");
- assertEquals(options.getPrivateKey(), "-----BEGIN RSA PRIVATE KEY-----");
- }
-
- @Test
- public void testNullinstallPrivateKey() {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- assertEquals(options.getPrivateKey(), null);
- }
-
- @Test
- public void testinstallPrivateKeyStatic() throws IOException {
- TerremarkVCloudTemplateOptions options = installPrivateKey("-----BEGIN RSA PRIVATE KEY-----");
- assertEquals(options.getPrivateKey(), "-----BEGIN RSA PRIVATE KEY-----");
- }
-
- @Test(expectedExceptions = NullPointerException.class)
- public void testinstallPrivateKeyNPE() {
- installPrivateKey(null);
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testauthorizePublicKeyBadFormat() {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- options.authorizePublicKey("whompy");
- }
-
- @Test
- public void testauthorizePublicKey() throws IOException {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- options.authorizePublicKey("ssh-rsa");
- assertEquals(options.getPublicKey(), "ssh-rsa");
- }
-
- @Test
- public void testNullauthorizePublicKey() {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- assertEquals(options.getPublicKey(), null);
- }
-
- @Test
- public void testauthorizePublicKeyStatic() throws IOException {
- TerremarkVCloudTemplateOptions options = authorizePublicKey("ssh-rsa");
- assertEquals(options.getPublicKey(), "ssh-rsa");
- }
-
- @Test(expectedExceptions = NullPointerException.class)
- public void testauthorizePublicKeyNPE() {
- authorizePublicKey(null);
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testblockOnPortBadFormat() {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- options.blockOnPort(-1, -1);
- }
-
- @Test
- public void testblockOnPort() {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- options.blockOnPort(22, 30);
- assertEquals(options.getPort(), 22);
- assertEquals(options.getSeconds(), 30);
-
- }
-
- @Test
- public void testNullblockOnPort() {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- assertEquals(options.getPort(), -1);
- assertEquals(options.getSeconds(), -1);
- }
-
- @Test
- public void testblockOnPortStatic() {
- TerremarkVCloudTemplateOptions options = blockOnPort(22, 30);
- assertEquals(options.getPort(), 22);
- assertEquals(options.getSeconds(), 30);
- }
-
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testinboundPortsBadFormat() {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- options.inboundPorts(-1, -1);
- }
-
- @Test
- public void testinboundPorts() {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- options.inboundPorts(22, 30);
- assertEquals(options.getInboundPorts()[0], 22);
- assertEquals(options.getInboundPorts()[1], 30);
-
- }
-
- @Test
- public void testDefaultOpen22() {
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
- assertEquals(options.getInboundPorts()[0], 22);
- }
-
- @Test
- public void testinboundPortsStatic() {
- TerremarkVCloudTemplateOptions options = inboundPorts(22, 30);
- assertEquals(options.getInboundPorts()[0], 22);
- assertEquals(options.getInboundPorts()[1], 30);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModuleTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModuleTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModuleTest.java
deleted file mode 100644
index cf71c5d..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/config/TerremarkVCloudComputeServiceContextModuleTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.trmk.vcloud_0_8.compute.config;
-
-import java.util.EnumSet;
-
-import org.jclouds.trmk.vcloud_0_8.domain.Status;
-import org.testng.annotations.Test;
-
-/**
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class TerremarkVCloudComputeServiceContextModuleTest {
-
- public void testAllStatusCovered() {
-
- for (Status state : EnumSet.allOf(Status.class)) {
- assert TerremarkVCloudComputeServiceContextModule.toPortableNodeStatus.containsKey(state) : state;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/CleanupOrphanKeysTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/CleanupOrphanKeysTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/CleanupOrphanKeysTest.java
deleted file mode 100644
index 099725c..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/CleanupOrphanKeysTest.java
+++ /dev/null
@@ -1,192 +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.trmk.vcloud_0_8.compute.strategy;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.jclouds.compute.predicates.NodePredicates.parentLocationId;
-
-import java.net.URI;
-import java.util.Map;
-
-import org.jclouds.compute.domain.NodeMetadata;
-import org.jclouds.compute.domain.NodeMetadata.Status;
-import org.jclouds.compute.strategy.ListNodesStrategy;
-import org.jclouds.domain.Credentials;
-import org.jclouds.trmk.vcloud_0_8.compute.domain.OrgAndName;
-import org.jclouds.trmk.vcloud_0_8.compute.functions.NodeMetadataToOrgAndName;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-
-/**
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class CleanupOrphanKeysTest {
-
- public void testWhenNoDeletedNodes() {
- Iterable<? extends NodeMetadata> deadOnes = ImmutableSet.<NodeMetadata> of();
- // create mocks
- CleanupOrphanKeys strategy = setupStrategy();
-
- // setup expectations
-
- // replay mocks
- replayStrategy(strategy);
-
- // run
- strategy.execute(deadOnes);
-
- // verify mocks
- verifyStrategy(strategy);
- }
-
- public void testWhenDeletedNodesHaveNoTag() {
- // create mocks
- CleanupOrphanKeys strategy = setupStrategy();
- NodeMetadata nodeMetadata = createMock(NodeMetadata.class);
- Iterable<? extends NodeMetadata> deadOnes = ImmutableSet.<NodeMetadata> of(nodeMetadata);
-
- // setup expectations
- expect(strategy.nodeToOrgAndName.apply(nodeMetadata)).andReturn(null).atLeastOnce();
- expectCleanupCredentialStore(strategy, nodeMetadata);
-
- // replay mocks
- replay(nodeMetadata);
- replayStrategy(strategy);
-
- // run
- strategy.execute(deadOnes);
-
- // verify mocks
- verify(nodeMetadata);
- verifyStrategy(strategy);
- }
-
- public void testWhenStillRunningWithTag() {
- // create mocks
- CleanupOrphanKeys strategy = setupStrategy();
- NodeMetadata nodeMetadata = createMock(NodeMetadata.class);
- Iterable<? extends NodeMetadata> deadOnes = ImmutableSet.<NodeMetadata> of(nodeMetadata);
- OrgAndName orgTag = new OrgAndName(URI.create("location"), "group");
-
- // setup expectations
- expect(strategy.nodeToOrgAndName.apply(nodeMetadata)).andReturn(orgTag).atLeastOnce();
- expect((Object) strategy.listNodes.listDetailsOnNodesMatching(parentLocationId(orgTag.getOrg().toASCIIString())))
- .andReturn(ImmutableSet.of(nodeMetadata));
- expect(nodeMetadata.getGroup()).andReturn(orgTag.getName()).atLeastOnce();
- expect(nodeMetadata.getStatus()).andReturn(Status.RUNNING).atLeastOnce();
- expectCleanupCredentialStore(strategy, nodeMetadata);
-
- // replay mocks
- replay(nodeMetadata);
- replayStrategy(strategy);
-
- // run
- strategy.execute(deadOnes);
-
- // verify mocks
- verify(nodeMetadata);
- verifyStrategy(strategy);
- }
-
- public void testWhenTerminatedWithTag() {
- // create mocks
- CleanupOrphanKeys strategy = setupStrategy();
- NodeMetadata nodeMetadata = createMock(NodeMetadata.class);
- Iterable<? extends NodeMetadata> deadOnes = ImmutableSet.<NodeMetadata> of(nodeMetadata);
- OrgAndName orgTag = new OrgAndName(URI.create("location"), "group");
-
- // setup expectations
- expect(strategy.nodeToOrgAndName.apply(nodeMetadata)).andReturn(orgTag).atLeastOnce();
- expect((Object) strategy.listNodes.listDetailsOnNodesMatching(parentLocationId(orgTag.getOrg().toASCIIString())))
- .andReturn(ImmutableSet.of(nodeMetadata));
- expect(nodeMetadata.getGroup()).andReturn(orgTag.getName()).atLeastOnce();
- expect(nodeMetadata.getStatus()).andReturn(Status.TERMINATED).atLeastOnce();
- strategy.deleteKeyPair.execute(orgTag);
- expectCleanupCredentialStore(strategy, nodeMetadata);
-
- // replay mocks
- replay(nodeMetadata);
- replayStrategy(strategy);
-
- // run
- strategy.execute(deadOnes);
-
- // verify mocks
- verify(nodeMetadata);
- verifyStrategy(strategy);
- }
-
- private void expectCleanupCredentialStore(CleanupOrphanKeys strategy, NodeMetadata nodeMetadata) {
- expect("node#" + nodeMetadata.getId()).andReturn("1");
- expect(strategy.credentialStore.remove("node#1")).andReturn(null);
- }
-
- public void testWhenNoneLeftWithTag() {
- // create mocks
- CleanupOrphanKeys strategy = setupStrategy();
- NodeMetadata nodeMetadata = createMock(NodeMetadata.class);
- Iterable<? extends NodeMetadata> deadOnes = ImmutableSet.<NodeMetadata> of(nodeMetadata);
- OrgAndName orgTag = new OrgAndName(URI.create("location"), "group");
-
- // setup expectations
- expect(strategy.nodeToOrgAndName.apply(nodeMetadata)).andReturn(orgTag).atLeastOnce();
- expect((Object) strategy.listNodes.listDetailsOnNodesMatching(parentLocationId(orgTag.getOrg().toASCIIString())))
- .andReturn(ImmutableSet.of());
- strategy.deleteKeyPair.execute(orgTag);
- expectCleanupCredentialStore(strategy, nodeMetadata);
-
- // replay mocks
- replay(nodeMetadata);
- replayStrategy(strategy);
-
- // run
- strategy.execute(deadOnes);
-
- // verify mocks
- verify(nodeMetadata);
- verifyStrategy(strategy);
- }
-
- private void verifyStrategy(CleanupOrphanKeys strategy) {
- verify(strategy.nodeToOrgAndName);
- verify(strategy.deleteKeyPair);
- verify(strategy.listNodes);
- verify(strategy.credentialStore);
- }
-
- private CleanupOrphanKeys setupStrategy() {
- NodeMetadataToOrgAndName nodeToOrgAndName = createMock(NodeMetadataToOrgAndName.class);
- DeleteKeyPair deleteKeyPair = createMock(DeleteKeyPair.class);
- ListNodesStrategy listNodes = createMock(ListNodesStrategy.class);
- @SuppressWarnings("unchecked")
- Map<String, Credentials> credentialStore = createMock(Map.class);
- return new CleanupOrphanKeys(nodeToOrgAndName, deleteKeyPair, credentialStore, listNodes);
- }
-
- private void replayStrategy(CleanupOrphanKeys strategy) {
- replay(strategy.nodeToOrgAndName);
- replay(strategy.deleteKeyPair);
- replay(strategy.listNodes);
- replay(strategy.credentialStore);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/CreateNewKeyPairUnlessUserSpecifiedOtherwiseTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/CreateNewKeyPairUnlessUserSpecifiedOtherwiseTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/CreateNewKeyPairUnlessUserSpecifiedOtherwiseTest.java
deleted file mode 100644
index 4d73d99..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/CreateNewKeyPairUnlessUserSpecifiedOtherwiseTest.java
+++ /dev/null
@@ -1,171 +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.trmk.vcloud_0_8.compute.strategy;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.jclouds.trmk.vcloud_0_8.compute.options.TerremarkVCloudTemplateOptions.Builder.noKeyPair;
-import static org.jclouds.trmk.vcloud_0_8.compute.options.TerremarkVCloudTemplateOptions.Builder.sshKeyFingerprint;
-import static org.testng.Assert.assertEquals;
-
-import java.net.URI;
-import java.util.Map;
-import java.util.concurrent.ConcurrentMap;
-
-import org.jclouds.domain.Credentials;
-import org.jclouds.domain.LoginCredentials;
-import org.jclouds.trmk.vcloud_0_8.compute.domain.OrgAndName;
-import org.jclouds.trmk.vcloud_0_8.compute.functions.CreateUniqueKeyPair;
-import org.jclouds.trmk.vcloud_0_8.compute.options.TerremarkVCloudTemplateOptions;
-import org.jclouds.trmk.vcloud_0_8.domain.KeyPair;
-import org.jclouds.trmk.vcloud_0_8.xml.KeyPairHandlerTest;
-import org.testng.annotations.Test;
-
-/**
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class CreateNewKeyPairUnlessUserSpecifiedOtherwiseTest {
-
- public void testExecuteWithDefaultOptionsAlreadyHasKey() throws SecurityException, NoSuchMethodException {
- // setup constants
- URI org = URI.create("org1");
- String identity = "identity";
- String group = "group";
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
-
- // create mocks
- CreateNewKeyPairUnlessUserSpecifiedOtherwise strategy = setupStrategy();
- LoginCredentials keyPairCredentials = LoginCredentials.builder().privateKey(KeyPairHandlerTest.keyPair.getPrivateKey()).build();
-
- // setup expectations
- expect(strategy.credentialStore.containsKey("group#group")).andReturn(true);
- expect(strategy.credentialStore.get("group#group")).andReturn(keyPairCredentials);
-
- // replay mocks
- replayStrategy(strategy);
-
- // run
- strategy.execute(org, group, identity, options);
- assertEquals(options.getSshKeyFingerprint(), KeyPairHandlerTest.keyPair.getFingerPrint());
-
- // verify mocks
- verifyStrategy(strategy);
- }
-
- public void testCreateNewKeyPairUnlessUserSpecifiedOtherwise_reusesKeyWhenToldTo() {
- // setup constants
- URI org = URI.create("org1");
- String identity = "identity";
- String group = "group";
- TerremarkVCloudTemplateOptions options = sshKeyFingerprint("fingerprintFromUser");
-
- // create mocks
- CreateNewKeyPairUnlessUserSpecifiedOtherwise strategy = setupStrategy();
-
- // setup expectations
-
- // replay mocks
- replayStrategy(strategy);
-
- // run
- strategy.execute(org, group, identity, options);
- assertEquals(options.getSshKeyFingerprint(), "fingerprintFromUser");
-
- // verify mocks
- verifyStrategy(strategy);
- }
-
- @Test(enabled = false)
- // TODO add any() mock as we are calling new on KeyPairCredentials inside the
- // strategy
- public void testCreateNewKeyPairUnlessUserSpecifiedOtherwise_createsNewKeyPairAndReturnsItsNameByDefault() {
- // setup constants
- URI org = URI.create("org1");
- String identity = "identity";
- String group = "group";
- String systemGeneratedFingerprint = "systemGeneratedKeyPairfinger";
- TerremarkVCloudTemplateOptions options = new TerremarkVCloudTemplateOptions();
-
- // create mocks
- CreateNewKeyPairUnlessUserSpecifiedOtherwise strategy = setupStrategy();
- LoginCredentials keyPairCredentials = LoginCredentials.builder().privateKey(KeyPairHandlerTest.keyPair.getPrivateKey()).build();
- KeyPair keyPair = createMock(KeyPair.class);
-
- // setup expectations
- expect(strategy.credentialStore.containsKey("group#group")).andReturn(false);
- expect(strategy.createUniqueKeyPair.apply(new OrgAndName(org, "group"))).andReturn(keyPair);
- expect(keyPair.getFingerPrint()).andReturn(KeyPairHandlerTest.keyPair.getFingerPrint()).atLeastOnce();
- expect(strategy.credentialStore.put("group#group", keyPairCredentials)).andReturn(null);
-
- // replay mocks
- replay(keyPair);
- replayStrategy(strategy);
-
- // run
- strategy.execute(org, group, identity, options);
- assertEquals(options.getSshKeyFingerprint(), systemGeneratedFingerprint);
-
- // verify mocks
- verify(keyPair);
- verifyStrategy(strategy);
- }
-
- public void testCreateNewKeyPairUnlessUserSpecifiedOtherwise_doesntCreateAKeyPairAndReturnsNullWhenToldNotTo() {
- // setup constants
- URI org = URI.create("org1");
- String identity = "identity";
- String group = "group";
- TerremarkVCloudTemplateOptions options = noKeyPair();
-
- // create mocks
- CreateNewKeyPairUnlessUserSpecifiedOtherwise strategy = setupStrategy();
-
- // setup expectations
-
- // replay mocks
- replayStrategy(strategy);
-
- // run
- strategy.execute(org, group, identity, options);
- assertEquals(options.getSshKeyFingerprint(), null);
-
- // verify mocks
- verifyStrategy(strategy);
- }
-
- private void verifyStrategy(CreateNewKeyPairUnlessUserSpecifiedOtherwise strategy) {
- verify(strategy.credentialStore);
- verify(strategy.createUniqueKeyPair);
- }
-
- @SuppressWarnings("unchecked")
- private CreateNewKeyPairUnlessUserSpecifiedOtherwise setupStrategy() {
- Map<String, Credentials> credentialStore = createMock(ConcurrentMap.class);
- CreateUniqueKeyPair createUniqueKeyPair = createMock(CreateUniqueKeyPair.class);
-
- return new CreateNewKeyPairUnlessUserSpecifiedOtherwise(credentialStore, createUniqueKeyPair);
- }
-
- private void replayStrategy(CreateNewKeyPairUnlessUserSpecifiedOtherwise strategy) {
- replay(strategy.credentialStore);
- replay(strategy.createUniqueKeyPair);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/DeleteKeyPairTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/DeleteKeyPairTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/DeleteKeyPairTest.java
deleted file mode 100644
index 23191ae..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/DeleteKeyPairTest.java
+++ /dev/null
@@ -1,137 +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.trmk.vcloud_0_8.compute.strategy;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-
-import java.net.URI;
-import java.util.Map;
-import java.util.concurrent.ConcurrentMap;
-
-import org.jclouds.domain.Credentials;
-import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudApi;
-import org.jclouds.trmk.vcloud_0_8.compute.domain.OrgAndName;
-import org.jclouds.trmk.vcloud_0_8.domain.KeyPair;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-
-/**
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class DeleteKeyPairTest {
-
- public void testWhenNoKeyPairsInOrg() {
- URI org = URI.create("org1");
-
- // setup constants
- OrgAndName orgTag = new OrgAndName(org, "tag");
-
- // create mocks
- DeleteKeyPair strategy = setupStrategy();
-
- // setup expectations
- expect(strategy.terremarkClient.listKeyPairsInOrg(orgTag.getOrg())).andReturn(ImmutableSet.<KeyPair> of());
-
- // replay mocks
- replayStrategy(strategy);
-
- // run
- strategy.execute(orgTag);
-
- // verify mocks
- verifyStrategy(strategy);
- }
-
- public void testWhenKeyPairMatches() {
- URI org = URI.create("org1");
-
- // setup constants
- OrgAndName orgTag = new OrgAndName(org, "tag");
-
- // create mocks
- DeleteKeyPair strategy = setupStrategy();
- KeyPair keyPair = createMock(KeyPair.class);
-
- // setup expectations
- expect(strategy.terremarkClient.listKeyPairsInOrg(orgTag.getOrg())).andReturn(ImmutableSet.<KeyPair> of(keyPair));
- expect(keyPair.getName()).andReturn("jclouds_" + orgTag.getName() + "_123").atLeastOnce();
- expect(keyPair.getId()).andReturn(URI.create("1245"));
- strategy.terremarkClient.deleteKeyPair(URI.create("1245"));
- expect(strategy.credentialStore.remove("group#tag")).andReturn(null);
-
- // replay mocks
- replay(keyPair);
- replayStrategy(strategy);
-
- // run
- strategy.execute(orgTag);
-
- // verify mocks
- verify(keyPair);
- verifyStrategy(strategy);
- }
-
- public void testWhenKeyPairDoesntMatch() {
- URI org = URI.create("org1");
-
- // setup constants
- OrgAndName orgTag = new OrgAndName(org, "tag");
-
- // create mocks
- DeleteKeyPair strategy = setupStrategy();
- KeyPair keyPair = createMock(KeyPair.class);
-
- // setup expectations
- expect(strategy.terremarkClient.listKeyPairsInOrg(orgTag.getOrg())).andReturn(ImmutableSet.<KeyPair> of(keyPair));
- expect(keyPair.getName()).andReturn("kclouds_" + orgTag.getName() + "_123");
-
- // replay mocks
- replay(keyPair);
- replayStrategy(strategy);
-
- // run
- strategy.execute(orgTag);
-
- // verify mocks
- verify(keyPair);
- verifyStrategy(strategy);
- }
-
- private void verifyStrategy(DeleteKeyPair strategy) {
- verify(strategy.credentialStore);
- verify(strategy.terremarkClient);
- }
-
- @SuppressWarnings("unchecked")
- private DeleteKeyPair setupStrategy() {
- Map<String, Credentials> credentialStore = createMock(ConcurrentMap.class);
- TerremarkVCloudApi terremarkClient = createMock(TerremarkVCloudApi.class);
-
- return new DeleteKeyPair(terremarkClient, credentialStore);
- }
-
- private void replayStrategy(DeleteKeyPair strategy) {
- replay(strategy.credentialStore);
- replay(strategy.terremarkClient);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/PopulateDefaultLoginCredentialsForVAppTemplateTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/PopulateDefaultLoginCredentialsForVAppTemplateTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/PopulateDefaultLoginCredentialsForVAppTemplateTest.java
deleted file mode 100644
index 6fa72d8..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/strategy/PopulateDefaultLoginCredentialsForVAppTemplateTest.java
+++ /dev/null
@@ -1,117 +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.trmk.vcloud_0_8.compute.strategy;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.verify;
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.jclouds.compute.domain.OsFamily;
-import org.jclouds.domain.Credentials;
-import org.jclouds.domain.LoginCredentials;
-import org.jclouds.trmk.vcloud_0_8.domain.VAppTemplate;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-import com.google.common.io.ByteStreams;
-
-/**
- * @author Adrian Cole
- */
-@Test(groups = "unit")
-public class PopulateDefaultLoginCredentialsForVAppTemplateTest {
-
- @Test
- public void testRhel() throws IOException {
- InputStream is = getClass().getResourceAsStream("/rhel_description.txt");
- String description = new String(ByteStreams.toByteArray(is));
- VAppTemplate template = createMock(VAppTemplate.class);
- expect(template.getDescription()).andReturn(description).atLeastOnce();
- replay(template);
- ParseVAppTemplateDescriptionToGetDefaultLoginCredentials converter = new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(
- null, ImmutableMap.<String, Credentials> of(), ImmutableMap.<OsFamily, LoginCredentials> of());
- Credentials creds = converter.apply(template);
- assertEquals(creds.identity, "vcloud");
- assertEquals(creds.credential, "$Ep455l0ud!2");
- verify(template);
- }
-
- @Test
- public void testLamp() throws IOException {
- InputStream is = getClass().getResourceAsStream("/lamp_description.txt");
- String description = new String(ByteStreams.toByteArray(is));
- VAppTemplate template = createMock(VAppTemplate.class);
- expect(template.getDescription()).andReturn(description).atLeastOnce();
- replay(template);
- ParseVAppTemplateDescriptionToGetDefaultLoginCredentials converter = new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(
- null, ImmutableMap.<String, Credentials> of(), ImmutableMap.<OsFamily, LoginCredentials> of());
- Credentials creds = converter.apply(template);
- assertEquals(creds.identity, "ecloud");
- assertEquals(creds.credential, "$Ep455l0ud!2");
- verify(template);
- }
-
- @Test
- public void testFt() throws IOException {
- InputStream is = getClass().getResourceAsStream("/ft_description.txt");
- String description = new String(ByteStreams.toByteArray(is));
- VAppTemplate template = createMock(VAppTemplate.class);
- expect(template.getDescription()).andReturn(description).atLeastOnce();
- replay(template);
- ParseVAppTemplateDescriptionToGetDefaultLoginCredentials converter = new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(
- null, ImmutableMap.<String, Credentials> of(), ImmutableMap.<OsFamily, LoginCredentials> of());
- Credentials creds = converter.apply(template);
- assertEquals(creds.identity, "vpncubed");
- assertEquals(creds.credential, "vpncubed");
- verify(template);
- }
-
- @Test
- public void testEC() throws IOException {
- InputStream is = getClass().getResourceAsStream("/ec_description.txt");
- String description = new String(ByteStreams.toByteArray(is));
- VAppTemplate template = createMock(VAppTemplate.class);
- expect(template.getDescription()).andReturn(description).atLeastOnce();
- replay(template);
- ParseVAppTemplateDescriptionToGetDefaultLoginCredentials converter = new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(
- null, ImmutableMap.<String, Credentials> of(), ImmutableMap.<OsFamily, LoginCredentials> of());
- Credentials creds = converter.apply(template);
- assertEquals(creds.identity, "ecloud");
- assertEquals(creds.credential, "TmrkCl0ud1s#1!");
- verify(template);
- }
-
- @Test
- public void testWindows() throws IOException {
- InputStream is = getClass().getResourceAsStream("/windows_description.txt");
- String description = new String(ByteStreams.toByteArray(is));
- VAppTemplate template = createMock(VAppTemplate.class);
- expect(template.getDescription()).andReturn(description).atLeastOnce();
- replay(template);
- ParseVAppTemplateDescriptionToGetDefaultLoginCredentials converter = new ParseVAppTemplateDescriptionToGetDefaultLoginCredentials(
- null, ImmutableMap.<String, Credentials> of(), ImmutableMap.<OsFamily, LoginCredentials> of());
- Credentials creds = converter.apply(template);
- assertEquals(creds.identity, "Administrator");
- assertEquals(creds.credential, null);
- verify(template);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/VAppTemplatesInOrgsLiveTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/VAppTemplatesInOrgsLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/VAppTemplatesInOrgsLiveTest.java
deleted file mode 100644
index 221fd71..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/compute/suppliers/VAppTemplatesInOrgsLiveTest.java
+++ /dev/null
@@ -1,74 +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.trmk.vcloud_0_8.compute.suppliers;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.Set;
-
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
-import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudApi;
-import org.jclouds.trmk.vcloud_0_8.domain.CatalogItem;
-import org.jclouds.trmk.vcloud_0_8.functions.AllCatalogItemsInOrg;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Iterables;
-import com.google.inject.Injector;
-
-/**
- * Tests behavior of {@code VAppTemplatesInOrgs}
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", singleThreaded = true, testName = "VAppTemplatesInOrgsLiveTest")
-public class VAppTemplatesInOrgsLiveTest
-extends BaseComputeServiceContextLiveTest {
-
- public VAppTemplatesInOrgsLiveTest() {
- provider = "trmk-vcloudexpress";
- }
-
- private TerremarkVCloudApi tmClient;
- private VAppTemplatesInOrgs parser;
- private AllCatalogItemsInOrg allCatalogItemsInOrg;
-
- @Override
- @BeforeClass(groups = { "integration", "live" })
- public void setupContext() {
- super.setupContext();
- Injector injector = view.utils().injector();
-
- tmClient = injector.getInstance(TerremarkVCloudApi.class);
- allCatalogItemsInOrg = injector.getInstance(AllCatalogItemsInOrg.class);
- parser = injector.getInstance(VAppTemplatesInOrgs.class);
- }
-
- @Test
- public void testParseAllImages() {
-
- Set<? extends Image> images = parser.get();
-
- Iterable<? extends CatalogItem> templates = allCatalogItemsInOrg.apply(tmClient
- .findOrgNamed(null));
-
- assertEquals(images.size(), Iterables.size(templates));
- assert images.size() > 0;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/filters/SetVCloudTokenCookieTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/filters/SetVCloudTokenCookieTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/filters/SetVCloudTokenCookieTest.java
deleted file mode 100644
index ea49487..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/filters/SetVCloudTokenCookieTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.trmk.vcloud_0_8.filters;
-
-import static org.testng.Assert.assertEquals;
-
-import javax.inject.Provider;
-import javax.ws.rs.core.HttpHeaders;
-
-import org.jclouds.http.HttpRequest;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-/**
- * @author Adrian Cole
- */
-@Test
-public class SetVCloudTokenCookieTest {
-
- private SetVCloudTokenCookie filter;
-
- @BeforeTest
- void setUp() {
- filter = new SetVCloudTokenCookie(new Provider<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/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/functions/ParseLoginResponseFromHeadersTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/functions/ParseLoginResponseFromHeadersTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/functions/ParseLoginResponseFromHeadersTest.java
deleted file mode 100644
index 65ff85d..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/functions/ParseLoginResponseFromHeadersTest.java
+++ /dev/null
@@ -1,147 +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.trmk.vcloud_0_8.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.trmk.vcloud_0_8.TerremarkVCloudMediaType;
-import org.jclouds.trmk.vcloud_0_8.domain.VCloudSession;
-import org.jclouds.trmk.vcloud_0_8.domain.internal.ReferenceTypeImpl;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Tests behavior of {@code ParseLoginResponseFromHeaders}
- *
- * @author Adrian Cole
- */
-// NOTE:without testName, this will not call @Before* and fail w/NPE during
-// surefire
-@Test(groups = "unit", testName = "ParseLoginResponseFromHeadersTest")
-public class ParseLoginResponseFromHeadersTest extends BaseHandlerTest {
-
- private ParseLoginResponseFromHeaders parser;
-
- @BeforeTest
- void setUp() {
- parser = injector.getInstance(ParseLoginResponseFromHeaders.class);
- }
-
- @Test
- public void testApply() {
- HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
- .payload(getClass().getResourceAsStream("/orglist.xml"))
- .addHeader("x-vcloud-authorization", "vcloud-token=9er4d061-4bff-48fa-84b1-5da7166764d2; path=/").build();
- response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
- response.getPayload().getContentMetadata().setContentLength(307l);
-
- VCloudSession reply = parser.apply(response);
- assertEquals(reply.getVCloudToken(), "9er4d061-4bff-48fa-84b1-5da7166764d2");
- assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
- TerremarkVCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
-
- }
-
- @Test
- public void testApplyBlueLock() {
- HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
- .payload(getClass().getResourceAsStream("/orglist.xml"))
- .addHeader("x-vcloud-authorization", "MUKOJ2HoAfoMmLnHRp4esNb2MtWscCLLhVysnsIsCG0=").build();
- response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
- response.getPayload().getContentMetadata().setContentLength(307l);
-
- VCloudSession reply = parser.apply(response);
- assertEquals(reply.getVCloudToken(), "MUKOJ2HoAfoMmLnHRp4esNb2MtWscCLLhVysnsIsCG0=");
- assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
- TerremarkVCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
-
- }
-
- @Test
- public void testApplyTerremark() {
- HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
- .payload(getClass().getResourceAsStream("/orglist.xml"))
- .addHeader("Set-Cookie", "vcloud-token=37ce2715-9aba-4f48-8e45-2db8a8da702d; path=/").build();
- response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
- response.getPayload().getContentMetadata().setContentLength(307l);
-
- VCloudSession reply = parser.apply(response);
- assertEquals(reply.getVCloudToken(), "37ce2715-9aba-4f48-8e45-2db8a8da702d");
- assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
- TerremarkVCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
-
- }
-
- @Test
- public void testApplyTerremarkMultipleCookies() {
- HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
- .payload(getClass().getResourceAsStream("/orglist.xml"))
- .addHeader("Set-Cookie", "NSC_ESUO_21654_72.46.239.132_443=fooo;expires=Thu, 02-Jun-2011 17:19:26 GMT;path=/;secure;httponly")
- .addHeader("Set-Cookie", "vcloud-token=37ce2715-9aba-4f48-8e45-2db8a8da702d; path=/").build();
- response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
- response.getPayload().getContentMetadata().setContentLength(307l);
-
- VCloudSession reply = parser.apply(response);
- assertEquals(reply.getVCloudToken(), "37ce2715-9aba-4f48-8e45-2db8a8da702d");
- assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
- TerremarkVCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
-
- }
-
- @Test(expectedExceptions = HttpResponseException.class)
- public void testUnmatchedCookieThrowsHttpResponseException() {
- HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
- .payload(getClass().getResourceAsStream("/orglist.xml"))
- .addHeader("Set-Cookie", "NSC_ESUO_21654_72.46.239.132_443=fooo;expires=Thu, 02-Jun-2011 17:19:26 GMT;path=/;secure;httponly").build();
- response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
- response.getPayload().getContentMetadata().setContentLength(307l);
-
- parser.apply(response);
- }
-
- @Test(expectedExceptions = HttpResponseException.class)
- public void testNoThrowsHttpResponseException() {
- HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
- .payload(getClass().getResourceAsStream("/orglist.xml")).build();
- response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
- response.getPayload().getContentMetadata().setContentLength(307l);
-
- parser.apply(response);
- }
-
- @Test
- public void testApplyVirtacore() {
- HttpResponse response = HttpResponse.builder().statusCode(200).message("OK")
- .payload(getClass().getResourceAsStream("/orglist.xml"))
- .addHeader("x-vcloud-authorization", "vcloud-token=IPy0w7UGD4lwtdWAK/ZVzfuLK+dztxGRqsOhWqV0i48=").build();
- response.getPayload().getContentMetadata().setContentType("Content-Type: application/xml; charset=utf-8");
- response.getPayload().getContentMetadata().setContentLength(307l);
-
- VCloudSession reply = parser.apply(response);
- assertEquals(reply.getVCloudToken(), "IPy0w7UGD4lwtdWAK/ZVzfuLK+dztxGRqsOhWqV0i48=");
- assertEquals(reply.getOrgs(), ImmutableMap.of("adrian@jclouds.org", new ReferenceTypeImpl("adrian@jclouds.org",
- TerremarkVCloudMediaType.ORG_XML, URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/org/48"))));
-
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/handlers/ParseTerremarkVCloudErrorFromHttpResponseTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/handlers/ParseTerremarkVCloudErrorFromHttpResponseTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/handlers/ParseTerremarkVCloudErrorFromHttpResponseTest.java
deleted file mode 100644
index f9abf53..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/handlers/ParseTerremarkVCloudErrorFromHttpResponseTest.java
+++ /dev/null
@@ -1,105 +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.trmk.vcloud_0_8.handlers;
-
-import java.net.URI;
-
-import org.jclouds.http.BaseHttpErrorHandlerTest;
-import org.jclouds.http.HttpErrorHandler;
-import org.jclouds.rest.AuthorizationException;
-import org.jclouds.rest.InsufficientResourcesException;
-import org.jclouds.rest.ResourceNotFoundException;
-import org.testng.annotations.Test;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = { "unit" })
-public class ParseTerremarkVCloudErrorFromHttpResponseTest extends BaseHttpErrorHandlerTest {
- @Test
- public void testGet400SetsIllegalArgumentException() {
- assertCodeMakes("GET", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"), 400,
- "HTTP/1.1 400 Service name is required.", "", IllegalArgumentException.class);
- }
-
- @Test
- public void testGet403SetsResourceNotFoundException() {
- assertCodeMakes(
- "GET",
- URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"),
- 403,
- "HTTP/1.1 403 Internet Service does not exist in the system. Internet Service was probably deleted by another user. Please refresh and retry the operation",
- "", ResourceNotFoundException.class);
- }
-
- @Test
- public void testDelete403SetsResourceNotFoundException() {
- assertCodeMakes(
- "DELETE",
- URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vapp/361849"),
- 403,
- "HTTP/1.1 403 Server does not exist in the system. Server was probably deleted by another user. Please refresh and retry the operation",
- "", ResourceNotFoundException.class);
- }
-
- @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 test401SetsAuthorizationException() {
- assertCodeMakes("GET", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"), 401,
- "", "", AuthorizationException.class);
- }
-
- @Test
- public void test403SetsInsufficientResourcesException() {
- assertCodeMakes("GET", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"), 403,
- "There are no additional Public IPs available", "", InsufficientResourcesException.class);
- }
-
- @Test
- public void test501SetsNotImplementedMakesUnsupportedOperationException() {
- assertCodeMakes("POST", URI
- .create("https://services.enterprisecloud.terremark.com/api/v0.8b-ext2.5/vapp/49373/action/undeploy"),
- 501, "HTTP/1.1 501 NotImplemented", "", UnsupportedOperationException.class);
- }
-
- @Test
- public void testbecause_there_is_a_pending_task_runningSetsIllegalStateException() {
- assertCodeMakes("GET", URI.create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/vdc/32"), 500,
- "because there is a pending task running", "because there is a pending task running",
- IllegalStateException.class);
- }
-
- @Test
- public void testKeyAlreadyExistsSetsIllegalStateException() {
- assertCodeMakes("POST", URI
- .create("https://services.vcloudexpress.terremark.com/api/v0.8a-ext1.6/extensions/org/48/keys"), 400,
- "Security key with name livetest exists.", "Security key with name livetest exists.",
- IllegalStateException.class);
- }
-
- @Override
- protected Class<? extends HttpErrorHandler> getHandlerClass() {
- return ParseTerremarkVCloudErrorFromHttpResponse.class;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BasePayloadTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BasePayloadTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BasePayloadTest.java
deleted file mode 100644
index 3a17701..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BasePayloadTest.java
+++ /dev/null
@@ -1,40 +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.trmk.vcloud_0_8.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 com.google.common.base.Throwables;
-
-public class BasePayloadTest {
-
- 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/incubator-jclouds/blob/ddfefd7e/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkApiLiveTest.java
----------------------------------------------------------------------
diff --git a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkApiLiveTest.java b/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkApiLiveTest.java
deleted file mode 100644
index ad14f33..0000000
--- a/common/trmk/src/test/java/org/jclouds/trmk/vcloud_0_8/internal/BaseTerremarkApiLiveTest.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.trmk.vcloud_0_8.internal;
-
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.jclouds.util.Predicates2.retry;
-
-import org.jclouds.compute.ComputeService;
-import org.jclouds.compute.internal.BaseComputeServiceContextLiveTest;
-import org.jclouds.predicates.SocketOpen;
-import org.jclouds.ssh.SshClient.Factory;
-import org.jclouds.sshj.config.SshjSshClientModule;
-import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudApi;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.net.HostAndPort;
-import com.google.inject.Injector;
-import com.google.inject.Module;
-
-/**
- *
- * @author Adrian Cole
- */
-@Test(groups = "live", enabled = true, singleThreaded = true)
-public abstract class BaseTerremarkApiLiveTest extends BaseComputeServiceContextLiveTest {
-
- protected String prefix = System.getProperty("user.name");
-
- protected ComputeService client;
-
- public BaseTerremarkApiLiveTest() {
- provider = "trmk-ecloud";
- }
-
- protected Predicate<HostAndPort> socketTester;
- protected Factory sshFactory;
- protected TerremarkVCloudApi api;
-
- @Override
- @BeforeClass(groups = { "integration", "live" })
- public void setupContext() {
- super.setupContext();
- Injector injector = view.utils().injector();
- SocketOpen socketOpen = injector.getInstance(SocketOpen.class);
- socketTester = retry(socketOpen, 300, 1, SECONDS);
- sshFactory = injector.getInstance(Factory.class);
- api = injector.getInstance(TerremarkVCloudApi.class);
- }
-
- protected Module getSshModule() {
- return new SshjSshClientModule();
- }
-
-}