test classes for development

This commit is contained in:
Dmitri Babaev 2011-04-22 13:26:31 +04:00
parent 78db8f1bfc
commit 4198f23f4b
4 changed files with 22 additions and 54 deletions

View File

@ -1,4 +1,4 @@
package org.jclouds.openstack.nova.live.nonmaven;
package org.jclouds.openstack.nova.live;
import com.google.common.collect.ImmutableSet;
import org.jclouds.compute.ComputeService;
@ -21,7 +21,11 @@ import java.util.Set;
import static org.jclouds.openstack.nova.live.PropertyHelper.setupOverrides;
import static org.jclouds.openstack.nova.live.PropertyHelper.setupProperties;
public class SimpleCreateServerCheck {
/**
* Not intended to be run with maven and does not performs a cleanup after tests
* @author Dmitri Babaev
*/
public class ComputeSericeCheck {
private ComputeServiceContextFactory contextFactory;
private ComputeServiceContext context;
@ -33,6 +37,16 @@ public class SimpleCreateServerCheck {
ImmutableSet.of(new JschSshClientModule(), new SLF4JLoggingModule()), properties);
}
@Test
public void testLists() {
ComputeService cs = context.getComputeService();
System.out.println(cs.listImages());
System.out.println(cs.listHardwareProfiles());
System.out.println(cs.listAssignableLocations());
System.out.println(cs.listNodes());
}
@Test
public void testCreateServer() throws RunNodesException {
ComputeService cs = context.getComputeService();

View File

@ -8,13 +8,13 @@ import org.jclouds.Constants;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.Properties;
/**
* @author Victor Galkin
*/
public class PropertyHelper {
public static String provider = "nova";
@ -30,10 +30,12 @@ public class PropertyHelper {
"public", Files.toString(new File(properties.getProperty("test.ssh.keyfile.public")), Charsets.UTF_8));
}
public static Properties setupProperties(Class clazz) throws IOException {
public static Properties setupProperties(Class<?> clazz) throws IOException {
Properties properties = new Properties();
properties.load(clazz.getResourceAsStream("/test.properties"));
InputStream propertiesStream = clazz.getResourceAsStream("/test.properties");
if (propertiesStream != null)
properties.load(propertiesStream);
overridePropertyFromSystemProperty(properties, "test." + provider + ".endpoint");
overridePropertyFromSystemProperty(properties, "test." + provider + ".apiversion");
overridePropertyFromSystemProperty(properties, "test." + provider + ".identity");

View File

@ -1,49 +0,0 @@
package org.jclouds.openstack.nova.live.nonmaven;
import com.google.common.collect.ImmutableSet;
import org.jclouds.compute.ComputeService;
import org.jclouds.compute.ComputeServiceContext;
import org.jclouds.compute.ComputeServiceContextFactory;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import org.jclouds.ssh.jsch.config.JschSshClientModule;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import java.io.IOException;
import java.util.Properties;
import static org.jclouds.openstack.nova.live.PropertyHelper.setupOverrides;
import static org.jclouds.openstack.nova.live.PropertyHelper.setupProperties;
public class SimpleListCheck {
private ComputeServiceContextFactory contextFactory;
private ComputeServiceContext context;
@BeforeTest
public void setupClient() throws IOException {
contextFactory = new ComputeServiceContextFactory();
Properties properties = setupOverrides(setupProperties(this.getClass()));
context = contextFactory.createContext("nova",
ImmutableSet.of(new JschSshClientModule(), new SLF4JLoggingModule()), properties);
}
@Test
public void testLists() {
ComputeService cs = context.getComputeService();
System.out.println(cs.listImages());
System.out.println(cs.listHardwareProfiles());
System.out.println(cs.listAssignableLocations());
System.out.println(cs.listNodes());
}
@AfterTest
public void after() {
context.close();
}
//curl -v -H "X-Auth-User:admin" -H "X-Auth-Key: d744752f-20d3-4d75-979f-f62f16033b07" http://dragon004.hw.griddynamics.net:8774/v1.0/
//curl -v -H "X-Auth-Token: c97b10659008d5a9ce91462f8c6a5c2c80439762" http://dragon004.hw.griddynamics.net:8774/v1.0/images/detail?format=json
}

View File

@ -0,0 +1 @@
/test.properties