adding more tests and fixing others

This commit is contained in:
Mike Arnold 2012-03-09 14:45:45 -06:00
parent ec2a83197d
commit 940dc4c29b
3 changed files with 81 additions and 10 deletions

View File

@ -0,0 +1,80 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.openstack.nova.v1_1.features;
import org.jclouds.openstack.nova.v1_1.domain.KeyPair;
import org.jclouds.openstack.nova.v1_1.internal.BaseNovaClientLiveTest;
import org.testng.annotations.Test;
import java.util.Map;
import java.util.Set;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
/**
* Tests behavior of {@code KeyPairClient}
*
* @author Michael Arnold
*/
@Test(groups = "live", testName = "KeyPairClientLiveTest")
public class KeyPairClientLiveTest extends BaseNovaClientLiveTest {
public void testListKeyPairs() throws Exception {
for (String regionId : context.getApi().getConfiguredRegions()) {
KeyPairClient client = context.getApi().getKeyPairClientForRegion(regionId);
Set<Map<String, KeyPair>> keyPairsList = client.listKeyPairs();
assertNotNull(keyPairsList);
}
}
public void testCreateAndDeleteKeyPair() throws Exception {
final String KEYPAIR_NAME = "testkp";
for(String regionId : context.getApi().getConfiguredRegions()) {
KeyPairClient client = context.getApi().getKeyPairClientForRegion(regionId);
KeyPair keyPair = null;
try {
keyPair = client.createKeyPair(KEYPAIR_NAME);
assertNotNull(keyPair);
} finally {
if (keyPair != null) {
client.deleteKeyPair(KEYPAIR_NAME);
}
}
}
}
public void testCreateAndDeleteKeyPairWithPublicKey() throws Exception {
final String KEYPAIR_NAME = "testkp";
final String PUBLIC_KEY = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCrrBREFxz3002l1HuXz0+UOdJQ/mOYD5DiJwwB/TOybwIKQJPOxJWA9gBoo4k9dthTKBTaEYbzrll7iZcp59E80S6mNiAr3mUgi+x5Y8uyXeJ2Ws+h6peVyFVUu9epkwpcTd1GVfdcVWsTajwDz9+lxCDhl0RZKDFoT0scTxbj/w== nova@nv-aw2az2-api0002";
for(String regionId : context.getApi().getConfiguredRegions()) {
KeyPairClient client = context.getApi().getKeyPairClientForRegion(regionId);
KeyPair keyPair = null;
try {
keyPair = client.createKeyPairWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY);
assertNotNull(keyPair);
} finally {
if (keyPair != null) {
client.deleteKeyPair(KEYPAIR_NAME);
}
}
}
}
}

View File

@ -23,9 +23,6 @@ import com.google.inject.Guice;
import com.google.inject.Injector;
import org.jclouds.json.BaseSetParserTest;
import org.jclouds.json.config.GsonModule;
import org.jclouds.openstack.domain.Link;
import org.jclouds.openstack.domain.Link.Relation;
import org.jclouds.openstack.domain.Resource;
import org.jclouds.openstack.nova.v1_1.config.NovaParserModule;
import org.jclouds.openstack.nova.v1_1.domain.FloatingIP;
import org.jclouds.rest.annotations.SelectJson;
@ -33,7 +30,6 @@ import org.testng.annotations.Test;
import javax.ws.rs.Consumes;
import javax.ws.rs.core.MediaType;
import java.net.URI;
import java.util.Set;
/**

View File

@ -18,25 +18,20 @@
*/
package org.jclouds.openstack.nova.v1_1.parse;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.jclouds.json.BaseItemParserTest;
import org.jclouds.json.config.GsonModule;
import org.jclouds.openstack.domain.Link;
import org.jclouds.openstack.domain.Link.Relation;
import org.jclouds.openstack.nova.v1_1.config.NovaParserModule;
import org.jclouds.openstack.nova.v1_1.domain.Flavor;
import org.jclouds.openstack.nova.v1_1.domain.FloatingIP;
import org.jclouds.rest.annotations.SelectJson;
import org.testng.annotations.Test;
import javax.ws.rs.Consumes;
import javax.ws.rs.core.MediaType;
import java.net.URI;
/**
* @author Jeremy Daggett
* @author Michael Arnold
*/
@Test(groups = "unit", testName = "ParseFloatingIPTest")
public class ParseFloatingIPTest extends BaseItemParserTest<FloatingIP> {