1 9 10 package org.netbeans.api.editor.mimelookup; 11 12 import org.netbeans.junit.NbTestCase; 13 import org.netbeans.modules.editor.mimelookup.TestUtilities; 14 15 19 public class MimePathMemoryTest extends NbTestCase { 20 21 22 public MimePathMemoryTest(String name) { 23 super(name); 24 } 25 26 public void testSimple() { 27 MimePath pathA = MimePath.get("text/x-java"); 28 MimePath pathB = MimePath.get("text/x-java"); 29 assertSame("MimePath instances are not cached and reused", pathA, pathB); 30 } 31 32 public void testListOfRecentlyUsed() { 33 int idA = System.identityHashCode(MimePath.get("text/x-java")); 34 35 TestUtilities.consumeAllMemory(); 36 TestUtilities.gc(); 37 38 int idB = System.identityHashCode(MimePath.get("text/x-java")); 39 40 assertEquals("The MimePath instance was lost", idA, idB); 42 43 for (int i = 0; i < MimePath.MAX_LRU_SIZE; i++) { 44 MimePath.get("text/x-nonsense-" + i); 45 } 46 47 TestUtilities.consumeAllMemory(); 49 TestUtilities.gc(); 50 51 int idC = System.identityHashCode(MimePath.get("text/x-java")); 52 assertTrue("The MimePath instance was not release", idA != idC); 53 } 54 } 55 | Popular Tags |