assertEquals(3, ((Integer)list.get(1)).intValue());
assertEquals(4, ((Integer)list.get(2)).intValue());
}
public void testMultipleArrayMultipleHit() {
SegmentConstantPoolArrayCache arrayCache = new SegmentConstantPoolArrayCache();
String arrayOne[] = {"Zero", "Shared", "Two", "Shared", "Shared"};
String arrayTwo[] = {"Shared", "One", "Shared", "Shared", "Shared"};
List listOne = arrayCache.indexesForArrayKey(arrayOne, "Shared");
List listTwo = arrayCache.indexesForArrayKey(arrayTwo, "Shared");
// Make sure we're using the cached values. First trip
// through builds the cache.
listOne = arrayCache.indexesForArrayKey(arrayOne, "Two");
listTwo = arrayCache.indexesForArrayKey(arrayTwo, "Shared");
assertEquals(1, listOne.size());
assertEquals(2, ((Integer)listOne.get(0)).intValue());
// Now look for a different element in list one
listOne = arrayCache.indexesForArrayKey(arrayOne, "Shared");
assertEquals(3, listOne.size());
assertEquals(1, ((Integer)listOne.get(0)).intValue());
assertEquals(3, ((Integer)listOne.get(1)).intValue());
assertEquals(4, ((Integer)listOne.get(2)).intValue());
assertEquals(4, listTwo.size());
assertEquals(0, ((Integer)listTwo.get(0)).intValue());
assertEquals(2, ((Integer)listTwo.get(1)).intValue());
assertEquals(3, ((Integer)listTwo.get(2)).intValue());
assertEquals(4, ((Integer)listTwo.get(3)).intValue());
List listThree = arrayCache.indexesForArrayKey(arrayOne, "Not found");
assertEquals(0, listThree.size());
}