You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by vy...@apache.org on 2021/07/09 13:51:03 UTC

[logging-log4j2] branch release-2.x updated: Consolidated JsonTemplateLayoutAdditionalField*Test classes.

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


The following commit(s) were added to refs/heads/release-2.x by this push:
     new b87f96a  Consolidated JsonTemplateLayoutAdditionalField*Test classes.
b87f96a is described below

commit b87f96ad2c53d5c19bbbf687a2605cf7ce0dc90d
Author: Volkan Yazici <vo...@gmail.com>
AuthorDate: Fri Jul 9 15:50:49 2021 +0200

    Consolidated JsonTemplateLayoutAdditionalField*Test classes.
---
 .../JsonTemplateLayoutAdditionalFieldJsonTest.java | 36 -----------------
 ...emplateLayoutAdditionalFieldPropertiesTest.java | 36 -----------------
 ... => JsonTemplateLayoutAdditionalFieldTest.java} | 45 +++++++++++++++++++---
 .../JsonTemplateLayoutAdditionalFieldXmlTest.java  | 36 -----------------
 .../JsonTemplateLayoutAdditionalFieldYamlTest.java | 36 -----------------
 5 files changed, 40 insertions(+), 149 deletions(-)

diff --git a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutAdditionalFieldJsonTest.java b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutAdditionalFieldJsonTest.java
deleted file mode 100644
index 41fd023..0000000
--- a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutAdditionalFieldJsonTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.
- */
-package org.apache.logging.log4j.layout.template.json;
-
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.junit.LoggerContextSource;
-import org.apache.logging.log4j.junit.Named;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.jupiter.api.Test;
-
-@LoggerContextSource("additionalFieldEnrichedJsonTemplateLayoutLogging.json")
-class JsonTemplateLayoutAdditionalFieldJsonTest {
-
-    @Test
-    void test_additional_fields_are_resolved(
-            final LoggerContext loggerContext,
-            final @Named(value = "List") ListAppender appender) {
-        JsonTemplateLayoutAdditionalFieldTestHelpers
-                .assertAdditionalFields(loggerContext, appender);
-    }
-
-}
diff --git a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutAdditionalFieldPropertiesTest.java b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutAdditionalFieldPropertiesTest.java
deleted file mode 100644
index 735a55d..0000000
--- a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutAdditionalFieldPropertiesTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.
- */
-package org.apache.logging.log4j.layout.template.json;
-
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.junit.LoggerContextSource;
-import org.apache.logging.log4j.junit.Named;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.jupiter.api.Test;
-
-@LoggerContextSource("additionalFieldEnrichedJsonTemplateLayoutLogging.properties")
-class JsonTemplateLayoutAdditionalFieldPropertiesTest {
-
-    @Test
-    void test_additional_fields_are_resolved(
-            final LoggerContext loggerContext,
-            final @Named(value = "List") ListAppender appender) {
-        JsonTemplateLayoutAdditionalFieldTestHelpers
-                .assertAdditionalFields(loggerContext, appender);
-    }
-
-}
diff --git a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutAdditionalFieldTestHelpers.java b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutAdditionalFieldTest.java
similarity index 59%
rename from log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutAdditionalFieldTestHelpers.java
rename to log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutAdditionalFieldTest.java
index 383206c..cb08cf7 100644
--- a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutAdditionalFieldTestHelpers.java
+++ b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutAdditionalFieldTest.java
@@ -18,27 +18,62 @@ package org.apache.logging.log4j.layout.template.json;
 
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.core.LoggerContext;
+import org.apache.logging.log4j.junit.LoggerContextSource;
+import org.apache.logging.log4j.junit.Named;
 import org.apache.logging.log4j.layout.template.json.util.JsonReader;
 import org.apache.logging.log4j.test.appender.ListAppender;
 import org.assertj.core.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.parallel.Execution;
