Package org.apache.commons.collections.map

Examples of org.apache.commons.collections.map.ReferenceMap.containsKey()


    @Test
    public void testReferenceMap_shouldWork() throws Exception {
        ReferenceMap map = new ReferenceMap(AbstractReferenceMap.HARD, AbstractReferenceMap.WEAK);
        Object referent = new Object();
        map.put("42", referent);
        assertThat(map.containsKey("42"), is(true));
        assertThat(map.get("42"), sameInstance(referent));
        referent = null;
        System.gc();
        assertThat(map.containsKey("42"), is(false));
        assertThat(map.get("42"), nullValue());
View Full Code Here


        map.put("42", referent);
        assertThat(map.containsKey("42"), is(true));
        assertThat(map.get("42"), sameInstance(referent));
        referent = null;
        System.gc();
        assertThat(map.containsKey("42"), is(false));
        assertThat(map.get("42"), nullValue());
    }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.