You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by za...@apache.org on 2015/01/29 03:13:50 UTC

jclouds git commit: Windows fixes, mostly separator related.

Repository: jclouds
Updated Branches:
  refs/heads/master 9e1d1cbfa -> a8c5e2812


Windows fixes, mostly separator related.


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

Branch: refs/heads/master
Commit: a8c5e28129ca9b905b07f1215c6548571ff28a58
Parents: 9e1d1cb
Author: Zack Shoylev <za...@rackspace.com>
Authored: Mon Jan 26 19:47:54 2015 -0600
Committer: Zack Shoylev <za...@rackspace.com>
Committed: Wed Jan 28 19:47:19 2015 -0600

----------------------------------------------------------------------
 .../internal/FilesystemStorageStrategyImpl.java | 22 +++++++++++---------
 .../filesystem/FilesystemBlobStoreTest.java     |  8 +++----
 .../FilesystemStorageStrategyImplTest.java      | 14 ++++++-------
 .../blobstore/config/LocalBlobStore.java        |  8 +++++--
 .../blobstore/reference/BlobStoreConstants.java |  2 +-
 .../internal/BaseContainerIntegrationTest.java  | 12 ++++++-----
 6 files changed, 37 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jclouds/blob/a8c5e281/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java
----------------------------------------------------------------------
diff --git a/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java b/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java
index 1642527..03c95e8 100644
--- a/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java
+++ b/apis/filesystem/src/main/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImpl.java
@@ -210,7 +210,7 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
 
    /**
     * Returns all the blobs key inside a container
-    * 
+    *
     * @param container
     * @return
     * @throws IOException
@@ -402,7 +402,9 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
          throw ex;
       } finally {
          closeQuietly(his);
-         payload.release();
+         if (payload != null) {
+            payload.release();
+         }
       }
    }
 
@@ -539,7 +541,7 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
    /**
     * Check if the file system resource whose name is obtained applying buildPath on the input path
     * tokens is a directory, otherwise a RuntimeException is thrown
-    * 
+    *
     * @param tokens
     *           the tokens that make up the name of the resource on the file system
     */
@@ -552,7 +554,7 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
 
    /**
     * Facility method used to concatenate path tokens normalizing separators
-    * 
+    *
     * @param pathTokens
     *           all the string in the proper order that must be concatenated in order to obtain the
     *           filename
@@ -575,7 +577,7 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
    /**
     * Substitutes all the file separator occurrences in the path with a file separator for the
     * current operative system
-    * 
+    *
     * @param pathToBeNormalized
     * @return
     */
@@ -599,7 +601,7 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
 
    /**
     * Remove leading and trailing {@link File.separator} character from the string.
-    * 
+    *
     * @param pathToBeCleaned
     * @param remove
     *           only trailing separator char from path
@@ -626,7 +628,7 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
    /**
     * Removes recursively the directory structure of a complex blob key, only if the directory is
     * empty
-    * 
+    *
     * @param container
     * @param normalizedKey
     */
@@ -673,9 +675,9 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
       File[] children = directory.listFiles();
       for (File child : children) {
          if (child.isFile()) {
-            blobNames.add(function.apply(child.getAbsolutePath()));
+            blobNames.add( function.apply(child.getAbsolutePath()) );
          } else if (child.isDirectory()) {
-            blobNames.add(function.apply(child.getAbsolutePath()) + File.separator);
+            blobNames.add(function.apply(child.getAbsolutePath()) + File.separator); // TODO: undo if failures
             populateBlobKeysInContainer(child, blobNames, function);
          }
       }