+import org.junit.jupiter.api.parallel.ExecutionMode;
 
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
-final class JsonTemplateLayoutAdditionalFieldTestHelpers {
+@Execution(ExecutionMode.SAME_THREAD)
+class JsonTemplateLayoutAdditionalFieldTest {
 
-    private JsonTemplateLayoutAdditionalFieldTestHelpers() {}
+    @Test
+    @LoggerContextSource("additionalFieldEnrichedJsonTemplateLayoutLogging.json")
+    void test_JSON_config_additional_fields(
+            final LoggerContext loggerContext,
+            final @Named(value = "List") ListAppender appender) {
+        assertAdditionalFields(loggerContext, appender);
+    }
+
+    @Test
+    @LoggerContextSource("additionalFieldEnrichedJsonTemplateLayoutLogging.properties")
+    void test_Properties_config_additional_fields(
+            final LoggerContext loggerContext,
+            final @Named(value = "List") ListAppender appender) {
+        assertAdditionalFields(loggerContext, appender);
+    }
+
+    @Test
+    @LoggerContextSource("additionalFieldEnrichedJsonTemplateLayoutLogging.xml")
+    void test_XML_config_additional_fields(
+            final LoggerContext loggerContext,
+            final @Named(value = "List") ListAppender appender) {
+        assertAdditionalFields(loggerContext, appender);
+    }
+
+    @Test
+    @LoggerContextSource("additionalFieldEnrichedJsonTemplateLayoutLogging.yaml")
+    void test_YAML_config_additional_fields(
+            final LoggerContext loggerContext,
+            final @Named(value = "List") ListAppender appender) {
+        assertAdditionalFields(loggerContext, appender);
+    }
 
-    static void assertAdditionalFields(
+    private static void assertAdditionalFields(
             final LoggerContext loggerContext,
             final ListAppender appender) {
 
         // Log an event.
         final Logger logger =
-                loggerContext.getLogger(
-                        JsonTemplateLayoutAdditionalFieldTestHelpers.class);
+                loggerContext.getLogger(JsonTemplateLayoutAdditionalFieldTest.class);
         logger.info("trigger");
 
         // Verify that the appender has logged the event.
diff --git a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutAdditionalFieldXmlTest.java b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutAdditionalFieldXmlTest.java
deleted file mode 100644
index f9194ee..0000000
--- a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutAdditionalFieldXmlTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.
- */
-package org.apache.logging.log4j.layout.template.json;
-
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.junit.LoggerContextSource;
-import org.apache.logging.log4j.junit.Named;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.jupiter.api.Test;
-
-@LoggerContextSource("additionalFieldEnrichedJsonTemplateLayoutLogging.xml")
-class JsonTemplateLayoutAdditionalFieldXmlTest {
-
-    @Test
-    void test_additional_fields_are_resolved(
-            final LoggerContext loggerContext,
-            final @Named(value = "List") ListAppender appender) {
-        JsonTemplateLayoutAdditionalFieldTestHelpers
-                .assertAdditionalFields(loggerContext, appender);
-    }
-
-}
diff --git a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutAdditionalFieldYamlTest.java b/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutAdditionalFieldYamlTest.java
deleted file mode 100644
index feecefb..0000000
--- a/log4j-layout-template-json/src/test/java/org/apache/logging/log4j/layout/template/json/JsonTemplateLayoutAdditionalFieldYamlTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.
- */
-package org.apache.logging.log4j.layout.template.json;
-
-import org.apache.logging.log4j.core.LoggerContext;
-import org.apache.logging.log4j.junit.LoggerContextSource;
-import org.apache.logging.log4j.junit.Named;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.jupiter.api.Test;
-
-@LoggerContextSource("additionalFieldEnrichedJsonTemplateLayoutLogging.yaml")
-class JsonTemplateLayoutAdditionalFieldYamlTest {
-
-    @Test
-    void test_additional_fields_are_resolved(
-            final LoggerContext loggerContext,
-            final @Named(value = "List") ListAppender appender) {
-        JsonTemplateLayoutAdditionalFieldTestHelpers
-                .assertAdditionalFields(loggerContext, appender);
-    }
-
-}