// Path: src/main/java/com/rmn/qa/AutomationConstants.java
// public interface AutomationConstants {
// 
//     // These NODE_CONFIG_* constants represent key names in the node configs
//     String CONFIG_CREATED_DATE = "createdDate";
//     String CONFIG_MAX_SESSION = "maxSession";
//     String CONFIG_BROWSER = "createdBrowser";
//     String CONFIG_OS = "createdOs";
//     // This is the value that will be in the desired capabilities that our node registers with
//     // Runtime value of the hub instance id that gets passed in as a system property.  Also used in the node config
//     String INSTANCE_ID = "instanceId";
//     // IP address of the hub that will be passed in as a system property
//     String IP_ADDRESS = "ipAddress";
//     // Test run UUID
//     String UUID = "uuid";
//     String WINDOWS_PROPERTY_NAME="node.windows.json";
//     String LINUX_PROPERTY_NAME="node.linux.json";
//     String EXTRA_CAPABILITIES_PROPERTY_NAME="extraCapabilities";
//     String AWS_ACCESS_KEY="awsAccessKey";
//     String AWS_PRIVATE_KEY="awsSecretKey";
//     String AWS_DEFAULT_RESOURCE_NAME= "aws.properties.default";
//     String REAPER_THREAD_CONFIG = "useReaperThread";
// }
// 
// Path: src/main/java/com/rmn/qa/NodesCouldNotBeStartedException.java
// public class NodesCouldNotBeStartedException extends Exception {
//     public NodesCouldNotBeStartedException(String msg) {
//         super(msg);
//     }
// 
//     public NodesCouldNotBeStartedException(String msg, Throwable t) {
//         super(msg,t);
//     }
// }


import com.amazonaws.AmazonServiceException;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.ec2.model.Instance;
import com.amazonaws.services.ec2.model.InstanceState;
import com.amazonaws.services.ec2.model.InstanceStateChange;
import com.amazonaws.services.ec2.model.Reservation;
import com.amazonaws.services.ec2.model.RunInstancesRequest;
import com.amazonaws.services.ec2.model.RunInstancesResult;
import com.amazonaws.services.ec2.model.TerminateInstancesRequest;
import com.amazonaws.services.ec2.model.TerminateInstancesResult;
import com.rmn.qa.AutomationConstants;
import com.rmn.qa.NodesCouldNotBeStartedException;
import junit.framework.Assert;
import org.apache.commons.collections.CollectionUtils;
import org.junit.After;
import org.junit.Test;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
        System.setProperty(AutomationConstants.AWS_PRIVATE_KEY,privateKey);
        MockManageVm manageEC2 = new MockManageVm();
    }

    @Test
    // Test that you can initialize the AWS properties from a custom properties file
    public void testInitPropertiesFromSystemProperties() {
        String path = "src/main/resources/" + AutomationConstants.AWS_DEFAULT_RESOURCE_NAME;
        path.replace("/", File.separator);
        System.setProperty("propertyFileLocation",path);
        MockManageVm manageEC2 = new MockManageVm(null,null,null);
        Properties retrievedProperties = manageEC2.initAWSProperties();
        File f = new File(path);
        Properties compareProperties = new Properties();
        try {
            InputStream is = new FileInputStream(f);
            compareProperties.load(is);
        } catch (IOException e) {
            throw new RuntimeException("Could not load custom aws.properties", e);
        }
        Assert.assertEquals("Properties should be equal",compareProperties,retrievedProperties);
    }

    @Test
    // Test that an incorrectly set properties file throws the appropriate exception
    public void testInvalidCustomProperty() {
        System.setProperty("propertyFileLocation","bogus");
        MockManageVm manageEC2 = new MockManageVm(null,null,null);
        try{

// Path: src/main/java/com/rmn/qa/AutomationConstants.java
// public interface AutomationConstants {
// 
//     // These NODE_CONFIG_* constants represent key names in the node configs
//     String CONFIG_CREATED_DATE = "createdDate";
//     String CONFIG_MAX_SESSION = "maxSession";
//     String CONFIG_BROWSER = "createdBrowser";
//     String CONFIG_OS = "createdOs";
//     // This is the value that will be in the desired capabilities that our node registers with
//     // Runtime value of the hub instance id that gets passed in as a system property.  Also used in the node config
//     String INSTANCE_ID = "instanceId";
//     // IP address of the hub that will be passed in as a system property
//     String IP_ADDRESS = "ipAddress";
//     // Test run UUID
//     String UUID = "uuid";
//     String WINDOWS_PROPERTY_NAME="node.windows.json";
//     String LINUX_PROPERTY_NAME="node.linux.json";
//     String EXTRA_CAPABILITIES_PROPERTY_NAME="extraCapabilities";
//     String AWS_ACCESS_KEY="awsAccessKey";
//     String AWS_PRIVATE_KEY="awsSecretKey";
//     String AWS_DEFAULT_RESOURCE_NAME= "aws.properties.default";
//     String REAPER_THREAD_CONFIG = "useReaperThread";
// }
// 
// Path: src/main/java/com/rmn/qa/NodesCouldNotBeStartedException.java
// public class NodesCouldNotBeStartedException extends Exception {
//     public NodesCouldNotBeStartedException(String msg) {
//         super(msg);
//     }
// 
//     public NodesCouldNotBeStartedException(String msg, Throwable t) {
//         super(msg,t);
//     }
// }


// Path: src/test/java/com/rmn/qa/aws/VmManagerTest.java
import com.amazonaws.AmazonServiceException;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.ec2.model.Instance;
import com.amazonaws.services.ec2.model.InstanceState;
import com.amazonaws.services.ec2.model.InstanceStateChange;
import com.amazonaws.services.ec2.model.Reservation;
import com.amazonaws.services.ec2.model.RunInstancesRequest;
import com.amazonaws.services.ec2.model.RunInstancesResult;
import com.amazonaws.services.ec2.model.TerminateInstancesRequest;
import com.amazonaws.services.ec2.model.TerminateInstancesResult;
import com.rmn.qa.AutomationConstants;
import com.rmn.qa.NodesCouldNotBeStartedException;
import junit.framework.Assert;
import org.apache.commons.collections.CollectionUtils;
import org.junit.After;
import org.junit.Test;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;

        System.setProperty(AutomationConstants.AWS_PRIVATE_KEY,privateKey);
        MockManageVm manageEC2 = new MockManageVm();
    }

    @Test
    // Test that you can initialize the AWS properties from a custom properties file
    public void testInitPropertiesFromSystemProperties() {
        String path = "src/main/resources/" + AutomationConstants.AWS_DEFAULT_RESOURCE_NAME;
        path.replace("/", File.separator);
        System.setProperty("propertyFileLocation",path);
        MockManageVm manageEC2 = new MockManageVm(null,null,null);
        Properties retrievedProperties = manageEC2.initAWSProperties();
        File f = new File(path);
        Properties compareProperties = new Properties();
        try {
            InputStream is = new FileInputStream(f);
            compareProperties.load(is);
        } catch (IOException e) {
            throw new RuntimeException("Could not load custom aws.properties", e);
        }
        Assert.assertEquals("Properties should be equal",compareProperties,retrievedProperties);
    }

    @Test
    // Test that an incorrectly set properties file throws the appropriate exception
    public void testInvalidCustomProperty() {
        System.setProperty("propertyFileLocation","bogus");
        MockManageVm manageEC2 = new MockManageVm(null,null,null);
        try{

            manageEC2.initAWSProperties();