Repository: logging-log4j2
Updated Branches:
  refs/heads/master ec3c623a8 -> 0eb5212e4


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0eb5212e/log4j-layout-jackson/src/test/java/org/apache/logging/log4j/jackson/LevelMixInTest.java
----------------------------------------------------------------------
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
new file mode 100644
index 0000000..0cdcb36
--- /dev/null
+++ 
b/log4j-layout-jackson/src/test/java/org/apache/logging/log4j/jackson/LevelMixInTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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.jackson;
+
+import java.io.IOException;
+
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.categories.Layouts;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.ObjectReader;
+import com.fasterxml.jackson.databind.ObjectWriter;
+
+/**
+ * Tests {@link LevelMixIn}.
+ */
+@Category(Layouts.Json.class)
+public abstract class LevelMixInTest {
+
+    static class Fixture {
+        @JsonProperty
+        private final Level level = Level.DEBUG;
+
+        @Override
+        public boolean equals(final Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            final Fixture other = (Fixture) obj;
+            if (this.level == null) {
+                if (other.level != null) {
+                    return false;
+                }
+            } else if (!this.level.equals(other.level)) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((this.level == null) ? 0 : 
this.level.hashCode());
+            return result;
+        }
+    }
+    private ObjectMapper log4jObjectMapper;
+
+    private ObjectReader reader;
+
+    private ObjectWriter writer;
+
+    protected abstract ObjectMapper newObjectMapper();
+
+    @Before
+    public void setUp() {
+        log4jObjectMapper = newObjectMapper();
+        writer = log4jObjectMapper.writer();
+        reader = log4jObjectMapper.readerFor(Level.class);
+    }
+
+    @Test
+    public void testContainer() throws IOException {
+        final Fixture expected = new Fixture();
+        final String str = writer.writeValueAsString(expected);
+        Assert.assertTrue(str.contains("DEBUG"));
+        final ObjectReader fixtureReader = 
log4jObjectMapper.readerFor(Fixture.class);
+        final Fixture actual = fixtureReader.readValue(str);
+        Assert.assertEquals(expected, actual);
+    }
+
+    @Test
+    public void testNameOnly() throws IOException {
+        final Level expected = Level.getLevel("DEBUG");
+        final String str = writer.writeValueAsString(expected);
+        Assert.assertTrue(str.contains("DEBUG"));
+        final Level actual = reader.readValue(str);
+        Assert.assertEquals(expected, actual);
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0eb5212e/log4j-layout-jackson/src/test/java/org/apache/logging/log4j/jackson/ThrowableProxyJacksonTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-layout-jackson/src/test/java/org/apache/logging/log4j/jackson/ThrowableProxyJacksonTest.java
 
b/log4j-layout-jackson/src/test/java/org/apache/logging/log4j/jackson/ThrowableProxyJacksonTest.java
new file mode 100644
index 0000000..ee07711
--- /dev/null
+++ 
b/log4j-layout-jackson/src/test/java/org/apache/logging/log4j/jackson/ThrowableProxyJacksonTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.jackson;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.apache.logging.log4j.core.impl.ThrowableProxy;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+/**
+ *
+ */
+public class ThrowableProxyJacksonTest {
+
+    static class Fixture {
+        @JsonProperty
+        ThrowableProxy proxy = new ThrowableProxy(new IOException("test"));
+    }
+
+    protected void testIoContainer(final ObjectMapper objectMapper) throws 
IOException {
+        final Fixture expected = new Fixture();
+        final String s = objectMapper.writeValueAsString(expected);
+        final Fixture actual = objectMapper.readValue(s, Fixture.class);
+        assertEquals(expected.proxy.getName(), actual.proxy.getName());
+        assertEquals(expected.proxy.getMessage(), actual.proxy.getMessage());
+        assertEquals(expected.proxy.getLocalizedMessage(), 
actual.proxy.getLocalizedMessage());
+        assertEquals(expected.proxy.getCommonElementCount(), 
actual.proxy.getCommonElementCount());
+        assertArrayEquals(expected.proxy.getExtendedStackTrace(), 
actual.proxy.getExtendedStackTrace());
+        assertEquals(expected.proxy, actual.proxy);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0eb5212e/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 2c8f327..ff8c1b9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1341,6 +1341,10 @@
     <module>log4j-api</module>
     <module>log4j-core-java9</module>
     <module>log4j-core</module>
+    <module>log4j-layout-jackson</module>
+    <module>log4j-layout-jackson-json</module>
+    <module>log4j-layout-jackson-xml</module>
+    <module>log4j-layout-jackson-yaml</module>
     <module>log4j-core-its</module>
     <module>log4j-1.2-api</module>
     <module>log4j-slf4j-impl</module>

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0eb5212e/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index d3f9420..edb22bc 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -61,6 +61,9 @@
       <action issue="LOG4J2-2244" dev="ggregory" type="update" due-to="Gary 
Gregory">
         org.apache.logging.log4j.core.lookup.EnvironmentLookup may throw NPE.
       </action>      
+      <action issue="LOG4J2-2237" dev="ggregory" type="update" due-to="Gary 
Gregory">
+        Move Jackson-based layouts to their own modules: JSON, XML, and YAML.
+      </action>      
     </release>
     <release version="2.11.0" date="2018-xx-xx" description="GA Release 
2.11.0">
       <action issue="LOG4J2-2254" dev="rgoers" type="fix">

Reply via email to