Search in sources :

Example 1 with SkipException

use of org.testng.SkipException in project reactive-streams-jvm by reactive-streams.

the class PublisherVerification method optional_spec104_mustSignalOnErrorWhenFails.

// Verifies rule: https://github.com/reactive-streams/reactive-streams-jvm#1.4
@Override
@Test
public void optional_spec104_mustSignalOnErrorWhenFails() throws Throwable {
    try {
        whenHasErrorPublisherTest(new PublisherTestRun<T>() {

            @Override
            public void run(final Publisher<T> pub) throws InterruptedException {
                final Latch onErrorlatch = new Latch(env);
                final Latch onSubscribeLatch = new Latch(env);
                pub.subscribe(new TestEnvironment.TestSubscriber<T>(env) {

                    @Override
                    public void onSubscribe(Subscription subs) {
                        onSubscribeLatch.assertOpen("Only one onSubscribe call expected");
                        onSubscribeLatch.close();
                    }

                    @Override
                    public void onError(Throwable cause) {
                        onSubscribeLatch.assertClosed("onSubscribe should be called prior to onError always");
                        onErrorlatch.assertOpen(String.format("Error-state Publisher %s called `onError` twice on new Subscriber", pub));
                        onErrorlatch.close();
                    }
                });
                onSubscribeLatch.expectClose("Should have received onSubscribe");
                onErrorlatch.expectClose(String.format("Error-state Publisher %s did not call `onError` on new Subscriber", pub));
                env.verifyNoAsyncErrors();
            }
        });
    } catch (SkipException se) {
        throw se;
    } catch (Throwable ex) {
        // which was wrong of him - he should have signalled on error using onError
        throw new RuntimeException(String.format("Publisher threw exception (%s) instead of signalling error via onError!", ex.getMessage()), ex);
    }
}
Also used : Latch(org.reactivestreams.tck.TestEnvironment.Latch) SkipException(org.testng.SkipException) Subscription(org.reactivestreams.Subscription) Override(java.lang.Override) Test(org.testng.annotations.Test) Override(java.lang.Override)

Example 2 with SkipException

use of org.testng.SkipException in project openstack4j by ContainX.

the class SkipTestListener method beforeInvocation.

@Override
public void beforeInvocation(IInvokedMethod iim, ITestResult itr) {
    Method method = iim.getTestMethod().getConstructorOrMethod().getMethod();
    // Check if method is annotated with @SkipTest
    if (method.isAnnotationPresent(SkipTest.class)) {
        SkipTest skipAnnotation = method.getAnnotation(SkipTest.class);
        String httpExecutorName = HttpExecutor.create().getExecutorName();
        // Annotation connector parameter can be a regex like ".*"
        if (httpExecutorName.matches(skipAnnotation.connector())) {
            StringBuilder message = new StringBuilder();
            message.append(String.format("Skip test %s for connector %s", method.getName(), httpExecutorName));
            if (skipAnnotation.issue() > 0) {
                message.append(String.format(" due to issue %s", skipAnnotation.issue()));
            }
            if (!skipAnnotation.description().isEmpty()) {
                message.append(String.format(": %s", skipAnnotation.description()));
            }
            // Skip Test
            Logger.getLogger(getClass().getName()).warning(message.toString());
            throw new SkipException(message.toString());
        }
    }
}
Also used : IInvokedMethod(org.testng.IInvokedMethod) Method(java.lang.reflect.Method) SkipException(org.testng.SkipException)

Example 3 with SkipException

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

the class VectorPairHMMUnitTest method testLikelihoodsFromHaplotypes.

