Search in sources :

Example 6 with SkipException

use of org.testng.SkipException in project selenium-tests by Wikia.

the class PageObjectLogging method onTestSkipped.

@Override
public void onTestSkipped(ITestResult result) {
    if (!testStarted) {
        start(result.getMethod().getConstructorOrMethod().getMethod());
    }
    if (result.getMethod().getConstructorOrMethod().getMethod().isAnnotationPresent(DontRun.class)) {
        log("Test SKIPPED", "this test is not supported in this environment", true);
        result.setStatus(ITestResult.SUCCESS);
        onTestSuccess(result);
    } else {
        result.setStatus(ITestResult.FAILURE);
        result.setThrowable(new SkipException("TEST SKIPPED"));
        onTestFailure(result);
    }
    if (testStarted) {
        stopLogging();
    }
}
Also used : SkipException(org.testng.SkipException)

Example 7 with SkipException

use of org.testng.SkipException in project gatk by broadinstitute.

the class IntelInflaterDeflaterIntegrationTest method deflateInflateWithIntel.

@Test
public void deflateInflateWithIntel() throws DataFormatException {
    if (!isIntelInflaterDeflaterSupported()) {
        throw new SkipException("IntelInflater/IntelDeflater not available on this platform");
    }
    // create buffers and random input
    final int LEN = 64 * 1024;
    final byte[] input = new RandomDNA().nextBases(LEN);
    final byte[] compressed = new byte[2 * LEN];
    final byte[] result = new byte[LEN];
    final IntelInflaterFactory intelInflaterFactory = new IntelInflaterFactory();
    final IntelDeflaterFactory intelDeflaterFactory = new IntelDeflaterFactory();
    Assert.assertTrue(intelInflaterFactory.usingIntelInflater());
    Assert.assertTrue(intelDeflaterFactory.usingIntelDeflater());
    for (int i = 0; i < 10; i++) {
        // create deflater with compression level i
        final Deflater deflater = intelDeflaterFactory.makeDeflater(i, true);
        // setup deflater
        deflater.setInput(input);
        deflater.finish();
        // compress data
        int compressedBytes = 0;
        // so this loop should always finish in one iteration
        while (!deflater.finished()) {
            compressedBytes = deflater.deflate(compressed, 0, compressed.length);
        }
        deflater.end();
        // decompress and check output == input
        Inflater inflater = intelInflaterFactory.makeInflater(true);
        inflater.setInput(compressed, 0, compressedBytes);
        inflater.inflate(result);
        inflater.end();
        Assert.assertEquals(input, result);
        // clear compressed and result buffers for next iteration
        Arrays.fill(compressed, (byte) 0);
        Arrays.fill(result, (byte) 0);
    }
}
Also used : IntelDeflaterFactory(com.intel.gkl.compression.IntelDeflaterFactory) IntelDeflater(com.intel.gkl.compression.IntelDeflater) Deflater(java.util.zip.Deflater) IntelInflaterFactory(com.intel.gkl.compression.IntelInflaterFactory) RandomDNA(org.broadinstitute.hellbender.utils.RandomDNA) Inflater(java.util.zip.Inflater) IntelInflater(com.intel.gkl.compression.IntelInflater) SkipException(org.testng.SkipException) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 8 with SkipException

use of org.testng.SkipException in project gatk by broadinstitute.

the class IntelInflaterDeflaterIntegrationTest method testIntelInflaterDeflaterWithPrintReads.

