edu.rice.cs.drjava.model.cache
Class DocumentCacheTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by edu.rice.cs.drjava.DrJavaTestCase
              extended by edu.rice.cs.drjava.model.cache.DocumentCacheTest
All Implemented Interfaces:
Test

public class DocumentCacheTest
extends DrJavaTestCase

This used to extend GlobalModelTestCase, but now it extends just TestCase. Perhaps it should be changed back.


Field Summary
protected  File _tempDir
           
 
Fields inherited from class edu.rice.cs.drjava.DrJavaTestCase
TEST_DRJAVA_CONFIG_PROPERTY
 
Constructor Summary
DocumentCacheTest()
           
 
Method Summary
protected  void createModel()
          Instantiates the GlobalModel to be used in the test cases.
protected  OpenDefinitionsDocument openFile(File f)
           
 void setUp()
          Set up for every test.
 void tearDown()
          Clean up for every test case.
protected  File tempFile()
          Create a new temporary file in _tempDir.
protected  File tempFile(int i)
          Create a new temporary file in _tempDir.
 void testCacheSize()
          A good warmup test case.
 void testGetDDocFromCache()
           
 void testMemoryLeak()
          There used to be a memory leak where various listeners, LeafElements, and other extraneous references from the model, definitions pane, and main frame would be preventing the definitions panes/documents from being GC'd at the correct times causing the entire program to run out of heap space when working with large numbers of files.
 void testNewDocumentsInAndOutOfTheCache()
           
 void testNoDDocInCache()
           
 void testNumListeners()
           
 void testOldDocumentsInAndOutOfTheCache()
           
 
Methods inherited from class edu.rice.cs.drjava.DrJavaTestCase
setConfigSetting, setDocText
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_tempDir

protected File _tempDir
Constructor Detail

DocumentCacheTest

public DocumentCacheTest()
Method Detail

setUp

public void setUp()
           throws Exception
Description copied from class: DrJavaTestCase
Set up for every test.

Overrides:
setUp in class DrJavaTestCase
Throws:
Exception - This convention is mandated by JUnit.TestCase, the superclass of this class.

tearDown

public void tearDown()
              throws Exception
Description copied from class: DrJavaTestCase
Clean up for every test case. Only used in unit tests. Added because Windows would intermittently throw a java.util.concurrent.RejectedExecutionException during cleanup.

Overrides:
tearDown in class DrJavaTestCase
Throws:
Exception

createModel

protected void createModel()
Instantiates the GlobalModel to be used in the test cases.


tempFile

protected File tempFile()
                 throws IOException
Create a new temporary file in _tempDir.

Throws:
IOException

tempFile

protected File tempFile(int i)
                 throws IOException
Create a new temporary file in _tempDir. Calls with the same int will return the same filename, while calls with different ints will return different filenames.

Throws:
IOException

openFile

protected OpenDefinitionsDocument openFile(File f)
                                    throws IOException
Throws:
IOException

testCacheSize

public void testCacheSize()
A good warmup test case.


testNewDocumentsInAndOutOfTheCache

public void testNewDocumentsInAndOutOfTheCache()
                                        throws BadLocationException,
                                               IOException
Throws:
BadLocationException
IOException

testOldDocumentsInAndOutOfTheCache

public void testOldDocumentsInAndOutOfTheCache()
                                        throws BadLocationException,
                                               IOException
Throws:
BadLocationException
IOException

testGetDDocFromCache

public void testGetDDocFromCache()
                          throws BadLocationException,
                                 IOException,
                                 OperationCanceledException
Throws:
BadLocationException
IOException
OperationCanceledException

testNoDDocInCache

public void testNoDDocInCache()

testNumListeners

public void testNumListeners()

testMemoryLeak

public void testMemoryLeak()
                    throws InterruptedException,
                           IOException
There used to be a memory leak where various listeners, LeafElements, and other extraneous references from the model, definitions pane, and main frame would be preventing the definitions panes/documents from being GC'd at the correct times causing the entire program to run out of heap space when working with large numbers of files. This problem was agrivated when we added project facility and implemented the document cache (which was supposed to solve our memory problem but actually worsened it).

Adam and Jonathan went through great pains to remove these references, so don't break our work!!!

Throws:
InterruptedException
IOException