@Test(dataProvider = "JustHMMProvider")
public void testLikelihoodsFromHaplotypes(final PairHMM hmm, Boolean loaded) {
    // skip if not loaded
    if (!loaded.booleanValue()) {
        throw new SkipException("AVX PairHMM is not supported on this system or the library is not available");
    }
    BasicInputParser parser = null;
    try {
        parser = new BasicInputParser(true, new FileInputStream(pairHMMTestData));
    } catch (FileNotFoundException e) {
        Assert.fail("PairHMM test data not found : " + pairHMMTestData);
    }
    while (parser.hasNext()) {
        String[] tokens = parser.next();
        final Haplotype hap = new Haplotype(tokens[0].getBytes(), true);
        final byte[] bases = tokens[1].getBytes();
        final byte[] baseQuals = normalize(tokens[2].getBytes(), 6);
        final byte[] insertionQuals = normalize(tokens[3].getBytes());
        final byte[] deletionQuals = normalize(tokens[4].getBytes());
        final byte[] gcp = normalize(tokens[5].getBytes());
        final double expectedResult = Double.parseDouble(tokens[6]);
        final int readLength = bases.length;
        final GATKRead read = ArtificialReadUtils.createArtificialRead(bases, baseQuals, readLength + "M");
        ReadUtils.setInsertionBaseQualities(read, insertionQuals);
        ReadUtils.setDeletionBaseQualities(read, deletionQuals);
        final Map<GATKRead, byte[]> gpcs = new LinkedHashMap<>(readLength);
        gpcs.put(read, gcp);
        hmm.initialize(Arrays.asList(hap), null, 0, 0);
        hmm.computeLog10Likelihoods(matrix(Arrays.asList(hap)), Arrays.asList(read), gpcs);
        final double[] la = hmm.getLogLikelihoodArray();
        Assert.assertEquals(la[0], expectedResult, 1e-5, "Likelihood not in expected range.");
    }
    hmm.close();
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) BasicInputParser(org.broadinstitute.hellbender.utils.text.parsers.BasicInputParser) FileNotFoundException(java.io.FileNotFoundException) FileInputStream(java.io.FileInputStream) SkipException(org.testng.SkipException) Haplotype(org.broadinstitute.hellbender.utils.haplotype.Haplotype) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 4 with SkipException

use of org.testng.SkipException in project presto by prestodb.

the class TestPrestoS3FileSystem method testCreateWithStagingDirectorySymlink.

@Test
public void testCreateWithStagingDirectorySymlink() throws Exception {
    java.nio.file.Path tmpdir = Paths.get(StandardSystemProperty.JAVA_IO_TMPDIR.value());
    java.nio.file.Path staging = Files.createTempDirectory(tmpdir, "staging");
    java.nio.file.Path link = Paths.get(staging + ".symlink");
    try {
        try {
            Files.createSymbolicLink(link, staging);
        } catch (UnsupportedOperationException e) {
            throw new SkipException("Filesystem does not support symlinks", e);
        }
        try (PrestoS3FileSystem fs = new PrestoS3FileSystem()) {
            MockAmazonS3 s3 = new MockAmazonS3();
            Configuration conf = new Configuration();
            conf.set(PrestoS3FileSystem.S3_STAGING_DIRECTORY, link.toString());
            fs.initialize(new URI("s3n://test-bucket/"), conf);
            fs.setS3Client(s3);
            FSDataOutputStream stream = fs.create(new Path("s3n://test-bucket/test"));
            stream.close();
            assertTrue(Files.exists(link));
        }
    } finally {
        deleteRecursively(link.toFile());
        deleteRecursively(staging.toFile());
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Configuration(org.apache.hadoop.conf.Configuration) ClientConfiguration(com.amazonaws.ClientConfiguration) SkipException(org.testng.SkipException) FSDataOutputStream(org.apache.hadoop.fs.FSDataOutputStream) URI(java.net.URI) Test(org.testng.annotations.Test)

Example 5 with SkipException

use of org.testng.SkipException in project OpenAM by OpenRock.

the class PropertiesFileLicenseLogTest method createTemporaryLogDir.

@BeforeMethod
public void createTemporaryLogDir() throws IOException {
    // Attempt to create a temporary log directory (Files.createTempDirectory only available in Java 7)
    int tries = 0;
    do {
        if (tries++ > 3) {
            throw new SkipException("Unable to create temp dir");
        }
        logDir = new File(System.getProperty("java.io.tmpdir") + File.separator + "licensetest" + RANDOM.nextInt());
    } while (!logDir.mkdir());
    System.out.println("tmpdir = " + logDir);
}
Also used : SkipException(org.testng.SkipException) File(java.io.File) BeforeMethod(org.testng.annotations.BeforeMethod)

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