Java Code Examples for org.junit.internal.AssumptionViolatedException

The following are top voted examples for showing how to use org.junit.internal.AssumptionViolatedException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: elasticsearch_my   File: ReproduceInfoPrinter.java   View source code 6 votes vote down vote up
@Override
public void testFailure(Failure failure) throws Exception {
    // Ignore assumptions.
    if (failure.getException() instanceof AssumptionViolatedException) {
        return;
    }

    final StringBuilder b = new StringBuilder("REPRODUCE WITH: gradle ");
    String task = System.getProperty("tests.task");
    // TODO: enforce (intellij still runs the runner?) or use default "test" but that won't work for integ
    b.append(task);

    GradleMessageBuilder gradleMessageBuilder = new GradleMessageBuilder(b);
    gradleMessageBuilder.appendAllOpts(failure.getDescription());

    // Client yaml suite tests are a special case as they allow for additional parameters
    if (ESClientYamlSuiteTestCase.class.isAssignableFrom(failure.getDescription().getTestClass())) {
        gradleMessageBuilder.appendClientYamlSuiteProperties();
    }

    System.err.println(b.toString());
}
 
Example 2
Project: elasticsearch_my   File: ESTestCase.java   View source code 6 votes vote down vote up
@Override
protected void afterAlways(List<Throwable> errors) throws Throwable {
    if (errors != null && errors.isEmpty() == false) {
        boolean allAssumption = true;
        for (Throwable error : errors) {
            if (false == error instanceof AssumptionViolatedException) {
                allAssumption = false;
                break;
            }
        }
        if (false == allAssumption) {
            ESTestCase.this.afterIfFailed(errors);
        }
    }
    super.afterAlways(errors);
}
 
Example 3
Project: hadoop   File: S3ATestUtils.java   View source code 6 votes vote down vote up
public static S3AFileSystem createTestFileSystem(Configuration conf) throws
    IOException {
  String fsname = conf.getTrimmed(TestS3AFileSystemContract.TEST_FS_S3A_NAME, "");


  boolean liveTest = !StringUtils.isEmpty(fsname);
  URI testURI = null;
  if (liveTest) {
    testURI = URI.create(fsname);
    liveTest = testURI.getScheme().equals(Constants.FS_S3A);
  }
  if (!liveTest) {
    // This doesn't work with our JUnit 3 style test cases, so instead we'll
    // make this whole class not run by default
    throw new AssumptionViolatedException(
        "No test filesystem in " + TestS3AFileSystemContract.TEST_FS_S3A_NAME);
  }
  S3AFileSystem fs1 = new S3AFileSystem();
  //enable purging in tests
  conf.setBoolean(Constants.PURGE_EXISTING_MULTIPART, true);
  conf.setInt(Constants.PURGE_EXISTING_MULTIPART_AGE, 0);
  fs1.initialize(testURI, conf);
  return fs1;
}
 
Example 4
Project: satisfy   File: SatisfyStepInterceptor.java   View source code 6 votes vote down vote up
private Object runTestStep(final Object obj, final Method method,
                           final Object[] args, final MethodProxy proxy)
        throws Throwable {
    LOGGER.debug("STARTING STEP: {}", method.getName());
    Object result = null;
    try {
        result = executeTestStepMethod(obj, method, args, proxy, result);
        LOGGER.debug("STEP DONE: {}", method.getName());
    } catch (AssertionError failedAssertion) {
        error = failedAssertion;
        logStepFailure(method, args, failedAssertion);
        return appropriateReturnObject(obj, method);
    } catch (AssumptionViolatedException assumptionFailed) {
        return appropriateReturnObject(obj, method);
    } catch (Throwable testErrorException) {
        error = testErrorException;
        logStepFailure(method, args, forError(error).convertToAssertion());
        return appropriateReturnObject(obj, method);
    }

    return result;
}
 
Example 5
Project: satisfy   File: SatisfyStepInterceptor.java   View source code 6 votes vote down vote up
private Object executeTestStepMethod(Object obj, Method method, Object[]
        args, MethodProxy proxy, Object result) throws Throwable {
    try {
        result = invokeMethod(obj, args, proxy);
        notifyStepFinishedFor(method, args);
    } catch (PendingStepException pendingStep) {
        notifyStepPending(pendingStep.getMessage());
    } catch (IgnoredStepException ignoredStep) {
        notifyStepIgnored(ignoredStep.getMessage());
    } catch (AssumptionViolatedException assumptionViolated) {
        notifyAssumptionViolated(assumptionViolated.getMessage());
    }

    Preconditions.checkArgument(true);
    return result;
}
 
