Code example for AbstractMap.SimpleImmutableEntry

0
    public void test_SimpleImmutableEntry_equals() throws Exception { 
        Entry entry = new AbstractMap.SimpleImmutableEntry<Integer, String>(1,"test");
        Map map = new TreeMap();
        map.put(1, "test");
        Entry entryToPut = (Entry)map.entrySet().iterator().next();
        Entry testEntry = new AbstractMap.SimpleImmutableEntry(entryToPut);
        assertEquals(entry,testEntry);
    } 
     
    public void test_SimpleImmutableEntry_hashCode() throws Exception { 
        Entry e = new AbstractMap.SimpleImmutableEntry<Integer, String>(1, "test");
        assertEquals((e.getKey() == null ? 0 : e.getKey().hashCode())
                ^ (e.getValue() == null ? 0 : e.getValue().hashCode()), e
                .hashCode());
    } 
     
    public void test_SimpleImmutableEntry_toString() throws Exception { 
        Entry e = new AbstractMap.SimpleImmutableEntry<Integer, String>(1, "test");
        assertEquals(e.getKey()+"="+e.getValue(),e.toString());
        Object array =Array.newInstance((byte[].class).getComponentType(), 10);
        assertEquals(10,((byte[])array).length);