@Test(dataProvider = "JdkFlags")
public void testIntelInflaterDeflaterWithPrintReads(final boolean use_jdk_inflater, final boolean use_jdk_deflater) throws Exception {
    if (!isIntelInflaterDeflaterSupported()) {
        throw new SkipException("IntelInflater/IntelDeflater not available on this platform");
    }
    final File ORIG_BAM = new File(largeFileTestDir, INPUT_FILE);
    final File outFile = BaseTest.createTempFile(INPUT_FILE, ".bam");
    final ArrayList<String> args = new ArrayList<>();
    args.add("--input");
    args.add(ORIG_BAM.getAbsolutePath());
    args.add("--output");
    args.add(outFile.getAbsolutePath());
    args.add("--use_jdk_inflater");
    args.add(String.valueOf(use_jdk_inflater));
    args.add("--use_jdk_deflater");
    args.add(String.valueOf(use_jdk_deflater));
    // store current default factories, so they can be restored later
    InflaterFactory currentInflaterFactory = BlockGunzipper.getDefaultInflaterFactory();
    DeflaterFactory currentDeflaterFactory = BlockCompressedOutputStream.getDefaultDeflaterFactory();
    // set default factories to jdk version
    // because PrintReads cannot change the factory to Jdk if it was already set to Intel
    BlockGunzipper.setDefaultInflaterFactory(new InflaterFactory());
    BlockCompressedOutputStream.setDefaultDeflaterFactory(new DeflaterFactory());
    // run PrintReads
    runCommandLine(args);
    // restore default factories
    BlockGunzipper.setDefaultInflaterFactory(currentInflaterFactory);
    BlockCompressedOutputStream.setDefaultDeflaterFactory(currentDeflaterFactory);
    // validate input and output files are the same
    SamAssertionUtils.assertSamsEqual(outFile, ORIG_BAM);
}
Also used : InflaterFactory(htsjdk.samtools.util.zip.InflaterFactory) IntelInflaterFactory(com.intel.gkl.compression.IntelInflaterFactory) IntelDeflaterFactory(com.intel.gkl.compression.IntelDeflaterFactory) DeflaterFactory(htsjdk.samtools.util.zip.DeflaterFactory) ArrayList(java.util.ArrayList) SkipException(org.testng.SkipException) File(java.io.File) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 9 with SkipException

use of org.testng.SkipException in project gatk by broadinstitute.

the class AlleleListUnitTester method alleleList.

/**
     * Generate testing alleles.
     *
     * <p>
     *     Basically all are random alleles given the maximum allele length.
     * </p>
     *
     * <p>
     *     So with a low max-allele-length and high allele-count you can force repeats.
     * </p>
     *
     * @param alleleCount number of alleles to generate.
     * @param maxAlleleLength the maximum length of the allele in bases.
     * @param skipIfRepeats throw an test-skip exception {@link SkipException} if the resulting allele-list
     *                     has repeats, thus is size is less than {@code alleleCount}
     *
     * @throws RuntimeException if {@code alleleCount} is negative or {@code maxAlleleLength} is less than 1.
     * @return never {@code null}.
     */
public static AlleleList<Allele> alleleList(final int alleleCount, final int maxAlleleLength, final boolean skipIfRepeats) {
    final Allele[] alleles = AlleleListUnitTester.generateRandomUniqueAlleles(alleleCount, maxAlleleLength);
    if (alleleCount > 0)
        alleles[0] = Allele.create(alleles[0].getBases(), true);
    final AlleleList<Allele> alleleList = new IndexedAlleleList<>(alleles);
    if (skipIfRepeats && alleleList.numberOfAlleles() != alleles.length)
        throw new SkipException("repeated alleles, should be infrequent");
    return alleleList;
}
Also used : Allele(htsjdk.variant.variantcontext.Allele) SkipException(org.testng.SkipException)

Aggregations

SkipException (org.testng.SkipException)9 Test (org.testng.annotations.Test)5 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)3 IntelDeflaterFactory (com.intel.gkl.compression.IntelDeflaterFactory)2 IntelInflaterFactory (com.intel.gkl.compression.IntelInflaterFactory)2 File (java.io.File)2 ClientConfiguration (com.amazonaws.ClientConfiguration)1 IntelDeflater (com.intel.gkl.compression.IntelDeflater)1 IntelInflater (com.intel.gkl.compression.IntelInflater)1 DeflaterFactory (htsjdk.samtools.util.zip.DeflaterFactory)1 InflaterFactory (htsjdk.samtools.util.zip.InflaterFactory)1 Allele (htsjdk.variant.variantcontext.Allele)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 Override (java.lang.Override)1 Method (java.lang.reflect.Method)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 Deflater (java.util.zip.Deflater)1 Inflater (java.util.zip.Inflater)1