Example 6
Project: openjdk-jdk10   File: UnsafeDeopt.java   View source code 6 votes vote down vote up
@Test
public void testUnsafe() {
    int m = 42;
    long addr1 = createBuffer();
    long addr2 = createBuffer();
    try {
        ResolvedJavaMethod method = getResolvedJavaMethod("readWriteReadUnsafe");
        Object receiver = method.isStatic() ? null : this;
        Result expect = executeExpected(method, receiver, addr1, m);
        if (getCodeCache() == null) {
            return;
        }
        testAgainstExpected(method, expect, receiver, addr2, m);
    } catch (AssumptionViolatedException e) {
        // Suppress so that subsequent calls to this method within the
        // same Junit @Test annotated method can proceed.
    } finally {
        disposeBuffer(addr1);
        disposeBuffer(addr2);
    }
}
 
Example 7
Project: openjdk-jdk10   File: UnsafeDeopt.java   View source code 6 votes vote down vote up
@Test
public void testByteBuffer() {
    int m = 42;
    try {
        ResolvedJavaMethod method = getResolvedJavaMethod("readWriteReadByteBuffer");
        Object receiver = method.isStatic() ? null : this;
        Result expect = executeExpected(method, receiver, ByteBuffer.allocateDirect(32), m);
        if (getCodeCache() == null) {
            return;
        }
        ByteBuffer warmupBuffer = ByteBuffer.allocateDirect(32);
        for (int i = 0; i < 10000; ++i) {
            readWriteReadByteBuffer(warmupBuffer, (i % 50) + 1);
            warmupBuffer.putInt(0, 0);
        }
        testAgainstExpected(method, expect, receiver, ByteBuffer.allocateDirect(32), m);
    } catch (AssumptionViolatedException e) {
        // Suppress so that subsequent calls to this method within the
        // same Junit @Test annotated method can proceed.
    }
}
 
Example 8
Project: aliyun-oss-hadoop-fs   File: S3ATestUtils.java   View source code 6 votes vote down vote up
public static S3AFileSystem createTestFileSystem(Configuration conf) throws
    IOException {
  String fsname = conf.getTrimmed(TestS3AFileSystemContract.TEST_FS_S3A_NAME, "");


  boolean liveTest = !StringUtils.isEmpty(fsname);
  URI testURI = null;
  if (liveTest) {
    testURI = URI.create(fsname);
    liveTest = testURI.getScheme().equals(Constants.FS_S3A);
  }
  if (!liveTest) {
    // This doesn't work with our JUnit 3 style test cases, so instead we'll
    // make this whole class not run by default
    throw new AssumptionViolatedException(
        "No test filesystem in " + TestS3AFileSystemContract.TEST_FS_S3A_NAME);
  }
  S3AFileSystem fs1 = new S3AFileSystem();
  //enable purging in tests
  conf.setBoolean(Constants.PURGE_EXISTING_MULTIPART, true);
  conf.setInt(Constants.PURGE_EXISTING_MULTIPART_AGE, 0);
  fs1.initialize(testURI, conf);
  return fs1;
}
 
Example 9
Project: graal-core   File: UnsafeDeopt.java   View source code 6 votes vote down vote up
@Test
public void testUnsafe() {
    int m = 42;
    long addr1 = createBuffer();
    long addr2 = createBuffer();
    try {
        ResolvedJavaMethod method = getResolvedJavaMethod("readWriteReadUnsafe");
        Object receiver = method.isStatic() ? null : this;
        Result expect = executeExpected(method, receiver, addr1, m);
        if (getCodeCache() == null) {
            return;
        }
        testAgainstExpected(method, expect, receiver, addr2, m);
    } catch (AssumptionViolatedException e) {
        // Suppress so that subsequent calls to this method within the
        // same Junit @Test annotated method can proceed.
    } finally {
        disposeBuffer(addr1);
        disposeBuffer(addr2);
    }
}
 
