This is an automated email from the ASF dual-hosted git repository. rgoers pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git
commit a56448a13021a6fc108f7842f1aba76c020ade49 Author: ulrichenslin <[email protected]> AuthorDate: Sat Mar 2 08:43:55 2019 +0200 Test for JEP223 detection --- .../log4j/core/layout/AbstractStringLayoutTest.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/AbstractStringLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/AbstractStringLayoutTest.java index 04505d4..f0b3d69 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/AbstractStringLayoutTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/AbstractStringLayoutTest.java @@ -15,7 +15,10 @@ package org.apache.logging.log4j.core.layout;/* * limitations under the license. */ +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; import java.nio.charset.Charset; +import java.util.Properties; import org.apache.logging.log4j.core.LogEvent; import org.junit.Test; @@ -74,4 +77,22 @@ public class AbstractStringLayoutTest { assertEquals("capacity, trimmed to MAX_STRING_BUILDER_SIZE", ConcreteStringLayout.MAX_STRING_BUILDER_SIZE, sb3.capacity()); assertEquals("empty, ready for use", 0, sb3.length()); } + + @Test + public void testJdkVersionDetection() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + + Properties properties120 = new Properties(); + properties120.put("java.version","1.2.0"); + System.setProperties(properties120); + + Method method = AbstractStringLayout.class.getDeclaredMethod("isPreJava8",null); + method.setAccessible(true); + assertTrue ((Boolean) method.invoke("isPreJava8")); + + Properties properties900 = new Properties(); + properties120.put("java.version","9.1.0"); + System.setProperties(properties120); + + assertFalse ((Boolean) method.invoke("isPreJava8")); + } } \ No newline at end of file
