use of org.junit.internal.AssumptionViolatedException in project hadoop by apache.
the class AliyunOSSTestUtils method createTestFileSystem.
/**
* Create the test filesystem.
*
* If the test.fs.oss.name property is not set,
* tests will fail.
*
* @param conf configuration
* @return the FS
* @throws IOException
*/
public static AliyunOSSFileSystem createTestFileSystem(Configuration conf) throws IOException {
String fsname = conf.getTrimmed(TestAliyunOSSFileSystemContract.TEST_FS_OSS_NAME, "");
boolean liveTest = StringUtils.isNotEmpty(fsname);
URI testURI = null;
if (liveTest) {
testURI = URI.create(fsname);
liveTest = testURI.getScheme().equals(Constants.FS_OSS);
}
if (!liveTest) {
throw new AssumptionViolatedException("No test filesystem in " + TestAliyunOSSFileSystemContract.TEST_FS_OSS_NAME);
}
AliyunOSSFileSystem ossfs = new AliyunOSSFileSystem();
ossfs.initialize(testURI, conf);
return ossfs;
}
use of org.junit.internal.AssumptionViolatedException in project hadoop by apache.
the class TestSwiftFileSystemPartitionedUploads method testFilePartUpload.
/**
* tests functionality for big files ( > 5Gb) upload
*/
@Test(timeout = SWIFT_BULK_IO_TEST_TIMEOUT)
public void testFilePartUpload() throws Throwable {
final Path path = new Path("/test/testFilePartUpload");
int len = 8192;
final byte[] src = SwiftTestUtils.dataset(len, 32, 144);
FSDataOutputStream out = fs.create(path, false, getBufferSize(), (short) 1, BLOCK_SIZE);
try {
int totalPartitionsToWrite = len / PART_SIZE_BYTES;
assertPartitionsWritten("Startup", out, 0);
//write 2048
int firstWriteLen = 2048;
out.write(src, 0, firstWriteLen);
//assert
long expected = getExpectedPartitionsWritten(firstWriteLen, PART_SIZE_BYTES, false);
SwiftUtils.debug(LOG, "First write: predict %d partitions written", expected);
assertPartitionsWritten("First write completed", out, expected);
//write the rest
int remainder = len - firstWriteLen;
SwiftUtils.debug(LOG, "remainder: writing: %d bytes", remainder);
out.write(src, firstWriteLen, remainder);
expected = getExpectedPartitionsWritten(len, PART_SIZE_BYTES, false);
assertPartitionsWritten("Remaining data", out, expected);
out.close();
expected = getExpectedPartitionsWritten(len, PART_SIZE_BYTES, true);
assertPartitionsWritten("Stream closed", out, expected);
Header[] headers = fs.getStore().getObjectHeaders(path, true);
for (Header header : headers) {
LOG.info(header.toString());
}
byte[] dest = readDataset(fs, path, len);
LOG.info("Read dataset from " + path + ": data length =" + len);
//compare data
SwiftTestUtils.compareByteArrays(src, dest, len);
FileStatus status;
final Path qualifiedPath = path.makeQualified(fs);
status = fs.getFileStatus(qualifiedPath);
//now see what block location info comes back.
//This will vary depending on the Swift version, so the results
//aren't checked -merely that the test actually worked
BlockLocation[] locations = fs.getFileBlockLocations(status, 0, len);
assertNotNull("Null getFileBlockLocations()", locations);
assertTrue("empty array returned for getFileBlockLocations()", locations.length > 0);
//to a skip
try {
validatePathLen(path, len);
} catch (AssertionError e) {
//downgrade to a skip
throw new AssumptionViolatedException(e, null);
}
} finally {
IOUtils.closeStream(out);
}
}
use of org.junit.internal.AssumptionViolatedException in project hadoop by apache.
the class SwiftTestUtils method downgrade.
/**
* downgrade a failure to a message and a warning, then an
* exception for the Junit test runner to mark as failed
* @param message text message
* @param failure what failed
* @throws AssumptionViolatedException always
*/
public static void downgrade(String message, Throwable failure) {
LOG.warn("Downgrading test " + message, failure);
AssumptionViolatedException ave = new AssumptionViolatedException(failure, null);
throw ave;
}
use of org.junit.internal.AssumptionViolatedException in project hadoop by apache.
the class NativeS3FileSystemContractBaseTest method setUp.
@Override
protected void setUp() throws Exception {
Configuration conf = new Configuration();
store = getNativeFileSystemStore();
fs = new NativeS3FileSystem(store);
String fsname = conf.get(KEY_TEST_FS);
if (StringUtils.isEmpty(fsname)) {
throw new AssumptionViolatedException("No test FS defined in :" + KEY_TEST_FS);
}
fs.initialize(URI.create(fsname), conf);
}
use of org.junit.internal.AssumptionViolatedException in project cucumber-jvm by cucumber.
the class RuntimeTest method non_strict_with_failed_junit_assumption_prior_to_junit_412.
@Test
public void non_strict_with_failed_junit_assumption_prior_to_junit_412() {
Runtime runtime = createNonStrictRuntime();
runtime.addError(new AssumptionViolatedException("should be treated like pending"));
assertEquals(0x0, runtime.exitStatus());
}
Aggregations