Example 10
Project: graal-core   File: UnsafeDeopt.java   View source code 6 votes vote down vote up
@Test
public void testByteBuffer() {
    int m = 42;
    try {
        ResolvedJavaMethod method = getResolvedJavaMethod("readWriteReadByteBuffer");
        Object receiver = method.isStatic() ? null : this;
        Result expect = executeExpected(method, receiver, ByteBuffer.allocateDirect(32), m);
        if (getCodeCache() == null) {
            return;
        }
        ByteBuffer warmupBuffer = ByteBuffer.allocateDirect(32);
        for (int i = 0; i < 10000; ++i) {
            readWriteReadByteBuffer(warmupBuffer, (i % 50) + 1);
            warmupBuffer.putInt(0, 0);
        }
        testAgainstExpected(method, expect, receiver, ByteBuffer.allocateDirect(32), m);
    } catch (AssumptionViolatedException e) {
        // Suppress so that subsequent calls to this method within the
        // same Junit @Test annotated method can proceed.
    }
}
 
Example 11
Project: big-c   File: S3ATestUtils.java   View source code 6 votes vote down vote up
public static S3AFileSystem createTestFileSystem(Configuration conf) throws
    IOException {
  String fsname = conf.getTrimmed(TestS3AFileSystemContract.TEST_FS_S3A_NAME, "");


  boolean liveTest = !StringUtils.isEmpty(fsname);
  URI testURI = null;
  if (liveTest) {
    testURI = URI.create(fsname);
    liveTest = testURI.getScheme().equals(Constants.FS_S3A);
  }
  if (!liveTest) {
    // This doesn't work with our JUnit 3 style test cases, so instead we'll
    // make this whole class not run by default
    throw new AssumptionViolatedException(
        "No test filesystem in " + TestS3AFileSystemContract.TEST_FS_S3A_NAME);
  }
  S3AFileSystem fs1 = new S3AFileSystem();
  //enable purging in tests
  conf.setBoolean(Constants.PURGE_EXISTING_MULTIPART, true);
  conf.setInt(Constants.PURGE_EXISTING_MULTIPART_AGE, 0);
  fs1.initialize(testURI, conf);
  return fs1;
}
 
Example 12
Project: LiteGraph   File: GremlinProcessRunner.java   View source code 6 votes vote down vote up
@Override
public void runChild(final FrameworkMethod method, final RunNotifier notifier) {
    final Description description = describeChild(method);
    if (this.isIgnored(method)) {
        notifier.fireTestIgnored(description);
    } else {
        EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description);
        eachNotifier.fireTestStarted();
        boolean ignored = false;
        try {
            this.methodBlock(method).evaluate();
        } catch (AssumptionViolatedException ave) {
            eachNotifier.addFailedAssumption(ave);
        } catch (Throwable e) {
            if (validateForGraphComputer(e)) {
                eachNotifier.fireTestIgnored();
                logger.info(e.getMessage());
                ignored = true;
            } else
                eachNotifier.addFailure(e);
        } finally {
            if (!ignored)
                eachNotifier.fireTestFinished();
        }
    }
}
 
Example 13
Project: flowable-engine   File: FlowableDmnRule.java   View source code 6 votes vote down vote up
/**
 * Implementation based on {@link TestWatcher}.
 */
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
 
Example 14
Project: flowable-engine   File: FlowableIdmRule.java   View source code 6 votes vote down vote up
/**
 * Implementation based on {@link TestWatcher}.
 */
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
 
Example 15
Project: flowable-engine   File: ActivitiRule.java   View source code 6 votes vote down vote up
/**
 * Implementation based on {@link TestWatcher}.
 */
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<Throwable>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
 
Example 16
Project: flowable-engine   File: FlowableCmmnRule.java   View source code 6 votes vote down vote up
/**
 * Implementation based on {@link TestWatcher}.
 */
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
 
Example 17
Project: flowable-engine   File: FlowableRule.java   View source code 6 votes vote down vote up
/**
 * Implementation based on {@link TestWatcher}.
 */
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
 
Example 18
Project: flowable-engine   File: FlowableFormRule.java   View source code 6 votes vote down vote up
/**
 * Implementation based on {@link TestWatcher}.
 */
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
 
Example 19
Project: flowable-engine   File: FlowableContentRule.java   View source code 6 votes vote down vote up
/**
 * Implementation based on {@link TestWatcher}.
 */
