[logback-dev] svn commit: r1611 - in logback/trunk: . logback-access logback-access/src/main/java/ch/qos/logback/access/tomcat logback-classic/src/main/java/ch/qos/logback/classic logback-classic/src/test/java/ch/qos/logback/classic logback-classic/src/test/java/ch/qos/logback/classic/control logback-classic/src/test/java/ch/qos/logback/classic/db logback-classic/src/test/java/ch/qos/logback/classic/joran logback-classic/src/test/java/ch/qos/logback/classic/net logback-classic/src/test/java/ch/qos/logback/classic/util logback-core/src/main/java/ch/qos/logback/core logback-core/src/main/java/ch/qos/logback/core/joran/action logback-core/src/main/java/ch/qos/logback/core/joran/spi logback-core/src/main/java/ch/qos/logback/core/util logback-core/src/test/java/ch/qos/logback/core/joran/action logback-core/src/test/java/ch/qos/logback/core/joran/replay logback-core/src/test/java/ch/qos/logback/core/util
noreply.ceki at qos.ch
noreply.ceki at qos.ch
Fri Jan 25 17:13:13 CET 2008
Author: ceki
Date: Fri Jan 25 17:13:12 2008
New Revision: 1611
Added:
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlAction.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/TeztConstants.java
- copied, changed from r1608, /logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/TestConstants.java
Removed:
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/TestAction.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/TestConstants.java
Modified:
logback/trunk/logback-access/pom.xml
logback/trunk/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/DynamicLoggerContextTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/CreateLogger.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/PackageTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/RandomUtilTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/Scenario.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMakerTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/SetLevel.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/BasicJoranTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/EvaluatorJoranTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/LoggingEventSerializationTest.java
logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/SocketAppenderTest.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Context.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/ContextPropertyAction.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/InterpretationContext.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/HelloAction.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactory.java
logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/OptionHelperTest.java
logback/trunk/pom.xml
Log:
- Joran's InterpretationContext no longer includes a substitutionPropertyMap.
Now, only Context's have a property map. A number of classes has to change to reflect this change.
- first-step to using JUnit 4.
Modified: logback/trunk/logback-access/pom.xml
==============================================================================
--- logback/trunk/logback-access/pom.xml (original)
+++ logback/trunk/logback-access/pom.xml Fri Jan 25 17:13:12 2008
@@ -103,9 +103,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
- <forkMode>once</forkMode>
- <reportFormat>plain</reportFormat>
- <trimStackTrace>false</trimStackTrace>
+ <fork>once</fork>
+ <reportFormat>plain</reportFormat>
+ <disableXmlReport>true</disableXmlReport>
<excludes>
<exclude>**/AllTest.java</exclude>
<exclude>**/PackageTest.java</exclude>
Modified: logback/trunk/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java
==============================================================================
--- logback/trunk/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java (original)
+++ logback/trunk/logback-access/src/main/java/ch/qos/logback/access/tomcat/LogbackValve.java Fri Jan 25 17:13:12 2008
@@ -189,7 +189,7 @@
return propertyMap;
}
- public void setProperty(String key, String val) {
+ public void putProperty(String key, String val) {
this.propertyMap.put(key, val);
}
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 Jan 25 17:13:12 2008
@@ -86,8 +86,8 @@
}
@Override
- public void setProperty(String key, String val) {
- super.setProperty(key, val);
+ public void putProperty(String key, String val) {
+ super.putProperty(key, val);
syncRemoteView();
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/DynamicLoggerContextTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/DynamicLoggerContextTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/DynamicLoggerContextTest.java Fri Jan 25 17:13:12 2008
@@ -24,7 +24,7 @@
import ch.qos.logback.classic.control.Scenario;
import ch.qos.logback.classic.control.ScenarioMaker;
import ch.qos.logback.classic.control.SetLevel;
-import ch.qos.logback.classic.control.TestAction;
+import ch.qos.logback.classic.control.ControlAction;
public class DynamicLoggerContextTest extends TestCase {
@@ -54,7 +54,7 @@
List actionList = s.getActionList();
int size = actionList.size();
for (int i = 0; i < size; i++) {
- TestAction action = (TestAction) actionList.get(i);
+ ControlAction action = (ControlAction) actionList.get(i);
if (action instanceof CreateLogger) {
CreateLogger cl = (CreateLogger) action;
lc.getLogger(cl.getLoggerName());
Added: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlAction.java
==============================================================================
--- (empty file)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ControlAction.java Fri Jan 25 17:13:12 2008
@@ -0,0 +1,14 @@
+/**
+ * LOGBack: the generic, reliable, fast and flexible logging framework.
+ *
+ * Copyright (C) 1999-2006, 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.control;
+
+public class ControlAction {
+
+}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/CreateLogger.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/CreateLogger.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/CreateLogger.java Fri Jan 25 17:13:12 2008
@@ -10,7 +10,7 @@
package ch.qos.logback.classic.control;
-public class CreateLogger extends TestAction {
+public class CreateLogger extends ControlAction {
final String loggerName;
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/PackageTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/PackageTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/PackageTest.java Fri Jan 25 17:13:12 2008
@@ -15,8 +15,8 @@
public static Test suite() {
TestSuite suite = new TestSuite();
- suite.addTestSuite(RandomUtilTest.class);
- suite.addTestSuite(ScenarioMakerTest.class);
+ suite.addTest(new JUnit4TestAdapter(RandomUtilTest.class));
+ suite.addTest(new JUnit4TestAdapter(ScenarioMakerTest.class));
return suite;
}
}
\ No newline at end of file
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/RandomUtilTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/RandomUtilTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/RandomUtilTest.java Fri Jan 25 17:13:12 2008
@@ -9,11 +9,12 @@
*/
package ch.qos.logback.classic.control;
+import org.junit.Test;
+import static org.junit.Assert.assertTrue;
-import junit.framework.*;
-
-public class RandomUtilTest extends TestCase {
+public class RandomUtilTest {
+ @Test
public void testGaussian() {
long sum = 0;
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/Scenario.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/Scenario.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/Scenario.java Fri Jan 25 17:13:12 2008
@@ -19,7 +19,7 @@
// the frequency of a set levelInt event for every create logger event
private final static int CREATE_LOGGER_TO_SET_LEVEL_FREQUENCY = 5;
- private List<TestAction> actionList = new Vector<TestAction>();
+ private List<ControlAction> actionList = new Vector<ControlAction>();
public void addAction(CreateLogger action) {
actionList.add(action);
@@ -29,15 +29,15 @@
}
}
- public List<TestAction> getActionList() {
- return new ArrayList<TestAction>(actionList);
+ public List<ControlAction> getActionList() {
+ return new ArrayList<ControlAction>(actionList);
}
public int size() {
return actionList.size();
}
- public TestAction get(int i) {
- return (TestAction) actionList.get(i);
+ public ControlAction get(int i) {
+ return (ControlAction) actionList.get(i);
}
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMakerTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMakerTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/ScenarioMakerTest.java Fri Jan 25 17:13:12 2008
@@ -9,12 +9,12 @@
*/
package ch.qos.logback.classic.control;
-import junit.framework.*;
-
import java.util.List;
+import org.junit.Test;
+
-public class ScenarioMakerTest extends TestCase {
+public class ScenarioMakerTest {
// public void test1() {
// Scenario s = ScenarioMaker.makeTypeAScenario(10);
@@ -24,9 +24,10 @@
// }
// }
+ @Test
public void testTypeB() {
Scenario s = ScenarioMaker.makeTypeBScenario(30);
- List actionList = s.getActionList();
+ List<ControlAction> actionList = s.getActionList();
for(int i = 0; i < actionList.size(); i++) {
//System.out.println(actionList.get(i)) ;
}
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/SetLevel.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/SetLevel.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/control/SetLevel.java Fri Jan 25 17:13:12 2008
@@ -11,7 +11,7 @@
import ch.qos.logback.classic.Level;
-public class SetLevel extends TestAction {
+public class SetLevel extends ControlAction {
final String loggerName;
final Level level;
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/db/DBAppenderTest.java Fri Jan 25 17:13:12 2008
@@ -98,7 +98,7 @@
public void testContextInfo() throws SQLException {
LoggingEvent event = createLoggingEvent();
- lc.setProperty("testKey1", "testValue1");
+ lc.putProperty("testKey1", "testValue1");
appender.append(event);
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/BasicJoranTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/BasicJoranTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/BasicJoranTest.java Fri Jan 25 17:13:12 2008
@@ -19,7 +19,7 @@
import ch.qos.logback.classic.turbo.DebugUsersTurboFilter;
import ch.qos.logback.classic.turbo.NOPTurboFilter;
import ch.qos.logback.classic.turbo.TurboFilter;
-import ch.qos.logback.classic.util.TestConstants;
+import ch.qos.logback.classic.util.TeztConstants;
import ch.qos.logback.core.joran.spi.JoranException;
import ch.qos.logback.core.read.ListAppender;
@@ -33,7 +33,7 @@
JoranConfigurator jc = new JoranConfigurator();
LoggerContext loggerContext = new LoggerContext();
jc.setContext(loggerContext);
- jc.doConfigure(TestConstants.TEST_DIR_PREFIX + "input/joran/simpleList.xml");
+ jc.doConfigure(TeztConstants.TEST_DIR_PREFIX + "input/joran/simpleList.xml");
//StatusPrinter.print(loggerContext.getStatusManager());
@@ -52,7 +52,7 @@
JoranConfigurator jc = new JoranConfigurator();
LoggerContext loggerContext = new LoggerContext();
jc.setContext(loggerContext);
- jc.doConfigure(TestConstants.TEST_DIR_PREFIX + "input/joran/simpleLevel.xml");
+ jc.doConfigure(TeztConstants.TEST_DIR_PREFIX + "input/joran/simpleLevel.xml");
Logger logger = loggerContext.getLogger(this.getClass().getName());
Logger root = loggerContext.getLogger(LoggerContext.ROOT_NAME);
@@ -67,7 +67,7 @@
JoranConfigurator jc = new JoranConfigurator();
LoggerContext loggerContext = new LoggerContext();
jc.setContext(loggerContext);
- jc.doConfigure(TestConstants.TEST_DIR_PREFIX + "input/joran/callerData.xml");
+ jc.doConfigure(TeztConstants.TEST_DIR_PREFIX + "input/joran/callerData.xml");
//StatusPrinter.print(loggerContext);
@@ -93,7 +93,7 @@
JoranConfigurator jc = new JoranConfigurator();
LoggerContext loggerContext = new LoggerContext();
jc.setContext(loggerContext);
- jc.doConfigure(TestConstants.TEST_DIR_PREFIX + "input/joran/turbo.xml");
+ jc.doConfigure(TeztConstants.TEST_DIR_PREFIX + "input/joran/turbo.xml");
//StatusPrinter.print(loggerContext.getStatusManager());
@@ -109,7 +109,7 @@
JoranConfigurator jc = new JoranConfigurator();
LoggerContext loggerContext = new LoggerContext();
jc.setContext(loggerContext);
- jc.doConfigure(TestConstants.TEST_DIR_PREFIX + "input/joran/turbo2.xml");
+ jc.doConfigure(TeztConstants.TEST_DIR_PREFIX + "input/joran/turbo2.xml");
//StatusPrinter.print(loggerContext.getStatusManager());
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/EvaluatorJoranTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/EvaluatorJoranTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/joran/EvaluatorJoranTest.java Fri Jan 25 17:13:12 2008
@@ -21,7 +21,7 @@
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.classic.boolex.JaninoEventEvaluator;
import ch.qos.logback.classic.spi.LoggingEvent;
-import ch.qos.logback.classic.util.TestConstants;
+import ch.qos.logback.classic.util.TeztConstants;
import ch.qos.logback.core.CoreGlobal;
import ch.qos.logback.core.boolex.EvaluationException;
import ch.qos.logback.core.joran.spi.JoranException;
@@ -33,7 +33,7 @@
JoranConfigurator jc = new JoranConfigurator();
LoggerContext loggerContext = new LoggerContext();
jc.setContext(loggerContext);
- jc.doConfigure(TestConstants.TEST_DIR_PREFIX + "input/joran/simpleEvaluator.xml");
+ jc.doConfigure(TeztConstants.TEST_DIR_PREFIX + "input/joran/simpleEvaluator.xml");
Map evalMap = (Map) loggerContext.getObject(CoreGlobal.EVALUATOR_MAP);
@@ -54,7 +54,7 @@
JoranConfigurator jc = new JoranConfigurator();
LoggerContext loggerContext = new LoggerContext();
jc.setContext(loggerContext);
- jc.doConfigure(TestConstants.TEST_DIR_PREFIX + "input/joran/ignore.xml");
+ jc.doConfigure(TeztConstants.TEST_DIR_PREFIX + "input/joran/ignore.xml");
//StatusPrinter.print(loggerContext.getStatusManager());
Modified: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/LoggingEventSerializationTest.java
==============================================================================
--- logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/LoggingEventSerializationTest.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/net/LoggingEventSerializationTest.java Fri Jan 25 17:13:12 2008
@@ -62,7 +62,7 @@
bos = new ByteArrayOutputStream();
oos = new ObjectOutputStream(bos);
- lc.setProperty("testKey", "testValue");
+ lc.putProperty("testKey", "testValue");
LoggingEvent event = createLoggingEvent();
oos.writeObject(event);
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 Jan 25 17:13:12 2008
@@ -158,7 +158,7 @@
private void configureClient() {
lc = new LoggerContext();
lc.setName("test");
- lc.setProperty("testKey", "testValue");
+ lc.putProperty("testKey", "testValue");
Logger root = lc.getLogger(LoggerContext.ROOT_NAME);
SocketAppender socketAppender = new SocketAppender();
socketAppender.setContext(lc);
Copied: logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/TeztConstants.java (from r1608, /logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/TestConstants.java)
==============================================================================
--- /logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/TestConstants.java (original)
+++ logback/trunk/logback-classic/src/test/java/ch/qos/logback/classic/util/TeztConstants.java Fri Jan 25 17:13:12 2008
@@ -1,7 +1,13 @@
package ch.qos.logback.classic.util;
-
-public class TestConstants {
+/**
+ *
+ * It seems to bother
+ *
+ * @author gulcu
+ *
+ */
+public class TeztConstants {
public static final String TEST_DIR_PREFIX = "src/test/";
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Context.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Context.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/Context.java Fri Jan 25 17:13:12 2008
@@ -9,8 +9,6 @@
*/
package ch.qos.logback.core;
-import java.util.Map;
-
import ch.qos.logback.core.status.StatusManager;
@@ -41,7 +39,7 @@
* the returned Map will have no effect (on the original.)
* @return
*/
- public Map<String, String> getPropertyMap();
+ //public Map<String, String> getPropertyMap();
/**
* Get the property of this context.
@@ -51,7 +49,7 @@
/**
* Set a property of this context.
*/
- public void setProperty(String key, String value);
+ public void putProperty(String key, String value);
/**
* Contexts are named objects.
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/ContextBase.java Fri Jan 25 17:13:12 2008
@@ -32,7 +32,7 @@
return new HashMap<String, String>(propertyMap);
}
- public void setProperty(String key, String val) {
+ public void putProperty(String key, String val) {
this.propertyMap.put(key, val);
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/ContextPropertyAction.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/ContextPropertyAction.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/action/ContextPropertyAction.java Fri Jan 25 17:13:12 2008
@@ -18,11 +18,11 @@
// TODO : test this method
for(Object o: props.keySet()) {
String key = (String) o;
- this.context.setProperty(key, props.getProperty(key));
+ this.context.putProperty(key, props.getProperty(key));
}
}
public void setProperty(InterpretationContext ec, String key, String value) {
- this.context.setProperty(key, value);
+ this.context.putProperty(key, value);
}
}
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/InterpretationContext.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/InterpretationContext.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/joran/spi/InterpretationContext.java Fri Jan 25 17:13:12 2008
@@ -38,15 +38,14 @@
public class InterpretationContext extends ContextAwareBase {
Stack<Object> objectStack;
Map<String, Object> objectMap;
- Map<String, String> substitutionMap;
Interpreter joranInterpreter;
final List<InPlayListener> listenerList = new ArrayList<InPlayListener>();
public InterpretationContext(Context context, Interpreter joranInterpreter) {
+ this.context = context;
this.joranInterpreter = joranInterpreter;
objectStack = new Stack<Object> ();
objectMap = new HashMap<String, Object>(5);
- substitutionMap = new HashMap<String, String>();
}
String updateLocationInfo(String msg) {
@@ -111,7 +110,7 @@
// values with leading or trailing spaces are bad. We remove them now.
value = value.trim();
- substitutionMap.put(key, value);
+ context.putProperty(key, value);
}
public void addSubstitutionProperties(Properties props) {
@@ -139,14 +138,14 @@
public String getSubstitutionProperty(String key) {
- return substitutionMap.get(key);
+ return context.getProperty(key);
}
public String subst(String value) {
if (value == null) {
return null;
}
- return OptionHelper.substVars(value, substitutionMap, context.getPropertyMap());
+ return OptionHelper.substVars(value, context, null);
}
public void addInPlayListener(InPlayListener ipl) {
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/util/OptionHelper.java Fri Jan 25 17:13:12 2008
@@ -129,7 +129,7 @@
* @throws IllegalArgumentException
* if <code>val</code> is malformed.
*/
- public static String substVars(String val, Map<String, String> primaryMap,
+ public static String substVars(String val, Context context,
Map<String, String> secondaryMap) {
StringBuffer sbuf = new StringBuffer();
@@ -172,9 +172,7 @@
String replacement = null;
// first try the props passed as parameter
- if (primaryMap != null) {
- replacement = primaryMap.get(key);
- }
+ replacement = context.getProperty(key);
if (replacement == null && secondaryMap != null) {
replacement = secondaryMap.get(key);
@@ -197,7 +195,7 @@
// where the properties are
// x1=p1
// x2=${x1}
- String recursiveReplacement = substVars(replacement, primaryMap,
+ String recursiveReplacement = substVars(replacement, context,
secondaryMap);
sbuf.append(recursiveReplacement);
}
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/HelloAction.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/HelloAction.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/action/HelloAction.java Fri Jan 25 17:13:12 2008
@@ -27,7 +27,7 @@
*/
public void begin(InterpretationContext ec, String name, Attributes attributes) {
String str = "Hello "+attributes.getValue("name")+".";
- ec.getContext().setProperty("hello", str);
+ ec.getContext().putProperty("hello", str);
}
/**
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactory.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactory.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/joran/replay/FruitFactory.java Fri Jan 25 17:13:12 2008
@@ -22,7 +22,7 @@
Context context = new ContextBase();
this.fruit = null;
- context.setProperty("fruitKey", "orange-"+count);
+ context.putProperty("fruitKey", "orange-"+count);
// for next round
count++;
FruitConfigurator fruitConfigurator = new FruitConfigurator(this);
Modified: logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/OptionHelperTest.java
==============================================================================
--- logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/OptionHelperTest.java (original)
+++ logback/trunk/logback-core/src/test/java/ch/qos/logback/core/util/OptionHelperTest.java Fri Jan 25 17:13:12 2008
@@ -3,28 +3,28 @@
import java.util.HashMap;
import java.util.Map;
+import ch.qos.logback.core.Context;
+import ch.qos.logback.core.ContextBase;
+
import junit.framework.TestCase;
public class OptionHelperTest extends TestCase {
String text = "Testing ${v1} variable substitution ${v2}";
String expected = "Testing if variable substitution works";
- Map<String, String> primaryMap;
+ Context context = new ContextBase();
Map<String, String> secondaryMap;
@Override
protected void setUp() throws Exception {
- primaryMap = new HashMap<String, String>();
secondaryMap = new HashMap<String, String>();
super.setUp();
}
@Override
protected void tearDown() throws Exception {
- primaryMap = null;
- primaryMap = null;
super.tearDown();
}
@@ -48,18 +48,18 @@
}
public void testSubstVarsPrimaryOnly() {
- primaryMap.put("v1", "if");
- primaryMap.put("v2", "works");
+ context.putProperty("v1", "if");
+ context.putProperty("v2", "works");
- String result = OptionHelper.substVars(text, primaryMap, null);
+ String result = OptionHelper.substVars(text, context, null);
assertEquals(expected, result);
}
public void testSubstVarsPrimaryAndSecondary() {
- primaryMap.put("v1", "if");
+ context.putProperty("v1", "if");
secondaryMap.put("v2", "works");
- String result = OptionHelper.substVars(text, primaryMap, secondaryMap);
+ String result = OptionHelper.substVars(text, context, secondaryMap);
assertEquals(expected, result);
}
@@ -68,7 +68,7 @@
System.setProperty("v1", "if");
System.setProperty("v2", "works");
- String result = OptionHelper.substVars(text, null, null);
+ String result = OptionHelper.substVars(text, context, null);
assertEquals(expected, result);
System.clearProperty("v1");
@@ -76,20 +76,20 @@
}
public void testSubstVarsWithDefault() {
- primaryMap.put("v1", "if");
+ context.putProperty("v1", "if");
String textWithDefault = "Testing ${v1} variable substitution ${v2:-toto}";
String resultWithDefault = "Testing if variable substitution toto";
- String result = OptionHelper.substVars(textWithDefault, primaryMap, null);
+ String result = OptionHelper.substVars(textWithDefault, context, null);
assertEquals(resultWithDefault, result);
}
public void testSubstVarsRecursive() {
- primaryMap.put("v1", "if");
- primaryMap.put("v2", "${v3}");
- primaryMap.put("v3", "works");
+ context.putProperty("v1", "if");
+ context.putProperty("v2", "${v3}");
+ context.putProperty("v3", "works");
- String result = OptionHelper.substVars(text, primaryMap, null);
+ String result = OptionHelper.substVars(text, context, null);
assertEquals(expected, result);
}
Modified: logback/trunk/pom.xml
==============================================================================
--- logback/trunk/pom.xml (original)
+++ logback/trunk/pom.xml Fri Jan 25 17:13:12 2008
@@ -29,7 +29,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>3.8.1</version>
+ <version>4.4</version>
<scope>test</scope>
</dependency>
</dependencies>
More information about the logback-dev
mailing list