use of java.util.concurrent.ConcurrentSkipListMap in project j2objc by google.
the class ConcurrentSkipListMapTest method testEntryImmutability.
/**
* lowerEntry, higherEntry, ceilingEntry, and floorEntry return
* immutable entries
*/
public void testEntryImmutability() {
ConcurrentSkipListMap map = map5();
Map.Entry e = map.lowerEntry(three);
assertEquals(two, e.getKey());
try {
e.setValue("X");
shouldThrow();
} catch (UnsupportedOperationException success) {
}
e = map.higherEntry(zero);
assertEquals(one, e.getKey());
try {
e.setValue("X");
shouldThrow();
} catch (UnsupportedOperationException success) {
}
e = map.floorEntry(one);
assertEquals(one, e.getKey());
try {
e.setValue("X");
shouldThrow();
} catch (UnsupportedOperationException success) {
}
e = map.ceilingEntry(five);
assertEquals(five, e.getKey());
try {
e.setValue("X");
shouldThrow();
} catch (UnsupportedOperationException success) {
}
}
use of java.util.concurrent.ConcurrentSkipListMap in project j2objc by google.
the class ConcurrentSkipListMapTest method testDescendingKeySetOrder.
/**
* descendingKeySet is ordered
*/
public void testDescendingKeySetOrder() {
ConcurrentSkipListMap map = map5();
Set s = map.descendingKeySet();
Iterator i = s.iterator();
Integer last = (Integer) i.next();
assertEquals(last, five);
int count = 1;
while (i.hasNext()) {
Integer k = (Integer) i.next();
assertTrue(last.compareTo(k) > 0);
last = k;
++count;
}
assertEquals(5, count);
}
use of java.util.concurrent.ConcurrentSkipListMap in project j2objc by google.
the class ConcurrentSkipListMapTest method testRemove3.
/**
* remove(x, null) returns false
*/
public void testRemove3() {
ConcurrentSkipListMap c = new ConcurrentSkipListMap();
c.put("sadsdf", "asdads");
assertFalse(c.remove("sadsdf", null));
}
use of java.util.concurrent.ConcurrentSkipListMap in project j2objc by google.
the class ConcurrentSkipListMapTest method testValuesToArray.
/**
* Values.toArray contains all values
*/
public void testValuesToArray() {
ConcurrentSkipListMap map = map5();
Collection v = map.values();
Object[] ar = v.toArray();
ArrayList s = new ArrayList(Arrays.asList(ar));
assertEquals(5, ar.length);
assertTrue(s.contains("A"));
assertTrue(s.contains("B"));
assertTrue(s.contains("C"));
assertTrue(s.contains("D"));
assertTrue(s.contains("E"));
}
use of java.util.concurrent.ConcurrentSkipListMap in project j2objc by google.
the class ConcurrentSkipListMapTest method testRemove2.
/**
* remove(key,value) removes only if pair present
*/
public void testRemove2() {
ConcurrentSkipListMap 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));
}
Aggregations