Package org.jzonic.jlo.handler

Examples of org.jzonic.jlo.handler.MockHandler


   
    public void testLogging() {       
        Logger logger = LogManager.getLogger("org.jzonic.jlo");
        logger.info("Hello");
        LogGenerator lg = (LogGenerator)logger.getLogGenerators().get(0);
        MockHandler handler = (MockHandler)lg.getHandler();
        assertEquals(1,handler.getMessages().size());                      
    }  
View Full Code Here


    public MockReader() {
    }
   
    public LogConfiguration parseConfiguration(String name) throws ReaderException {
        LogConfiguration lc = new LogConfiguration("Test");
        Handler handler = new MockHandler("Test");
        Formatter simpleFormatter = new SimpleFormatter("Test");        
        LogGenerator lg = new LogGenerator("org.jzonic.jlo", handler, simpleFormatter);
        Logger logger = new Logger("org.jzonic.jlo", Target.parse("ALL"),"Test");
        logger.addLogGenerator(lg);
        lc.addLogger( logger );
View Full Code Here

        TestSuite suite = new TestSuite(CompleteLoggerTest.class);
        return suite;
    }
   
    public void testSimpleLogging() {
        MockHandler mockHandler = getFreshHandler("TestGenerator");
        Logger logger = LogManager.getLogger("org.jzonic.jlo");       
        logger.debug("debug message");
        Vector entries = mockHandler.getMessages();
        assertEquals(2,entries.size());
    }
View Full Code Here

        Vector entries = mockHandler.getMessages();
        assertEquals(2,entries.size());
    }
   
    public void testSimpleLoggingTargetOff() {
        MockHandler mockHandler = getFreshHandler("TestGenerator");
        Logger logger = LogManager.getLogger("org.jzonic.jlo");
        int targets = logger.getTargets();       
        logger.setTargets(0);
        logger.debug("debug message");       
        Vector entries = mockHandler.getMessages();
        assertEquals(0,entries.size());
        logger.setTargets(targets);
    }
View Full Code Here

        assertEquals(0,entries.size());
        logger.setTargets(targets);
    }
   
    public void testChannel() {       
        MockHandler mockHandler = getFreshHandler("TestGenerator");
        Channel channel = LogManager.getChannel("debug");
        channel.log("debug message");       
        Vector entries = mockHandler.getMessages();
        assertEquals(1,entries.size());
    }
View Full Code Here

        Vector entries = mockHandler.getMessages();
        assertEquals(1,entries.size());
    }
       
    public void testLogger2() {     
        MockHandler mockHandler = getFreshHandler("TestGenerator");
        Logger testLogger = LogManager.getLogger("org.jzonic.jlo");       
        testLogger.trace("Hello world");
        assertEquals(1,mockHandler.getMessages().size());
        testLogger.info("Hello world");
        assertEquals(2,mockHandler.getMessages().size());
        testLogger.debug("Hello world");
        assertEquals(4,mockHandler.getMessages().size());
        testLogger.warn("Hello world");
        assertEquals(5,mockHandler.getMessages().size());
        testLogger.error("Hello world");
        assertEquals(6,mockHandler.getMessages().size());
        testLogger.fatal("Hello world");
        assertEquals(7,mockHandler.getMessages().size());
    }
View Full Code Here

        test = testLogger.isFatalEnabled();
        assertEquals(true, test);
    }
   
    public void testLoggerWithFilter() {
        MockHandler mockHandler = getFreshHandler("TestGenerator2");
        Logger logger = LogManager.getLogger("org.jzonic");
        logger.debug("hello world");
        assertEquals(0,mockHandler.getMessages().size());
        logger.debug("Exception");
        assertEquals(1,mockHandler.getMessages().size());
    }
View Full Code Here

        logger.debug("Exception");
        assertEquals(1,mockHandler.getMessages().size());
    }
   
    public void testLoggerWithRegExFilter() {
        MockHandler mockHandler = getFreshHandler("TestGenerator");
        Logger logger = LogManager.getLogger("org.jzonic.filter");
        logger.debug("hello world");
        assertEquals(0,mockHandler.getMessages().size());
        logger.debug("This is 1.2 text");
        assertEquals(2,mockHandler.getMessages().size());
    }
View Full Code Here

    private MockHandler getFreshHandler(String handlerName) {
        LogConfiguration config = manager.getLogConfiguration();
        assertNotNull(config);
        LogGenerator lg = config.getLogGenerator(handlerName);
        assertNotNull(lg);
        MockHandler mockHandler = (MockHandler)lg.getHandler();
        mockHandler.clear();
        return mockHandler;
    }
View Full Code Here

    public void setUp() throws Exception {
        lc = new LogConfiguration("Test");
    }
   
    public void testAddLogger() {
        Handler fileHandler = new MockHandler("Test");
        Formatter simpleFormatter = new SimpleFormatter("Test");       
        LogGenerator lg = new LogGenerator("TestGenerator", fileHandler, simpleFormatter);
        Logger logger = new Logger("org.jzonic.jlo", Target.parse("ALL"),"Default");
        logger.addLogGenerator(lg);
        lc.addLogger(logger);
View Full Code Here

TOP

Related Classes of org.jzonic.jlo.handler.MockHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.