Example usage for junit.framework Protectable Protectable

List of usage examples for junit.framework Protectable Protectable

Introduction

In this page you can find the example usage for junit.framework Protectable Protectable.

Prototype

Protectable

Source Link

Usage

From source file:org.eclipse.gemini.blueprint.test.AbstractOsgiTests.java

/**
 * {@inheritDoc}/*from  w  w w. j ava  2 s. c om*/
 * 
 * <p/> Replacement run method. Gets a hold of the TestRunner used for running this test so it can populate it with
 * the results retrieved from OSGi.
 */
public final void run(TestResult result) {

    // get a hold of the test result
    originalResult = result;

    result.startTest(osgiJUnitTest);
    result.runProtected(osgiJUnitTest, new Protectable() {

        public void protect() throws Throwable {
            AbstractOsgiTests.this.runBare();
        }
    });
    result.endTest(osgiJUnitTest);

    // super.run(result);
}

From source file:org.eclipse.gemini.blueprint.test.internal.support.OsgiJUnitService.java

/**
 * Run fixture setup, test from the given test case and fixture teardown.
 * //w w  w  .  ja  v a2  s .c om
 * @param osgiTestExtensions
 * @param testName
 */
protected TestResult runTest(final OsgiJUnitTest osgiTestExtensions, String testName) {
    if (log.isDebugEnabled())
        log.debug("Running test [" + testName + "] on testCase " + osgiTestExtensions);
    final TestResult result = new TestResult();
    TestCase rawTest = osgiTestExtensions.getTestCase();

    rawTest.setName(testName);

    try {
        osgiTestExtensions.osgiSetUp();

        try {
            // use TestResult method to bypass the setUp/tearDown methods
            result.runProtected(rawTest, new Protectable() {

                public void protect() throws Throwable {
                    osgiTestExtensions.osgiRunTest();
                }

            });
        } finally {
            osgiTestExtensions.osgiTearDown();
        }

    }
    // exceptions thrown by osgiSetUp/osgiTearDown
    catch (Exception ex) {
        log.error("test exception threw exception ", ex);
        result.addError((Test) rawTest, ex);
    }
    return result;
}