@Override
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
 
Example 20
Project: hadoop-2.6.0-cdh5.4.3   File: S3ATestUtils.java   View source code 6 votes vote down vote up
public static S3AFileSystem createTestFileSystem(Configuration conf) throws
    IOException {
  String fsname = conf.getTrimmed(TestS3AFileSystemContract.TEST_FS_S3A_NAME, "");


  boolean liveTest = !StringUtils.isEmpty(fsname);
  URI testURI = null;
  if (liveTest) {
    testURI = URI.create(fsname);
    liveTest = testURI.getScheme().equals(Constants.FS_S3A);
  }
  if (!liveTest) {
    // This doesn't work with our JUnit 3 style test cases, so instead we'll
    // make this whole class not run by default
    throw new AssumptionViolatedException(
        "No test filesystem in " + TestS3AFileSystemContract.TEST_FS_S3A_NAME);
  }
  S3AFileSystem fs1 = new S3AFileSystem();
  fs1.initialize(testURI, conf);
  return fs1;
}
 
Example 21
Project: tinkerpop   File: GremlinProcessRunner.java   View source code 6 votes vote down vote up
@Override
public void runChild(final FrameworkMethod method, final RunNotifier notifier) {
    final Description description = describeChild(method);
    if (this.isIgnored(method)) {
        notifier.fireTestIgnored(description);
    } else {
        EachTestNotifier eachNotifier = new EachTestNotifier(notifier, description);
        eachNotifier.fireTestStarted();
        boolean ignored = false;
        try {
            this.methodBlock(method).evaluate();
        } catch (AssumptionViolatedException ave) {
            eachNotifier.addFailedAssumption(ave);
        } catch (Throwable e) {
            if (validateForGraphComputer(e)) {
                eachNotifier.fireTestIgnored();
                logger.info(e.getMessage());
                ignored = true;
            } else
                eachNotifier.addFailure(e);
        } finally {
            if (!ignored)
                eachNotifier.fireTestFinished();
        }
    }
}
 
Example 22
Project: hifive-pitalium   File: ParameterizedTestWatcher.java   View source code 6 votes vote down vote up
@Override
public Statement apply(final Statement base, final Description description, final Object[] params) {
	return new Statement() {
		public void evaluate() throws Throwable {
			ArrayList<Throwable> errors = new ArrayList<Throwable>();
			ParameterizedTestWatcher.this.startingQuietly(description, errors, params);

			try {
				base.evaluate();
				ParameterizedTestWatcher.this.succeededQuietly(description, errors, params);
			} catch (AssumptionViolatedException var7) {
				errors.add(var7);
				ParameterizedTestWatcher.this.skippedQuietly(var7, description, errors, params);
			} catch (Throwable var8) {
				errors.add(var8);
				ParameterizedTestWatcher.this.failedQuietly(var8, description, errors, params);
			} finally {
				ParameterizedTestWatcher.this.finishedQuietly(description, errors, params);
			}

			MultipleFailureException.assertEmpty(errors);
		}
	};
}
 
Example 23
Project: ant   File: XmlValidateTest.java   View source code 6 votes vote down vote up
/**
 * Test xml schema validation
 */
@Test
public void testXmlSchemaGood() throws BuildException {
    try {
        buildRule.executeTarget("testSchemaGood");
    } catch (BuildException e) {
        if (e.getMessage().endsWith(
                " doesn't recognize feature http://apache.org/xml/features/validation/schema")
                || e.getMessage().endsWith(
                        " doesn't support feature http://apache.org/xml/features/validation/schema")) {
            throw new AssumptionViolatedException("parser doesn't support schema");
        } else {
            throw e;
        }
    }
}
 
Example 24
Project: ant   File: XmlValidateTest.java   View source code 6 votes vote down vote up
/**
 * Test xml schema validation
 */
@Test
public void testXmlSchemaBad() {
    try {
        buildRule.executeTarget("testSchemaBad");
        fail("Should throw BuildException because 'Bad Schema Validation'");
    } catch (BuildException e) {
        if (e.getMessage().endsWith(
                " doesn't recognize feature http://apache.org/xml/features/validation/schema")
                || e.getMessage().endsWith(
                        " doesn't support feature http://apache.org/xml/features/validation/schema")) {
            throw new AssumptionViolatedException("parser doesn't support schema");
        } else {
            assertTrue(
                e.getMessage().indexOf("not a valid XML document") > -1);
        }
    }
}
 
