From 5f5b01ad35bbb95835e01388fa25296faee86b49 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Sun, 7 Nov 2010 20:20:35 +0100 Subject: [PATCH] fixed test cases --- .../handlers/ParseAWSErrorFromXmlContent.java | 2 + .../EucalyptusComputeServiceLiveTest.java | 62 ------------------- .../jclouds/aws/sqs/SQSClientLiveTest.java | 24 +++---- ...kVCloudDirectorComputeServiceLiveTest.java | 4 +- .../jclouds/vcloud/VCloudClientLiveTest.java | 12 ++-- ...eTerremarkVCloudErrorFromHttpResponse.java | 3 +- ...TerremarkECloudComputeServiceLiveTest.java | 8 +-- ...remarkVCloudErrorFromHttpResponseTest.java | 7 +++ 8 files changed, 35 insertions(+), 87 deletions(-) delete mode 100644 aws/core/src/test/java/org/jclouds/aws/ec2/compute/EucalyptusComputeServiceLiveTest.java diff --git a/aws/core/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java b/aws/core/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java index b7af9095f3..c31338a882 100755 --- a/aws/core/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java +++ b/aws/core/src/main/java/org/jclouds/aws/handlers/ParseAWSErrorFromXmlContent.java @@ -116,6 +116,8 @@ public class ParseAWSErrorFromXmlContent implements HttpErrorHandler { exception = new KeyNotFoundException(container, key, message); } break; + case 409: + exception = new IllegalStateException(message, exception); } } finally { releasePayload(response); diff --git a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EucalyptusComputeServiceLiveTest.java b/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EucalyptusComputeServiceLiveTest.java deleted file mode 100644 index da51847a03..0000000000 --- a/aws/core/src/test/java/org/jclouds/aws/ec2/compute/EucalyptusComputeServiceLiveTest.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * - * Copyright (C) 2010 Cloud Conscious, LLC. - * - * ==================================================================== - * Licensed 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.aws.ec2.compute; - -import static org.jclouds.compute.util.ComputeServiceUtils.getCores; -import static org.testng.Assert.assertEquals; - -import org.jclouds.compute.domain.OsFamily; -import org.jclouds.compute.domain.Template; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - -/** - * - * @author Adrian Cole - */ -@Test(groups = "live", sequential = true, testName = "ec2.EucalyptusComputeServiceLiveTest") -public class EucalyptusComputeServiceLiveTest extends EC2ComputeServiceLiveTest { - - public EucalyptusComputeServiceLiveTest() { - provider = "eucalyptus"; - } - - @BeforeClass - @Override - public void setServiceDefaults() { - // security groups must be <30 characters - tag = "euc"; - } - - @Override - @Test(enabled = false) - public void testExtendedOptionsAndLogin() throws Exception { - // euc does not support monitoring - } - - @Override - protected void assertDefaultWorks() { - Template defaultTemplate = client.templateBuilder().build(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.CENTOS); - assertEquals(getCores(defaultTemplate.getHardware()), 2.0d); - } - -} diff --git a/aws/core/src/test/java/org/jclouds/aws/sqs/SQSClientLiveTest.java b/aws/core/src/test/java/org/jclouds/aws/sqs/SQSClientLiveTest.java index 77692c30ba..53b57d3186 100644 --- a/aws/core/src/test/java/org/jclouds/aws/sqs/SQSClientLiveTest.java +++ b/aws/core/src/test/java/org/jclouds/aws/sqs/SQSClientLiveTest.java @@ -68,10 +68,9 @@ public class SQSClientLiveTest { protected void setupCredentials() { identity = checkNotNull(System.getProperty("test." + provider + ".identity"), "test." + provider + ".identity"); credential = checkNotNull(System.getProperty("test." + provider + ".credential"), "test." + provider - + ".credential"); - endpoint = checkNotNull(System.getProperty("test." + provider + ".endpoint"), "test." + provider + ".endpoint"); - apiversion = checkNotNull(System.getProperty("test." + provider + ".apiversion"), "test." + provider - + ".apiversion"); + + ".credential"); + endpoint = System.getProperty("test." + provider + ".endpoint"); + apiversion = System.getProperty("test." + provider + ".apiversion"); } protected Properties setupProperties() { @@ -79,9 +78,12 @@ public class SQSClientLiveTest { overrides.setProperty(Constants.PROPERTY_TRUST_ALL_CERTS, "true"); overrides.setProperty(Constants.PROPERTY_RELAX_HOSTNAME, "true"); overrides.setProperty(provider + ".identity", identity); - overrides.setProperty(provider + ".credential", credential); - overrides.setProperty(provider + ".endpoint", endpoint); - overrides.setProperty(provider + ".apiversion", apiversion); + if (credential != null) + overrides.setProperty(provider + ".credential", credential); + if (endpoint != null) + overrides.setProperty(provider + ".endpoint", endpoint); + if (apiversion != null) + overrides.setProperty(provider + ".apiversion", apiversion); return overrides; } @@ -90,14 +92,14 @@ public class SQSClientLiveTest { setupCredentials(); Properties overrides = setupProperties(); context = new RestContextFactory().createContext(provider, ImmutableSet. of(new Log4JLoggingModule()), - overrides); + overrides); this.client = context.getApi(); } @Test void testListQueuesInRegion() throws InterruptedException { for (String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1, - Region.AP_SOUTHEAST_1)) { + Region.AP_SOUTHEAST_1)) { SortedSet allResults = Sets.newTreeSet(client.listQueuesInRegion(region)); assertNotNull(allResults); if (allResults.size() >= 1) { @@ -114,7 +116,7 @@ public class SQSClientLiveTest { String queueName = PREFIX + "1"; for (final String region : Lists.newArrayList(null, Region.EU_WEST_1, Region.US_EAST_1, Region.US_WEST_1, - Region.AP_SOUTHEAST_1)) { + Region.AP_SOUTHEAST_1)) { try { SortedSet result = Sets.newTreeSet(client.listQueuesInRegion(region, queuePrefix(queueName))); if (result.size() >= 1) { @@ -182,7 +184,7 @@ public class SQSClientLiveTest { assertion.run(); if (i > 0) System.err.printf("%d attempts and %dms asserting %s%n", i + 1, System.currentTimeMillis() - start, - assertion.getClass().getSimpleName()); + assertion.getClass().getSimpleName()); return; } catch (AssertionError e) { error = e; diff --git a/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java b/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java index 5a216d0ead..6eebfa0a8e 100644 --- a/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java +++ b/vcloud/bluelock/src/test/java/org/jclouds/vcloud/bluelock/compute/BlueLockVCloudDirectorComputeServiceLiveTest.java @@ -49,10 +49,10 @@ public class BlueLockVCloudDirectorComputeServiceLiveTest extends VCloudComputeS @Test public void testTemplateBuilder() { Template defaultTemplate = client.templateBuilder().build(); - assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), false); + assertEquals(defaultTemplate.getImage().getOperatingSystem().is64Bit(), true); assert OperatingSystemPredicates.supportsApt().apply(defaultTemplate.getImage().getOperatingSystem()); assertEquals(defaultTemplate.getImage().getOperatingSystem().getFamily(), OsFamily.UBUNTU); - assertEquals(defaultTemplate.getImage().getOperatingSystem().getDescription(), "Ubuntu Linux (32-bit)"); + assertEquals(defaultTemplate.getImage().getOperatingSystem().getDescription(), "Ubuntu Linux (64-bit)"); assert defaultTemplate.getLocation().getId() != null : defaultTemplate.getLocation(); assertEquals(getCores(defaultTemplate.getHardware()), 1.0d); System.out.println(defaultTemplate.getHardware()); diff --git a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java index 927ab5be2c..df802533d5 100644 --- a/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java +++ b/vcloud/core/src/test/java/org/jclouds/vcloud/VCloudClientLiveTest.java @@ -78,13 +78,13 @@ public class VCloudClientLiveTest extends CommonVCloudClientLiveTest tmContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); + .createContext(provider, identity, credential).getProviderSpecificContext(); } @Override @@ -84,7 +84,7 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv @Override protected void checkOsMatchesTemplate(NodeMetadata node) { if (node.getOperatingSystem() != null) - assertEquals(node.getOperatingSystem().getFamily(), OsFamily.UNRECOGNIZED); + assertEquals(node.getOperatingSystem().getFamily(), null); } @Override @@ -94,7 +94,7 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv // image.getLocationId() can be null, if it is a location-free image assertEquals(image.getType(), ComputeType.IMAGE); if (image.getOperatingSystem().getFamily() != OsFamily.WINDOWS - && image.getOperatingSystem().getFamily() != OsFamily.SOLARIS) { + && image.getOperatingSystem().getFamily() != OsFamily.SOLARIS) { assert image.getDefaultCredentials() != null && image.getDefaultCredentials().identity != null : image; assert image.getDefaultCredentials().credential != null : image; } @@ -110,7 +110,7 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv NodeMetadata allData = client.getNodeMetadata(node.getId()); System.out.println(allData.getHardware()); RestContext tmContext = new ComputeServiceContextFactory() - .createContext(provider, identity, credential).getProviderSpecificContext(); + .createContext(provider, identity, credential).getProviderSpecificContext(); VCloudExpressVApp vApp = tmContext.getApi().findVAppInOrgVDCNamed(null, null, allData.getName()); assertEquals(vApp.getName(), allData.getName()); } diff --git a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponseTest.java b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponseTest.java index 19062050d9..1c1365a1cc 100644 --- a/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponseTest.java +++ b/vcloud/terremark/src/test/java/org/jclouds/vcloud/terremark/handlers/ParseTerremarkVCloudErrorFromHttpResponseTest.java @@ -85,6 +85,13 @@ public class ParseTerremarkVCloudErrorFromHttpResponseTest extends BaseHttpError 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 getHandlerClass() { return ParseTerremarkVCloudErrorFromHttpResponse.class;