Code example for Attributes

Methods: getValue, put

0
 
    /** 
     * @tests java.util.jar.Attributes.put(java.lang.Object, java.lang.Object) 
     */ 
    public void test_putLjava_lang_ObjectLjava_lang_Object() { 
        Attributes atts = new Attributes();
        assertNull("Assert 0: ", atts.put(Attributes.Name.CLASS_PATH,
                "tools.jar")); 
        assertEquals("Assert 1: ", "tools.jar", atts
                .getValue(Attributes.Name.CLASS_PATH));
        // Regression for HARMONY-79 
        try { 
            atts.put("not a name", "value");
            fail("Assert 2: no class cast from key parameter");
        } catch (ClassCastException e) {
            // Expected 
        } 
        try { 
            atts.put(Attributes.Name.CLASS_PATH, Boolean.TRUE);
            fail("Assert 3: no class cast from value parameter");
        } catch (ClassCastException e) {
            // Expected 
        } 
    }