use of junit.framework.TestResult in project android_frameworks_base by crdroidandroid.
the class InstrumentationTestSuiteBuilderTest method runSuite.
private SuiteExecutionRecorder runSuite(TestSuiteBuilder builder) {
TestSuite suite = builder.build();
SuiteExecutionRecorder recorder = new SuiteExecutionRecorder();
TestResult result = new TestResult();
result.addListener(recorder);
suite.run(result);
return recorder;
}
use of junit.framework.TestResult in project android_frameworks_base by crdroidandroid.
the class UnitTestSuiteBuilderTest method runSuite.
private SuiteExecutionRecorder runSuite(TestSuiteBuilder builder) {
TestSuite suite = builder.build();
SuiteExecutionRecorder recorder = new SuiteExecutionRecorder();
TestResult result = new TestResult();
result.addListener(recorder);
suite.run(result);
return recorder;
}
use of junit.framework.TestResult in project ofbiz-framework by apache.
the class TestRunContainer method start.
public boolean start() throws ContainerException {
boolean failedRun = false;
for (ModelTestSuite modelSuite : jsWrapper.getModelTestSuites()) {
// prepare
TestSuite suite = modelSuite.makeTestSuite();
JUnitTest test = new JUnitTest(suite.getName());
JunitXmlListener xml = createJunitXmlListener(suite, logDir);
TestResult results = new TestResult();
results.addListener(new JunitListener());
results.addListener(xml);
// test
xml.startTestSuite(test);
suite.run(results);
test.setCounts(results.runCount(), results.failureCount(), results.errorCount());
// rollback all entity operations
modelSuite.getDelegator().rollback();
xml.endTestSuite(test);
logTestSuiteResults(suite, results);
failedRun = !results.wasSuccessful() ? true : failedRun;
}
if (failedRun) {
throw new ContainerException("Test run was unsuccessful");
}
return true;
}
use of junit.framework.TestResult in project narayana by jbosstm.
the class TestServlet method doPost.
/**
* Execute the test
* @param request The HTTP servlet request.
* @param response The HTTP servlet response.
*/
protected void doPost(final HttpServletRequest request, final HttpServletResponse response) throws ServletException, IOException {
final String serviceURI = request.getParameter(TestConstants.PARAM_SERVICE_URI);
final String test = request.getParameter(TestConstants.PARAM_TEST);
final String testTimeoutValue = request.getParameter(TestConstants.PARAM_TEST_TIMEOUT);
// final String asyncTestValue = request.getParameter(TestConstants.PARAM_ASYNC_TEST) ;
String resultPageAddress = request.getParameter(TestConstants.PARAM_RESULT_PAGE);
if (resultPageAddress == null || resultPageAddress.length() == 0) {
resultPageAddress = TestConstants.DEFAULT_RESULT_PAGE_ADDRESS;
}
final int serviceURILength = (serviceURI == null ? 0 : serviceURI.length());
final int testLength = (test == null ? 0 : test.length());
long testTimeout = 0;
boolean testTimeoutValid = false;
if ((testTimeoutValue != null) && (testTimeoutValue.length() > 0)) {
try {
testTimeout = Long.parseLong(testTimeoutValue);
testTimeoutValid = true;
}// ignore
catch (final NumberFormatException nfe) {
}
}
// final boolean asyncTest = (asyncTestValue != null) ;
final boolean asyncTest = true;
if ((serviceURILength == 0) || (testLength == 0) || !testTimeoutValid) {
final RequestDispatcher dispatcher = getServletContext().getRequestDispatcher("/invalidParameters.html");
dispatcher.forward(request, response);
return;
}
final HttpSession session = request.getSession();
final String id = session.getId();
final int logCount = getLogCount(session);
final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss");
final String date = format.format(new Date());
final String logName = date + "-" + id + "-" + logCount;
session.setAttribute(TestConstants.ATTRIBUTE_TEST_RESULT, null);
session.setAttribute(TestConstants.ATTRIBUTE_TEST_VALIDATION, null);
session.setAttribute(TestConstants.ATTRIBUTE_LOG_NAME, null);
final String threadLog;
try {
final TestResult result = TestRunner.execute(serviceURI, testTimeout, asyncTest, test);
if (result != null) {
session.setAttribute(TestConstants.ATTRIBUTE_TEST_RESULT, result);
threadLog = MessageLogging.getThreadLog();
try {
TestLogController.writeLog(logName, threadLog);
session.setAttribute(TestConstants.ATTRIBUTE_LOG_NAME, logName);
} catch (final IOException ioe) {
log("Unexpected IOException writing message log", ioe);
}
} else {
threadLog = null;
}
} finally {
MessageLogging.clearThreadLog();
}
if ((threadLog != null) && (threadLog.length() > 0)) {
try {
final String testValidation = transform(threadLog);
session.setAttribute(TestConstants.ATTRIBUTE_TEST_VALIDATION, testValidation);
} catch (final Throwable th) {
log("Unexpected throwable transforming message log", th);
}
}
final RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(resultPageAddress);
dispatcher.forward(request, response);
}
use of junit.framework.TestResult in project narayana by jbosstm.
the class TestRunner method execute.
/**
* Execute the specific test against the specified participant.
* @param participantURI The URI of the participant.
* @param testTimeout The test timeout.
* @param asyncTest The asynchronous test flag.
* @param testName The name of the test to execute.
* @return The test result.
*/
public static TestResult execute(final String participantURI, final long testTimeout, final boolean asyncTest, final String testName) {
MessageLogging.clearThreadLog();
final Test test;
if (TestConstants.NAME_ALL_TESTS.equals(testName)) {
final TestSuite testSuite = new TestSuite();
testSuite.addTest(new InteropTestSuite(participantURI, testTimeout, asyncTest, SC007_TEST_CLASS));
test = testSuite;
} else if (testName.startsWith(TestConstants.PREFIX_TESTS)) {
final Class testClass = SC007_TEST_CLASS;
try {
test = createTest(testClass, participantURI, testTimeout, asyncTest, testName);
} catch (final Throwable th) {
System.err.println("Unexpected error instantiating test class: " + th);
return null;
}
} else {
System.err.println("Unidentified test name: " + testName);
return null;
}
MessageLogging.appendThreadLog(LOG_MESSAGE_PREFIX);
final TestResult testResult = new FullTestResult();
test.run(testResult);
MessageLogging.appendThreadLog(LOG_MESSAGE_SUFFIX);
return testResult;
}
Aggregations