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);
}
}
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());
}
}
}
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();
}
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());
}
}
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);
}
Aggregations