Code example for WeakHashMap

Methods: put, remove, size

0
	 * @tests java.util.WeakHashMap#put(java.lang.Object, java.lang.Object) 
	 */ 
	public void test_putLjava_lang_ObjectLjava_lang_Object() { 
		// Test for method java.lang.Object 
		// java.util.WeakHashMap.put(java.lang.Object, java.lang.Object) 
		WeakHashMap map = new WeakHashMap();
		map.put(null, "value"); // add null key
		System.gc();
		System.runFinalization();
		map.remove("nothing"); // Cause objects in queue to be removed
		assertEquals("null key was removed", 1, map.size());
	} 
 
    /** 
     * @tests 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());