"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,