Java 8 MemoryHandler - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 MemoryHandler class.

This code example shows how to use the following methods:getEncoding, getErrorManager, getFilter, getFormatter, getLevel
        assertTrue(handler.isLoggable(new LogRecord(Level.WARNING, "2")));
        assertTrue(handler.isLoggable(new LogRecord(Level.SEVERE, "3")));
    } 
 
    public void testMemoryHandler() throws IOException { 
        assertNotNull("Filter should not be null", handler.getFilter());
        assertNotNull("Formatter should not be null", handler.getFormatter());
        assertNull("character encoding should be null", handler.getEncoding());
        assertNotNull("ErrorManager should not be null", handler.getErrorManager());
        assertEquals("Level should be FINE", Level.FINE, handler.getLevel());
        assertEquals("Level should be WARNING", Level.WARNING, handler.getPushLevel());
    } 
 
    public static class MockFilter implements Filter {
        public boolean isLoggable(LogRecord record) {
            return !record.getMessage().equals("false");
        } 
    } 
 
    public static class MockHandler extends Handler {
7
CodeRank
This code example shows how to use the following methods:getEncoding, getErrorManager, getFilter, getFormatter, getLevel
		props.put("java.util.logging.MemoryHandler.target", baseClassName
				+ "$MockHandler"); 
 
		manager.readConfiguration(EnvironmentHelper
				.PropertiesToInputStream(props));
		handler = new MemoryHandler();
		assertNull(handler.getFilter());
		assertTrue(handler.getFormatter() instanceof SimpleFormatter);
		assertNull(handler.getEncoding());
		assertNotNull(handler.getErrorManager());
		assertEquals(handler.getLevel(), Level.ALL);
		assertEquals(handler.getPushLevel(), Level.SEVERE);
	} 
 
	/* 
	 * Class under test for void MemoryHandler(Handler, int, Level) 
	 */ 
	public void testMemoryHandlerHandlerintLevel() { 
		handler = new MemoryHandler(target, 2, Level.FINEST);
		assertTrue(handler.getFilter() instanceof MockFilter);
6
CodeRank
This code example shows how to use the following methods:getEncoding, getErrorManager, getFilter, getFormatter, getLevel
 
	/* 
	 * Class under test for void MemoryHandler() 
	 */ 
	public void testMemoryHandler() { 
		assertTrue(handler.getFilter() instanceof MockFilter);
		assertTrue(handler.getFormatter() instanceof MockFormatter);
		assertNull(handler.getEncoding());
		assertNotNull(handler.getErrorManager());
		assertEquals(handler.getLevel(), Level.FINE);
		assertEquals(handler.getPushLevel(), Level.WARNING);
	} 
 
	public void testMemoryHandlerInvalidProps() throws IOException { 
		// null target 
		try { 
			props.remove("java.util.logging.MemoryHandler.target");
			manager.readConfiguration(EnvironmentHelper
					.PropertiesToInputStream(props));
			handler = new MemoryHandler();
6
CodeRank
See Code Examples for Java 8 MemoryHandler Methods: