Examples of ITestThread


Examples of net.sf.jdistunit.platform.action.ITestThread

        final List<ITestThread> testList = new ArrayList<ITestThread>(requestCount);
        this.resultList = new ArrayList<ITestActionResult>(requestCount);

        // Create parallel requests.
        for (int cnt = 0; cnt < requestCount; cnt++) {
            ITestThread thread = new TestThread(cnt, action);
            testList.add(thread);
        }

        // Start parallel requests.
        // If so dictated, sleep a little between starts.
        for (ITestThread thread : testList) {
            if (0 != threadTimeStep) {
                OS.sleep(threadTimeStep);
            }
            thread.getThread().start();
        }

        // Wait until all tests are finished or timeout has come.
        long timePassed = 0;
        boolean isThreadsDone = false;
        while (!isThreadsDone && timePassed < getTimeOut()) {
            logStatus("Waiting on " + getMarketPlace().getHomeId() + " for tests to finish (" + (timePassed / JDistUnitConstants.WAIT_ONE_CYCLE) + ")");

            // Sleep the next cycle.
            OS.sleep(JDistUnitConstants.WAIT_ONE_CYCLE);
            timePassed += JDistUnitConstants.WAIT_ONE_CYCLE;

            // Take results out.
            retrievePendingResults(testList);

            // Set break flag if all threads have finished.
            isThreadsDone = isTestThreadsDone(testList);
        }

        // If not all threads finished successfully, stop all remaining
        // test threads -- they are timed out, and may die peacefully.
        if (!isThreadsDone) {
            for (ITestThread thread : testList) {
                thread.stopAction();
            }
        }
    }
View Full Code Here

Examples of net.sf.jdistunit.platform.action.ITestThread

     *
     * @param testList The list of test threads.
     */
    private void retrievePendingResults(List<ITestThread> testList) {
        for (int pos = testList.size() - 1; pos >= 0; pos--) {
            final ITestThread thread = testList.get(pos);
            final ITestActionResult result = thread.getActionResult();
            if (null == result) {
                continue;
            }

            // If finished, add result, and remove thread.
View Full Code Here

Examples of net.sf.jdistunit.platform.action.ITestThread

    public void testWholePageRead() throws Exception {
        // Instantiate ITestAction.
        TestActionTest.ExampleTestAction action = new TestActionTest.ExampleTestAction();

        // Start thread.
        ITestThread thread = new TestThread(0, action);
        thread.getThread().start();
        OS.sleep(200);

        // Sleep to wait until the request has been carried out.
        long sleepTime = 0;
        while (sleepTime < 5000 && null == thread.getActionResult()) {
            OS.sleep(200);
            sleepTime += 200;
        }

        // Get the action result.
        ITestActionResult result = thread.getActionResult();
        assertNotNull(result);

        // Check for errors.
        Throwable exc = result.getActionError();
        if (null != exc) {
            exc.printStackTrace();
        }

        // Check if the thread finished successfully.
        assertFalse(thread.isActionStopped());
        assertEquals(TestActionStatus.FINISHED, result.getActionStatus());

        // Check that the page was read.
        assertTrue(action.page.length() > 0);
        assertTrue(-1 != action.page.indexOf("JDistUnit"));
View Full Code Here

Examples of net.sf.jdistunit.platform.action.ITestThread

        // Instantiate ITestAction.
        TestActionTest.ExampleTestAction action = new TestActionTest.ExampleTestAction();
        action.lineDelay = 100;

        // Start thread.
        ITestThread thread = new TestThread(0, action);
        thread.getThread().start();
        OS.sleep(200);

        // Sleep 1 second; this should be enough to read 10 lines.
        // Then stop the action.
        OS.sleep(1000);
        thread.stopAction();
        assertTrue(thread.isActionStopped());

        // Get the action result.
        ITestActionResult result = thread.getActionResult();
        assertNotNull(result);

        // Check for errors.
        Throwable exc = result.getActionError();
        if (null != exc) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.