Examples of PlaybackSession


Examples of org.apache.beehive.netui.tools.testrecorder.server.state.PlaybackSession

        String testId = request.getParameter( Constants.TEST_ID_HEADER );
        if ( log.isInfoEnabled() ) {
            log.info( "playback stop testId( " + testId + " )" );
        }
        TestRecorderFilter filter = TestRecorderFilter.instance();
        PlaybackSession session = null;
        try {
            // this may take some time, this waits for recording threads to finish
            // may throw IOException
            session = filter.getState().playbackStop( testId );
        }
        catch ( Exception ex ) {
            String msg = "ERROR: unable to stop playback session for testId( " + testId + " ), exception( " +
                    ex.getMessage() + " )";
            request.setAttribute( Constants.MSG_ATTRIBUTE, msg );
            response.setHeader( Constants.OUTCOME_HEADER, Constants.ERROR );
            log.error( msg, ex );
            if ( ex instanceof IOException ) {
                throw (IOException) ex;
            }
            else if ( ex instanceof RuntimeException ) {
                throw (RuntimeException) ex;
            }
            else {
                throw new RuntimeException( msg, ex );
            }
        }
        if ( log.isInfoEnabled() ) {
            log.info( "STOP: playback session( " + session + " )" );
        }
        if ( session == null ) {
            // fail, not currently doing playback
            String msg = "ERROR: no playback session exists for testId( " + testId + " )";
            request.setAttribute( Constants.MSG_ATTRIBUTE, msg );
            // set response headers for the client.
            response.setHeader( Constants.OUTCOME_HEADER, Constants.ERROR );
            response.setHeader( Constants.MSG_ATTRIBUTE, msg );
            log.error( msg );
        }
        else {
            // gen playback summary
            // set outcome to stop or fail via resp header
            // return playback summary as response body.
            String outcome = session.getStatus();
            String msg = "playback session( " + session.getSessionName() + " ) stopped with status( " + outcome +
                    " ).";
            request.setAttribute( Constants.MSG_ATTRIBUTE, msg );
            request.setAttribute( Constants.PLAYBACK_SESSION_ATTRIBUTE, session );
            if ( log.isInfoEnabled() ) {
                log.info( msg );
            }
            // set response headers for the client.
            response.setHeader( Constants.OUTCOME_HEADER, outcome );
            response.setHeader( Constants.MSG_ATTRIBUTE, msg );
            response.setHeader( Constants.RESULTS_FILE_HEADER, session.getPlaybackFile().getAbsolutePath() );
            File diffFile = session.getDiffFile();
            if ( diffFile != null ) {
                response.setHeader( Constants.RESULTS_DIFF_HEADER, diffFile.getAbsolutePath() );
            }
        }
    }
View Full Code Here

Examples of org.apache.beehive.netui.tools.testrecorder.server.state.PlaybackSession

                    "ERROR: playback start failed, unable to find a test for test name( " + testName + " )" );
        }
        if ( log.isInfoEnabled() ) {
            log.info( "playback start test( " + test.getName() + " )" );
        }
        PlaybackSession session = null;
        try {
            session = getPlaybackSession( test );
        }
        catch ( Exception ex ) {
            String msg = "ERROR: unable to start playback, unable to obtain session, exception( " +
                    ex.getMessage() + " )";
            request.setAttribute( Constants.MSG_ATTRIBUTE, msg );
            log.error( msg, ex );
            System.err.println( "\nPLAYBACK ERROR:\n" + msg );
            if ( ex instanceof IOException ) {
                throw (IOException) ex;
            }
            else if ( ex instanceof RuntimeException ) {
                throw (RuntimeException) ex;
            }
            else {
                throw new RuntimeException( msg, ex );
            }
        }
        TestRecorderFilter filter = TestRecorderFilter.instance();
        boolean start = false;
        try {
            // may throw IOException
            start = filter.getState().playbackStart( session );
        }
        catch ( Exception ex ) {
            String msg = "ERROR: failed to start playback session( " + session + " ), exception( " +
                    ex.getMessage() + " )";
            request.setAttribute( Constants.MSG_ATTRIBUTE, msg );
            log.error( msg, ex );
            System.err.println( "\nPLAYBACK ERROR:\n" + msg );
            if ( ex instanceof IOException ) {
                throw (IOException) ex;
            }
            else if ( ex instanceof RuntimeException ) {
                throw (RuntimeException) ex;
            }
            else {
                throw new RuntimeException( msg, ex );
            }
        }
        if ( log.isInfoEnabled() ) {
            log.info( "playback start( " + start + " )" );
        }
        if ( start ) {
            String msg = "playback session( " +
                    session.getSessionName() + " ) started.";
            request.setAttribute( Constants.MSG_ATTRIBUTE, msg );
            request.setAttribute( Constants.PLAYBACK_SESSION_ATTRIBUTE, session );
            if ( log.isInfoEnabled() ) {
                log.info( msg );
            }
            // set response headers for the client.
            response.setHeader( Constants.OUTCOME_HEADER,
                    Constants.PASS );
            response.setHeader( Constants.TEST_ID_HEADER,
                    session.getStringUID() );
            response.setHeader( Constants.RECORD_FILE_HEADER,
                    session.getRecordFile().getAbsolutePath() );
        }
        else {
            // fail
            String msg = "ERROR: failed to start playback session( " +
                    session.getSessionName() + " )";
            request.setAttribute( Constants.MSG_ATTRIBUTE, msg );
            request.setAttribute( Constants.PLAYBACK_SESSION_ATTRIBUTE, session );
            log.error( msg );
            // set response headers for the client.
            response.setHeader( Constants.OUTCOME_HEADER,
View Full Code Here

Examples of org.apache.beehive.netui.tools.testrecorder.server.state.PlaybackSession

        }
        // may throw IOException or SecurityException (runtime)
        File diffFile = getDiffFile( test );
        File recordFile = getTestFile( test );
        // may throw IOException or SecurityException (runtime)
        PlaybackSession session = State.createPlaybackSession( test.getName(), playbackFile,
                recordFile, diffFile );
        return session;
    }
View Full Code Here

Examples of org.apache.beehive.netui.tools.testrecorder.server.state.PlaybackSession

            // playback ...
            if ( log.isDebugEnabled() ) {
                log.debug( "filter data( " + data + " )" );
            }
            if ( data.isNewRequest() ) {
                PlaybackSession session = getState().getPlaybackSession( data.getTestId() );
                if ( session == null ) {
                    String msg = "ERROR: no playback session found for test id( " + data.getTestId() + " )";
                    log.error( msg );
                    throw new SessionFailedException( msg );
                }
                data.setPlaybackSession( session );
                if ( data.isTestException() ) {
                    if ( log.isDebugEnabled() ) {
                        log.debug( "skipping playback start, isTestException(" + data.isTestException() + ")" );
                    }
                }
                else {
                    boolean started = session.startTest();
                    // may throw SessionFailedException
                    if ( !started ) {
                        throw new SessionFailedException( "Playback session failed to start, session( " +
                                session.getSessionName() + " )" );
                    }
                }
            }
            else {
                // this is a forward ... do nothing
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.