Search in sources :

Example 16 with AbstractMap

use of java.util.AbstractMap in project j2objc by google.

the class AbstractMapTest method test_containsKey.

/**
     * @tests java.util.AbstractMap#containsKey(Object)
     */
public void test_containsKey() {
    AbstractMap map = new AMT();
    assertFalse(map.containsKey("k"));
    assertFalse(map.containsKey(null));
    map.put("k", "v");
    map.put("key", null);
    map.put(null, "value");
    map.put(null, null);
    assertTrue(map.containsKey("k"));
    assertTrue(map.containsKey("key"));
    assertTrue(map.containsKey(null));
}
Also used : AbstractMap(java.util.AbstractMap)

Example 17 with AbstractMap

use of java.util.AbstractMap in project j2objc by google.

the class AbstractMapTest method test_keySet.

/**
     * @tests java.util.AbstractMap#keySet()
     */
public void test_keySet() {
    AbstractMap map1 = new HashMap(0);
    assertSame("HashMap(0)", map1.keySet(), map1.keySet());
    AbstractMap map2 = new HashMap(10);
    assertSame("HashMap(10)", map2.keySet(), map2.keySet());
    Map map3 = Collections.EMPTY_MAP;
    assertSame("EMPTY_MAP", map3.keySet(), map3.keySet());
    AbstractMap map4 = new IdentityHashMap(1);
    assertSame("IdentityHashMap", map4.keySet(), map4.keySet());
    AbstractMap map5 = new LinkedHashMap(122);
    assertSame("LinkedHashMap", map5.keySet(), map5.keySet());
    AbstractMap map6 = new TreeMap();
    assertSame("TreeMap", map6.keySet(), map6.keySet());
}
Also used : AbstractMap(java.util.AbstractMap) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IdentityHashMap(java.util.IdentityHashMap) TreeMap(java.util.TreeMap) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) AbstractMap(java.util.AbstractMap) TreeMap(java.util.TreeMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 18 with AbstractMap

use of java.util.AbstractMap in project j2objc by google.

the class AbstractMapTest method test_values.

/**
     * @tests java.util.AbstractMap#values()
     */
public void test_values() {
    AbstractMap map1 = new HashMap(0);
    assertSame("HashMap(0)", map1.values(), map1.values());
    AbstractMap map2 = new HashMap(10);
    assertSame("HashMap(10)", map2.values(), map2.values());
    Map map3 = Collections.EMPTY_MAP;
    assertSame("EMPTY_MAP", map3.values(), map3.values());
    AbstractMap map4 = new IdentityHashMap(1);
    assertSame("IdentityHashMap", map4.values(), map4.values());
    AbstractMap map5 = new LinkedHashMap(122);
    assertSame("IdentityHashMap", map5.values(), map5.values());
    AbstractMap map6 = new TreeMap();
    assertSame("TreeMap", map6.values(), map6.values());
}
Also used : AbstractMap(java.util.AbstractMap) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IdentityHashMap(java.util.IdentityHashMap) TreeMap(java.util.TreeMap) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) AbstractMap(java.util.AbstractMap) TreeMap(java.util.TreeMap) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap)

Example 19 with AbstractMap

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

the class IdentityHashMapTest method test_clone.

/**
     * java.util.IdentityHashMap#clone()
     */
