Search in sources :

Example 1 with CopyOnWriteIdentityMap

use of org.eclipse.osgi.framework.eventmgr.CopyOnWriteIdentityMap in project rt.equinox.framework by eclipse.

the class EquinoxEventPublisher method publishFrameworkEventPrivileged.

public void publishFrameworkEventPrivileged(FrameworkEvent event, FrameworkListener... callerListeners) {
    if (!isEventManagerSet()) {
        return;
    }
    // Build the listener snapshot
    Map<BundleContextImpl, Set<Map.Entry<FrameworkListener, FrameworkListener>>> listenerSnapshot;
    synchronized (allFrameworkListeners) {
        listenerSnapshot = new HashMap<>(allFrameworkListeners.size());
        for (Map.Entry<BundleContextImpl, CopyOnWriteIdentityMap<FrameworkListener, FrameworkListener>> entry : allFrameworkListeners.entrySet()) {
            CopyOnWriteIdentityMap<FrameworkListener, FrameworkListener> listeners = entry.getValue();
            if (!listeners.isEmpty()) {
                listenerSnapshot.put(entry.getKey(), listeners.entrySet());
            }
        }
    }
    // If framework event hook were defined they would be called here
    // deliver the event to the snapshot
    ListenerQueue<FrameworkListener, FrameworkListener, FrameworkEvent> queue = newListenerQueue();
    // add the listeners specified by the caller first
    if (callerListeners != null && callerListeners.length > 0) {
        Map<FrameworkListener, FrameworkListener> listeners = new HashMap<>();
        for (FrameworkListener listener : callerListeners) {
            if (listener != null)
                listeners.put(listener, listener);
        }
        // We use the system bundle context as the dispatcher
        if (listeners.size() > 0) {
            BundleContextImpl systemContext = (BundleContextImpl) container.getStorage().getModuleContainer().getModule(0).getBundle().getBundleContext();
            @SuppressWarnings({ "rawtypes", "unchecked" }) EventDispatcher<FrameworkListener, FrameworkListener, FrameworkEvent> dispatcher = (EventDispatcher) systemContext;
            queue.queueListeners(listeners.entrySet(), dispatcher);
        }
    }
    for (Map.Entry<BundleContextImpl, Set<Map.Entry<FrameworkListener, FrameworkListener>>> entry : listenerSnapshot.entrySet()) {
        @SuppressWarnings({ "rawtypes", "unchecked" }) EventDispatcher<FrameworkListener, FrameworkListener, FrameworkEvent> dispatcher = (EventDispatcher) entry.getKey();
        Set<Map.Entry<FrameworkListener, FrameworkListener>> listeners = entry.getValue();
        queue.queueListeners(listeners, dispatcher);
    }
    queue.dispatchEventAsynchronous(FRAMEWORKEVENT, event);
    // close down the publisher if we got the stopped event
    if ((event.getType() & FRAMEWORK_STOPPED_MASK) != 0) {
        close();
    }
}
Also used : Set(java.util.Set) FrameworkEvent(org.osgi.framework.FrameworkEvent) HashMap(java.util.HashMap) CopyOnWriteIdentityMap(org.eclipse.osgi.framework.eventmgr.CopyOnWriteIdentityMap) EventDispatcher(org.eclipse.osgi.framework.eventmgr.EventDispatcher) FrameworkListener(org.osgi.framework.FrameworkListener) HashMap(java.util.HashMap) Map(java.util.Map) CopyOnWriteIdentityMap(org.eclipse.osgi.framework.eventmgr.CopyOnWriteIdentityMap)

Example 2 with CopyOnWriteIdentityMap

use of org.eclipse.osgi.framework.eventmgr.CopyOnWriteIdentityMap in project rt.equinox.framework by eclipse.

the class EventManagerTests method testCopyOnWriteIdentityMap.

