You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by pk...@apache.org on 2023/01/15 22:35:24 UTC

[logging-log4j2] 18/18: Disables broken test and merges with `release-2.x`

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

pkarwasz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 85ea13b9dba58a7b3c4b350fdaa6d2e3b9d0d405
Author: Piotr P. Karwasz <pi...@karwasz.org>
AuthorDate: Sun Jan 15 22:33:56 2023 +0100

    Disables broken test and merges with `release-2.x`
    
    The `LevelMixInXmlTest#testNameOnly` works sporadically on certain
    Jackson versions. Anyway it doesn't make sense to serialize simple
    string values as XML documents (that must always have a root).
---
 .../log4j/jackson/json/LevelMixInJsonTest.java     |  4 ----
 .../log4j/jackson/xml/LevelMixInXmlTest.java       | 18 +++++++++++------
 .../logging/log4j/jackson/LevelMixInTest.java      | 23 +++++++++-------------
 3 files changed, 21 insertions(+), 24 deletions(-)

diff --git a/log4j-layout-jackson-json/src/test/java/org/apache/logging/log4j/jackson/json/LevelMixInJsonTest.java b/log4j-layout-jackson-json/src/test/java/org/apache/logging/log4j/jackson/json/LevelMixInJsonTest.java
index 6c15f90d13..203b481e34 100644
--- a/log4j-layout-jackson-json/src/test/java/org/apache/logging/log4j/jackson/json/LevelMixInJsonTest.java
+++ b/log4j-layout-jackson-json/src/test/java/org/apache/logging/log4j/jackson/json/LevelMixInJsonTest.java
@@ -14,16 +14,12 @@
  * See the license for the specific language governing permissions and
  * limitations under the license.
  */
-
 package org.apache.logging.log4j.jackson.json;
 
-import org.apache.logging.log4j.core.test.categories.Layouts;
 import org.apache.logging.log4j.jackson.LevelMixInTest;
-import org.junit.experimental.categories.Category;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 
-@Category(Layouts.Json.class)
 public class LevelMixInJsonTest extends LevelMixInTest {
 
     @Override
diff --git a/log4j-layout-jackson-xml/src/test/java/org/apache/logging/log4j/jackson/xml/LevelMixInXmlTest.java b/log4j-layout-jackson-xml/src/test/java/org/apache/logging/log4j/jackson/xml/LevelMixInXmlTest.java
index 8b9790914c..047ff7c4c9 100644
--- a/log4j-layout-jackson-xml/src/test/java/org/apache/logging/log4j/jackson/xml/LevelMixInXmlTest.java
+++ b/log4j-layout-jackson-xml/src/test/java/org/apache/logging/log4j/jackson/xml/LevelMixInXmlTest.java
@@ -14,18 +14,16 @@
  * See the license for the specific language governing permissions and
  * limitations under the license.
  */
-
 package org.apache.logging.log4j.jackson.xml;
 
-import org.apache.logging.log4j.core.test.categories.Layouts;
+import java.io.IOException;
+
 import org.apache.logging.log4j.jackson.LevelMixInTest;
-import org.junit.Ignore;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
 
-@Ignore("Fails for #testNameOnly()")
-@Category(Layouts.Xml.class)
 public class LevelMixInXmlTest extends LevelMixInTest {
 
     @Override
@@ -33,4 +31,12 @@ public class LevelMixInXmlTest extends LevelMixInTest {
         return new Log4jXmlObjectMapper();
     }
 
+    @Test
+    @Disabled("String-like objects like Level do not work as root elements.")
+    @Override
+    public void testNameOnly() throws IOException {
+        // Disabled: see https://github.com/FasterXML/jackson-dataformat-xml
+        super.testNameOnly();
+    }
+
 }
diff --git a/log4j-layout-jackson/src/test/java/org/apache/logging/log4j/jackson/LevelMixInTest.java b/log4j-layout-jackson/src/test/java/org/apache/logging/log4j/jackson/LevelMixInTest.java
index 3fb55a2f43..898b74fe3c 100644
--- a/log4j-layout-jackson/src/test/java/org/apache/logging/log4j/jackson/LevelMixInTest.java
+++ b/log4j-layout-jackson/src/test/java/org/apache/logging/log4j/jackson/LevelMixInTest.java
@@ -16,15 +16,17 @@
  */
 package org.apache.logging.log4j.jackson;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.ObjectReader;
-import com.fasterxml.jackson.databind.ObjectWriter;
+import java.io.IOException;
+import java.util.Objects;
+
 import org.apache.logging.log4j.Level;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import java.io.IOException;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
+import com.fasterxml.jackson.databind.ObjectWriter;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -50,11 +52,7 @@ public abstract class LevelMixInTest {
                 return false;
             }
             final Fixture other = (Fixture) obj;
-            if (this.level == null) {
-                if (other.level != null) {
-                    return false;
-                }
-            } else if (!this.level.equals(other.level)) {
+            if (!Objects.equals(this.level, other.level)) {
                 return false;
             }
             return true;
@@ -62,10 +60,7 @@ public abstract class LevelMixInTest {
 
         @Override
         public int hashCode() {
-            final int prime = 31;
-            int result = 1;
-            result = prime * result + ((this.level == null) ? 0 : this.level.hashCode());
-            return result;
+            return 31 + Objects.hashCode(level);
         }
     }
     private ObjectMapper log4jObjectMapper;