Search in sources :

Example 1 with AssumptionViolatedException

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;
}
Also used : AssumptionViolatedException(org.junit.internal.AssumptionViolatedException) URI(java.net.URI)

Example 2 with AssumptionViolatedException

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);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) FileStatus(org.apache.hadoop.fs.FileStatus) Header(org.apache.commons.httpclient.Header) AssumptionViolatedException(org.junit.internal.AssumptionViolatedException) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) BlockLocation(org.apache.hadoop.fs.BlockLocation) Test(org.junit.Test)

Example 3 with AssumptionViolatedException

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;
}
Also used : AssumptionViolatedException(org.junit.internal.AssumptionViolatedException)

Example 4 with AssumptionViolatedException

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);
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) AssumptionViolatedException(org.junit.internal.AssumptionViolatedException)

Example 5 with AssumptionViolatedException

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());
}
Also used : AssumptionViolatedException(org.junit.internal.AssumptionViolatedException) Test(org.junit.Test)

Aggregations

AssumptionViolatedException (org.junit.internal.AssumptionViolatedException)26 Test (org.junit.Test)7 Statement (org.junit.runners.model.Statement)6 EachTestNotifier (org.junit.internal.runners.model.EachTestNotifier)4 Failure (org.junit.runner.notification.Failure)4 URI (java.net.URI)3 Description (org.junit.runner.Description)3 MultipleFailureException (org.junit.runners.model.MultipleFailureException)3 FileStatus (org.apache.hadoop.fs.FileStatus)2 Path (org.apache.hadoop.fs.Path)2 SuppressForbidden (com.carrotsearch.randomizedtesting.annotations.SuppressForbidden)1 BufferedReader (java.io.BufferedReader)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 Reader (java.io.Reader)1 ArrayList (java.util.ArrayList)1 Locale (java.util.Locale)1