From 506c5cbd24cc7ac3efad9705fd219db426bc50d7 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Fri, 3 Jun 2011 17:37:22 +0200 Subject: [PATCH] Modified apis/filesystem tests to skip tests that are known not to work on Windows --- .../FilesystemAsyncBlobStoreTest.java | 19 +++++++++++-------- .../FilesystemStorageStrategyImplTest.java | 10 +++++++++- .../jclouds/filesystem/utils/TestUtils.java | 6 ++++++ 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java index 5b4a24c61e..2d5f70d533 100644 --- a/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java +++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java @@ -18,13 +18,7 @@ */ package org.jclouds.filesystem; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; +import static org.testng.Assert.*; import java.io.File; import java.io.FileInputStream; @@ -52,6 +46,7 @@ import org.jclouds.filesystem.reference.FilesystemConstants; import org.jclouds.filesystem.utils.TestUtils; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; import com.google.inject.CreationException; @@ -73,7 +68,6 @@ public class FilesystemAsyncBlobStoreTest { static { System.setProperty(LOGGING_CONFIG_KEY, LOGGING_CONFIG_VALUE); - } private BlobStoreContext context = null; @@ -109,6 +103,12 @@ public class FilesystemAsyncBlobStoreTest { } } + @DataProvider + public Object[][] ignoreOnWindows() { + return (TestUtils.isWindowsOs() ? TestUtils.NO_INVOCATIONS + : TestUtils.SINGLE_NO_ARG_INVOCATION); + } + /** * Checks if context parameters are managed in the correct way * @@ -390,6 +390,7 @@ public class FilesystemAsyncBlobStoreTest { /** * Test of removeBlob method, with only one blob with a complex path as key */ + @Test(dataProvider = "ignoreOnWindows") public void testRemoveBlob_ComplexBlobKey() throws IOException { final String BLOB_KEY = TestUtils.createRandomBlobKey("aa/bb/cc/dd/", null); boolean result; @@ -419,6 +420,7 @@ public class FilesystemAsyncBlobStoreTest { * Test of removeBlob method, with two blobs with a complex path as key and when first blob is * removed, not all of its key's path is removed, because it is shared with the second blob's key */ + @Test(dataProvider = "ignoreOnWindows") public void testRemoveBlob_TwoComplexBlobKeys() throws IOException { final String BLOB_KEY1 = TestUtils.createRandomBlobKey("aa/bb/cc/dd/", null); final String BLOB_KEY2 = TestUtils.createRandomBlobKey("aa/bb/ee/ff/", null); @@ -692,6 +694,7 @@ public class FilesystemAsyncBlobStoreTest { TestUtils.directoryExists(TARGET_CONTAINER_NAME2, false); } + @Test(dataProvider = "ignoreOnWindows") public void testInvalidContainerName() { try { blobStore.createContainerInLocation(null, "file/system"); 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 2b44d5f139..2b57bb7ed4 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 @@ -48,6 +48,7 @@ import org.jclouds.filesystem.utils.TestUtils; import org.jclouds.io.payloads.FilePayload; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; /** @@ -92,6 +93,12 @@ public class FilesystemStorageStrategyImplTest { TestUtils.cleanDirectoryContent(TestUtils.TARGET_BASE_DIR); } + @DataProvider + public Object[][] ignoreOnWindows() { + return (TestUtils.isWindowsOs() ? TestUtils.NO_INVOCATIONS + : TestUtils.SINGLE_NO_ARG_INVOCATION); + } + public void testCreateDirectory() { storageStrategy.createDirectory(CONTAINER_NAME, null); TestUtils.directoryExists(TARGET_CONTAINER_NAME, true); @@ -114,10 +121,11 @@ public class FilesystemStorageStrategyImplTest { storageStrategy.createDirectory(CONTAINER_NAME, null); } + @Test(dataProvider = "ignoreOnWindows") public void testCreateDirectory_WrongDirectoryName() { try { storageStrategy.createDirectory(CONTAINER_NAME, "$%&!'`\\/"); - fail("No exception throwed"); + fail("No exception thrown"); } catch (Exception e) { } } diff --git a/apis/filesystem/src/test/java/org/jclouds/filesystem/utils/TestUtils.java b/apis/filesystem/src/test/java/org/jclouds/filesystem/utils/TestUtils.java index 8ec538adf3..2ccd389408 100644 --- a/apis/filesystem/src/test/java/org/jclouds/filesystem/utils/TestUtils.java +++ b/apis/filesystem/src/test/java/org/jclouds/filesystem/utils/TestUtils.java @@ -48,6 +48,12 @@ public class TestUtils { public static final String TARGET_BASE_DIR = "." + File.separator + "target" + File.separator + "basedir" + File.separator; + public static final Object[][] NO_INVOCATIONS = new Object[0][0]; + public static final Object[][] SINGLE_NO_ARG_INVOCATION = new Object[][] { new Object[0] }; + + public static boolean isWindowsOs() { + return System.getProperty("os.name", "").toLowerCase().contains("windows"); + } /** * Generate a random blob key simple name (with no path in the key)