Package co.paralleluniverse.fibers.instrument

Source Code of co.paralleluniverse.fibers.instrument.Merge2Test$Interface

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package co.paralleluniverse.fibers.instrument;

import co.paralleluniverse.strands.SuspendableRunnable;
import co.paralleluniverse.common.util.Exceptions;
import co.paralleluniverse.fibers.Fiber;
import co.paralleluniverse.fibers.SuspendExecution;
import co.paralleluniverse.fibers.TestsHelper;
import co.paralleluniverse.strands.Strand;
import static org.junit.Assert.*;
import org.junit.BeforeClass;
import org.junit.Test;

/**
*
* @author mam
*/
public class Merge2Test implements SuspendableRunnable {
    @BeforeClass
    public static void setupClass() {
        Fiber.setDefaultUncaughtExceptionHandler(new Strand.UncaughtExceptionHandler() {

            @Override
            public void uncaughtException(Strand s, Throwable e) {
                Exceptions.rethrow(e);
            }
        });
    }
   
    public interface Interface {
        public void method();
    }

    public static Interface getInterface() {
        return null;
    }

    public static void suspendable() throws SuspendExecution {
    }

    @Override
    public void run() throws SuspendExecution {
        try {
            Interface iface = getInterface();
            iface.method();
        } catch(IllegalStateException ise) {
            suspendable();
        }
    }

    @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
        }
    }
}
TOP

Related Classes of co.paralleluniverse.fibers.instrument.Merge2Test$Interface

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.