@Test public void testIteratorPredictableRemove() { TimeoutMap map = (TimeoutMap) makeFullMap(); map.setExpiryTime(50l); assertFalse(map.isEmpty()); int count = 0; for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) { if (count == 0) { // NOTE: Only wait fist time, to avoid slooow tests synchronized (this) { try { wait(60l); } catch (InterruptedException e) { } } } try { iterator.remove(); count++; } catch (NoSuchElementException nse) { fail("Elements expired between Interator.hasNext() and Iterator.remove()"); } } assertTrue("Elements expired too early, test did not run as expected.", count > 0); //assertEquals("Elements did not expire as expected.", 1, count); }
@Test public void testIteratorPredictableNext() { TimeoutMap map = (TimeoutMap) makeFullMap(); map.setExpiryTime(50l); assertFalse(map.isEmpty()); int count = 0; for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) { if (count == 0) { // NOTE: Only wait fist time, to avoid slooow tests synchronized (this) { try { wait(60l); } catch (InterruptedException e) { } } } try { Map.Entry entry = (Map.Entry) iterator.next(); assertNotNull(entry); count++; } catch (NoSuchElementException nse) { fail("Elements expire between Interator.hasNext() and Iterator.next()"); } } assertTrue("Elements expired too early, test did not run as expected.", count > 0); //assertEquals("Elements did not expire as expected.", 1, count); }
TimeoutMap map = (TimeoutMap) makeFullMap(); map.setExpiryTime(50l); assertFalse(map.isEmpty());
map.put("key-2", new Integer(2)); assertFalse(map.isEmpty());
/** * Method testTimeoutIsEmpty */ @Test public void testTimeoutIsEmpty() { TimeoutMap map = new TimeoutMap(50L); assertNull(map.put("key", "value-1")); assertEquals("value-1", map.get("key")); assertNull(map.put("another", "value-2")); assertEquals("value-2", map.get("another")); synchronized (this) { try { Thread.sleep(100L); } catch (InterruptedException e) { // Continue, but might break the timeout thing below... } } // This for loop should not print anything, if the tests succeed. Set set = map.keySet(); assertEquals(0, set.size()); for (Iterator iterator = set.iterator(); iterator.hasNext(); System.out.println(iterator.next())) { ; } assertEquals(0, map.size()); assertTrue(map.isEmpty()); }
public void testIteratorPredictableRemove() { TimeoutMap map = (TimeoutMap) makeFullMap(); map.setExpiryTime(50l); assertFalse(map.isEmpty()); int count = 0; for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) { if (count == 0) { // NOTE: Only wait fist time, to avoid slooow tests synchronized (this) { try { wait(60l); } catch (InterruptedException e) { } } } try { iterator.remove(); count++; } catch (NoSuchElementException nse) { fail("Elements expired between Interator.hasNext() and Iterator.remove()"); } } assertTrue("Elements expired too early, test did not run as expected.", count > 0); //assertEquals("Elements did not expire as expected.", 1, count); }
public void testIteratorPredictableRemove() { TimeoutMap map = (TimeoutMap) makeFullMap(); map.setExpiryTime(50l); assertFalse(map.isEmpty()); int count = 0; for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) { if (count == 0) { // NOTE: Only wait fist time, to avoid slooow tests synchronized (this) { try { wait(60l); } catch (InterruptedException e) { } } } try { iterator.remove(); count++; } catch (NoSuchElementException nse) { fail("Elements expired between Interator.hasNext() and Iterator.remove()"); } } assertTrue("Elements expired too early, test did not run as expected.", count > 0); //assertEquals("Elements did not expire as expected.", 1, count); }
public void testIteratorPredictableNext() { TimeoutMap map = (TimeoutMap) makeFullMap(); map.setExpiryTime(50l); assertFalse(map.isEmpty()); int count = 0; for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) { if (count == 0) { // NOTE: Only wait fist time, to avoid slooow tests synchronized (this) { try { wait(60l); } catch (InterruptedException e) { } } } try { Map.Entry entry = (Map.Entry) iterator.next(); assertNotNull(entry); count++; } catch (NoSuchElementException nse) { fail("Elements expire between Interator.hasNext() and Iterator.next()"); } } assertTrue("Elements expired too early, test did not run as expected.", count > 0); //assertEquals("Elements did not expire as expected.", 1, count); }
public void testIteratorPredictableNext() { TimeoutMap map = (TimeoutMap) makeFullMap(); map.setExpiryTime(50l); assertFalse(map.isEmpty()); int count = 0; for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) { if (count == 0) { // NOTE: Only wait fist time, to avoid slooow tests synchronized (this) { try { wait(60l); } catch (InterruptedException e) { } } } try { Map.Entry entry = (Map.Entry) iterator.next(); assertNotNull(entry); count++; } catch (NoSuchElementException nse) { fail("Elements expire between Interator.hasNext() and Iterator.next()"); } } assertTrue("Elements expired too early, test did not run as expected.", count > 0); //assertEquals("Elements did not expire as expected.", 1, count); }
@Test public void testIteratorPredictableRemove() { TimeoutMap map = (TimeoutMap) makeFullMap(); map.setExpiryTime(50l); assertFalse(map.isEmpty()); int count = 0; for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) { if (count == 0) { // NOTE: Only wait fist time, to avoid slooow tests synchronized (this) { try { wait(60l); } catch (InterruptedException e) { } } } try { iterator.remove(); count++; } catch (NoSuchElementException nse) { fail("Elements expired between Interator.hasNext() and Iterator.remove()"); } } assertTrue("Elements expired too early, test did not run as expected.", count > 0); //assertEquals("Elements did not expire as expected.", 1, count); }
public void testIteratorPredictableNextRemove() { TimeoutMap map = (TimeoutMap) makeFullMap(); map.setExpiryTime(50l); assertFalse(map.isEmpty());
public void testIteratorPredictableNextRemove() { TimeoutMap map = (TimeoutMap) makeFullMap(); map.setExpiryTime(50l); assertFalse(map.isEmpty());
@Test public void testIteratorPredictableNext() { TimeoutMap map = (TimeoutMap) makeFullMap(); map.setExpiryTime(50l); assertFalse(map.isEmpty()); int count = 0; for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext();) { if (count == 0) { // NOTE: Only wait fist time, to avoid slooow tests synchronized (this) { try { wait(60l); } catch (InterruptedException e) { } } } try { Map.Entry entry = (Map.Entry) iterator.next(); assertNotNull(entry); count++; } catch (NoSuchElementException nse) { fail("Elements expire between Interator.hasNext() and Iterator.next()"); } } assertTrue("Elements expired too early, test did not run as expected.", count > 0); //assertEquals("Elements did not expire as expected.", 1, count); }
TimeoutMap map = (TimeoutMap) makeFullMap(); map.setExpiryTime(50l); assertFalse(map.isEmpty());
map.put("key-2", new Integer(2)); assertFalse(map.isEmpty());
map.put("key-2", new Integer(2)); assertFalse(map.isEmpty());
map.put("key-2", new Integer(2)); assertFalse(map.isEmpty());
/** * Method testTimeoutIsEmpty */ public void testTimeoutIsEmpty() { TimeoutMap map = new TimeoutMap(50L); assertNull(map.put("key", "value-1")); assertEquals("value-1", map.get("key")); assertNull(map.put("another", "value-2")); assertEquals("value-2", map.get("another")); synchronized (this) { try { Thread.sleep(100L); } catch (InterruptedException e) { // Continue, but might break the timeout thing below... } } // This for loop should not print anything, if the tests succeed. Set set = map.keySet(); assertEquals(0, set.size()); for (Iterator iterator = set.iterator(); iterator.hasNext(); System.out.println(iterator.next())) { ; } assertEquals(0, map.size()); assertTrue(map.isEmpty()); }
/** * Method testTimeoutIsEmpty */ public void testTimeoutIsEmpty() { TimeoutMap map = new TimeoutMap(50L); assertNull(map.put("key", "value-1")); assertEquals("value-1", map.get("key")); assertNull(map.put("another", "value-2")); assertEquals("value-2", map.get("another")); synchronized (this) { try { Thread.sleep(100L); } catch (InterruptedException e) { // Continue, but might break the timeout thing below... } } // This for loop should not print anything, if the tests succeed. Set set = map.keySet(); assertEquals(0, set.size()); for (Iterator iterator = set.iterator(); iterator.hasNext(); System.out.println(iterator.next())) { ; } assertEquals(0, map.size()); assertTrue(map.isEmpty()); }
/** * Method testTimeoutIsEmpty */ @Test public void testTimeoutIsEmpty() { TimeoutMap map = new TimeoutMap(50L); assertNull(map.put("key", "value-1")); assertEquals("value-1", map.get("key")); assertNull(map.put("another", "value-2")); assertEquals("value-2", map.get("another")); synchronized (this) { try { Thread.sleep(100L); } catch (InterruptedException e) { // Continue, but might break the timeout thing below... } } // This for loop should not print anything, if the tests succeed. Set set = map.keySet(); assertEquals(0, set.size()); for (Iterator iterator = set.iterator(); iterator.hasNext(); System.out.println(iterator.next())) { ; } assertEquals(0, map.size()); assertTrue(map.isEmpty()); }