Package org.jzonic.jlo.handler

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


        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

    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 LoggerTest(java.lang.String testName) {
        super(testName);
    }
   
    public void setUp() throws Exception {
        mockHandler = new MockHandler("Test");
        LogGenerator lg = new LogGenerator("test", mockHandler, new SimpleFormatter("Test"));
        logger = new Logger("test",255,"Test");
        logger.addLogGenerator(lg);
        channel = new Channel("debug",lg,true);       
        testLogger = new Logger("test2",Target.warn.intValue(),"Test");
View Full Code Here

        TestSuite suite = new TestSuite(TestConfigLoggerTest.class);
        return suite;
    }
   
    public void testSimpleLogging() {
        MockHandler mockHandler = getFreshHandler("TestGenerator");
        Logger logger = LogManager.getLogger("de.xcom","test");       
        logger.debug("debug message");
        Vector entries = mockHandler.getMessages();
        assertEquals(1,entries.size());
    }
View Full Code Here

        Vector entries = mockHandler.getMessages();
        assertEquals(1,entries.size());
    }
   
    public void testSimpleLoggingTargetOff() {
        MockHandler mockHandler = getFreshHandler("TestGenerator");
        Logger logger = LogManager.getLogger("de.xcom","test");
        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("timing","test");
        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("de.xcom","test");       
        testLogger.trace("Hello world");
        assertEquals(1,mockHandler.getMessages().size());
        testLogger.info("Hello world");
        assertEquals(2,mockHandler.getMessages().size());
        testLogger.debug("Hello world");
        assertEquals(3,mockHandler.getMessages().size());
        testLogger.warn("Hello world");
        assertEquals(4,mockHandler.getMessages().size());
        testLogger.error("Hello world");
        assertEquals(5,mockHandler.getMessages().size());
        testLogger.fatal("Hello world");
        assertEquals(6,mockHandler.getMessages().size());
    }
View Full Code Here

        testLogger.fatal("Hello world");
        assertEquals(6,mockHandler.getMessages().size());
    }
   
    public void testLogger2Loggable() {
        MockHandler mockHandler = getFreshHandler("TestGenerator");
        Logger testLogger = LogManager.getLogger("de.xcom.test","test");
        boolean test = testLogger.isTraceEnabled();
        assertEquals(true, test);
        test = testLogger.isInfoEnabled();
        assertEquals(false, test);
View Full Code Here

    private MockHandler getFreshHandler(String handlerName) {
        LogConfiguration config = manager.getLogConfiguration("test");
        assertNotNull(config);
        LogGenerator lg = config.getLogGenerator(handlerName);
        assertNotNull(lg);
        MockHandler mockHandler = (MockHandler)lg.getHandler();
        assertNotNull(mockHandler);
        mockHandler.clear();
        return mockHandler;
    }
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.