@@ -683,7 +685,7 @@ public class FilesystemStorageStrategyImpl implements LocalStorageStrategy {
 
    /**
     * Creates a directory and returns the result
-    * 
+    *
     * @param container
     * @param directory
     * @return true if the directory was created, otherwise false

http://git-wip-us.apache.org/repos/asf/jclouds/blob/a8c5e281/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemBlobStoreTest.java
----------------------------------------------------------------------
diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemBlobStoreTest.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemBlobStoreTest.java
index cb82ad9..a5cff21 100644
--- a/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemBlobStoreTest.java
+++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemBlobStoreTest.java
@@ -32,7 +32,6 @@ import java.util.Iterator;
 import java.util.Properties;
 import java.util.Set;
 
-import com.google.common.collect.ImmutableSet;
 import org.jclouds.ContextBuilder;
 import org.jclouds.blobstore.BlobRequestSigner;
 import org.jclouds.blobstore.BlobStore;
@@ -61,6 +60,7 @@ import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.DataProvider;
 import org.testng.annotations.Test;
 
+import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Sets;
 import com.google.common.io.ByteSource;
 import com.google.common.io.Files;
@@ -232,7 +232,7 @@ public class FilesystemBlobStoreTest {
         blobsExpected.remove("4rrr.jpg");
 
         checkForContainerContent(CONTAINER_NAME, "rrr", blobsExpected);
-        checkForContainerContent(CONTAINER_NAME, "rrr" + File.separator, blobsExpected);
+        checkForContainerContent(CONTAINER_NAME, "rrr/", blobsExpected);
     }
 
     /**
@@ -466,7 +466,7 @@ public class FilesystemBlobStoreTest {
     public void testPutDirectoryBlobs() {
         blobStore.createContainerInLocation(null, CONTAINER_NAME);
 
-        String parentKey = TestUtils.createRandomBlobKey("a/b/c/directory-", File.separator);
+        String parentKey = TestUtils.createRandomBlobKey("a/b/c/directory-", "/");
         String childKey = TestUtils.createRandomBlobKey(parentKey + "directory-", File.separator);
         blobStore.putBlob(CONTAINER_NAME, createDirBlob(parentKey));
         assertTrue(blobStore.blobExists(CONTAINER_NAME, parentKey));
@@ -483,7 +483,7 @@ public class FilesystemBlobStoreTest {
     public void testGetDirectoryBlob() throws IOException {
         blobStore.createContainerInLocation(null, CONTAINER_NAME);
 
-        String blobKey = TestUtils.createRandomBlobKey("a/b/c/directory-", File.separator);
+        String blobKey = TestUtils.createRandomBlobKey("a/b/c/directory-", "/");
         blobStore.putBlob(CONTAINER_NAME, createDirBlob(blobKey));
 
         assertTrue(blobStore.blobExists(CONTAINER_NAME, blobKey));

http://git-wip-us.apache.org/repos/asf/jclouds/blob/a8c5e281/apis/filesystem/src/test/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImplTest.java
----------------------------------------------------------------------
diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImplTest.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImplTest.java
index ebab631..f5c73eb 100644
--- a/apis/filesystem/src/test/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImplTest.java
+++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImplTest.java
@@ -93,7 +93,7 @@ public class FilesystemStorageStrategyImplTest {
    protected void tearDown() throws IOException {
       TestUtils.cleanDirectoryContent(TestUtils.TARGET_BASE_DIR);
    }
-   
+
    public void testCreateDirectory() {
       storageStrategy.createDirectory(CONTAINER_NAME, null);
       TestUtils.directoryExists(TARGET_CONTAINER_NAME, true);
@@ -344,7 +344,7 @@ public class FilesystemStorageStrategyImplTest {
 
    @Test(dataProvider = "ignoreOnMacOSX")
    public void testWriteDirectoryBlob() throws IOException {
-      String blobKey = TestUtils.createRandomBlobKey("a/b/c/directory-", File.separator);
+      String blobKey = TestUtils.createRandomBlobKey("a/b/c/directory-", "/");
       Blob blob = storageStrategy.newBlob(blobKey);
       storageStrategy.putBlob(CONTAINER_NAME, blob);
       // verify that the files is equal
@@ -356,7 +356,7 @@ public class FilesystemStorageStrategyImplTest {
 
    @Test(dataProvider = "ignoreOnMacOSX")
    public void testGetDirectoryBlob() throws IOException {
-      String blobKey = TestUtils.createRandomBlobKey("a/b/c/directory-", File.separator);
+      String blobKey = TestUtils.createRandomBlobKey("a/b/c/directory-", "/");
       Blob blob = storageStrategy.newBlob(blobKey);
       storageStrategy.putBlob(CONTAINER_NAME, blob);
 
@@ -382,7 +382,7 @@ public class FilesystemStorageStrategyImplTest {
    }
 
    public void testDeleteDirectoryBlob() throws IOException {
-      String blobKey = TestUtils.createRandomBlobKey("a/b/c/directory-", File.separator);
+      String blobKey = TestUtils.createRandomBlobKey("a/b/c/directory-", "/");
       Blob blob = storageStrategy.newBlob(blobKey);
       storageStrategy.putBlob(CONTAINER_NAME, blob);
       File blobFullPath = new File(TARGET_CONTAINER_NAME, blobKey);
@@ -393,8 +393,8 @@ public class FilesystemStorageStrategyImplTest {
 
    @Test(dataProvider = "ignoreOnMacOSX")
    public void testDeleteIntermediateDirectoryBlob() throws IOException {
-      String parentKey = TestUtils.createRandomBlobKey("a/b/c/directory-", File.separator);
-      String childKey = TestUtils.createRandomBlobKey(parentKey + "directory-", File.separator);
+      String parentKey = TestUtils.createRandomBlobKey("a/b/c/directory-", "/");
+      String childKey = TestUtils.createRandomBlobKey(parentKey + "directory-", "/");
       storageStrategy.putBlob(CONTAINER_NAME, storageStrategy.newBlob(parentKey));
       storageStrategy.putBlob(CONTAINER_NAME, storageStrategy.newBlob(childKey));
 
@@ -623,7 +623,7 @@ public class FilesystemStorageStrategyImplTest {
 
    /**
     * Calculates an absolute directory path that depends on operative system
-    * 
+    *
     * @return
     */
    private String getAbsoluteDirectory() throws IOException {

http://git-wip-us.apache.org/repos/asf/jclouds/blob/a8c5e281/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java
----------------------------------------------------------------------
diff --git a/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java b/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java
index 898aa37..d523d04 100644
--- a/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java
+++ b/blobstore/src/main/java/org/jclouds/blobstore/config/LocalBlobStore.java
@@ -28,6 +28,7 @@ import static com.google.common.collect.Sets.newTreeSet;
 import static org.jclouds.blobstore.options.ListContainerOptions.Builder.recursive;
 
 import java.io.ByteArrayOutputStream;
+import java.io.File;
 import java.io.IOException;
 import java.util.Date;
 import java.util.Set;
@@ -231,15 +232,18 @@ public final class LocalBlobStore implements BlobStore {
             }));
 
       String marker = null;
