Search in sources :

Example 41 with WeakHashMap

use of java.util.WeakHashMap in project robovm by robovm.

the class WeakHashMapTest method test_Constructor.

/**
     * java.util.WeakHashMap#WeakHashMap()
     */
public void test_Constructor() {
    // Test for method java.util.WeakHashMap()
    new Support_MapTest2(new WeakHashMap()).runTest();
    whm = new WeakHashMap();
    for (int i = 0; i < 100; i++) whm.put(keyArray[i], valueArray[i]);
    for (int i = 0; i < 100; i++) assertTrue("Incorrect value retrieved", whm.get(keyArray[i]) == valueArray[i]);
}
Also used : Support_MapTest2(tests.support.Support_MapTest2) WeakHashMap(java.util.WeakHashMap)

Example 42 with WeakHashMap

use of java.util.WeakHashMap in project robovm by robovm.

the class WeakHashMapTest method test_putAllLjava_util_Map.

/**
     * java.util.WeakHashMap#putAll(java.util.Map)
     */
public void test_putAllLjava_util_Map() {
    Map mockMap = new MockMap();
    WeakHashMap map = new WeakHashMap();
    map.putAll(mockMap);
    assertEquals("Size should be 0", 0, map.size());
    try {
        map.putAll(null);
        fail("NullPointerException exected");
    } catch (NullPointerException e) {
    //expected
    }
}
Also used : AbstractMap(java.util.AbstractMap) Map(java.util.Map) WeakHashMap(java.util.WeakHashMap) WeakHashMap(java.util.WeakHashMap)

Example 43 with WeakHashMap

use of java.util.WeakHashMap in project robovm by robovm.

the class WeakHashMapTest method test_containsValueLjava_lang_Object.

/**
     * java.util.WeakHashMap#containsValue(java.lang.Object)
     */
public void test_containsValueLjava_lang_Object() {
    // Test for method boolean java.util.WeakHashMap.containsValue()
    whm = new WeakHashMap();
    for (int i = 0; i < 100; i++) whm.put(keyArray[i], valueArray[i]);
    for (int i = 0; i < 100; i++) assertTrue("Should contain referenced value", whm.containsValue(valueArray[i]));
    keyArray[25] = null;
    keyArray[50] = null;
}
Also used : WeakHashMap(java.util.WeakHashMap)

Example 44 with WeakHashMap

use of java.util.WeakHashMap in project robovm by robovm.

the class WeakHashMapTest method test_ConstructorI.

/**
     * java.util.WeakHashMap#WeakHashMap(int)
     */
public void test_ConstructorI() {
    // Test for method java.util.WeakHashMap(int)
    whm = new WeakHashMap(50);
    for (int i = 0; i < 100; i++) whm.put(keyArray[i], valueArray[i]);
    for (int i = 0; i < 100; i++) assertTrue("Incorrect value retrieved", whm.get(keyArray[i]) == valueArray[i]);
    WeakHashMap empty = new WeakHashMap(0);
    assertNull("Empty weakhashmap access", empty.get("nothing"));
    empty.put("something", "here");
    assertTrue("cannot get element", empty.get("something") == "here");
    try {
        new WeakHashMap(-50);
        fail("IllegalArgumentException expected");
    } catch (IllegalArgumentException e) {
    //expected
    }
}
Also used : WeakHashMap(java.util.WeakHashMap)

Example 45 with WeakHashMap

use of java.util.WeakHashMap in project robovm by robovm.

the class WeakHashMapTest method test_removeLjava_lang_Object.

/**
     * java.util.WeakHashMap#remove(java.lang.Object)
     */
public void test_removeLjava_lang_Object() {
    // Test for method java.lang.Object
    // java.util.WeakHashMap.remove(java.lang.Object)
    whm = new WeakHashMap();
    for (int i = 0; i < 100; i++) whm.put(keyArray[i], valueArray[i]);
    assertTrue("Remove returned incorrect value", whm.remove(keyArray[25]) == valueArray[25]);
    assertNull("Remove returned incorrect value", whm.remove(keyArray[25]));
    assertEquals("Size should be 99 after remove", 99, whm.size());
}
Also used : WeakHashMap(java.util.WeakHashMap)

Aggregations

WeakHashMap (java.util.WeakHashMap)65 Map (java.util.Map)19 HashMap (java.util.HashMap)18 TreeMap (java.util.TreeMap)15 IdentityHashMap (java.util.IdentityHashMap)13 AbstractMap (java.util.AbstractMap)12 LinkedHashMap (java.util.LinkedHashMap)12 ICC_ColorSpace (java.awt.color.ICC_ColorSpace)8 ColorTransform (sun.java2d.cmm.ColorTransform)8 PCMM (sun.java2d.cmm.PCMM)8 Hashtable (java.util.Hashtable)6 AttributedString (java.text.AttributedString)5 Properties (java.util.Properties)5 ArrayList (java.util.ArrayList)4 Comparator (java.util.Comparator)4 List (java.util.List)4 TreeSet (java.util.TreeSet)4 WeakReference (java.lang.ref.WeakReference)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 AttributedCharacterIterator (java.text.AttributedCharacterIterator)3