Search in sources :

Example 1 with TestResourceSetTransition

use of org.apache.axis2.transport.testkit.tests.TestResourceSetTransition in project wso2-axis2-transports by wso2.

the class ManagedTestSuite method run.

@Override
public void run(TestResult result) {
    LogManager logManager = LogManager.INSTANCE;
    if (!reuseResources) {
        super.run(result);
    } else {
        TestResourceSet resourceSet = null;
        for (Enumeration<?> e = tests(); e.hasMoreElements(); ) {
            Test test = (Test) e.nextElement();
            if (test instanceof ManagedTestCase) {
                ManagedTestCase ttest = (ManagedTestCase) test;
                TestResourceSet newResourceSet = ttest.getResourceSet();
                try {
                    if (resourceSet == null) {
                        logManager.setTestCase(ttest);
                        newResourceSet.setUp();
                    } else {
                        TestResourceSetTransition transition = new TestResourceSetTransition(resourceSet, newResourceSet);
                        transition.tearDown();
                        logManager.setTestCase(ttest);
                        transition.setUp();
                    }
                } catch (Throwable t) {
                    result.addError(this, t);
                    return;
                }
                resourceSet = newResourceSet;
            }
            runTest(test, result);
        }
        if (resourceSet != null) {
            try {
                resourceSet.tearDown();
                logManager.setTestCase(null);
            } catch (Throwable t) {
                result.addError(this, t);
                return;
            }
        }
    }
}
Also used : ManagedTestCase(org.apache.axis2.transport.testkit.tests.ManagedTestCase) Test(junit.framework.Test) TestResourceSet(org.apache.axis2.transport.testkit.tests.TestResourceSet) TestResourceSetTransition(org.apache.axis2.transport.testkit.tests.TestResourceSetTransition) LogManager(org.apache.axis2.transport.testkit.util.LogManager)

Aggregations

Test (junit.framework.Test)1 ManagedTestCase (org.apache.axis2.transport.testkit.tests.ManagedTestCase)1 TestResourceSet (org.apache.axis2.transport.testkit.tests.TestResourceSet)1 TestResourceSetTransition (org.apache.axis2.transport.testkit.tests.TestResourceSetTransition)1 LogManager (org.apache.axis2.transport.testkit.util.LogManager)1