Examples of MockHandler


Examples of org.jzonic.jlo.handler.MockHandler

        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

Examples of org.jzonic.jlo.handler.MockHandler

        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

Examples of org.jzonic.jlo.handler.MockHandler

        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

Examples of org.jzonic.jlo.handler.MockHandler

        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

Examples of org.jzonic.jlo.handler.MockHandler

        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

Examples of org.jzonic.jlo.handler.MockHandler

    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

Examples of org.jzonic.jlo.handler.MockHandler

    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

Examples of org.jzonic.jlo.handler.MockHandler

        assertEquals(1,lc.getLoggerCount());
        assertNotNull(lc.getLogger("org.jzonic.jlo"));
    }
   
    public void testAddLogGenerator() {
        Handler fileHandler = new MockHandler("Test");
        Formatter simpleFormatter = new SimpleFormatter("Test");       
        LogGenerator lg = new LogGenerator("TestGenerator", fileHandler, simpleFormatter);       
        lc.addLogGenerator(lg);
        assertEquals(1,lc.getLogGeneratorCount());
    }
View Full Code Here

Examples of org.jzonic.jlo.handler.MockHandler

        TestSuite suite = new TestSuite(LogPipeTest.class);
        return suite;
    }
   
    public void testSimpleLogging() {
        MockHandler mockHandler = getFreshHandler("TestGenerator");
        MockHandler pipeHandler = getFreshHandler("PipeGenerator");
        Logger logger = LogManager.getLogger("org.jzonic.jlo");       
        logger.info("debug message");
        Vector entries = mockHandler.getMessages();       
        assertEquals(1,entries.size());
        entries = pipeHandler.getMessages();
        assertEquals(1,entries.size());
        logger.info("Exception is coming here");
        entries = mockHandler.getMessages();
        assertEquals(2,entries.size());
        entries = pipeHandler.getMessages();
        assertEquals(3,entries.size());
    }
View Full Code Here

Examples of org.jzonic.jlo.handler.MockHandler

    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
TOP
Copyright © 2018 www.massapi.com. 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.