[issue 737] Modified apis/filesystem tests to skip tests that are known not to work on Windows

This commit is contained in:
Andrew Phillips 2011-10-26 17:15:58 -04:00
parent c889077f50
commit cfe31695c0
3 changed files with 34 additions and 6 deletions

View File

@ -62,6 +62,7 @@ import org.jclouds.io.payloads.PhantomPayload;
import org.jclouds.io.payloads.StringPayload; import org.jclouds.io.payloads.StringPayload;
import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.inject.CreationException; import com.google.inject.CreationException;
@ -83,7 +84,6 @@ public class FilesystemAsyncBlobStoreTest {
static { static {
System.setProperty(LOGGING_CONFIG_KEY, LOGGING_CONFIG_VALUE); System.setProperty(LOGGING_CONFIG_KEY, LOGGING_CONFIG_VALUE);
} }
private BlobStoreContext context = null; private BlobStoreContext context = null;
@ -119,6 +119,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 * Checks if context parameters are managed in the correct way
*/ */
@ -399,6 +405,7 @@ public class FilesystemAsyncBlobStoreTest {
/** /**
* Test of removeBlob method, with only one blob with a complex path as key * Test of removeBlob method, with only one blob with a complex path as key
*/ */
@Test(dataProvider = "ignoreOnWindows", description = "see http://code.google.com/p/jclouds/issues/detail?id=737")
public void testRemoveBlob_ComplexBlobKey() throws IOException { public void testRemoveBlob_ComplexBlobKey() throws IOException {
final String BLOB_KEY = TestUtils.createRandomBlobKey("aa/bb/cc/dd/", null); final String BLOB_KEY = TestUtils.createRandomBlobKey("aa/bb/cc/dd/", null);
boolean result; boolean result;
@ -429,6 +436,7 @@ public class FilesystemAsyncBlobStoreTest {
* when first blob is removed, not all of its key's path is removed, because * when first blob is removed, not all of its key's path is removed, because
* it is shared with the second blob's key * it is shared with the second blob's key
*/ */
@Test(dataProvider = "ignoreOnWindows", description = "see http://code.google.com/p/jclouds/issues/detail?id=737")
public void testRemoveBlob_TwoComplexBlobKeys() throws IOException { public void testRemoveBlob_TwoComplexBlobKeys() throws IOException {
final String BLOB_KEY1 = TestUtils.createRandomBlobKey("aa/bb/cc/dd/", null); final String BLOB_KEY1 = TestUtils.createRandomBlobKey("aa/bb/cc/dd/", null);
final String BLOB_KEY2 = TestUtils.createRandomBlobKey("aa/bb/ee/ff/", null); final String BLOB_KEY2 = TestUtils.createRandomBlobKey("aa/bb/ee/ff/", null);
@ -702,6 +710,7 @@ public class FilesystemAsyncBlobStoreTest {
TestUtils.directoryExists(TARGET_CONTAINER_NAME2, false); TestUtils.directoryExists(TARGET_CONTAINER_NAME2, false);
} }
@Test(dataProvider = "ignoreOnWindows", description = "see http://code.google.com/p/jclouds/issues/detail?id=737")
public void testInvalidContainerName() { public void testInvalidContainerName() {
try { try {
blobStore.createContainerInLocation(null, "file/system"); blobStore.createContainerInLocation(null, "file/system");
@ -716,23 +725,28 @@ public class FilesystemAsyncBlobStoreTest {
} }
public void testRanges() throws IOException { public void testRanges() throws IOException {
/*
* Using CONTAINER_NAME here breaks tests on Windows because the container
* can't be deleted. See http://code.google.com/p/jclouds/issues/detail?id=737
*/
final String containerName = "containerWithRanges";
String payload = "abcdefgh"; String payload = "abcdefgh";
Blob blob = blobStore.blobBuilder("test").payload(new StringPayload(payload)).build(); Blob blob = blobStore.blobBuilder("test").payload(new StringPayload(payload)).build();
blobStore.putBlob(CONTAINER_NAME, blob); blobStore.putBlob(containerName, blob);
GetOptions getOptionsRangeStartAt = new GetOptions(); GetOptions getOptionsRangeStartAt = new GetOptions();
getOptionsRangeStartAt.startAt(1); getOptionsRangeStartAt.startAt(1);
Blob blobRangeStartAt = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsRangeStartAt); Blob blobRangeStartAt = blobStore.getBlob(containerName, blob.getMetadata().getName(), getOptionsRangeStartAt);
Assert.assertEquals("bcdefgh", IOUtils.toString(blobRangeStartAt.getPayload().getInput())); Assert.assertEquals("bcdefgh", IOUtils.toString(blobRangeStartAt.getPayload().getInput()));
GetOptions getOptionsRangeTail = new GetOptions(); GetOptions getOptionsRangeTail = new GetOptions();
getOptionsRangeTail.tail(3); getOptionsRangeTail.tail(3);
Blob blobRangeTail = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsRangeTail); Blob blobRangeTail = blobStore.getBlob(containerName, blob.getMetadata().getName(), getOptionsRangeTail);
Assert.assertEquals("fgh", IOUtils.toString(blobRangeTail.getPayload().getInput())); Assert.assertEquals("fgh", IOUtils.toString(blobRangeTail.getPayload().getInput()));
GetOptions getOptionsFragment = new GetOptions(); GetOptions getOptionsFragment = new GetOptions();
getOptionsFragment.range(4, 6); getOptionsFragment.range(4, 6);
Blob blobFragment = blobStore.getBlob(CONTAINER_NAME, blob.getMetadata().getName(), getOptionsFragment); Blob blobFragment = blobStore.getBlob(containerName, blob.getMetadata().getName(), getOptionsFragment);
Assert.assertEquals("efg", IOUtils.toString(blobFragment.getPayload().getInput())); Assert.assertEquals("efg", IOUtils.toString(blobFragment.getPayload().getInput()));
} }

View File

@ -48,6 +48,7 @@ import org.jclouds.filesystem.utils.TestUtils;
import org.jclouds.io.payloads.FilePayload; import org.jclouds.io.payloads.FilePayload;
import org.testng.annotations.AfterMethod; import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod; import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test; import org.testng.annotations.Test;
/** /**
@ -92,6 +93,12 @@ public class FilesystemStorageStrategyImplTest {
TestUtils.cleanDirectoryContent(TestUtils.TARGET_BASE_DIR); TestUtils.cleanDirectoryContent(TestUtils.TARGET_BASE_DIR);
} }
@DataProvider
public Object[][] ignoreOnWindows() {
return (TestUtils.isWindowsOs() ? TestUtils.NO_INVOCATIONS
: TestUtils.SINGLE_NO_ARG_INVOCATION);
}
public void testCreateDirectory() { public void testCreateDirectory() {
storageStrategy.createDirectory(CONTAINER_NAME, null); storageStrategy.createDirectory(CONTAINER_NAME, null);
TestUtils.directoryExists(TARGET_CONTAINER_NAME, true); TestUtils.directoryExists(TARGET_CONTAINER_NAME, true);
@ -114,10 +121,11 @@ public class FilesystemStorageStrategyImplTest {
storageStrategy.createDirectory(CONTAINER_NAME, null); storageStrategy.createDirectory(CONTAINER_NAME, null);
} }
@Test(dataProvider = "ignoreOnWindows", description = "see http://code.google.com/p/jclouds/issues/detail?id=737")
public void testCreateDirectory_WrongDirectoryName() { public void testCreateDirectory_WrongDirectoryName() {
try { try {
storageStrategy.createDirectory(CONTAINER_NAME, "$%&!'`\\/"); storageStrategy.createDirectory(CONTAINER_NAME, "$%&!'`\\/");
fail("No exception throwed"); fail("No exception thrown");
} catch (Exception e) { } catch (Exception e) {
} }
} }

View File

@ -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 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) * Generate a random blob key simple name (with no path in the key)