Package jp.vmi.selenium.selenese.utils

Examples of jp.vmi.selenium.selenese.utils.LogRecorder$LogMessage


        ITestCase[] testCases = new ITestCase[4];
        for (int i = 0; i < testCases.length; i++) {
            final int num = i;
            testCases[i] = new ITestCase() {
                private final StopWatch stopWatch = new StopWatch();
                private final LogRecorder logRecorder = new LogRecorder(System.out);

                @Override
                public String getBaseName() {
                    return getName();
                }

                @Override
                public String getName() {
                    return "test-case" + num;
                }

                @Override
                public boolean isError() {
                    return false;
                }

                @Override
                public StopWatch getStopWatch() {
                    return stopWatch;
                }

                @Override
                public void setLogRecorder(LogRecorder logRecorder) {
                    throw new UnsupportedOperationException();
                }

                @Override
                public LogRecorder getLogRecorder() {
                    return logRecorder;
                }
            };
        }
        jur.startTestSuite(testSuite);
        jur.addProperty(testSuite, "prop-name1", "prop-value1");
        jur.addProperty(testSuite, "prop-name2", "prop-value2");
        jur.addProperty(testSuite, "prop-name3", "prop-value3");
        ITestCase tc;
        StopWatch sw;
        LogRecorder clr;
        tc = testCases[0];
        sw = tc.getStopWatch();
        clr = tc.getLogRecorder();
        jur.startTestCase(testSuite, tc);
        testSuite.getStopWatch().start();
        sw.start();
        jur.setSuccess(tc);
        clr.info("systemOut00");
        clr.error("systemErr00");
        clr.info("systemOut01");
        clr.error("systemErr01");
        clr.info("systemOut02");
        clr.error("systemErr02");
        Thread.sleep(100);
        sw.end();
        jur.endTestCase(tc);
        tc = testCases[1];
        sw = tc.getStopWatch();
        clr = tc.getLogRecorder();
        jur.startTestCase(testSuite, tc);
        sw.start();
        jur.setError(tc, "detail1", "trace1");
        clr.info("systemOut1");
        clr.error("systemErr1");
        Thread.sleep(50);
        sw.end();
        jur.endTestCase(tc);
        tc = testCases[2];
        sw = tc.getStopWatch();
        clr = tc.getLogRecorder();
        jur.startTestCase(testSuite, tc);
        sw.start();
        jur.setFailure(tc, "detail2", "trace2");
        clr.info("systemOut2");
        clr.error("systemErr2");
        Thread.sleep(10);
        sw.end();
        jur.endTestCase(tc);
        tc = testCases[3];
        sw = tc.getStopWatch();
View Full Code Here


        Context context = (Context) invocation.getArguments()[CONTEXT];
        testSuite.setWebDriverName(context.getWrappedDriver().getClass().getSimpleName());
        JUnitResult jUnitResult = (context instanceof JUnitResultHolder) ? ((JUnitResultHolder) context).getJUnitResult() : null;
        HtmlResult htmlResult = (context instanceof HtmlResultHolder) ? ((HtmlResultHolder) context).getHtmlResult() : null;
        StopWatch sw = testSuite.getStopWatch();
        LogRecorder slr = new LogRecorder(context.getPrintStream());
        sw.start();
        if (!testSuite.isError()) {
            String msg = "Start: " + testSuite;
            log.info(msg);
            slr.info(msg);
        }
        initTestSuiteResult(jUnitResult, testSuite);
        try {
            return invocation.proceed();
        } catch (Throwable t) {
            String msg = t.getMessage();
            log.error(msg);
            slr.error(msg);
            throw t;
        } finally {
            if (!testSuite.isError()) {
                String msg = "End(" + sw.getDurationString() + "): " + testSuite;
                log.info(msg);
                slr.info(msg);
            }
            sw.end();
            if (jUnitResult != null)
                jUnitResult.endTestSuite(testSuite);
            if (htmlResult != null)
View Full Code Here

    public Object invoke(MethodInvocation invocation) throws Throwable {
        LogIndentLevelHolder holder = (LogIndentLevelHolder) invocation.getThis();
        Object[] args = invocation.getArguments();
        Context context = (Context) args[CONTEXT];
        ICommand command = (ICommand) args[COMMAND];
        LogRecorder clr = context.getCurrentTestCase().getLogRecorder();
        String indent = StringUtils.repeat("  ", holder.getLogIndentLevel());
        String cmdStr = command.toString();
        log.info(indent + cmdStr);
        clr.info(indent + cmdStr);
        try {
            Result result = (Result) invocation.proceed();
            logResult(clr, indent, cmdStr, result, context);
            return result;
        } catch (Exception e) {
            String msg = cmdStr + " => " + e.getMessage();
            log.error(indent + msg);
            clr.error(indent + msg);
            if (context instanceof JUnitResultHolder)
                ((JUnitResultHolder) context).getJUnitResult().setError(context.getCurrentTestCase(), e.getMessage(), e.toString());
            throw e;
        }
    }
View Full Code Here

            jUnitResult.startTestCase((ITestSuite) args[PARENT], testCase);
        } else {
            jUnitResult = null;
        }
        StopWatch sw = testCase.getStopWatch();
        LogRecorder clr = new LogRecorder(context.getPrintStream());
        testCase.setLogRecorder(clr);
        sw.start();
        if (!testCase.isError()) {
            log.info("Start: {}", testCase);
            clr.info("Start: " + testCase);
        }
        if (testCase instanceof TestCase) {
            String baseURL = StringUtils.defaultString(context.getOverridingBaseURL(), ((TestCase) testCase).getBaseURL());
            log.info("baseURL: {}", baseURL);
            clr.info("baseURL: " + baseURL);
        }
        try {
            Result result = (Result) invocation.proceed();
            if (jUnitResult != null) {
                if (result.isSuccess())
                    jUnitResult.setSuccess(testCase);
                else
                    jUnitResult.setFailure(testCase, result.getMessage(), null);
            }
            return result;
        } catch (Throwable t) {
            String msg = t.getMessage();
            log.error(msg);
            clr.error(msg);
            if (jUnitResult != null)
                jUnitResult.setError(testCase, msg, t.toString());
            throw t;
        } finally {
            sw.end();
            if (!testCase.isError()) {
                String msg = "End(" + sw.getDurationString() + "): " + testCase;
                log.info(msg);
                clr.info(msg);
            }
            if (jUnitResult != null)
                jUnitResult.endTestCase(testCase);
        }
    }
View Full Code Here

TOP

Related Classes of jp.vmi.selenium.selenese.utils.LogRecorder$LogMessage

Copyright © 2018 www.massapicom. 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.