fixed test cases

This commit is contained in:
Adrian Cole 2010-11-07 20:20:35 +01:00
parent 15e30cfbaa
commit 5f5b01ad35
8 changed files with 35 additions and 87 deletions

View File

@ -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);

View File

@ -1,62 +0,0 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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);
}
}

View File

@ -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.<Module> 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<Queue> 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<Queue> 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;

View File

@ -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());

View File

@ -78,13 +78,13 @@ public class VCloudClientLiveTest extends CommonVCloudClientLiveTest<VCloudClien
Catalog response = connection.getCatalog(cat.getHref());
for (ReferenceType resource : response.values()) {
if (resource.getType().equals(VCloudMediaType.CATALOGITEM_XML)) {
CatalogItem item = connection.getCatalogItem(resource.getHref());
if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) {
try {
try {
CatalogItem item = connection.getCatalogItem(resource.getHref());
if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) {
assertNotNull(connection.getOvfEnvelopeForVAppTemplate(item.getEntity().getHref()));
} catch (AuthorizationException e) {
}
} catch (AuthorizationException e) {
}
}
}
@ -162,7 +162,7 @@ public class VCloudClientLiveTest extends CommonVCloudClientLiveTest<VCloudClien
if (item.getEntity().getType().equals(VCloudMediaType.VAPPTEMPLATE_XML)) {
try {
assertNotNull(connection.findVAppTemplateInOrgCatalogNamed(org.getName(), response.getName(), item
.getEntity().getName()));
.getEntity().getName()));
} catch (AuthorizationException e) {
}

View File

@ -57,8 +57,7 @@ public class ParseTerremarkVCloudErrorFromHttpResponse implements HttpErrorHandl
if (response.getMessage() != null
&& ((response.getMessage().indexOf("because there is a pending task running") != -1)
|| (response.getMessage().indexOf("because it is already powered off") != -1)
|| (response.getMessage().indexOf("already exists") != -1) || (response.getMessage()
.indexOf("same name exists") != -1)))
|| (response.getMessage().indexOf("exists") != -1)))
exception = new IllegalStateException(response.getMessage(), exception);
else
switch (response.getStatusCode()) {

View File

@ -68,7 +68,7 @@ public class TerremarkECloudComputeServiceLiveTest extends BaseComputeServiceLiv
public void testAssignability() throws Exception {
@SuppressWarnings("unused")
RestContext<TerremarkECloudClient, TerremarkECloudAsyncClient> 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<TerremarkVCloudClient, TerremarkVCloudClient> 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());
}

View File

@ -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<? extends HttpErrorHandler> getHandlerClass() {
return ParseTerremarkVCloudErrorFromHttpResponse.class;