Code example for Properties

Methods: clear, put, store

0
    protected void setUp() throws Exception { 
        super.setUp(); 
        manager.reset();
 
        //initProp 
        props.clear();
        props.put("java.util.logging.FileHandler.level", "FINE");
        props.put("java.util.logging.FileHandler.filter", className
                + "$MockFilter"); 
        props.put("java.util.logging.FileHandler.formatter", className
                + "$MockFormatter"); 
        props.put("java.util.logging.FileHandler.encoding", "iso-8859-1");
        // limit to only two message 
        props.put("java.util.logging.FileHandler.limit", "1000");
        // rotation count is 2 
        props.put("java.util.logging.FileHandler.count", "2");
        // using append mode 
        props.put("java.util.logging.FileHandler.append", "true");
        props.put("java.util.logging.FileHandler.pattern",
                        "%t/log/java%u.test"); 
 
        HOMEPATH = System.getProperty("user.home");
        TEMPPATH = System.getProperty("java.io.tmpdir");
 
        File file = new File(TEMPPATH + SEP + "log");
        file.mkdir();
        manager.readConfiguration(propertiesToInputStream(props));
        handler = new FileHandler();
        r = new LogRecord(Level.CONFIG, "msg");
    } 
 
    protected void tearDown() throws Exception { 
        if (null != handler) {
            handler.close();
        } 
        reset(TEMPPATH + SEP + "log", "");
        // RoboVM note: Since we run the tests in the same process (and Android apparently doesn't) 
        // we need to clear the allLocks Map in FileHandler for all tests in here to succeed. 
        java.lang.reflect.Field f = FileHandler.class.getDeclaredField("allLocks");
        f.setAccessible(true);
        ((java.util.Map) f.get(null)).clear();
        super.tearDown(); 
    } 
 
    public static InputStream propertiesToInputStream(Properties p) throws IOException {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        p.store(bos, "");
        return new ByteArrayInputStream(bos.toByteArray());
    } 
 
    public void testFileHandler() throws Exception { 
        assertEquals("character encoding is non equal to actual value",