+      String prefix;
       if (options != null) {
-         final String prefix = options.getDir();
+         prefix = options.getDir();
          if (prefix != null && !prefix.isEmpty()) {
             final String dirPrefix = prefix.endsWith("/") ?
                     prefix :
                     prefix + "/";
             contents = newTreeSet(filter(contents, new Predicate<StorageMetadata>() {
                public boolean apply(StorageMetadata o) {
-                  return o != null && o.getName().startsWith(dirPrefix) && !o.getName().equals(dirPrefix);
+                  return o != null
+                        && o.getName().replace(File.separatorChar, '/').startsWith(dirPrefix)
+                        && !o.getName().replace(File.separatorChar, '/').equals(dirPrefix);
                }
             }));
          }

http://git-wip-us.apache.org/repos/asf/jclouds/blob/a8c5e281/blobstore/src/main/java/org/jclouds/blobstore/reference/BlobStoreConstants.java
----------------------------------------------------------------------
diff --git a/blobstore/src/main/java/org/jclouds/blobstore/reference/BlobStoreConstants.java b/blobstore/src/main/java/org/jclouds/blobstore/reference/BlobStoreConstants.java
index 86dcee6..5f196f4 100644
--- a/blobstore/src/main/java/org/jclouds/blobstore/reference/BlobStoreConstants.java
+++ b/blobstore/src/main/java/org/jclouds/blobstore/reference/BlobStoreConstants.java
@@ -39,7 +39,7 @@ public final class BlobStoreConstants {
    public static final String DIRECTORY_SUFFIX_ROOT = "/";
    public static final String DIRECTORY_SUFFIX_FOLDER = "_$folder$";
    public static final Collection<String> DIRECTORY_SUFFIXES =
-         ImmutableList.of(DIRECTORY_SUFFIX_FOLDER, DIRECTORY_SUFFIX_ROOT);
+         ImmutableList.of(DIRECTORY_SUFFIX_FOLDER, DIRECTORY_SUFFIX_ROOT, "/", "\\");
 
    /**
     * Key-value implementations of BlobStore, such as S3, do not have directories. We use an empty

http://git-wip-us.apache.org/repos/asf/jclouds/blob/a8c5e281/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java
index 2aa3478..41542e4 100644
--- a/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java
+++ b/blobstore/src/test/java/org/jclouds/blobstore/integration/internal/BaseContainerIntegrationTest.java
@@ -16,11 +16,11 @@
  */
 package org.jclouds.blobstore.integration.internal;
 
-import static org.assertj.core.api.Assertions.assertThat;
 import static com.google.common.base.Charsets.UTF_8;
 import static com.google.common.base.Throwables.propagateIfPossible;
 import static com.google.common.collect.Iterables.get;
 import static com.google.common.hash.Hashing.md5;
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.jclouds.blobstore.options.ListContainerOptions.Builder.afterMarker;
 import static org.jclouds.blobstore.options.ListContainerOptions.Builder.inDirectory;
 import static org.jclouds.blobstore.options.ListContainerOptions.Builder.maxResults;
@@ -28,6 +28,7 @@ import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertTrue;
 
+import java.io.File;
 import java.io.IOException;
 import java.util.Iterator;
 import java.util.Set;
@@ -36,8 +37,6 @@ import java.util.concurrent.TimeoutException;
 
 import javax.ws.rs.core.MediaType;
 
-import com.google.common.io.ByteSource;
-
 import org.jclouds.blobstore.domain.Blob;
 import org.jclouds.blobstore.domain.BlobMetadata;
 import org.jclouds.blobstore.domain.PageSet;
@@ -46,6 +45,7 @@ import org.jclouds.blobstore.options.ListContainerOptions;
 import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableMap;
+import com.google.common.io.ByteSource;
 
 public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
 
@@ -317,11 +317,13 @@ public class BaseContainerIntegrationTest extends BaseBlobStoreIntegrationTest {
       }
    }
 
-   @Test(groups = { "integration", "live" })
+   @Test(dataProvider = "ignoreOnWindows", groups = { "integration", "live" })
    public void testDelimiter() throws Exception {
       String containerName = getContainerName();
       try {
-         for (String blobName : new String[] { "asdf", "boo/bar", "boo/baz/xyzzy", "cquux/thud", "cquux/bla" }) {
+         for (String blobName : new String[] { "asdf", "boo" + File.separator + "bar", "boo" + File.separator
+               + "baz"  + File.separator + "xyzzy", "cquux" + File.separator + "thud", "cquux" + File.separator
+               + "bla" }) {
             Blob blob = view.getBlobStore().blobBuilder(blobName).payload(TEST_STRING).build();
             addBlobToContainer(containerName, blob);
          }