Code example for TreeMap

Methods: clear, entrySet, put

0
        new AbstractMap.SimpleImmutableEntry<Integer, String>(1,"test"); 
        new AbstractMap.SimpleImmutableEntry(null,null);         
    } 
     
    public void test_SimpleImmutableEntry_Constructor_LEntry() throws Exception { 
        Map map = new TreeMap(); 
        map.put(1, "test"); 
        Entry entryToPut = (Entry)map.entrySet().iterator().next(); 
        Entry testEntry = new AbstractMap.SimpleImmutableEntry(entryToPut); 
        assertEquals(1,testEntry.getKey()); 
        assertEquals("test",testEntry.getValue()); 
        map.clear(); 
        map.put(null, null); 
        entryToPut = (Entry)map.entrySet().iterator().next(); 
        testEntry = new AbstractMap.SimpleImmutableEntry(entryToPut); 
        assertNull(testEntry.getKey()); 
        assertNull(testEntry.getValue()); 
        try { 
            new AbstractMap.SimpleImmutableEntry(null); 
            fail("Should throw NullPointerException"); 
        } catch (NullPointerException e) {