Index: lutinutil/src/test/org/codelutin/util/LogTest.java diff -u /dev/null lutinutil/src/test/org/codelutin/util/LogTest.java:1.1 --- /dev/null Thu Aug 12 17:44:36 2004 +++ lutinutil/src/test/org/codelutin/util/LogTest.java Thu Aug 12 17:44:31 2004 @@ -0,0 +1,103 @@ +/* *##% + * Copyright (C) 2002, 2003 Code Lutin, Cédric Pineau, + Benjamin Poussin + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *##%*/ + +/* * + * LogTest.java + * + * Created: 12 août 2004 + * + * @author Benjamin Poussin + * @version $Revision: 1.1 $ + * + * Mise a jour: $Date: 2004/08/12 17:44:31 $ + * par : $Author: bpoussin $ + */ + +package org.codelutin.util; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; +import junit.framework.TestResult; +import java.util.ArrayList; +import java.io.File; +import java.net.URLClassLoader; + +public class LogTest extends TestCase { // LogTest + + protected int callTest = 0; + protected int callAll = 0; + + public class LogListenerTest implements Log.LogListener { + boolean all = false; + public LogListenerTest(boolean all){ + this.all = all; + } + public void logSend(Log.LogEvent e){ + if(all) callAll++; + else callTest++; + } + } + + public void testLog() throws Exception { + LogListenerTest ltest = new LogListenerTest(false); + LogListenerTest lall = new LogListenerTest(true); + + Log.addLogListener(lall); + Log.addLogListener(ltest, "TEST"); + + assertEquals(callTest, 0); + assertEquals(callAll, 0); + + Log.logUserInfo("TEST", "coucou"); + + assertEquals(callTest, 1); + assertEquals(callAll, 1); + + Log.logUserInfo("OTHERTEST", "coucou"); + + assertEquals(callTest, 1); + assertEquals(callAll, 2); + + Log.removeLogListener(lall); + Log.logUserInfo("TEST", "coucou"); + + assertEquals(callTest, 2); + assertEquals(callAll, 2); + + Log.logUserInfo("OTHERTEST", "coucou"); + + assertEquals(callTest, 2); + assertEquals(callAll, 2); + + Log.removeLogListener(ltest, "TEST"); + Log.logUserInfo("TEST", "coucou"); + + assertEquals(callTest, 2); + assertEquals(callAll, 2); + + Log.addLogListener(lall); + Log.logUserInfo("TEST", "coucou"); + + assertEquals(callTest, 2); + assertEquals(callAll, 3); + } + +} // LogTest +