@@ -0,0 +1,2194 @@
+import java.util.ArrayList;%0Aimport java.util.List;%0A%0Aimport junit.framework.Assert;%0A%0Aimport org.junit.Test;%0A%0Aimport com.amazonaws.services.ec2.model.Instance;%0Aimport com.tlswe.awsmock.common.util.PropertiesUtils;%0Aimport com.tlswe.awsmock.ec2.model.AbstractMockEc2Instance.InstanceState;%0A%0Apublic class TestExamples %7B%0A%0A    @Test%0A    public void test() %7B%0A%0A        // run 10 instances%0A        String imageId = %22ami-12345678%22; // pre-defined ami%0A        int runCount = 10;%0A        List%3CInstance%3E exampleInstances = RunInstancesExample.runInstances(imageId, runCount);%0A%0A        // describe all instances%0A        List%3CInstance%3E allInstances = DescribeInstancesExample.describeAllInstances();%0A%0A        // check if all of the 10 new instances are there%0A        Assert.assertTrue(%22Actual started instance count (%22 + exampleInstances.size() + %22) does not equal to runCount(%22%0A                + runCount + %22).%22,%0A                exampleInstances.size() == runCount);%0A%0A        // get max boot time for each instance (in seconds), from properties%0A        int maxBootSeconds = Integer.parseInt(PropertiesUtils.getProperty(%22instance.max.boot.time.seconds%22));%0A%0A        // sleep for at least such a time of max boot seconds%0A        try %7B%0A            Thread.sleep((maxBootSeconds + 1) * 1000L);%0A        %7D catch (InterruptedException e) %7B%0A            e.printStackTrace();%0A            Assert.fail(e.getMessage());%0A        %7D%0A%0A        // then check if the 10 new instances are all turned into 'running'%0A        List%3CString%3E exampleInstanceIDs = new ArrayList%3CString%3E();%0A        for (Instance inst : exampleInstances) %7B%0A            exampleInstanceIDs.add(inst.getInstanceId());%0A        %7D%0A%0A        // now we describe our 10 instances again, and assert all of them should be running now%0A        exampleInstances = DescribeInstancesExample.describeInstances(exampleInstanceIDs);%0A        for (Instance inst : exampleInstances) %7B%0A            Assert.assertTrue(%22Instance state did not turn to 'running' after %22 + maxBootSeconds + %22 seconds.%22,%0A                    InstanceState.RUNNING.equals(inst.getState().getName()));%0A        %7D%0A%0A        // pick one of the example instances, for testing: stop, start and terminate%0A%0A    %7D%0A%0A%7D%0A

Add test for Java examples