You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2016/02/26 00:53:36 UTC
[4/8] logging-log4j2 git commit: temporary workaround for
ReusableParameterizedMessageFactory being the default;
this test probably needs tests for both factories
temporary workaround for ReusableParameterizedMessageFactory being the default; this test probably needs tests for both factories
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/91d176ca
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/91d176ca
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/91d176ca
Branch: refs/heads/LOG4J2-1278-gc-free-logger
Commit: 91d176ca3d1aa1b4788ef28dea16e54711cac21b
Parents: 54656a4
Author: rpopma <rp...@apache.org>
Authored: Fri Feb 26 03:08:33 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Fri Feb 26 03:08:33 2016 +0900
----------------------------------------------------------------------
.../logging/log4j/AbstractLoggerTest.java | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/91d176ca/log4j-api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
----------------------------------------------------------------------
diff --git a/log4j-api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java b/log4j-api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
index 4c191a5..399b450 100644
--- a/log4j-api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
+++ b/log4j-api/src/test/java/org/apache/logging/log4j/AbstractLoggerTest.java
@@ -16,11 +16,18 @@
*/
package org.apache.logging.log4j;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+
import org.apache.logging.log4j.message.Message;
+import org.apache.logging.log4j.message.MessageFactory;
import org.apache.logging.log4j.message.ObjectMessage;
import org.apache.logging.log4j.message.ParameterizedMessage;
+import org.apache.logging.log4j.message.ParameterizedMessageFactory;
import org.apache.logging.log4j.message.SimpleMessage;
import org.apache.logging.log4j.spi.AbstractLogger;
+import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
@@ -30,6 +37,19 @@ import static org.junit.Assert.*;
*/
public class AbstractLoggerTest extends AbstractLogger {
+ // TODO add proper tests for ReusableMessage
+ @Before
+ public void before() throws Exception {
+ Field field = AbstractLogger.class.getDeclaredField("messageFactory");
+ field.setAccessible(true); // make non-private
+
+ Field modifierField = Field.class.getDeclaredField("modifiers");
+ modifierField.setAccessible(true);
+ modifierField.setInt(field, field.getModifiers() &~ Modifier.FINAL); // make non-private
+
+ field.set(this, ParameterizedMessageFactory.INSTANCE);
+ }
+
private static class LogEvent {
String markerName;