Example 25
Project: ant   File: TestProcess.java   View source code 6 votes vote down vote up
public void shutdown() {
    if (!done) {
        System.out.println("shutting down TestProcess");
        run = false;

        synchronized (this) {
            while (!done) {
                try {
                    wait();
                } catch (InterruptedException ie) {
                    throw new AssumptionViolatedException("Thread interrupted", ie);
                }
            }
        }

        System.out.println("TestProcess shut down");
    }
}
 
Example 26
Project: ant   File: TestProcess.java   View source code 6 votes vote down vote up
public void run() {
    for (int i = 0; i < 5 && run; i++) {
        System.out.println(Thread.currentThread().getName());

        try {
            Thread.sleep(2000);
        } catch (InterruptedException ie) {
            throw new AssumptionViolatedException("Thread interrupted", ie);
        }
    }

    synchronized (this) {
        done = true;
        notifyAll();
    }
}
 
Example 27
Project: JGiven   File: JGivenMethodRule.java   View source code 6 votes vote down vote up
@Override
public Statement apply( final Statement base, final FrameworkMethod method, final Object target ) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            starting( base, method, target );
            try {
                base.evaluate();
                succeeded();
            } catch( AssumptionViolatedException e ) {
                throw e;
            } catch( Throwable t ) {
                failed( t );
                throw t;
            }
        }
    };
}
 
Example 28
Project: lcm   File: TestWatchman.java   View source code 6 votes vote down vote up
public Statement apply(final Statement base, final FrameworkMethod method,
        Object target) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            starting(method);
            try {
                base.evaluate();
                succeeded(method);
            } catch (AssumptionViolatedException e) {
                throw e;
            } catch (Throwable t) {
                failed(t, method);
                throw t;
            } finally {
                finished(method);
            }
        }
    };
}
 
Example 29
Project: lcm   File: TestWatcher.java   View source code 6 votes vote down vote up
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<Throwable>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
 
Example 30
Project: marmotta   File: KiWiDatabaseRunner.java   View source code 6 votes vote down vote up
@Override
public Statement apply(final Statement base, final FrameworkMethod method,
        Object target) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            logger.info("{} starting...", testName(method));
            try {
                base.evaluate();
                logger.debug("{} SUCCESS", testName(method));
            } catch (AssumptionViolatedException e) {
                logger.info("{} Ignored: {}", testName(method), e.getMessage());
                throw e;
            } catch (Throwable t) {
                logger.warn("{} FAILED: {}", testName(method), t.getMessage());
                throw t;
            }
        }
    };
}
 
Example 31
Project: marmotta   File: LDCacheFileTest.java   View source code 6 votes vote down vote up
/**
 * Needs to be implemented by tests to provide the correct backend. Backend needs to be properly initialised.
 *
 * @return
 */
@Override
protected LDCachingBackend createBackend() {
    final File storageDir = Files.createTempDir();

    LDCachingBackend backend = null;
    try {
        backend = new LDCachingFileBackend(storageDir) {
            @Override
            public void shutdown() {
                super.shutdown();

                try {
                    FileUtils.deleteDirectory(storageDir);
                } catch (IOException e) {
                }
            }
        };
        backend.initialize();

        return backend;
    } catch (RepositoryException e) {
        throw new AssumptionViolatedException("could not initialise backend",e);
    }
}
 
Example 32
Project: junit   File: TestWatchman.java   View source code 6 votes vote down vote up
public Statement apply(final Statement base, final FrameworkMethod method,
        Object target) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            starting(method);
            try {
                base.evaluate();
                succeeded(method);
            } catch (AssumptionViolatedException e) {
                throw e;
            } catch (Throwable t) {
                failed(t, method);
                throw t;
            } finally {
                finished(method);
            }
        }
    };
}
 
Example 33
Project: junit   File: TestWatcher.java   View source code 6 votes vote down vote up
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<Throwable>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
 
Example 34
Project: org.openntf.domino   File: TestWatchman.java   View source code 6 votes vote down vote up
public Statement apply(final Statement base, final FrameworkMethod method,
        Object target) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            starting(method);
            try {
                base.evaluate();
                succeeded(method);
            } catch (AssumptionViolatedException e) {
                throw e;
            } catch (Throwable t) {
                failed(t, method);
                throw t;
            } finally {
                finished(method);
            }
        }
    };
}
 
