Search in sources :

Example 71 with ConcurrentSkipListMap

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) {
    }
}
Also used : ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) NavigableMap(java.util.NavigableMap) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) Map(java.util.Map)

Example 72 with ConcurrentSkipListMap

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);
}
Also used : ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) Set(java.util.Set) NavigableSet(java.util.NavigableSet) BitSet(java.util.BitSet) Iterator(java.util.Iterator)

Example 73 with ConcurrentSkipListMap

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));
}
Also used : ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap)

Example 74 with ConcurrentSkipListMap

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"));
}
Also used : ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap) ArrayList(java.util.ArrayList) Collection(java.util.Collection)

Example 75 with ConcurrentSkipListMap

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));
}
Also used : ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap)

Aggregations

ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)183 Test (org.junit.Test)66 PollStatus (org.opennms.netmgt.poller.PollStatus)32 MonitoredService (org.opennms.netmgt.poller.MonitoredService)31 Map (java.util.Map)30 ServiceMonitor (org.opennms.netmgt.poller.ServiceMonitor)25 MqttDeviceTwin (com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttDeviceTwin)23 HashMap (java.util.HashMap)21 DeviceTwinMessage (com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceTwinMessage)17 NavigableMap (java.util.NavigableMap)14 Set (java.util.Set)12 Iterator (java.util.Iterator)11 NavigableSet (java.util.NavigableSet)11 MockMonitoredService (org.opennms.netmgt.poller.mock.MockMonitoredService)11 IOException (java.io.IOException)10 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)10 ArrayList (java.util.ArrayList)9 BitSet (java.util.BitSet)9 DeviceOperations (com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceOperations)8 JUnitHttpServer (org.opennms.core.test.http.annotations.JUnitHttpServer)8