use of org.junit.AssumptionViolatedException in project mongo-java-driver by mongodb.
the class UnifiedTest method setUp.
@Before
public void setUp() {
assertTrue(String.format("Unsupported schema version %s", schemaVersion), schemaVersion.startsWith("1.0") || schemaVersion.startsWith("1.1") || schemaVersion.startsWith("1.2") || schemaVersion.startsWith("1.3") || schemaVersion.startsWith("1.4") || schemaVersion.startsWith("1.5") || schemaVersion.startsWith("1.6"));
if (runOnRequirements != null) {
assumeTrue("Run-on requirements not met", runOnRequirementsMet(runOnRequirements, getMongoClientSettings(), getServerVersion()));
}
if (definition.containsKey("runOnRequirements")) {
assumeTrue("Run-on requirements not met", runOnRequirementsMet(definition.getArray("runOnRequirements", new BsonArray()), getMongoClientSettings(), getServerVersion()));
}
if (definition.containsKey("skipReason")) {
throw new AssumptionViolatedException(definition.getString("skipReason").getValue());
}
entities.init(entitiesArray, this::createMongoClient, fileDescription != null && PRESTART_POOL_ASYNC_WORK_MANAGER_FILE_DESCRIPTIONS.contains(fileDescription), this::createGridFSBucket);
addInitialData();
}
use of org.junit.AssumptionViolatedException in project vert.x by eclipse.
the class FileSystemTest method testCopyNoFollowLinks.
@Test
public void testCopyNoFollowLinks() throws Exception {
// Symlinks require a modified security policy in Windows. -- See http://stackoverflow.com/questions/23217460/how-to-create-soft-symbolic-link-using-java-nio-files
Assume.assumeFalse(Utils.isWindows());
String source = "foo.txt";
String link = "link.txt";
String target = "bar.txt";
createFileWithJunk(source, 100);
try {
Files.createSymbolicLink(new File(testDir, link).toPath(), new File(testDir, source).toPath());
} catch (UnsupportedOperationException e) {
throw new AssumptionViolatedException("Links unsupported");
}
FileSystem fs = vertx.fileSystem();
String from = testDir + pathSep + link;
String to = testDir + pathSep + target;
CopyOptions options = new CopyOptions().setNofollowLinks(true);
fs.copy(from, to, options, onSuccess(v -> {
fs.lprops(to, onSuccess(props -> {
assertTrue(props.isSymbolicLink());
fs.readFile(from, onSuccess(expected -> {
fs.readFile(to, onSuccess(actual -> {
assertEquals(expected, actual);
complete();
}));
}));
}));
}));
await();
}
use of org.junit.AssumptionViolatedException in project vert.x by eclipse.
the class FileSystemTest method testAtomicMove.
@Test
public void testAtomicMove() throws Exception {
String source = "foo.txt";
String middle = "baz.txt";
String target = "bar.txt";
createFileWithJunk(source, 100);
try {
Files.move(new File(testDir, source).toPath(), new File(testDir, middle).toPath(), StandardCopyOption.ATOMIC_MOVE);
} catch (AtomicMoveNotSupportedException e) {
throw new AssumptionViolatedException("Atomic move unsupported");
}
FileSystem fs = vertx.fileSystem();
String from = testDir + pathSep + middle;
String to = testDir + pathSep + target;
CopyOptions options = new CopyOptions().setAtomicMove(true);
fs.move(from, to, options, onSuccess(v -> {
assertFalse(fileExists(middle));
assertTrue(fileExists(target));
complete();
}));
await();
}
use of org.junit.AssumptionViolatedException in project auto by google.
the class AutoValueJava8Test method testDefaultToJSpecifyNullable.
// Tests that we generate equals(@Nullable x) using JSpecify @Nullable if that annotation is
// available and there is no other @Nullable type annotation mentioned in the @AutoValue class.
// If there *are* other @Nullable type annotations, other test methods here will check that they
// are used instead.
@Test
public void testDefaultToJSpecifyNullable() throws ReflectiveOperationException {
Class<? extends Annotation> jspecifyNullable;
try {
// We write this using .concat in order to hide it from rewriting rules.
jspecifyNullable = Class.forName("org".concat(".jspecify.nullness.Nullable")).asSubclass(Annotation.class);
} catch (ClassNotFoundException e) {
throw new AssumptionViolatedException("No JSpecify @Nullable available", e);
}
Class<? extends NoNullableRef> autoValueImpl = NoNullableRef.of("foo").getClass();
Method equals = autoValueImpl.getDeclaredMethod("equals", Object.class);
assertThat(equals.getAnnotatedParameterTypes()[0].isAnnotationPresent(jspecifyNullable)).isTrue();
}
use of org.junit.AssumptionViolatedException in project auto by google.
the class AutoAnnotationTest method testEqualsParameterAnnotation.
@Test
public void testEqualsParameterAnnotation() throws ReflectiveOperationException {
assume().that(Double.parseDouble(StandardSystemProperty.JAVA_SPECIFICATION_VERSION.value())).isAtLeast(8.0);
Class<? extends Annotation> jspecifyNullable;
try {
// We write this using .concat in order to hide it from rewriting rules.
jspecifyNullable = Class.forName("org".concat(".jspecify.nullness.Nullable")).asSubclass(Annotation.class);
} catch (ClassNotFoundException e) {
throw new AssumptionViolatedException("No JSpecify @Nullable available", e);
}
// yes, I really want the implementation class
@SuppressWarnings("GetClassOnAnnotation") Class<? extends StringValues> autoAnnotationImpl = newStringValues(new String[0]).getClass();
Method equals = autoAnnotationImpl.getDeclaredMethod("equals", Object.class);
// The remaining faffing around with reflection is there because we have a Google-internal test
// that runs this code with -source 7 -target 7. We're really just doing this:
// assertThat(equals.getAnnotatedParameterTypes()[0].isAnnotationPresent(jspecifyNullable))
// .isTrue();
Method getAnnotatedParameterTypes = Method.class.getMethod("getAnnotatedParameterTypes");
Object[] annotatedParameterTypes = (Object[]) getAnnotatedParameterTypes.invoke(equals);
Method isAnnotationPresent = annotatedParameterTypes[0].getClass().getMethod("isAnnotationPresent", Class.class);
assertThat(isAnnotationPresent.invoke(annotatedParameterTypes[0], jspecifyNullable)).isEqualTo(true);
}
Aggregations