Repository: jclouds
Updated Branches:
  refs/heads/master 2ed971d21 -> affad9fa3


JCLOUDS-96: JCLOUDS-351: Fix S3 copy if tests

Use correct options in testCopyIfUnmodifiedSince, use looser time
bounds, and ensure that tests throw HttpResponseException when
expected.


Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/affad9fa
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/affad9fa
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/affad9fa

Branch: refs/heads/master
Commit: affad9fa3b66e45c4b7c0bb2483e959dc0f5341a
Parents: 2ed971d
Author: Andrew Gaul <[email protected]>
Authored: Fri Jan 23 19:24:21 2015 -0800
Committer: Andrew Gaul <[email protected]>
Committed: Sat Jan 24 10:56:21 2015 -0800

----------------------------------------------------------------------
 .../test/java/org/jclouds/s3/S3ClientLiveTest.java   | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/affad9fa/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java 
b/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java
index 04fd5a3..378eb11 100644
--- a/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java
+++ b/apis/s3/src/test/java/org/jclouds/s3/S3ClientLiveTest.java
@@ -27,6 +27,7 @@ import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertNotNull;
 import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
 
 import java.io.IOException;
 import java.net.URI;
@@ -359,14 +360,13 @@ public class S3ClientLiveTest extends 
BaseBlobStoreIntegrationTest {
       return etag;
    }
 
-   // TODO: fails on linux and windows
    public void testCopyIfModifiedSince() throws InterruptedException, 
ExecutionException, TimeoutException, IOException {
       String containerName = getContainerName();
       String destinationContainer = getContainerName();
       try {
-         Date before = new Date();
+         Date before = new Date(System.currentTimeMillis() - 10 * 1000);
          addToContainerAndValidate(containerName, sourceKey + "mod");
-         Date after = new Date(System.currentTimeMillis() + 1000);
+         Date after = new Date(System.currentTimeMillis() + 10 * 1000);
 
          getApi().copyObject(containerName, sourceKey + "mod", 
destinationContainer, destinationKey,
                   ifSourceModifiedSince(before));
@@ -375,6 +375,7 @@ public class S3ClientLiveTest extends 
BaseBlobStoreIntegrationTest {
          try {
             getApi().copyObject(containerName, sourceKey + "mod", 
destinationContainer, destinationKey,
                      ifSourceModifiedSince(after));
+            fail("should have thrown HttpResponseException");
          } catch (HttpResponseException ex) {
             assertEquals(ex.getResponse().getStatusCode(), 412);
          }
@@ -385,15 +386,14 @@ public class S3ClientLiveTest extends 
BaseBlobStoreIntegrationTest {
       }
    }
 
-   // TODO: fails on linux and windows
    public void testCopyIfUnmodifiedSince() throws InterruptedException, 
ExecutionException, TimeoutException,
             IOException {
       String containerName = getContainerName();
       String destinationContainer = getContainerName();
       try {
-         Date before = new Date();
+         Date before = new Date(System.currentTimeMillis() - 10 * 1000);
          addToContainerAndValidate(containerName, sourceKey + "un");
-         Date after = new Date(System.currentTimeMillis() + 1000);
+         Date after = new Date(System.currentTimeMillis() + 10 * 1000);
 
          getApi().copyObject(containerName, sourceKey + "un", 
destinationContainer, destinationKey,
                   ifSourceUnmodifiedSince(after));
@@ -401,7 +401,8 @@ public class S3ClientLiveTest extends 
BaseBlobStoreIntegrationTest {
 
          try {
             getApi().copyObject(containerName, sourceKey + "un", 
destinationContainer, destinationKey,
-                     ifSourceModifiedSince(before));
+                     ifSourceUnmodifiedSince(before));
+            fail("should have thrown HttpResponseException");
          } catch (HttpResponseException ex) {
             assertEquals(ex.getResponse().getStatusCode(), 412);
          }

Reply via email to