@After public void cleanup() throws IOException { if (reuseQueue) { queue.clear(); } else { queue.dispose(); } }
private void test(int numInList) throws IOException { for (int i = 0; i < numInList; i++) { queue.add(i); } Iterator<Integer> it = queue.reread().iterator(); for (int i = 0; i < numInList; i++) { assertEquals(new Integer(i), it.next()); } }
@Test public void testMultipleCycles() throws IOException { for (int i = 0; i < 10; i++) { // also test reading increasingly short lists back in test(maxObjectsInMemory * 2 * (10 - i)); queue.clear(); // garbage collection can trigger finalizers, // which in turn close file descriptors System.gc(); } }
@AfterClass public static void cleanupClass() throws IOException { if (queue != null) { queue.dispose(); } }