Search in sources :

Example 91 with Fiber

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

the class InstrumentationOptimizerTest method testDontSkipForwardsWithTryCatch.

@Test
public void testDontSkipForwardsWithTryCatch() throws InterruptedException, SuspendExecution, ExecutionException {
    new Fiber(new SuspendableRunnable() {

        @Override
        public void run() throws SuspendExecution, InterruptedException {
            dontSkipForwardsWithTryCatch();
        }
    }).start().join();
    assertFalse(isOptimized("skipForwardsWithTryCatch"));
}
Also used : SuspendExecution(co.paralleluniverse.fibers.SuspendExecution) SuspendableRunnable(co.paralleluniverse.strands.SuspendableRunnable) Fiber(co.paralleluniverse.fibers.Fiber) Test(org.junit.Test)

Example 92 with Fiber

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

the class Merge2Test method testMerge2.

@Test
public void testMerge2() {
    try {
        Fiber c = new Fiber((String) null, null, new Merge2Test());
        TestsHelper.exec(c);
        assertTrue("Should not reach here", false);
    } catch (NullPointerException ex) {
    // NPE expected
    }
}
Also used : Fiber(co.paralleluniverse.fibers.Fiber) Test(org.junit.Test)

Example 93 with Fiber

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

the class MergeTest method testMerge.

@Test
public void testMerge() {
    Fiber c = new Fiber((String) null, null, new MergeTest());
    TestsHelper.exec(c);
}
Also used : Fiber(co.paralleluniverse.fibers.Fiber) Test(org.junit.Test)

Example 94 with Fiber

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

the class NullTest method testNull.

@Test
public void testNull() {
    Fiber co = new Fiber((String) null, null, this);
    int count = 1;
    while (!TestsHelper.exec(co)) count++;
    assertEquals(2, count);
    assertEquals("a", result);
}
Also used : Fiber(co.paralleluniverse.fibers.Fiber) Test(org.junit.Test)

Example 95 with Fiber

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

the class SuspendableAnnotationTest method testAnnotated.

@Test
public void testAnnotated() {
    try {
        Fiber co = new Fiber((String) null, null, (SuspendableCallable) null) {

            @Override
            protected Object run() throws SuspendExecution, InterruptedException {
                suspendableMethod();
                return null;
            }
        };
        exec(co);
        exec(co);
        exec(co);
    } finally {
        System.out.println(results);
    }
    assertEquals(3, results.size());
    assertEquals(Arrays.asList("A", "B", "C"), results);
}
Also used : Fiber(co.paralleluniverse.fibers.Fiber) Test(org.junit.Test)

Aggregations

Fiber (co.paralleluniverse.fibers.Fiber)105 Test (org.junit.Test)88 SuspendableRunnable (co.paralleluniverse.strands.SuspendableRunnable)73 SuspendExecution (co.paralleluniverse.fibers.SuspendExecution)20 Strand (co.paralleluniverse.strands.Strand)8 IntChannel (co.paralleluniverse.strands.channels.IntChannel)4 QueueCapacityExceededException (co.paralleluniverse.strands.queues.QueueCapacityExceededException)4 ExecutionException (java.util.concurrent.ExecutionException)3 Ignore (org.junit.Ignore)3 Timeout (co.paralleluniverse.strands.Timeout)2 Channel (co.paralleluniverse.strands.channels.Channel)2 ReceivePort (co.paralleluniverse.strands.channels.ReceivePort)2 TimeoutException (java.util.concurrent.TimeoutException)2 ActorRef (co.paralleluniverse.actors.ActorRef)1 AbstractServerHandler (co.paralleluniverse.actors.behaviors.AbstractServerHandler)1 ServerActor (co.paralleluniverse.actors.behaviors.ServerActor)1 Function2 (co.paralleluniverse.common.util.Function2)1 Pair (co.paralleluniverse.common.util.Pair)1 FiberScheduler (co.paralleluniverse.fibers.FiberScheduler)1 FiberWriter (co.paralleluniverse.fibers.FiberWriter)1