From 00e28b99107ef8ee9cb4f6925f60a3becdc8d8d6 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 7 May 2012 16:54:29 -0700 Subject: [PATCH] fixed syntax of perftest --- .../aws/s3/AmazonPerformanceLiveTest.java | 23 ++++++++------ .../aws/s3/Jets3tPerformanceLiveTest.java | 31 ++++++++++++------- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/demos/perftest/src/test/java/org/jclouds/aws/s3/AmazonPerformanceLiveTest.java b/demos/perftest/src/test/java/org/jclouds/aws/s3/AmazonPerformanceLiveTest.java index da9ee4ed29..9c6d63e9ea 100644 --- a/demos/perftest/src/test/java/org/jclouds/aws/s3/AmazonPerformanceLiveTest.java +++ b/demos/perftest/src/test/java/org/jclouds/aws/s3/AmazonPerformanceLiveTest.java @@ -21,13 +21,13 @@ package org.jclouds.aws.s3; import java.io.ByteArrayInputStream; import java.io.File; import java.io.InputStream; +import java.util.Properties; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; import java.util.concurrent.Future; -import org.testng.ITestContext; -import org.testng.annotations.BeforeClass; +import org.jclouds.blobstore.BlobStoreContext; import org.testng.annotations.Test; import com.amazonaws.auth.BasicAWSCredentials; @@ -35,24 +35,29 @@ import com.amazonaws.services.s3.AmazonS3; import com.amazonaws.services.s3.AmazonS3Client; import com.amazonaws.services.s3.model.ObjectMetadata; import com.amazonaws.services.s3.model.PutObjectRequest; +import com.google.inject.Module; /** * Runs operations that amazon s3 sample code is capable of performing. * * @author Adrian Cole */ -@Test(sequential = true, timeOut = 2 * 60 * 1000, groups = { "live" }) +@Test(singleThreaded = true, timeOut = 2 * 60 * 1000, groups = "live", testName = "AmazonPerformanceLiveTest") public class AmazonPerformanceLiveTest extends BasePerformanceLiveTest { + + public AmazonPerformanceLiveTest(){ + exec = Executors.newCachedThreadPool(); + } + private AmazonS3 s3; - @BeforeClass(groups = { "integration", "live" }) - public void setUpResourcesOnThisThread(ITestContext testContext) throws Exception { - super.setUpResourcesOnThisThread(testContext); - exec = Executors.newCachedThreadPool(); + @Override + protected BlobStoreContext createView(Properties props, Iterable modules) { s3 = new AmazonS3Client(new BasicAWSCredentials(System.getProperty("test.aws-s3.identity"), - System.getProperty("test.aws-s3.credential"))); + System.getProperty("test.aws-s3.credential"))); + return super.createView(props, modules); } - + @Override @Test(enabled = false) public void testPutStringSerial() throws Exception { diff --git a/demos/perftest/src/test/java/org/jclouds/aws/s3/Jets3tPerformanceLiveTest.java b/demos/perftest/src/test/java/org/jclouds/aws/s3/Jets3tPerformanceLiveTest.java index 7f442a456b..fc06a48a63 100644 --- a/demos/perftest/src/test/java/org/jclouds/aws/s3/Jets3tPerformanceLiveTest.java +++ b/demos/perftest/src/test/java/org/jclouds/aws/s3/Jets3tPerformanceLiveTest.java @@ -21,36 +21,46 @@ package org.jclouds.aws.s3; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.util.Properties; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; import java.util.concurrent.Future; +import org.jclouds.blobstore.BlobStoreContext; import org.jets3t.service.S3Service; +import org.jets3t.service.S3ServiceException; import org.jets3t.service.impl.rest.httpclient.RestS3Service; import org.jets3t.service.model.S3Object; import org.jets3t.service.security.AWSCredentials; -import org.testng.ITestContext; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import com.google.appengine.repackaged.com.google.common.base.Throwables; +import com.google.inject.Module; /** * Runs operations that jets3t is capable of performing. * * @author Adrian Cole */ -@Test(sequential = true, timeOut = 2 * 60 * 1000, groups = { "live" }) +@Test(singleThreaded = true, timeOut = 2 * 60 * 1000, groups = "live", testName = "Jets3tPerformanceLiveTest") public class Jets3tPerformanceLiveTest extends BasePerformanceLiveTest { - private S3Service jetClient; - - @BeforeClass(groups = { "integration", "live" }) - public void setUpResourcesOnThisThread(ITestContext testContext) throws Exception { - super.setUpResourcesOnThisThread(testContext); + + public Jets3tPerformanceLiveTest(){ exec = Executors.newCachedThreadPool(); - jetClient = new RestS3Service(new AWSCredentials(System.getProperty("test.aws-s3.identity"), - System.getProperty("test.aws-s3.credential"))); + } + + private S3Service jetClient; + + @Override + protected BlobStoreContext createView(Properties props, Iterable modules) { + try { + jetClient = new RestS3Service(new AWSCredentials(System.getProperty("test.aws-s3.identity"), + System.getProperty("test.aws-s3.credential"))); + } catch (S3ServiceException e) { + throw Throwables.propagate(e); + } + return super.createView(props, modules); } @Override @@ -93,7 +103,6 @@ public class Jets3tPerformanceLiveTest extends BasePerformanceLiveTest { @Test(enabled = false) protected Future putByteArray(String bucket, String key, byte[] data, String contentType) { throw new UnsupportedOperationException(); - } @Override