Search in sources :

Example 1 with ManagedTestCase

use of org.apache.axis2.transport.testkit.tests.ManagedTestCase 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)

Example 2 with ManagedTestCase

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

the class ManagedTestSuite method addTest.

@Override
public void addTest(Test test) {
    if (test instanceof ManagedTestCase) {
        ManagedTestCase ttest = (ManagedTestCase) test;
        Map<String, String> map = ttest.getNameComponents();
        boolean excluded = false;
        for (FilterExpression exclude : excludes) {
            if (exclude.matches(map)) {
                excluded = true;
                break;
            }
        }
        if (excluded != invertExcludes) {
            return;
        }
        ttest.init(StringUtils.leftPad(String.valueOf(nextId++), 4, '0'), reuseResources, testClass);
        ttest.getResourceSet().resolve();
    }
    super.addTest(test);
}
Also used : ManagedTestCase(org.apache.axis2.transport.testkit.tests.ManagedTestCase) FilterExpression(org.apache.axis2.transport.testkit.filter.FilterExpression)

Aggregations

ManagedTestCase (org.apache.axis2.transport.testkit.tests.ManagedTestCase)2 Test (junit.framework.Test)1 FilterExpression (org.apache.axis2.transport.testkit.filter.FilterExpression)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