public void test_clone() {
    // Test for method java.lang.Object java.util.IdentityHashMap.clone()
    IdentityHashMap hm2 = (IdentityHashMap) hm.clone();
    assertTrue("Clone answered equivalent IdentityHashMap", hm2 != hm);
    for (int counter = 0; counter < hmSize; counter++) assertTrue("Clone answered unequal IdentityHashMap", hm.get(objArray2[counter]) == hm2.get(objArray2[counter]));
    IdentityHashMap map = new IdentityHashMap();
    map.put("key", "value");
    // get the keySet() and values() on the original Map
    Set keys = map.keySet();
    Collection values = map.values();
    assertEquals("values() does not work", "value", values.iterator().next());
    assertEquals("keySet() does not work", "key", keys.iterator().next());
    AbstractMap map2 = (AbstractMap) map.clone();
    map2.put("key", "value2");
    Collection values2 = map2.values();
    assertTrue("values() is identical", values2 != values);
    // values() and keySet() on the cloned() map should be different
    assertEquals("values() was not cloned", "value2", values2.iterator().next());
    map2.clear();
    map2.put("key2", "value3");
    Set key2 = map2.keySet();
    assertTrue("keySet() is identical", key2 != keys);
    assertEquals("keySet() was not cloned", "key2", key2.iterator().next());
}
Also used : AbstractMap(java.util.AbstractMap) Set(java.util.Set) IdentityHashMap(java.util.IdentityHashMap) Collection(java.util.Collection)

Example 20 with AbstractMap

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

the class AbstractMapTest method test_removeLjava_lang_Object.

/**
     * java.util.AbstractMap#remove(java.lang.Object)
     */
public void test_removeLjava_lang_Object() {
    Object key = new Object();
    Object value = new Object();
    AbstractMap map1 = new HashMap(0);
    map1.put("key", value);
    assertSame("HashMap(0)", map1.remove("key"), value);
    AbstractMap map4 = new IdentityHashMap(1);
    map4.put(key, value);
    assertSame("IdentityHashMap", map4.remove(key), value);
    AbstractMap map5 = new LinkedHashMap(122);
    map5.put(key, value);
    assertSame("LinkedHashMap", map5.remove(key), value);
    AbstractMap map6 = new TreeMap(new Comparator() {

        // Bogus comparator
        public int compare(Object object1, Object object2) {
            return 0;
        }
    });
    map6.put(key, value);
    assertSame("TreeMap", map6.remove(key), value);
    AbstractMap map7 = new WeakHashMap();
    map7.put(key, value);
    assertSame("WeakHashMap", map7.remove(key), value);
    AbstractMap aSpecialMap = new MyMap();
    aSpecialMap.put(specialKey, specialValue);
    Object valueOut = aSpecialMap.remove(specialKey);
    assertSame("MyMap", valueOut, specialValue);
}
Also used : AbstractMap(java.util.AbstractMap) IdentityHashMap(java.util.IdentityHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) WeakHashMap(java.util.WeakHashMap) IdentityHashMap(java.util.IdentityHashMap) TreeMap(java.util.TreeMap) LinkedHashMap(java.util.LinkedHashMap) Comparator(java.util.Comparator) WeakHashMap(java.util.WeakHashMap)

Aggregations

AbstractMap (java.util.AbstractMap)23 LinkedHashMap (java.util.LinkedHashMap)14 HashMap (java.util.HashMap)13 IdentityHashMap (java.util.IdentityHashMap)13 TreeMap (java.util.TreeMap)12 Map (java.util.Map)8 WeakHashMap (java.util.WeakHashMap)8 Collection (java.util.Collection)5 Set (java.util.Set)5 Comparator (java.util.Comparator)3 Decorator (javax.enterprise.inject.spi.Decorator)1 InjectionPoint (javax.enterprise.inject.spi.InjectionPoint)1 Analyzer (org.apache.lucene.analysis.Analyzer)1 IndexSettings (org.elasticsearch.index.IndexSettings)1 IndexAnalyzers (org.elasticsearch.index.analysis.IndexAnalyzers)1 NamedAnalyzer (org.elasticsearch.index.analysis.NamedAnalyzer)1 MapperService (org.elasticsearch.index.mapper.MapperService)1 SimilarityService (org.elasticsearch.index.similarity.SimilarityService)1 CurrentInjectionPoint (org.jboss.weld.injection.CurrentInjectionPoint)1 EmptyInjectionPoint (org.jboss.weld.injection.EmptyInjectionPoint)1