Search in sources :

Example 1 with DefaultExceptionHandler

use of com.ctrip.xpipe.exception.DefaultExceptionHandler in project x-pipe by ctripcorp.

the class AbstractTest method beforeAbstractTest.

@Before
public void beforeAbstractTest() throws Exception {
    ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.PARANOID);
    // clear interrupt
    Thread.interrupted();
    executors = Executors.newCachedThreadPool(XpipeThreadFactory.create(getTestName()));
    scheduled = Executors.newScheduledThreadPool(OsUtils.getCpuCount(), XpipeThreadFactory.create(getTestName()));
    orginProperties = (Properties) System.getProperties().clone();
    doBeforeAbstractTest();
    logger.info(remarkableMessage("[begin test][{}]"), name.getMethodName());
    componentRegistry = new DefaultRegistry(new CreatedComponentRedistry(), getSpringRegistry());
    startedComponentRegistry = new CreatedComponentRedistry();
    startedComponentRegistry.initialize();
    startedComponentRegistry.start();
    Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());
    InputStream fins = getClass().getClassLoader().getResourceAsStream("xpipe-test.properties");
    try {
        properties.load(fins);
    } finally {
        if (fins != null) {
            fins.close();
        }
    }
    File file = new File(getTestFileDir());
    if (file.exists() && deleteTestDirBeforeTest()) {
        deleteTestDir();
    }
    if (!file.exists()) {
        boolean testSucceed = file.mkdirs();
        if (!testSucceed) {
            throw new IllegalStateException("test dir make failed!" + file);
        }
    }
}
Also used : CreatedComponentRedistry(com.ctrip.xpipe.lifecycle.CreatedComponentRedistry) DefaultRegistry(com.ctrip.xpipe.lifecycle.DefaultRegistry) DefaultExceptionHandler(com.ctrip.xpipe.exception.DefaultExceptionHandler)

Aggregations

DefaultExceptionHandler (com.ctrip.xpipe.exception.DefaultExceptionHandler)1 CreatedComponentRedistry (com.ctrip.xpipe.lifecycle.CreatedComponentRedistry)1 DefaultRegistry (com.ctrip.xpipe.lifecycle.DefaultRegistry)1