mil.dod.th.ose.gui.integration/src/mil/dod/th/ose/gui/integration/screenrecorder/ScreenRecorderExt.java
public void stopRecording(final String testName, final String className) throws InterruptedException, IOException
    {
        //Added second sleep so recordings don't end as abruptly making it hard to sometimes see the final state 
        //of a test.
        final int extendRecordingTimeMS = 1000;
        Thread.sleep(extendRecordingTimeMS);
        super.stop();
        if (testName != null && !testName.isEmpty() && className != null && !className.isEmpty())
        {
            final int lastIndex = super.getCreatedMovieFiles().size() - 1;
            final File movieFile = super.getCreatedMovieFiles().get(lastIndex);
            final File movieDir = new File(movieFile.getParent() + File.separator + className);
            final File renamedFile = new File(movieDir.getAbsolutePath(), testName + ".avi");

            RandomAccessFile randFile = null; 
            FileChannel channel = null;
            FileLock lock = null;
            try
            {
                //Retrieve the lock on the created screen capture file. This is needed to insure that the screen capture
                //software has finished writing to the file.
                randFile = new RandomAccessFile(movieFile, "rw");
                channel = randFile.getChannel();
                lock = channel.lock();
            }
            finally
            {
                //Release the lock on the file so that it can be renamed. Lock was needed or otherwise the old file 
                //might still remain as an empty file after being renamed since the screen capture may not have released
                //its lock on the file.
                if (lock != null)
                {
                    try
                    {
                        lock.release();
                    }
                    finally
                    {
                        if (randFile != null)
                        {
                            randFile.close();
                        }
                    }
                } 
            }
            
            //Check if the directory exists and create it if it does not.
            if (!movieDir.exists())
            {
                LOGGER.info(String.format("Directory with the name %s does not exist and will be created.", 
                        movieDir.getName()));
                movieDir.mkdir();
            }
            //File cannot be renamed if a file with the specified name already exists.
            if (renamedFile.exists())
            {
                LOGGER.info(String.format("Screen recording file with the name %s already exists and will be removed.", 
                        renamedFile.getName()));
                renamedFile.delete();
            }
            
            //Rename the file.
            movieFile.renameTo(renamedFile);
        }
    }
/**
     * Method that is responsible for stopping recording. Sets the name of the file the screen recorder was recording to
     * if one was set. Has to be done after the file is created because the default {@link ScreenRecorder} class does 
     * not allow for setting the file name. This method will check if the screen recording file already exists and 
     * delete it if it does.
     * 
     * @param testName
     *      Name of the test that was being recorded.
     * @param className
     *      Name of the class the test being recorded belonged to.
     * @throws InterruptedException
     *      Thrown if a current thread is interrupted during a thread.sleep().
     * @throws IOException
     *      Thrown if the screen recording cannot be renamed.
     */
Method that is responsible for stopping recording. Sets the name of the file the screen recorder was recording to
if one was set. Has to be done after the file is created because the default  ScreenRecorder class does
not allow for setting the file name. This method will check if the screen recording file already exists and
delete it if it does.

@param testName
Name of the test that was being recorded.
@param className
Name of the class the test being recorded belonged to.
@throws InterruptedException
Thrown if a current thread is interrupted during a thread.sleep().
@throws IOException
Thrown if the screen recording cannot be renamed.
Method that is responsible for stopping recording . Sets the name of the file the screen recorder was recording to if one was set . Has to be done after the file is created because the default ScreenRecorder class does not allow for setting the file name . This method will check if the screen recording file already exists and delete it if it does . @param testName Name of the test that was being recorded . @param className Name of the class the test being recorded belonged to . @throws InterruptedException Thrown if a current thread is interrupted during a thread . sleep () . @throws IOException Thrown if the screen recording cannot be renamed .
public void stopRecording(final String testName, final String className) throws InterruptedException, IOException
    {
        final int extendRecordingTimeMS = 1000;
        Thread.sleep(extendRecordingTimeMS);
        super.stop();
        if (testName != null && !testName.isEmpty() && className != null && !className.isEmpty())
        {
            final int lastIndex = super.getCreatedMovieFiles().size() - 1;
            final File movieFile = super.getCreatedMovieFiles().get(lastIndex);
            final File movieDir = new File(movieFile.getParent() + File.separator + className);
            final File renamedFile = new File(movieDir.getAbsolutePath(), testName + ".avi");
            RandomAccessFile randFile = null; 
            FileChannel channel = null;
            FileLock lock = null;
            try
            {
                randFile = new RandomAccessFile(movieFile, "rw");
                channel = randFile.getChannel();
                lock = channel.lock();
            }
            finally
            {
                if (lock != null)
                {
                    try
                    {
                        lock.release();
                    }
                    finally
                    {
                        if (randFile != null)
                        {
                            randFile.close();
                        }
                    }
                } 
            }
            if (!movieDir.exists())
            {
                LOGGER.info(String.format("Directory with the name %s does not exist and will be created.", 
                        movieDir.getName()));
                movieDir.mkdir();
            }
            if (renamedFile.exists())
            {
                LOGGER.info(String.format("Screen recording file with the name %s already exists and will be removed.", 
                        renamedFile.getName()));
                renamedFile.delete();
            }
            movieFile.renameTo(renamedFile);
        }
    }
public void stopRecording ( final String testName , final String className ) throws InterruptedException , IOException { final int extendRecordingTimeMS = 1000 ; Thread . sleep ( extendRecordingTimeMS ) ; super . stop ( ) ; if ( testName != null && ! testName . isEmpty ( ) && className != null && ! className . isEmpty ( ) ) { final int lastIndex = super . getCreatedMovieFiles ( ) . size ( ) - 1 ; final File movieFile = super . getCreatedMovieFiles ( ) . get ( lastIndex ) ; final File movieDir = new File ( movieFile . getParent ( ) + File . separator + className ) ; final File renamedFile = new File ( movieDir . getAbsolutePath ( ) , testName + ".avi" ) ; RandomAccessFile randFile = null ; FileChannel channel = null ; FileLock lock = null ; try { randFile = new RandomAccessFile ( movieFile , "rw" ) ; channel = randFile . getChannel ( ) ; lock = channel . lock ( ) ; } finally { if ( lock != null ) { try { lock . release ( ) ; } finally { if ( randFile != null ) { randFile . close ( ) ; } } } } if ( ! movieDir . exists ( ) ) { LOGGER . info ( String . format ( "Directory with the name %s does not exist and will be created." , movieDir . getName ( ) ) ) ; movieDir . mkdir ( ) ; } if ( renamedFile . exists ( ) ) { LOGGER . info ( String . format ( "Screen recording file with the name %s already exists and will be removed." , renamedFile . getName ( ) ) ) ; renamedFile . delete ( ) ; } movieFile . renameTo ( renamedFile ) ; } }
Method that is responsible for stopping recording.
Method that is responsible for stopping recording .
//Added second sleep so recordings don't end as abruptly making it hard to sometimes see the final state  //of a test. //Retrieve the lock on the created screen capture file. This is needed to insure that the screen capture //software has finished writing to the file. //Release the lock on the file so that it can be renamed. Lock was needed or otherwise the old file  //might still remain as an empty file after being renamed since the screen capture may not have released //its lock on the file. //Check if the directory exists and create it if it does not. //File cannot be renamed if a file with the specified name already exists. //Rename the file.