Example 35
Project: org.openntf.domino   File: TestWatcher.java   View source code 6 votes vote down vote up
public Statement apply(final Statement base, final Description description) {
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            List<Throwable> errors = new ArrayList<Throwable>();

            startingQuietly(description, errors);
            try {
                base.evaluate();
                succeededQuietly(description, errors);
            } catch (AssumptionViolatedException e) {
                errors.add(e);
                skippedQuietly(e, description, errors);
            } catch (Throwable t) {
                errors.add(t);
                failedQuietly(t, description, errors);
            } finally {
                finishedQuietly(description, errors);
            }

            MultipleFailureException.assertEmpty(errors);
        }
    };
}
 
Example 36
Project: spring-struts-testcase   File: SpringMockStrutsRule.java   View source code 6 votes vote down vote up
@Override
protected void succeeded(Description description) {
	try {
		if (!this.actionExecutedAlready) {
			doAction();
		}
		StrutsAction strutsActionAnnotation = getStrutsActionAnnotation(description);
		this.springMockStrutsTestCase.verifyForward(strutsActionAnnotation.expectedForward(), strutsActionAnnotation.expectedForwardPath());
	} catch (Throwable e) {
		Class<? extends Throwable> expected = description.getAnnotation(Test.class).expected();
		if (e.getClass().equals(expected)) {
			throw new AssumptionViolatedException("Expected exception on the struts");
		}
		throw new IllegalStateException(e);
	}
}
 
Example 37
Project: marathonv5   File: AllureMarathonRunListener.java   View source code 5 votes vote down vote up
public void fireTestCaseFailure(Throwable throwable) {
    if (throwable instanceof AssumptionViolatedException) {
        getLifecycle().fire(new TestCaseCanceledEvent().withThrowable(throwable));
    } else {
        getLifecycle().fire(new TestCaseFailureEvent().withThrowable(throwable));
    }
}
 
Example 38
Project: shabdiz   File: ExperimentWatcher.java   View source code 5 votes vote down vote up
@Override
protected void skipped(final AssumptionViolatedException e, final Description description) {

    super.skipped(e, description);
    LOGGER.warn("skipped test {} due to assumption violation", description);
    LOGGER.warn("assumption violation", e);
}
 
Example 39
Project: spring-data-examples   File: RequiresRedisSentinel.java   View source code 5 votes vote down vote up
private void verify(SentinelsAvailable verificationMode) {

		int failed = 0;
		for (RedisNode node : sentinelConfig.getSentinels()) {
			if (!isAvailable(node)) {
				failed++;
			}
		}

		if (failed > 0) {
			if (SentinelsAvailable.ALL_ACTIVE.equals(verificationMode)) {
				throw new AssumptionViolatedException(String.format(
						"Expected all Redis Sentinels to respone but %s of %s did not responde", failed, sentinelConfig
								.getSentinels().size()));
			}

			if (SentinelsAvailable.ONE_ACTIVE.equals(verificationMode) && sentinelConfig.getSentinels().size() - 1 < failed) {
				throw new AssumptionViolatedException(
						"Expected at least one sentinel to respond but it seems all are offline - Game Over!");
			}
		}

		if (SentinelsAvailable.NONE_ACTIVE.equals(verificationMode) && failed != sentinelConfig.getSentinels().size()) {
			throw new AssumptionViolatedException(String.format(
					"Expected to have no sentinels online but found that %s are still alive.", (sentinelConfig.getSentinels()
							.size() - failed)));
		}
	}
 
Example 40
Project: spring-data-examples   File: RequiresSolrServer.java   View source code 5 votes vote down vote up
private void checkServerRunning() {

		try (CloseableHttpClient client = HttpClientBuilder.create().build()) {
			CloseableHttpResponse response = client.execute(new HttpGet(baseUrl + PING_PATH));
			if (response != null && response.getStatusLine() != null) {
				Assume.assumeThat(response.getStatusLine().getStatusCode(), Is.is(200));
			}
		} catch (IOException e) {
			throw new AssumptionViolatedException("SolrServer does not seem to be running", e);
		}
	}