From dcfbb7dde119548b382e58c18548ff962c472ec4 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Mon, 8 Nov 2010 14:11:34 +0100 Subject: [PATCH] Modified jclouds-filesystem tests to skip tests that are known not to work on Windows --- .../FilesystemAsyncBlobStoreTest.java | 20 ++++++++++--------- .../FilesystemStorageStrategyImplTest.java | 8 +++++++- .../jclouds/filesystem/utils/TestUtils.java | 7 ++++++- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java b/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java index b80fc6bc9e..25fe254738 100644 --- a/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java +++ b/filesystem/src/test/java/org/jclouds/filesystem/FilesystemAsyncBlobStoreTest.java @@ -19,13 +19,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; @@ -53,6 +47,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; @@ -117,6 +112,11 @@ 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 @@ -429,6 +429,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; @@ -463,6 +464,7 @@ public class FilesystemAsyncBlobStoreTest { * 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); @@ -761,7 +763,7 @@ public class FilesystemAsyncBlobStoreTest { TestUtils.directoryExists(TARGET_CONTAINER_NAME2, false); } - + @Test(dataProvider = "ignoreOnWindows") public void testInvalidContainerName() { try { blobStore.createContainerInLocation(null, "file/system"); @@ -772,7 +774,7 @@ public class FilesystemAsyncBlobStoreTest { fail("Wrong container name not recognized"); } catch (IllegalArgumentException e) {} } - + // public void testInvalidBlobKey() { // try { // blobStore.newBlob(File.separator + "testwrongblobkey"); diff --git a/filesystem/src/test/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImplTest.java b/filesystem/src/test/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImplTest.java index e1cfc40303..b4a3ab4e93 100644 --- a/filesystem/src/test/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImplTest.java +++ b/filesystem/src/test/java/org/jclouds/filesystem/strategy/internal/FilesystemStorageStrategyImplTest.java @@ -85,7 +85,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); @@ -108,6 +113,7 @@ public class FilesystemStorageStrategyImplTest { storageStrategy.createDirectory(CONTAINER_NAME, null); } + @Test(dataProvider = "ignoreOnWindows") public void testCreateDirectory_WrongDirectoryName() { try { storageStrategy.createDirectory(CONTAINER_NAME, "$%&!'`\\/"); diff --git a/filesystem/src/test/java/org/jclouds/filesystem/utils/TestUtils.java b/filesystem/src/test/java/org/jclouds/filesystem/utils/TestUtils.java index 34b65f8e33..05427ee40b 100644 --- a/filesystem/src/test/java/org/jclouds/filesystem/utils/TestUtils.java +++ b/filesystem/src/test/java/org/jclouds/filesystem/utils/TestUtils.java @@ -48,7 +48,12 @@ public class TestUtils { private static int imageResourceIndex = 0; 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)