Search in sources :

Example 21 with AssumptionViolatedException

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

Example 22 with AssumptionViolatedException

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();
}
Also used : AsyncFileImpl(io.vertx.core.file.impl.AsyncFileImpl) io.vertx.core(io.vertx.core) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) VertxTestBase(io.vertx.test.core.VertxTestBase) AtomicReference(java.util.concurrent.atomic.AtomicReference) Utils(io.vertx.core.impl.Utils) java.nio.file(java.nio.file) Unpooled(io.netty.buffer.Unpooled) HashSet(java.util.HashSet) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) ByteBuf(io.netty.buffer.ByteBuf) TestUtils(io.vertx.test.core.TestUtils) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) WriteStream(io.vertx.core.streams.WriteStream) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) ReadStream(io.vertx.core.streams.ReadStream) Pump(io.vertx.core.streams.Pump) JsonObject(io.vertx.core.json.JsonObject) Assume(org.junit.Assume) EnumSet(java.util.EnumSet) AssumptionViolatedException(org.junit.AssumptionViolatedException) Set(java.util.Set) Test(org.junit.Test) IOException(java.io.IOException) File(java.io.File) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) Rule(org.junit.Rule) Buffer(io.vertx.core.buffer.Buffer) TemporaryFolder(org.junit.rules.TemporaryFolder) java.nio.file.attribute(java.nio.file.attribute) AssumptionViolatedException(org.junit.AssumptionViolatedException) File(java.io.File) Test(org.junit.Test)

Example 23 with AssumptionViolatedException

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();
}
Also used : AsyncFileImpl(io.vertx.core.file.impl.AsyncFileImpl) io.vertx.core(io.vertx.core) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) VertxTestBase(io.vertx.test.core.VertxTestBase) AtomicReference(java.util.concurrent.atomic.AtomicReference) Utils(io.vertx.core.impl.Utils) java.nio.file(java.nio.file) Unpooled(io.netty.buffer.Unpooled) HashSet(java.util.HashSet) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) ByteBuf(io.netty.buffer.ByteBuf) TestUtils(io.vertx.test.core.TestUtils) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) WriteStream(io.vertx.core.streams.WriteStream) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) ReadStream(io.vertx.core.streams.ReadStream) Pump(io.vertx.core.streams.Pump) JsonObject(io.vertx.core.json.JsonObject) Assume(org.junit.Assume) EnumSet(java.util.EnumSet) AssumptionViolatedException(org.junit.AssumptionViolatedException) Set(java.util.Set) Test(org.junit.Test) IOException(java.io.IOException) File(java.io.File) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) Rule(org.junit.Rule) Buffer(io.vertx.core.buffer.Buffer) TemporaryFolder(org.junit.rules.TemporaryFolder) java.nio.file.attribute(java.nio.file.attribute) AssumptionViolatedException(org.junit.AssumptionViolatedException) File(java.io.File) Test(org.junit.Test)

Example 24 with AssumptionViolatedException

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();
}
Also used : AssumptionViolatedException(org.junit.AssumptionViolatedException) Method(java.lang.reflect.Method) Annotation(java.lang.annotation.Annotation) Test(org.junit.Test)

Example 25 with AssumptionViolatedException

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);
}
Also used : AssumptionViolatedException(org.junit.AssumptionViolatedException) Method(java.lang.reflect.Method) Annotation(java.lang.annotation.Annotation) Test(org.junit.Test)

Aggregations

AssumptionViolatedException (org.junit.AssumptionViolatedException)79 Test (org.junit.Test)26 IOException (java.io.IOException)16 Statement (org.junit.runners.model.Statement)9 ByteArrayOutputStream (java.io.ByteArrayOutputStream)6 Method (java.lang.reflect.Method)6 Set (java.util.Set)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 File (java.io.File)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 ZipEntry (java.util.zip.ZipEntry)5 ZipOutputStream (java.util.zip.ZipOutputStream)5 InputStream (java.io.InputStream)4 HashSet (java.util.HashSet)4 ZipInputStream (java.util.zip.ZipInputStream)4 FilterInputStream (java.io.FilterInputStream)3 UnknownHostException (java.net.UnknownHostException)3 JarInputStream (java.util.jar.JarInputStream)3 Configuration (org.apache.flink.configuration.Configuration)3 IInjectorProvider (org.eclipse.xtext.junit4.IInjectorProvider)3