Search in sources :

Example 1 with VerifyInstrumentationException

use of co.paralleluniverse.fibers.VerifyInstrumentationException in project quasar by puniverse.

the class VerificationTest method testVerifyUninstrumentedMethod.

@Test
public final void testVerifyUninstrumentedMethod() throws ExecutionException, InterruptedException {
    assumeTrue(SystemProperties.isEmptyOrTrue("co.paralleluniverse.fibers.verifyInstrumentation"));
    final I1 i1 = new C1();
    Throwable t = null;
    final Fiber<?> fUninstrumentedMethod1 = new Fiber<>(new SuspendableRunnable() {

        @Override
        public final void run() throws SuspendExecution, InterruptedException {
            try {
                // **
                doUninstrumented();
                Fiber.sleep(10);
            } catch (final Exception e) {
                throw new RuntimeException(e);
            }
        }
    }).start();
    try {
        fUninstrumentedMethod1.join();
    } catch (final ExecutionException re) {
        t = re.getCause().getCause();
        t.printStackTrace();
    }
    assertTrue(t instanceof VerifyInstrumentationException && t.getMessage().contains(" **"));
    final Fiber<?> fUninstrumentedMethod2 = new Fiber(new SuspendableRunnable() {

        @Override
        public final void run() throws SuspendExecution, InterruptedException {
            try {
                i1.doIt();
            } finally {
                i1.doIt();
            }
        }
    }).start();
    try {
        fUninstrumentedMethod2.join();
    } catch (final ExecutionException re) {
        t = re.getCause();
        t.printStackTrace();
    }
    assertTrue(t instanceof VerifyInstrumentationException && t.getMessage().contains(" **"));
}
Also used : SuspendableRunnable(co.paralleluniverse.strands.SuspendableRunnable) Fiber(co.paralleluniverse.fibers.Fiber) ExecutionException(java.util.concurrent.ExecutionException) ExecutionException(java.util.concurrent.ExecutionException) VerifyInstrumentationException(co.paralleluniverse.fibers.VerifyInstrumentationException) VerifyInstrumentationException(co.paralleluniverse.fibers.VerifyInstrumentationException) Test(org.junit.Test)

Aggregations

Fiber (co.paralleluniverse.fibers.Fiber)1 VerifyInstrumentationException (co.paralleluniverse.fibers.VerifyInstrumentationException)1 SuspendableRunnable (co.paralleluniverse.strands.SuspendableRunnable)1 ExecutionException (java.util.concurrent.ExecutionException)1 Test (org.junit.Test)1