use of org.apache.logging.log4j.message.SimpleMessage in project logging-log4j2 by apache.
the class Log4jLogEventTest method testEquals.
@SuppressWarnings("deprecation")
@Test
public void testEquals() {
final StringMap contextData = ContextDataFactory.createContextData();
contextData.putValue("A", "B");
ThreadContext.push("first");
final ContextStack contextStack = ThreadContext.getImmutableStack();
final Exception exception = new Exception("test");
final Marker marker = MarkerManager.getMarker("EVENTTEST");
final Message message = new SimpleMessage("foo");
final StackTraceElement stackTraceElement = new StackTraceElement("A", "B", "file", 123);
final String fqcn = "qualified";
final String name = "Ceci n'est pas une pipe";
final String threadName = "threadName";
final Log4jLogEvent event = //
Log4jLogEvent.newBuilder().setContextData(//
contextData).setContextStack(//
contextStack).setEndOfBatch(//
true).setIncludeLocation(//
true).setLevel(//
Level.FATAL).setLoggerFqcn(//
fqcn).setLoggerName(//
name).setMarker(//
marker).setMessage(//
message).setNanoTime(//
1234567890L).setSource(//
stackTraceElement).setThreadName(//
threadName).setThrown(//
exception).setTimeMillis(987654321L).build();
assertEquals(contextData, event.getContextData());
assertSame(contextStack, event.getContextStack());
assertTrue(event.isEndOfBatch());
assertTrue(event.isIncludeLocation());
assertSame(Level.FATAL, event.getLevel());
assertSame(fqcn, event.getLoggerFqcn());
assertSame(name, event.getLoggerName());
assertSame(marker, event.getMarker());
assertSame(message, event.getMessage());
assertEquals(1234567890L, event.getNanoTime());
assertSame(stackTraceElement, event.getSource());
assertSame(threadName, event.getThreadName());
assertSame(exception, event.getThrown());
assertEquals(987654321L, event.getTimeMillis());
final LogEvent event2 = builder(event).build();
assertEquals(event2, event, "copy constructor builder");
assertEquals(event2.hashCode(), event.hashCode(), "same hashCode");
assertEquals(contextData, event2.getContextData());
assertSame(contextStack, event2.getContextStack());
assertTrue(event2.isEndOfBatch());
assertTrue(event2.isIncludeLocation());
assertSame(Level.FATAL, event2.getLevel());
assertSame(fqcn, event2.getLoggerFqcn());
assertSame(name, event2.getLoggerName());
assertSame(marker, event2.getMarker());
assertSame(message, event2.getMessage());
assertEquals(1234567890L, event2.getNanoTime());
assertSame(stackTraceElement, event2.getSource());
assertSame(threadName, event2.getThreadName());
assertSame(exception, event2.getThrown());
assertEquals(987654321L, event2.getTimeMillis());
final StringMap differentMap = ContextDataFactory.emptyFrozenContextData();
different("different contextMap", builder(event).setContextData(differentMap), event);
different("null contextMap", builder(event).setContextData(null), event);
ThreadContext.push("abc");
final ContextStack contextStack2 = ThreadContext.getImmutableStack();
different("different contextStack", builder(event).setContextStack(contextStack2), event);
different("null contextStack", builder(event).setContextStack(null), event);
different("different EndOfBatch", builder(event).setEndOfBatch(false), event);
different("different IncludeLocation", builder(event).setIncludeLocation(false), event);
different("different level", builder(event).setLevel(Level.INFO), event);
different("null level", builder(event).setLevel(null), event);
different("different fqcn", builder(event).setLoggerFqcn("different"), event);
different("null fqcn", builder(event).setLoggerFqcn(null), event);
different("different name", builder(event).setLoggerName("different"), event);
assertThrows(NullPointerException.class, () -> different("null name", builder(event).setLoggerName(null), event));
different("different marker", builder(event).setMarker(MarkerManager.getMarker("different")), event);
different("null marker", builder(event).setMarker(null), event);
different("different message", builder(event).setMessage(new ObjectMessage("different")), event);
assertThrows(NullPointerException.class, () -> different("null message", builder(event).setMessage(null), event));
different("different nanoTime", builder(event).setNanoTime(135), event);
different("different milliTime", builder(event).setTimeMillis(137), event);
final StackTraceElement stack2 = new StackTraceElement("XXX", "YYY", "file", 123);
different("different source", builder(event).setSource(stack2), event);
different("null source", builder(event).setSource(null), event);
different("different threadname", builder(event).setThreadName("different"), event);
different("null threadname", builder(event).setThreadName(null), event);
different("different exception", builder(event).setThrown(new Error("Boo!")), event);
different("null exception", builder(event).setThrown(null), event);
}
use of org.apache.logging.log4j.message.SimpleMessage in project logging-log4j2 by apache.
the class Log4jLogEventTest method testJavaIoSerializableWithUnknownThrowable.
// DO NOT REMOVE THIS COMMENT:
// UNCOMMENT WHEN GENERATING SERIALIZED EVENT FOR #testJavaIoSerializableWithUnknownThrowable
// public static class DeletedException extends Exception {
// private static final long serialVersionUID = 1L;
// public DeletedException(String msg) {
// super(msg);
// }
// };
@Test
public void testJavaIoSerializableWithUnknownThrowable() throws Exception {
final String loggerName = "some.test";
final Marker marker = null;
final String loggerFQN = Strings.EMPTY;
final Level level = Level.INFO;
final Message msg = new SimpleMessage("abc");
final String threadName = Thread.currentThread().getName();
final String errorMessage = "OMG I've been deleted!";
// DO NOT DELETE THIS COMMENT:
// UNCOMMENT TO RE-GENERATE SERIALIZED EVENT WHEN UPDATING THIS TEST.
// final Exception thrown = new DeletedException(errorMessage);
// final Log4jLogEvent evt = new Log4jLogEvent(loggerName, marker, loggerFQN, level, msg, thrown);
// final byte[] binary = serialize(evt);
// String base64Str = DatatypeConverter.printBase64Binary(binary);
// System.out.println("final String base64 = \"" + base64Str.replaceAll("\r\n", "\\\\r\\\\n\" +\r\n\"") +
// "\";");
final String base64 = "rO0ABXNyAD5vcmcuYXBhY2hlLmxvZ2dpbmcubG9nNGouY29yZS5pbXBsLkxvZzRqTG9nRXZlbnQkTG9nRXZlbnRQcm94eYgtmn+yXsP9AwAQWgAMaXNFbmRPZkJhdGNoWgASaXNMb2NhdGlvblJlcXVpcmVkSgAIdGhyZWFkSWRJAA50aHJlYWRQcmlvcml0eUoACnRpbWVNaWxsaXNMAAtjb250ZXh0RGF0YXQAKUxvcmcvYXBhY2hlL2xvZ2dpbmcvbG9nNGovdXRpbC9TdHJpbmdNYXA7TAAMY29udGV4dFN0YWNrdAA1TG9yZy9hcGFjaGUvbG9nZ2luZy9sb2c0ai9UaHJlYWRDb250ZXh0JENvbnRleHRTdGFjaztMAAVsZXZlbHQAIExvcmcvYXBhY2hlL2xvZ2dpbmcvbG9nNGovTGV2ZWw7TAAKbG9nZ2VyRlFDTnQAEkxqYXZhL2xhbmcvU3RyaW5nO0wACmxvZ2dlck5hbWVxAH4ABEwABm1hcmtlcnQAIUxvcmcvYXBhY2hlL2xvZ2dpbmcvbG9nNGovTWFya2VyO0wAEW1hcnNoYWxsZWRNZXNzYWdldAAbTG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ACtzcQB+ACwAAAEGdAAsY29tLmludGVsbGlqLnJ0LmV4ZWN1dGlvbi5qdW5pdC5KVW5pdFN0YXJ0ZXJ0ABFKVW5pdFN0YXJ0ZXIuamF2YXQAFnByZXBhcmVTdHJlYW1zQW5kU3RhcnRzcQB+ACVzcQB+ACgBdAAManVuaXQtcnQuamFycQB+ACtzcQB+ACwAAABUcQB+ALNxAH4AtHQABG1haW5zcQB+ACVzcQB+ACgAcQB+ACtxAH4AM3NxAH4ALP////5xAH4ANXEAfgA2cQB+ADdzcQB+ACVzcQB+ACgAcQB+ACtxAH4AM3NxAH4ALAAAADlxAH4ANXEAfgA2cQB+ADtzcQB+ACVzcQB+ACgAcQB+ACtxAH4AM3NxAH4ALAAAACtxAH4AP3EAfgBAcQB+ADtzcQB+ACVzcQB+ACgAcQB+ACtxAH4AM3NxAH4ALAAAAl5xAH4ARHEAfgBFcQB+ADtzcQB+ACVzcQB+ACgBdAALaWRlYV9ydC5qYXJxAH4AK3NxAH4ALAAAAJN0AC1jb20uaW50ZWxsaWoucnQuZXhlY3V0aW9uLmFwcGxpY2F0aW9uLkFwcE1haW50AAxBcHBNYWluLmphdmFxAH4AunQAFk9NRyBJJ3ZlIGJlZW4gZGVsZXRlZCFxAH4AzXQARW9yZy5hcGFjaGUubG9nZ2luZy5sb2c0ai5jb3JlLmltcGwuTG9nNGpMb2dFdmVudFRlc3QkRGVsZXRlZEV4Y2VwdGlvbnVyADRbTG9yZy5hcGFjaGUubG9nZ2luZy5sb2c0ai5jb3JlLmltcGwuVGhyb3dhYmxlUHJveHk7+u0B4IWi6zkCAAB4cAAAAAB4";
final byte[] binaryDecoded = decoder.decode(base64);
final Log4jLogEvent evt2 = deserialize(binaryDecoded);
assertEquals(loggerFQN, evt2.getLoggerFqcn());
assertEquals(level, evt2.getLevel());
assertEquals(loggerName, evt2.getLoggerName());
assertEquals(marker, evt2.getMarker());
assertEquals(msg, evt2.getMessage());
assertEquals(threadName, evt2.getThreadName());
assertNull(evt2.getThrown());
assertEquals(this.getClass().getName() + "$DeletedException", evt2.getThrownProxy().getName());
assertEquals(errorMessage, evt2.getThrownProxy().getMessage());
}
use of org.apache.logging.log4j.message.SimpleMessage in project logging-log4j2 by apache.
the class ReusableLogEventFactoryTest method testCreateEventReturnsSameInstance.
@Test
public void testCreateEventReturnsSameInstance() throws Exception {
final ReusableLogEventFactory factory = new ReusableLogEventFactory();
final LogEvent event1 = callCreateEvent(factory, "a", Level.DEBUG, new SimpleMessage("abc"), null);
ReusableLogEventFactory.release(event1);
final LogEvent event2 = callCreateEvent(factory, "b", Level.INFO, new SimpleMessage("xyz"), null);
assertSame(event1, event2);
ReusableLogEventFactory.release(event2);
final LogEvent event3 = callCreateEvent(factory, "c", Level.INFO, new SimpleMessage("123"), null);
assertSame(event2, event3);
ReusableLogEventFactory.release(event3);
}
use of org.apache.logging.log4j.message.SimpleMessage in project logging-log4j2 by apache.
the class ReusableLogEventFactoryTest method testCreateEventInitFieldsProperly.
@SuppressWarnings("deprecation")
@Test
public void testCreateEventInitFieldsProperly() throws Exception {
final ReusableLogEventFactory factory = new ReusableLogEventFactory();
final LogEvent event = callCreateEvent(factory, "logger", Level.INFO, new SimpleMessage("xyz"), null);
try {
assertNotNull(event.getContextData());
assertNotNull(event.getContextStack());
} finally {
ReusableLogEventFactory.release(event);
}
}
use of org.apache.logging.log4j.message.SimpleMessage in project logging-log4j2 by apache.
the class DynamicThresholdFilterTest method testFilter.
@Test
public void testFilter() {
ThreadContext.put("userid", "testuser");
ThreadContext.put("organization", "apache");
final KeyValuePair[] pairs = new KeyValuePair[] { new KeyValuePair("testuser", "DEBUG"), new KeyValuePair("JohnDoe", "warn") };
final DynamicThresholdFilter filter = DynamicThresholdFilter.createFilter("userid", pairs, Level.ERROR, null, null);
filter.start();
assertTrue(filter.isStarted());
assertSame(Filter.Result.NEUTRAL, filter.filter(null, Level.DEBUG, null, (Object) null, (Throwable) null));
assertSame(Filter.Result.NEUTRAL, filter.filter(null, Level.ERROR, null, (Object) null, (Throwable) null));
ThreadContext.clearMap();
ThreadContext.put("userid", "JohnDoe");
ThreadContext.put("organization", "apache");
LogEvent event = Log4jLogEvent.newBuilder().setLevel(Level.DEBUG).setMessage(new SimpleMessage("Test")).build();
assertSame(Filter.Result.DENY, filter.filter(event));
event = Log4jLogEvent.newBuilder().setLevel(Level.ERROR).setMessage(new SimpleMessage("Test")).build();
assertSame(Filter.Result.NEUTRAL, filter.filter(event));
ThreadContext.clearMap();
}
Aggregations