public void testCopyOnWriteIdentityMap() {
    Object l1 = new Object();
    Object l2 = new Object();
    Object l3 = new Object();
    Object l4 = new Object();
    Object c1 = new Object();
    Object c2 = new Object();
    Object c3 = new Object();
    Object c4 = new Object();
    CopyOnWriteIdentityMap el1 = new CopyOnWriteIdentityMap();
    // $NON-NLS-1$
    assertTrue("not empty", el1.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 0, el1.size());
    // $NON-NLS-1$
    assertNull("non null", el1.put(l1, c1));
    // $NON-NLS-1$
    assertFalse("empty", el1.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 1, el1.size());
    // $NON-NLS-1$
    assertNull("non null", el1.put(l2, c2));
    // $NON-NLS-1$
    assertFalse("empty", el1.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 2, el1.size());
    // $NON-NLS-1$
    assertNull("non null", el1.put(l3, c3));
    // $NON-NLS-1$
    assertFalse("empty", el1.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 3, el1.size());
    // $NON-NLS-1$
    assertNull("non null", el1.put(l4, c4));
    // $NON-NLS-1$
    assertFalse("empty", el1.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 4, el1.size());
    // $NON-NLS-1$
    assertEquals("wrong value", c1, el1.get(l1));
    // $NON-NLS-1$
    assertEquals("wrong value", c2, el1.get(l2));
    // $NON-NLS-1$
    assertEquals("wrong value", c3, el1.get(l3));
    // $NON-NLS-1$
    assertEquals("wrong value", c4, el1.get(l4));
    CopyOnWriteIdentityMap el2 = new CopyOnWriteIdentityMap(el1);
    // $NON-NLS-1$
    assertFalse("empty", el2.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 4, el2.size());
    // $NON-NLS-1$
    assertEquals("wrong value", c1, el2.get(l1));
    // $NON-NLS-1$
    assertEquals("wrong value", c2, el2.get(l2));
    // $NON-NLS-1$
    assertEquals("wrong value", c3, el2.get(l3));
    // $NON-NLS-1$
    assertEquals("wrong value", c4, el2.get(l4));
    // $NON-NLS-1$
    assertEquals("wrong value", c2, el1.remove(l2));
    // $NON-NLS-1$
    assertFalse("empty", el1.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 3, el1.size());
    // $NON-NLS-1$
    assertEquals("not null", null, el1.remove(l2));
    // $NON-NLS-1$
    assertFalse("empty", el1.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 3, el1.size());
    // $NON-NLS-1$
    assertEquals("wrong value", c4, el1.remove(l4));
    // $NON-NLS-1$
    assertFalse("empty", el1.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 2, el1.size());
    // $NON-NLS-1$
    assertEquals("not null", null, el1.remove(l4));
    // $NON-NLS-1$
    assertFalse("empty", el1.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 2, el1.size());
    // $NON-NLS-1$
    assertEquals("wrong value", c1, el1.get(l1));
    // $NON-NLS-1$
    assertEquals("wrong value", c3, el1.get(l3));
    // $NON-NLS-1$
    assertFalse("empty", el2.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 4, el2.size());
    // $NON-NLS-1$
    assertEquals("wrong value", c1, el2.get(l1));
    // $NON-NLS-1$
    assertEquals("wrong value", c2, el2.get(l2));
    // $NON-NLS-1$
    assertEquals("wrong value", c3, el2.get(l3));
    // $NON-NLS-1$
    assertEquals("wrong value", c4, el2.get(l4));
    // $NON-NLS-1$
    assertEquals("wrong value", c1, el2.remove(l1));
    // $NON-NLS-1$
    assertEquals("wrong value", c3, el2.remove(l3));
    el1.putAll(el2);
    // $NON-NLS-1$
    assertFalse("empty", el1.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 4, el1.size());
    // $NON-NLS-1$
    assertEquals("wrong value", c1, el1.get(l1));
    // $NON-NLS-1$
    assertEquals("wrong value", c2, el1.get(l2));
    // $NON-NLS-1$
    assertEquals("wrong value", c3, el1.get(l3));
    // $NON-NLS-1$
    assertEquals("wrong value", c4, el1.get(l4));
    // $NON-NLS-1$
    assertFalse("empty", el2.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 2, el2.size());
    // $NON-NLS-1$
    assertEquals("wrong value", c2, el2.get(l2));
    // $NON-NLS-1$
    assertEquals("wrong value", c4, el2.get(l4));
    el2.putAll(el1);
    // $NON-NLS-1$
    assertFalse("empty", el1.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 4, el1.size());
    // $NON-NLS-1$
    assertEquals("wrong value", c1, el1.get(l1));
    // $NON-NLS-1$
    assertEquals("wrong value", c2, el1.get(l2));
    // $NON-NLS-1$
    assertEquals("wrong value", c3, el1.get(l3));
    // $NON-NLS-1$
    assertEquals("wrong value", c4, el1.get(l4));
    // $NON-NLS-1$
    assertFalse("empty", el2.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 4, el2.size());
    // $NON-NLS-1$
    assertEquals("wrong value", c1, el2.get(l1));
    // $NON-NLS-1$
    assertEquals("wrong value", c2, el2.get(l2));
    // $NON-NLS-1$
    assertEquals("wrong value", c3, el2.get(l3));
    // $NON-NLS-1$
    assertEquals("wrong value", c4, el2.get(l4));
    el2.clear();
    // $NON-NLS-1$
    assertTrue("not empty", el2.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 0, el2.size());
    // $NON-NLS-1$
    assertNull("non null", el2.put(l1, c1));
    // $NON-NLS-1$
    assertEquals("wrong value", c1, el2.put(l1, c3));
    // $NON-NLS-1$
    assertEquals("wrong value", c3, el2.get(l1));
    // $NON-NLS-1$
    assertTrue("missed key", el2.containsKey(l1));
    // $NON-NLS-1$
    assertTrue("missed value", el2.containsValue(c3));
    // $NON-NLS-1$
    assertFalse("invalid key", el2.containsKey(l2));
    // $NON-NLS-1$
    assertFalse("invalid value", el2.containsValue(c1));
    el2.clear();
    Map source = new HashMap();
    source.put(l1, c1);
    source.put(l4, c4);
    el2.putAll(source);
    // $NON-NLS-1$
    assertFalse("empty", el2.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 2, el2.size());
    // $NON-NLS-1$
    assertEquals("wrong value", c1, el2.get(l1));
    // $NON-NLS-1$
    assertEquals("wrong value", c4, el2.get(l4));
    el2.clear();
    Set k1 = el1.keySet();
    Set k2 = el2.keySet();
    Set k3 = el1.keySet();
    Set k4 = el1.keySet();
    Collection v1 = el1.values();
    Collection v2 = el2.values();
    Collection v3 = el1.values();
    Collection v4 = el1.values();
    Set e1 = el1.entrySet();
    Set e2 = el2.entrySet();
    Set e3 = el1.entrySet();
    Set e4 = el1.entrySet();
    Set e5 = el1.entrySet();
    el1.clear();
    // $NON-NLS-1$
    assertFalse("empty", k1.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 4, k1.size());
    // $NON-NLS-1$
    assertTrue("missed key", k1.contains(l1));
    // $NON-NLS-1$
    assertTrue("missed key", k1.contains(l2));
    // $NON-NLS-1$
    assertTrue("missed key", k1.contains(l3));
    // $NON-NLS-1$
    assertTrue("missed key", k1.contains(l4));
    // $NON-NLS-1$
    assertTrue("missed key", k1.containsAll(Arrays.asList(new Object[] { l1, l2, l3, l4 })));
    // $NON-NLS-1$
    assertTrue("array unequal", Arrays.equals(new Object[] { l1, l3, l2, l4 }, k1.toArray()));
    // $NON-NLS-1$
    assertTrue("array unequal", Arrays.equals(new Object[] { l1, l3, l2, l4 }, k1.toArray(new Object[4])));
    Iterator i1 = k1.iterator();
    // $NON-NLS-1$
    assertTrue("missing next", i1.hasNext());
    // $NON-NLS-1$
    assertEquals("wrong key", l1, i1.next());
    i1.remove();
    // $NON-NLS-1$
    assertEquals("wrong size", 3, k1.size());
    assertFalse("still present", k1.contains(l1));
    // $NON-NLS-1$
    assertTrue("missing next", i1.hasNext());
    // $NON-NLS-1$
    assertEquals("wrong key", l3, i1.next());
    i1.remove();
    // $NON-NLS-1$
    assertEquals("wrong size", 2, k1.size());
    assertFalse("still present", k1.contains(l3));
    // $NON-NLS-1$
    assertTrue("missing next", i1.hasNext());
    // $NON-NLS-1$
    assertEquals("wrong key", l2, i1.next());
    i1.remove();
    // $NON-NLS-1$
    assertEquals("wrong size", 1, k1.size());
    assertFalse("still present", k1.contains(l2));
    // $NON-NLS-1$
    assertTrue("missing next", i1.hasNext());
    // $NON-NLS-1$
    assertEquals("wrong key", l4, i1.next());
    i1.remove();
    // $NON-NLS-1$
    assertEquals("wrong size", 0, k1.size());
    assertFalse("still present", k1.contains(l4));
    // $NON-NLS-1$
    assertFalse("extra next", i1.hasNext());
    try {
        i1.next();
        // $NON-NLS-1$
        fail("next did not throw exception");
    } catch (NoSuchElementException e) {
    // expected
    }
    // $NON-NLS-1$
    assertTrue("not empty", k2.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 0, k2.size());
    Iterator i2 = k2.iterator();
    // $NON-NLS-1$
    assertFalse("extra next", i2.hasNext());
    try {
        i2.next();
        // $NON-NLS-1$
        fail("next did not throw exception");
    } catch (NoSuchElementException e) {
    // expected
    }
    try {
        k2.add(l1);
        // $NON-NLS-1$
        fail("add did not throw exception");
    } catch (UnsupportedOperationException e) {
    // expected
    }
    try {
        k2.addAll(Arrays.asList(new Object[] { l1, l2 }));
        // $NON-NLS-1$
        fail("addAll did not throw exception");
    } catch (UnsupportedOperationException e) {
    // expected
    }
    k3.remove(l3);
    // $NON-NLS-1$
    assertFalse("not removed", k3.contains(l3));
    k3.removeAll(Arrays.asList(new Object[] { l1, l2 }));
    // $NON-NLS-1$
    assertFalse("not removed", k3.contains(l1));
    // $NON-NLS-1$
    assertFalse("not removed", k3.contains(l2));
    k4.retainAll(Arrays.asList(new Object[] { l1, l2 }));
    // $NON-NLS-1$
    assertTrue("missing", k4.contains(l1));
    // $NON-NLS-1$
    assertTrue("missing", k4.contains(l2));
    // $NON-NLS-1$
    assertFalse("not removed", k4.contains(l3));
    // $NON-NLS-1$
    assertFalse("not removed", k4.contains(l4));
    k4.clear();
    // $NON-NLS-1$
    assertTrue("not empty", k4.isEmpty());
    // $NON-NLS-1$
    assertFalse("empty", v1.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 4, v1.size());
    // $NON-NLS-1$
    assertTrue("missed key", v1.contains(c1));
    // $NON-NLS-1$
    assertTrue("missed key", v1.contains(c2));
    // $NON-NLS-1$
    assertTrue("missed key", v1.contains(c3));
    // $NON-NLS-1$
    assertTrue("missed key", v1.contains(c4));
    // $NON-NLS-1$
    assertTrue("missed key", v1.containsAll(Arrays.asList(new Object[] { c1, c2, c3, c4 })));
    // $NON-NLS-1$
    assertTrue("array unequal", Arrays.equals(new Object[] { c1, c3, c2, c4 }, v1.toArray()));
    // $NON-NLS-1$
    assertTrue("array unequal", Arrays.equals(new Object[] { c1, c3, c2, c4 }, v1.toArray(new Object[4])));
    Iterator i3 = v1.iterator();
    // $NON-NLS-1$
    assertTrue("missing next", i3.hasNext());
    // $NON-NLS-1$
    assertEquals("wrong key", c1, i3.next());
    i3.remove();
    // $NON-NLS-1$
    assertEquals("wrong size", 3, v1.size());
    assertFalse("still present", v1.contains(c1));
    // $NON-NLS-1$
    assertTrue("missing next", i3.hasNext());
    // $NON-NLS-1$
    assertEquals("wrong key", c3, i3.next());
    i3.remove();
    // $NON-NLS-1$
    assertEquals("wrong size", 2, v1.size());
    assertFalse("still present", v1.contains(c3));
    // $NON-NLS-1$
    assertTrue("missing next", i3.hasNext());
    // $NON-NLS-1$
    assertEquals("wrong key", c2, i3.next());
    i3.remove();
    // $NON-NLS-1$
    assertEquals("wrong size", 1, v1.size());
    assertFalse("still present", v1.contains(c2));
    // $NON-NLS-1$
    assertTrue("missing next", i3.hasNext());
    // $NON-NLS-1$
    assertEquals("wrong key", c4, i3.next());
    i3.remove();
    // $NON-NLS-1$
    assertEquals("wrong size", 0, v1.size());
    assertFalse("still present", v1.contains(c4));
    // $NON-NLS-1$
    assertFalse("extra next", i3.hasNext());
    try {
        i3.next();
        // $NON-NLS-1$
        fail("next did not throw exception");
    } catch (NoSuchElementException e) {
    // expected
    }
    // $NON-NLS-1$
    assertTrue("not empty", v2.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 0, v2.size());
    Iterator i4 = v2.iterator();
    // $NON-NLS-1$
    assertFalse("extra next", i4.hasNext());
    try {
        i4.next();
        // $NON-NLS-1$
        fail("next did not throw exception");
    } catch (NoSuchElementException e) {
    // expected
    }
    try {
        v2.add(c1);
        // $NON-NLS-1$
        fail("add did not throw exception");
    } catch (UnsupportedOperationException e) {
    // expected
    }
    try {
        v2.addAll(Arrays.asList(new Object[] { c1, c2 }));
        // $NON-NLS-1$
        fail("addAll did not throw exception");
    } catch (UnsupportedOperationException e) {
    // expected
    }
    v3.remove(c3);
    // $NON-NLS-1$
    assertFalse("not removed", v3.contains(c3));
    v3.removeAll(Arrays.asList(new Object[] { c1, c2 }));
    // $NON-NLS-1$
    assertFalse("not removed", v3.contains(c1));
    // $NON-NLS-1$
    assertFalse("not removed", v3.contains(c2));
    v4.retainAll(Arrays.asList(new Object[] { c1, c2 }));
    // $NON-NLS-1$
    assertTrue("missing", v4.contains(c1));
    // $NON-NLS-1$
    assertTrue("missing", v4.contains(c2));
    // $NON-NLS-1$
    assertFalse("not removed", v4.contains(c3));
    // $NON-NLS-1$
    assertFalse("not removed", v4.contains(c4));
    v4.clear();
    // $NON-NLS-1$
    assertTrue("not empty", v4.isEmpty());
    // $NON-NLS-1$
    assertFalse("empty", e1.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 4, e1.size());
    Iterator i5 = e1.iterator();
    // $NON-NLS-1$
    assertTrue("missing next", i5.hasNext());
    Map.Entry me1 = (Map.Entry) i5.next();
    // $NON-NLS-1$
    assertEquals("wrong key", l1, me1.getKey());
    // $NON-NLS-1$
    assertEquals("wrong value", c1, me1.getValue());
    try {
        me1.setValue(c2);
        // $NON-NLS-1$
        fail("remove did not throw exception");
    } catch (UnsupportedOperationException e) {
    // expected
    }
    i5.remove();
    // $NON-NLS-1$
    assertEquals("wrong size", 3, e1.size());
    assertFalse("still present", e1.contains(me1));
    // $NON-NLS-1$
    assertTrue("missing next", i5.hasNext());
    Map.Entry me3 = (Map.Entry) i5.next();
    // $NON-NLS-1$
    assertEquals("wrong key", l3, me3.getKey());
    // $NON-NLS-1$
    assertEquals("wrong value", c3, me3.getValue());
    try {
        me3.setValue(c2);
        // $NON-NLS-1$
        fail("remove did not throw exception");
    } catch (UnsupportedOperationException e) {
    // expected
    }
    i5.remove();
    // $NON-NLS-1$
    assertEquals("wrong size", 2, e1.size());
    assertFalse("still present", e1.contains(me3));
    // $NON-NLS-1$
    assertTrue("missing next", i5.hasNext());
    Map.Entry me2 = (Map.Entry) i5.next();
    // $NON-NLS-1$
    assertEquals("wrong key", l2, me2.getKey());
    // $NON-NLS-1$
    assertEquals("wrong value", c2, me2.getValue());
    try {
        me2.setValue(c3);
        // $NON-NLS-1$
        fail("remove did not throw exception");
    } catch (UnsupportedOperationException e) {
    // expected
    }
    i5.remove();
    // $NON-NLS-1$
    assertEquals("wrong size", 1, e1.size());
    assertFalse("still present", e1.contains(me2));
    // $NON-NLS-1$
    assertTrue("missing next", i5.hasNext());
    Map.Entry me4 = (Map.Entry) i5.next();
    // $NON-NLS-1$
    assertEquals("wrong key", l4, me4.getKey());
    // $NON-NLS-1$
    assertEquals("wrong value", c4, me4.getValue());
    try {
        me4.setValue(c2);
        // $NON-NLS-1$
        fail("remove did not throw exception");
    } catch (UnsupportedOperationException e) {
    // expected
    }
    i5.remove();
    // $NON-NLS-1$
    assertEquals("wrong size", 0, e1.size());
    assertFalse("still present", e1.contains(me4));
    // $NON-NLS-1$
    assertFalse("extra next", i5.hasNext());
    try {
        i1.next();
        // $NON-NLS-1$
        fail("next did not throw exception");
    } catch (NoSuchElementException e) {
    // expected
    }
    // $NON-NLS-1$
    assertTrue("not empty", e2.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 0, e2.size());
    Iterator i6 = e2.iterator();
    // $NON-NLS-1$
    assertFalse("extra next", i6.hasNext());
    try {
        i6.next();
        // $NON-NLS-1$
        fail("next did not throw exception");
    } catch (NoSuchElementException e) {
    // expected
    }
    try {
        e2.add(me1);
        // $NON-NLS-1$
        fail("add did not throw exception");
    } catch (UnsupportedOperationException e) {
    // expected
    }
    try {
        e2.addAll(Arrays.asList(new Map.Entry[] { me2, me4 }));
        // $NON-NLS-1$
        fail("addAll did not throw exception");
    } catch (UnsupportedOperationException e) {
    // expected
    }
    e3.remove(me3);
    // $NON-NLS-1$
    assertFalse("not removed", e3.contains(me3));
    e3.removeAll(Arrays.asList(new Object[] { me1, me2 }));
    // $NON-NLS-1$
    assertFalse("not removed", e3.contains(me1));
    // $NON-NLS-1$
    assertFalse("not removed", e3.contains(me2));
    e4.retainAll(Arrays.asList(new Object[] { me1, me2 }));
    // $NON-NLS-1$
    assertTrue("missing", e4.contains(me1));
    // $NON-NLS-1$
    assertTrue("missing", e4.contains(me2));
    // $NON-NLS-1$
    assertFalse("not removed", e4.contains(me3));
    // $NON-NLS-1$
    assertFalse("not removed", e4.contains(me4));
    e4.clear();
    // $NON-NLS-1$
    assertTrue("not empty", e4.isEmpty());
    // $NON-NLS-1$
    assertTrue("array unequal", Arrays.equals(new Map.Entry[] { me1, me3, me2, me4 }, e5.toArray()));
    // $NON-NLS-1$
    assertTrue("array unequal", Arrays.equals(new Map.Entry[] { me1, me3, me2, me4 }, e5.toArray(new Map.Entry[4])));
    el2.clear();
    el2.putAll(new Object[] { l1, l3 });
    // $NON-NLS-1$
    assertFalse("empty", el2.isEmpty());
    // $NON-NLS-1$
    assertEquals("wrong size", 2, el2.size());
    // $NON-NLS-1$
    assertTrue("missed key", el2.containsKey(l1));
    // $NON-NLS-1$
    assertTrue("missed key", el2.containsKey(l3));
    // $NON-NLS-1$
    assertNull("value not null", el2.get(l1));
    // $NON-NLS-1$
    assertNull("value not null", el2.get(l3));
}
Also used : CopyOnWriteIdentityMap(org.eclipse.osgi.framework.eventmgr.CopyOnWriteIdentityMap) CopyOnWriteIdentityMap(org.eclipse.osgi.framework.eventmgr.CopyOnWriteIdentityMap)

Aggregations

CopyOnWriteIdentityMap (org.eclipse.osgi.framework.eventmgr.CopyOnWriteIdentityMap)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Set (java.util.Set)1 EventDispatcher (org.eclipse.osgi.framework.eventmgr.EventDispatcher)1 FrameworkEvent (org.osgi.framework.FrameworkEvent)1 FrameworkListener (org.osgi.framework.FrameworkListener)1