This is an automated email from the ASF dual-hosted git repository.

vy pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit dd1bec2364763c03b8a6a83e35457c4ad2804b65
Author: Volkan Yazici <[email protected]>
AuthorDate: Wed Feb 17 15:10:59 2021 +0100

    Test RecyclerFactory read from XML config.
---
 .../template/json/util/RecyclerFactoriesTest.java  | 19 ++++++++++++++
 ...rFactoryCustomizedJsonTemplateLayoutLogging.xml | 30 ++++++++++++++++++++++
 2 files changed, 49 insertions(+)

diff --git 
a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/util/RecyclerFactoriesTest.java
 
b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/util/RecyclerFactoriesTest.java
index 80824f1..1c7b439 100644
--- 
a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/util/RecyclerFactoriesTest.java
+++ 
b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/util/RecyclerFactoriesTest.java
@@ -18,9 +18,15 @@ package org.apache.logging.log4j.layout.template.json.util;
 
 import org.apache.logging.log4j.core.config.plugins.convert.TypeConverter;
 import 
org.apache.logging.log4j.core.config.plugins.convert.TypeConverterRegistry;
+import org.apache.logging.log4j.junit.LoggerContextSource;
+import org.apache.logging.log4j.junit.Named;
+import org.apache.logging.log4j.layout.template.json.JsonTemplateLayout;
+import org.apache.logging.log4j.test.appender.ListAppender;
 import org.assertj.core.api.Assertions;
+import org.jctools.queues.MpmcArrayQueue;
 import org.junit.jupiter.api.Test;
 
+import java.lang.reflect.Field;
 import java.util.ArrayDeque;
 import java.util.concurrent.ArrayBlockingQueue;
 
@@ -117,4 +123,17 @@ class RecyclerFactoriesTest {
 
     }
 
+    @Test
+    
@LoggerContextSource("recyclerFactoryCustomizedJsonTemplateLayoutLogging.xml")
+    void test_RecyclerFactoryConverter_using_XML_config(
+            final @Named(value = "List") ListAppender appender)
+            throws Exception {
+        final JsonTemplateLayout layout = (JsonTemplateLayout) 
appender.getLayout();
+        final Field field = 
JsonTemplateLayout.class.getDeclaredField("contextRecycler");
+        field.setAccessible(true);
+        final QueueingRecycler<?> contextRecycler = (QueueingRecycler<?>) 
field.get(layout);
+        final MpmcArrayQueue<?> queue = (MpmcArrayQueue<?>) 
contextRecycler.getQueue();
+        Assertions.assertThat(queue.capacity()).isEqualTo(512);
+    }
+
 }
diff --git 
a/log4j-layout-template-json/src/test/resources/recyclerFactoryCustomizedJsonTemplateLayoutLogging.xml
 
b/log4j-layout-template-json/src/test/resources/recyclerFactoryCustomizedJsonTemplateLayoutLogging.xml
new file mode 100644
index 0000000..8fd8957
--- /dev/null
+++ 
b/log4j-layout-template-json/src/test/resources/recyclerFactoryCustomizedJsonTemplateLayoutLogging.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<Configuration status="OFF">
+  <Appenders>
+    <List name="List" raw="true">
+      <JsonTemplateLayout
+          
recyclerFactory="queue:supplier=org.jctools.queues.MpmcArrayQueue.new,capacity=512"/>
+    </List>
+  </Appenders>
+  <Loggers>
+    <Root level="TRACE">
+      <AppenderRef ref="List"/>
+    </Root>
+  </Loggers>
+</Configuration>

Reply via email to