[logback-dev] svn commit: r2392 - in logback/trunk/logback-classic/src: main/java/ch/qos/logback/classic main/java/ch/qos/logback/classic/joran/action main/java/ch/qos/logback/classic/selector/servlet main/java/ch/qos/logback/classic/spi test/input/joran/rolling test/java/ch/qos/logback/classic test/java/ch/qos/logback/classic/html test/java/ch/qos/logback/classic/issue/lbclassic135 test/java/ch/qos/logback/classic/issue/lbclassic135/lbclassic139 test/java/ch/qos/logback/classic/joran test/java/ch/qos/logback/classic/multiJVM test/java/ch/qos/logback/classic/net test/java/ch/qos/logback/classic/net/testObjectBuilders test/java/ch/qos/logback/classic/pattern test/java/ch/qos/logback/classic/rolling test/java/ch/qos/logback/classic/sift test/java/ch/qos/logback/classic/spi
noreply.ceki at qos.ch
noreply.ceki at qos.ch
Fri Jul 31 17:23:40 CEST 2009
Author: ceki
Date: Fri Jul 31 17:23:40 2009
New Revision: 2392
Added:
logback/trunk/logback-classic/src/test/input/joran/rolling/
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/ClassicTestConstants.java
- copied, changed from r2389, /logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/TestConstants.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/rolling/
Removed:
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/TestConstants.java
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/BasicConfigurator.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConsolePluginAction.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/RootLoggerAction.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/ContextDetachingSCL.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerComparator.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/MessageFormattingTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/LoggingToFileThrouhput.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/lbclassic139/Accessor.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/lbclassic139/LB139_DeadlockTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/lbclassic139/Worker.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/multiJVM/FileAppenderPerf.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/multiJVM/SafeModeFileAppender.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/multiJVM/SafeModeRollingFileAppender.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventWithParametersBuilder.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/TrivialLoggingEventBuilder.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverterTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/MDCConverterTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/MarkerConverterTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ThrowableProxyConverterTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/sift/SiftingAppenderTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java
Log:
- replaced references to LoggerContext.ROOT_NAME with references to org.slf4j.Logger.ROOT_LOGGER_NAME
- minor tweaking of LB139_Deadlocktest
- renamed TestConstants as ClassicTestConstants
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/BasicConfigurator.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/BasicConfigurator.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/BasicConfigurator.java Fri Jul 31 17:23:40 2009
@@ -47,7 +47,7 @@
ca.setLayout(pl);
ca.start();
- Logger rootLogger = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
rootLogger.addAppender(ca);
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java Fri Jul 31 17:23:40 2009
@@ -45,8 +45,6 @@
public class LoggerContext extends ContextBase implements ILoggerFactory,
LifeCycle {
- public static final String ROOT_NAME = "root";
-
final Logger root;
private int size;
private int noAppenderWarning = 0;
@@ -72,9 +70,9 @@
super();
this.loggerCache = new Hashtable<String, Logger>();
this.loggerContextRemoteView = new LoggerContextVO(this);
- this.root = new Logger(ROOT_NAME, null, this);
+ this.root = new Logger(Logger.ROOT_LOGGER_NAME, null, this);
this.root.setLevel(Level.DEBUG);
- loggerCache.put(ROOT_NAME, root);
+ loggerCache.put(Logger.ROOT_LOGGER_NAME, root);
putObject(CoreConstants.EVALUATOR_MAP, new HashMap());
size = 1;
}
@@ -114,7 +112,7 @@
// if we are asking for the root logger, then let us return it without
// wasting time
- if (ROOT_NAME.equalsIgnoreCase(name)) {
+ if (Logger.ROOT_LOGGER_NAME.equalsIgnoreCase(name)) {
return root;
}
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConsolePluginAction.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConsolePluginAction.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/ConsolePluginAction.java Fri Jul 31 17:23:40 2009
@@ -38,7 +38,7 @@
appender.setRemoteHost("localhost");
appender.setPort(port.intValue());
appender.start();
- Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
root.addAppender(appender);
addInfo("Sending LoggingEvents to the plugin using port " + port);
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/RootLoggerAction.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/RootLoggerAction.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/joran/action/RootLoggerAction.java Fri Jul 31 17:23:40 2009
@@ -28,7 +28,7 @@
inError = false;
LoggerContext loggerContext = (LoggerContext) this.context;
- root = loggerContext.getLogger(LoggerContext.ROOT_NAME);
+ root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
String levelStr = ec.subst(attributes.getValue(ActionConst.LEVEL_ATTRIBUTE));
if (!OptionHelper.isEmpty(levelStr)) {
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/ContextDetachingSCL.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/ContextDetachingSCL.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/selector/servlet/ContextDetachingSCL.java Fri Jul 31 17:23:40 2009
@@ -41,7 +41,7 @@
ContextSelector selector = StaticLoggerBinder.getSingleton().getContextSelector();
LoggerContext context = selector.detachLoggerContext(loggerContextName);
if (context != null) {
- Logger logger = context.getLogger(LoggerContext.ROOT_NAME);
+ Logger logger = context.getLogger(Logger.ROOT_LOGGER_NAME);
logger.warn("Stopping logger context " + loggerContextName);
// when the web-app is destroyed, its logger context should be stopped
context.stop();
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerComparator.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerComparator.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/spi/LoggerComparator.java Fri Jul 31 17:23:40 2009
@@ -3,7 +3,6 @@
import java.util.Comparator;
import ch.qos.logback.classic.Logger;
-import ch.qos.logback.classic.LoggerContext;
public class LoggerComparator implements Comparator<Logger> {
@@ -11,10 +10,10 @@
if (l1.getName().equals(l2.getName())) {
return 0;
}
- if (l1.getName().equals(LoggerContext.ROOT_NAME)) {
+ if (l1.getName().equals(Logger.ROOT_LOGGER_NAME)) {
return -1;
}
- if (l2.getName().equals(LoggerContext.ROOT_NAME)) {
+ if (l2.getName().equals(Logger.ROOT_LOGGER_NAME)) {
return 1;
}
return l1.getName().compareTo(l2.getName());
Copied: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/ClassicTestConstants.java (from r2389, /logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/TestConstants.java)
==============================================================================
--- /logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/TestConstants.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/ClassicTestConstants.java Fri Jul 31 17:23:40 2009
@@ -9,10 +9,10 @@
*/
package ch.qos.logback.classic;
-public class TestConstants {
+public class ClassicTestConstants {
final static public String ISO_REGEX = "\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2},\\d{3}";
final static public String NAKED_MAIN_REGEX = "[mM]ain(\\sThread)?";
final static public String MAIN_REGEX = "\\["+NAKED_MAIN_REGEX+"\\]";
- final static public String JORAN_ONPUT_PREFIX = "src/test/input/joran";
+ final static public String JORAN_INPUT_PREFIX = "src/test/input/joran";
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerContextTest.java Fri Jul 31 17:23:40 2009
@@ -34,7 +34,7 @@
@Test
public void testRootGetLogger() {
- Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
assertEquals(Level.DEBUG, root.getLevel());
assertEquals(Level.DEBUG, root.getEffectiveLevel());
}
@@ -162,7 +162,7 @@
@Test
public void resetTest() {
- Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
Logger a = lc.getLogger("a");
Logger ab = lc.getLogger("a.b");
@@ -203,7 +203,7 @@
@Test
public void levelResetTest() {
- Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
root.setLevel(Level.TRACE);
assertTrue(root.isTraceEnabled());
lc.reset();
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/LoggerTest.java Fri Jul 31 17:23:40 2009
@@ -27,7 +27,7 @@
public class LoggerTest {
LoggerContext lc = new LoggerContext();
- Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
Logger loggerTest = lc.getLogger(LoggerTest.class);
ListAppender<ILoggingEvent> listAppender = new ListAppender<ILoggingEvent>();
@@ -70,12 +70,12 @@
@Test
public void testRootLogger() {
- Logger logger = (Logger) LoggerFactory.getLogger(LoggerContext.ROOT_NAME);
+ Logger logger = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
LoggerContext lc = logger.getLoggerContext();
assertNotNull("Returned logger is null", logger);
assertEquals("Return logger isn't named root", logger.getName(),
- LoggerContext.ROOT_NAME);
+ Logger.ROOT_LOGGER_NAME);
assertTrue("logger instances should be indentical", logger == lc.root);
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/MessageFormattingTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/MessageFormattingTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/MessageFormattingTest.java Fri Jul 31 17:23:40 2009
@@ -25,7 +25,7 @@
@Before
public void setUp() {
lc = new LoggerContext();
- Logger logger = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger logger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
listAppender = new ListAppender<ILoggingEvent>();
listAppender.setContext(lc);
listAppender.start();
@@ -34,7 +34,7 @@
@Test
public void testFormattingOneArg() {
- Logger logger = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger logger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
logger.debug("{}", new Integer(12));
ILoggingEvent event = (ILoggingEvent) listAppender.list.get(0);
assertEquals("12", event.getFormattedMessage());
@@ -42,7 +42,7 @@
@Test
public void testFormattingTwoArg() {
- Logger logger = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger logger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
logger.debug("{}-{}", new Integer(12), new Integer(13));
ILoggingEvent event = (ILoggingEvent) listAppender.list.get(0);
assertEquals("12-13", event.getFormattedMessage());
@@ -50,7 +50,7 @@
@Test
public void testNoFormatting() {
- Logger logger = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger logger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
logger.debug("test", new Integer(12), new Integer(13));
ILoggingEvent event = (ILoggingEvent) listAppender.list.get(0);
assertEquals("test", event.getFormattedMessage());
@@ -58,7 +58,7 @@
@Test
public void testNoFormatting2() {
- Logger logger = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger logger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
logger.debug("test");
ILoggingEvent event = (ILoggingEvent) listAppender.list.get(0);
assertEquals("test", event.getFormattedMessage());
@@ -66,7 +66,7 @@
@Test
public void testMessageConverter() {
- Logger logger = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger logger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
logger.debug("{}", 12);
ILoggingEvent event = (ILoggingEvent) listAppender.list.get(0);
PatternLayout layout = new PatternLayout();
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/PatternLayoutTest.java Fri Jul 31 17:23:40 2009
@@ -9,8 +9,8 @@
*/
package ch.qos.logback.classic;
-import static ch.qos.logback.classic.TestConstants.ISO_REGEX;
-import static ch.qos.logback.classic.TestConstants.MAIN_REGEX;
+import static ch.qos.logback.classic.ClassicTestConstants.ISO_REGEX;
+import static ch.qos.logback.classic.ClassicTestConstants.MAIN_REGEX;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -38,7 +38,7 @@
private PatternLayout pl = new PatternLayout();
private LoggerContext lc = new LoggerContext();
Logger logger = lc.getLogger(ConverterTest.class);
- Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
ILoggingEvent le;
List optionList = new ArrayList();
@@ -128,7 +128,7 @@
String val = pl.doLayout(getEventObject());
// 2006-02-01 22:38:06,212 INFO [main] c.q.l.pattern.ConverterTest - Some
// message
- String regex = TestConstants.ISO_REGEX + " INFO " + MAIN_REGEX
+ String regex = ClassicTestConstants.ISO_REGEX + " INFO " + MAIN_REGEX
+ " c.q.l.c.pattern.ConverterTest - Some message\\s*";
assertTrue(val.matches(regex));
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/html/HTMLLayoutTest.java Fri Jul 31 17:23:40 2009
@@ -20,7 +20,7 @@
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.TestConstants;
+import ch.qos.logback.classic.ClassicTestConstants;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.classic.spi.DummyThrowableProxy;
import ch.qos.logback.classic.spi.ILoggingEvent;
@@ -53,7 +53,7 @@
layout.setPattern("%level%thread%msg");
layout.start();
appender.setLayout(layout);
- root = lc.getLogger(LoggerContext.ROOT_NAME);
+ root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
root.addAppender(appender);
appender.start();
}
@@ -150,7 +150,7 @@
}
{
Element tdElement = (Element) trElement.elements().get(1);
- String regex = TestConstants.NAKED_MAIN_REGEX;
+ String regex = ClassicTestConstants.NAKED_MAIN_REGEX;
assertTrue(tdElement.getText().toString().matches(regex));
}
{
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/LoggingToFileThrouhput.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/LoggingToFileThrouhput.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/LoggingToFileThrouhput.java Fri Jul 31 17:23:40 2009
@@ -45,7 +45,7 @@
}
static Logger buildLoggerContext(LoggerContext lc) {
- Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
PatternLayout patternLayout = new PatternLayout();
patternLayout.setContext(lc);
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/lbclassic139/Accessor.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/lbclassic139/Accessor.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/lbclassic139/Accessor.java Fri Jul 31 17:23:40 2009
@@ -1,8 +1,17 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ *
+ * Copyright (C) 2000-2009, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
package ch.qos.logback.classic.issue.lbclassic135.lbclassic139;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.contention.RunnableWithCounterAndDone;
/**
@@ -11,20 +20,28 @@
*
*/
public class Accessor extends RunnableWithCounterAndDone {
- private Logger logger = LoggerFactory.getLogger(Accessor.class);
-
+ private Logger logger;
final Worker worker;
+ final LoggerContext loggerContext;
- Accessor(Worker worker) {
+
+ Accessor(Worker worker, LoggerContext lc) {
this.worker = worker;
+ this.loggerContext = lc;
+ logger = lc.getLogger(this.getClass());
}
public void run() {
- System.out.println("enter Accessor.run");
- Thread.yield();
+ print("entered run()");
+ //Thread.yield();
while (!isDone()) {
logger.info("Current worker status is: {}.", worker);
}
- System.out.println("leaving Accessor.run");
+ print("leaving run()");
+ }
+
+ void print(String msg) {
+ String thread = Thread.currentThread().getName();
+ System.out.println("["+thread+"] "+msg);
}
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/lbclassic139/LB139_DeadlockTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/lbclassic139/LB139_DeadlockTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/lbclassic139/LB139_DeadlockTest.java Fri Jul 31 17:23:40 2009
@@ -1,13 +1,25 @@
package ch.qos.logback.classic.issue.lbclassic135.lbclassic139;
+import org.junit.Before;
import org.junit.Test;
+import ch.qos.logback.classic.BasicConfigurator;
+import ch.qos.logback.classic.LoggerContext;
+
public class LB139_DeadlockTest {
+ LoggerContext loggerContext = new LoggerContext();
+
+ @Before
+ public void setUp() {
+ loggerContext.setName("LB139");
+ BasicConfigurator.configure(loggerContext);
+ }
+
@Test(timeout=3000)
public void test() throws Exception {
- Worker worker = new Worker();
- Accessor accessor = new Accessor(worker);
+ Worker worker = new Worker(loggerContext);
+ Accessor accessor = new Accessor(worker, loggerContext);
Thread workerThread = new Thread(worker, "WorkerThread");
Thread accessorThread = new Thread(accessor, "AccessorThread");
@@ -15,8 +27,11 @@
workerThread.start();
accessorThread.start();
- Thread.sleep(1500);
+ int sleep = Worker.SLEEP_DUIRATION*10;
+ System.out.println("Will sleep for "+sleep+" millis");
+ Thread.sleep(sleep);
+ System.out.println("Done sleeping ("+sleep+" millis)");
worker.setDone(true);
accessor.setDone(true);
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/lbclassic139/Worker.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/lbclassic139/Worker.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/issue/lbclassic135/lbclassic139/Worker.java Fri Jul 31 17:23:40 2009
@@ -1,8 +1,17 @@
+/**
+ * Logback: the generic, reliable, fast and flexible logging framework.
+ *
+ * Copyright (C) 2000-2009, QOS.ch
+ *
+ * This library is free software, you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation.
+ */
package ch.qos.logback.classic.issue.lbclassic135.lbclassic139;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.contention.RunnableWithCounterAndDone;
/**
@@ -11,29 +20,51 @@
*
*/
public class Worker extends RunnableWithCounterAndDone {
- private Logger logger = LoggerFactory.getLogger(Worker.class);
-
+ static final int SLEEP_DUIRATION = 50;
+
+ private Logger logger;
private final Object lock = new Object();
+ final LoggerContext loggerContext;
+ Worker(LoggerContext lc) {
+ loggerContext = lc;
+ logger = lc.getLogger(this.getClass());
+ }
+
public void run() {
- System.out.println("enter Worker.run");
+ print("entered run()");
while (!isDone()) {
synchronized (lock) {
- try {
- Thread.sleep(500);
- } catch (InterruptedException exc) {
- }
+ sleep();
logger.info("lock the logger");
}
}
- System.out.println("leaving done");
+ print("leaving run()");
}
@Override
public String toString() {
+ print("In Worker.toString() - about to access lock");
synchronized (lock) {
+ print("In Worker.toString() - got the lock");
+ //sleep();
final StringBuffer buf = new StringBuffer("STATUS");
return buf.toString();
}
}
+
+ public void sleep() {
+ try {
+ print("About to go to sleep");
+ Thread.sleep(SLEEP_DUIRATION);
+ print("just woke up");
+ } catch (InterruptedException exc) {
+ exc.printStackTrace();
+ }
+ }
+
+ void print(String msg) {
+ String thread = Thread.currentThread().getName();
+ System.out.println("["+thread+"] "+msg);
+ }
}
\ No newline at end of file
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/JoranConfiguratorTest.java Fri Jul 31 17:23:40 2009
@@ -37,7 +37,7 @@
LoggerContext loggerContext = new LoggerContext();
Logger logger = loggerContext.getLogger(this.getClass().getName());
- Logger root = loggerContext.getLogger(LoggerContext.ROOT_NAME);
+ Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
void configure(String file) throws JoranException {
JoranConfigurator jc = new JoranConfigurator();
@@ -50,7 +50,7 @@
configure(TeztConstants.TEST_DIR_PREFIX + "input/joran/simpleList.xml");
Logger logger = loggerContext.getLogger(this.getClass().getName());
- Logger root = loggerContext.getLogger(LoggerContext.ROOT_NAME);
+ Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
ListAppender listAppender = (ListAppender) root.getAppender("LIST");
assertEquals(0, listAppender.list.size());
String msg = "hello world";
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/multiJVM/FileAppenderPerf.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/multiJVM/FileAppenderPerf.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/multiJVM/FileAppenderPerf.java Fri Jul 31 17:23:40 2009
@@ -45,7 +45,7 @@
fa.start();
ch.qos.logback.classic.Logger root = loggerContext
- .getLogger(LoggerContext.ROOT_NAME);
+ .getLogger(Logger.ROOT_LOGGER_NAME);
root.addAppender(fa);
return loggerContext;
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/multiJVM/SafeModeFileAppender.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/multiJVM/SafeModeFileAppender.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/multiJVM/SafeModeFileAppender.java Fri Jul 31 17:23:40 2009
@@ -70,7 +70,7 @@
fa.start();
ch.qos.logback.classic.Logger root = loggerContext
- .getLogger(LoggerContext.ROOT_NAME);
+ .getLogger(Logger.ROOT_LOGGER_NAME);
root.addAppender(fa);
return loggerContext;
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/multiJVM/SafeModeRollingFileAppender.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/multiJVM/SafeModeRollingFileAppender.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/multiJVM/SafeModeRollingFileAppender.java Fri Jul 31 17:23:40 2009
@@ -84,7 +84,7 @@
rfa.start();
ch.qos.logback.classic.Logger root = loggerContext
- .getLogger(LoggerContext.ROOT_NAME);
+ .getLogger(Logger.ROOT_LOGGER_NAME);
root.addAppender(rfa);
return loggerContext;
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java Fri Jul 31 17:23:40 2009
@@ -57,7 +57,7 @@
waitForServerToStart();
configureClient();
- Logger logger = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger logger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
logger.debug("test msg");
Thread.sleep(SLEEP_AFTER_LOG);
@@ -78,7 +78,7 @@
waitForServerToStart();
configureClient();
- Logger logger = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger logger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
logger.debug("test msg");
Thread.sleep(SLEEP_AFTER_LOG);
@@ -91,7 +91,7 @@
String loggerName = remoteEvent.getLoggerName();
assertNotNull(loggerName);
- assertEquals("root", loggerName);
+ assertEquals(Logger.ROOT_LOGGER_NAME, loggerName);
LoggerContextVO loggerContextRemoteView = remoteEvent
.getLoggerContextVO();
@@ -107,7 +107,7 @@
waitForServerToStart();
configureClient();
- Logger logger = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger logger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
MDC.put("key", "testValue");
logger.debug("test msg");
@@ -132,7 +132,7 @@
// Thread.sleep(SLEEP_AFTER_SERVER_START);
configureClient();
- Logger logger = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger logger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
Marker marker = MarkerFactory.getMarker("testMarker");
logger.debug(marker, "test msg");
@@ -154,7 +154,7 @@
configureClient();
- Logger logger = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger logger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
MDC.put("key", "testValue");
logger.debug("test msg");
@@ -181,7 +181,7 @@
public void lateServerLaunch() throws InterruptedException {
socketAppender.setReconnectionDelay(20);
configureClient();
- Logger logger = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger logger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
logger.debug("test msg");
fireServer();
@@ -229,7 +229,7 @@
lc = new LoggerContext();
lc.setName("test");
lc.putProperty("testKey", "testValue");
- Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
+ Logger root = lc.getLogger(Logger.ROOT_LOGGER_NAME);
socketAppender.setContext(lc);
socketAppender.setName("socket");
socketAppender.setPort(port);
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketMin.java Fri Jul 31 17:23:40 2009
@@ -16,7 +16,6 @@
import ch.qos.logback.classic.BasicConfigurator;
import ch.qos.logback.classic.Logger;
-import ch.qos.logback.classic.LoggerContext;
public class SocketMin {
@@ -49,7 +48,7 @@
}
static void init(String host, String portStr) {
- Logger root = (Logger) LoggerFactory.getLogger(LoggerContext.ROOT_NAME);
+ Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
BasicConfigurator.configure(root.getLoggerContext());
try {
int port = Integer.parseInt(portStr);
@@ -68,7 +67,7 @@
}
static void loop() {
- Logger root = (Logger) LoggerFactory.getLogger(LoggerContext.ROOT_NAME);
+ Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
InputStreamReader in = new InputStreamReader(System.in);
System.out.println("Type 'q' to quit");
int i;
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SyslogAppenderTest.java Fri Jul 31 17:23:40 2009
@@ -19,7 +19,7 @@
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.TestConstants;
+import ch.qos.logback.classic.ClassicTestConstants;
import ch.qos.logback.classic.joran.JoranConfigurator;
import ch.qos.logback.classic.net.mock.MockSyslogServer;
import ch.qos.logback.core.joran.spi.JoranException;
@@ -142,7 +142,7 @@
JoranConfigurator configurator = new JoranConfigurator();
configurator.setContext(lc);
lc.reset();
- configurator.doConfigure(TestConstants.JORAN_ONPUT_PREFIX
+ configurator.doConfigure(ClassicTestConstants.JORAN_INPUT_PREFIX
+ "/syslog_LBCLASSIC_50.xml");
org.slf4j.Logger logger = LoggerFactory.getLogger(this.getClass());
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventWithParametersBuilder.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventWithParametersBuilder.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/LoggingEventWithParametersBuilder.java Fri Jul 31 17:23:40 2009
@@ -19,7 +19,7 @@
final String MSG = "aaaaabbbbbcccc {} cdddddaaaaabbbbbcccccdddddaaaa {}";
private Logger logger = new LoggerContext()
- .getLogger(LoggerContext.ROOT_NAME);
+ .getLogger(Logger.ROOT_LOGGER_NAME);
public Object build(int i) {
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/TrivialLoggingEventBuilder.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/TrivialLoggingEventBuilder.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/testObjectBuilders/TrivialLoggingEventBuilder.java Fri Jul 31 17:23:40 2009
@@ -17,7 +17,7 @@
public class TrivialLoggingEventBuilder implements Builder {
private Logger logger = new LoggerContext()
- .getLogger(LoggerContext.ROOT_NAME);
+ .getLogger(Logger.ROOT_LOGGER_NAME);
public Object build(int i) {
LoggingEvent le = new LoggingEvent();
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ConverterTest.java Fri Jul 31 17:23:40 2009
@@ -25,7 +25,7 @@
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
-import ch.qos.logback.classic.TestConstants;
+import ch.qos.logback.classic.ClassicTestConstants;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.CoreConstants;
@@ -96,7 +96,7 @@
DynamicConverter<ILoggingEvent> converter = new ThreadConverter();
StringBuffer buf = new StringBuffer();
converter.write(buf, le);
- String regex = TestConstants.NAKED_MAIN_REGEX;
+ String regex = ClassicTestConstants.NAKED_MAIN_REGEX;
assertTrue(buf.toString().matches(regex));
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverterTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverterTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ExtendedThrowableProxyConverterTest.java Fri Jul 31 17:23:40 2009
@@ -22,6 +22,7 @@
import org.junit.Test;
import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.PatternLayout;
import ch.qos.logback.classic.spi.ILoggingEvent;
@@ -46,7 +47,7 @@
private ILoggingEvent createLoggingEvent(Throwable t) {
ILoggingEvent le = new LoggingEvent(this.getClass().getName(), lc
- .getLogger(LoggerContext.ROOT_NAME), Level.DEBUG, "test message", t,
+ .getLogger(Logger.ROOT_LOGGER_NAME), Level.DEBUG, "test message", t,
null);
return le;
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/MDCConverterTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/MDCConverterTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/MDCConverterTest.java Fri Jul 31 17:23:40 2009
@@ -8,6 +8,7 @@
import org.slf4j.MDC;
import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.LoggingEvent;
@@ -57,7 +58,7 @@
private ILoggingEvent createLoggingEvent() {
ILoggingEvent le = new LoggingEvent(this.getClass().getName(), lc
- .getLogger(LoggerContext.ROOT_NAME), Level.DEBUG, "test message", null,
+ .getLogger(Logger.ROOT_LOGGER_NAME), Level.DEBUG, "test message", null,
null);
return le;
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/MarkerConverterTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/MarkerConverterTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/MarkerConverterTest.java Fri Jul 31 17:23:40 2009
@@ -10,6 +10,7 @@
import org.slf4j.helpers.BasicMarkerFactory;
import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.LoggingEvent;
@@ -72,7 +73,7 @@
}
private ILoggingEvent createLoggingEvent(Marker marker) {
- LoggingEvent le = new LoggingEvent(this.getClass().getName(), lc.getLogger(LoggerContext.ROOT_NAME),
+ LoggingEvent le = new LoggingEvent(this.getClass().getName(), lc.getLogger(Logger.ROOT_LOGGER_NAME),
Level.DEBUG, "test message", null, null);
le.setMarker(marker);
return le;
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ThrowableProxyConverterTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ThrowableProxyConverterTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/pattern/ThrowableProxyConverterTest.java Fri Jul 31 17:23:40 2009
@@ -10,6 +10,7 @@
import org.junit.Test;
import ch.qos.logback.classic.Level;
+import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.LoggingEvent;
@@ -34,7 +35,7 @@
private ILoggingEvent createLoggingEvent(Throwable t) {
ILoggingEvent le = new LoggingEvent(this.getClass().getName(), lc
- .getLogger(LoggerContext.ROOT_NAME), Level.DEBUG, "test message", t,
+ .getLogger(Logger.ROOT_LOGGER_NAME), Level.DEBUG, "test message", t,
null);
return le;
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/sift/SiftingAppenderTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/sift/SiftingAppenderTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/sift/SiftingAppenderTest.java Fri Jul 31 17:23:40 2009
@@ -37,7 +37,7 @@
LoggerContext loggerContext = new LoggerContext();
Logger logger = loggerContext.getLogger(this.getClass().getName());
- Logger root = loggerContext.getLogger(LoggerContext.ROOT_NAME);
+ Logger root = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
void configure(String file) throws JoranException {
JoranConfigurator jc = new JoranConfigurator();
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/spi/LoggingEventSerializationTest.java Fri Jul 31 17:23:40 2009
@@ -37,7 +37,7 @@
public void setUp() throws Exception {
lc = new LoggerContext();
lc.setName("testContext");
- logger = lc.getLogger(LoggerContext.ROOT_NAME);
+ logger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
// create the byte output stream
bos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(bos);
@@ -65,7 +65,7 @@
checkForEquality(event, remoteEvent);
assertNotNull(remoteEvent.getLoggerName());
- assertEquals("root", remoteEvent.getLoggerName());
+ assertEquals(Logger.ROOT_LOGGER_NAME, remoteEvent.getLoggerName());
LoggerContextVO loggerContextRemoteView = remoteEvent.getLoggerContextVO();
assertNotNull(loggerContextRemoteView);
More information about the logback-dev
mailing list