コード例 #1
0
 /** remove(key,value) removes only if pair present */
 public void testRemove2() {
   ConcurrentNavigableMap map = map5();
   assertTrue(map.containsKey(five));
   assertEquals("E", map.get(five));
   map.remove(five, "E");
   assertEquals(4, map.size());
   assertFalse(map.containsKey(five));
   map.remove(four, "A");
   assertEquals(4, map.size());
   assertTrue(map.containsKey(four));
 }
コード例 #2
0
 /** remove(key,value) removes only if pair present */
 public void testDescendingRemove2() {
   ConcurrentNavigableMap map = dmap5();
   assertTrue(map.containsKey(m5));
   assertEquals("E", map.get(m5));
   map.remove(m5, "E");
   assertEquals(4, map.size());
   assertFalse(map.containsKey(m5));
   map.remove(m4, "A");
   assertEquals(4, map.size());
   assertTrue(map.containsKey(m4));
 }
コード例 #3
0
 /** remove(null, x) throws NPE */
 public void testRemove2_NullPointerException() {
   try {
     ConcurrentNavigableMap c = map5();
     c.remove(null, "whatever");
     shouldThrow();
   } catch (NullPointerException success) {
   }
 }
コード例 #4
0
 /** remove(null) throws NPE */
 public void testDescendingRemove1_NullPointerException() {
   try {
     ConcurrentNavigableMap c = dmap5();
     c.remove(null);
     shouldThrow();
   } catch (NullPointerException success) {
   }
 }
コード例 #5
0
 /** pollLastEntry returns entries in order */
 public void testDescendingPollLastEntry() {
   ConcurrentNavigableMap map = dmap5();
   Map.Entry e = map.pollLastEntry();
   assertEquals(m5, e.getKey());
   assertEquals("E", e.getValue());
   e = map.pollLastEntry();
   assertEquals(m4, e.getKey());
   map.put(m5, "E");
   e = map.pollLastEntry();
   assertEquals(m5, e.getKey());
   assertEquals("E", e.getValue());
   e = map.pollLastEntry();
   assertEquals(m3, e.getKey());
   map.remove(m2);
   e = map.pollLastEntry();
   assertEquals(m1, e.getKey());
   try {
     e.setValue("E");
     shouldThrow();
   } catch (UnsupportedOperationException success) {
   }
   e = map.pollLastEntry();
   assertNull(e);
 }
コード例 #6
0
 /** pollLastEntry returns entries in order */
 public void testPollLastEntry() {
   ConcurrentNavigableMap map = map5();
   Map.Entry e = map.pollLastEntry();
   assertEquals(five, e.getKey());
   assertEquals("E", e.getValue());
   e = map.pollLastEntry();
   assertEquals(four, e.getKey());
   map.put(five, "E");
   e = map.pollLastEntry();
   assertEquals(five, e.getKey());
   assertEquals("E", e.getValue());
   e = map.pollLastEntry();
   assertEquals(three, e.getKey());
   map.remove(two);
   e = map.pollLastEntry();
   assertEquals(one, e.getKey());
   try {
     e.setValue("E");
     shouldThrow();
   } catch (UnsupportedOperationException success) {
   }
   e = map.pollLastEntry();
   assertNull(e);
 }
コード例 #7
0
 /** remove removes the correct key-value pair from the map */
 public void testDescendingRemove() {
   ConcurrentNavigableMap map = dmap5();
   map.remove(m5);
   assertEquals(4, map.size());
   assertFalse(map.containsKey(m5));
 }
コード例 #8
0
 /** remove removes the correct key-value pair from the map */
 public void testRemove() {
   ConcurrentNavigableMap map = map5();
   map.remove(five);
   assertEquals(4, map.size());
   assertFalse(map.containsKey(five));
 }