Refactor to add XML test. Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/a2d3215a Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/a2d3215a Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/a2d3215a
Branch: refs/heads/LOG4J2-1356 Commit: a2d3215ab02d058e226e13b6d75336595d164447 Parents: 96a9e99 Author: ggregory <[email protected]> Authored: Wed Apr 6 14:21:45 2016 -0700 Committer: ggregory <[email protected]> Committed: Wed Apr 6 14:21:45 2016 -0700 ---------------------------------------------------------------------- .../logging/log4j/MarkerMixInJsonTest.java | 31 ++++++++++++++++++++ .../apache/logging/log4j/MarkerMixInTest.java | 7 +++-- .../logging/log4j/MarkerMixInXmlTest.java | 31 ++++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a2d3215a/log4j-core/src/test/java/org/apache/logging/log4j/MarkerMixInJsonTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/MarkerMixInJsonTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/MarkerMixInJsonTest.java new file mode 100644 index 0000000..6ae91c8 --- /dev/null +++ b/log4j-core/src/test/java/org/apache/logging/log4j/MarkerMixInJsonTest.java @@ -0,0 +1,31 @@ +/* +* 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; + +import org.apache.logging.log4j.core.jackson.Log4jJsonObjectMapper; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public class MarkerMixInJsonTest extends MarkerMixInTest { + + @Override + protected ObjectMapper newObjectMapper() { + return new Log4jJsonObjectMapper(); + } + +} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a2d3215a/log4j-core/src/test/java/org/apache/logging/log4j/MarkerMixInTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/MarkerMixInTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/MarkerMixInTest.java index ddde008..99ba28a 100644 --- a/log4j-core/src/test/java/org/apache/logging/log4j/MarkerMixInTest.java +++ b/log4j-core/src/test/java/org/apache/logging/log4j/MarkerMixInTest.java @@ -25,6 +25,7 @@ import org.junit.Before; import org.junit.Test; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectReader; import com.fasterxml.jackson.databind.ObjectWriter; @@ -33,19 +34,21 @@ import com.fasterxml.jackson.databind.ObjectWriter; * * This class is in this package to let {@link Log4jMarker} have the least visibility. */ -public class MarkerMixInTest { +public abstract class MarkerMixInTest { private ObjectReader reader; private ObjectWriter writer; @Before public void setUp() { - final Log4jJsonObjectMapper log4jObjectMapper = new Log4jJsonObjectMapper(); + final ObjectMapper log4jObjectMapper = newObjectMapper(); writer = log4jObjectMapper.writer(); reader = log4jObjectMapper.readerFor(Log4jMarker.class); MarkerManager.clear(); } + protected abstract ObjectMapper newObjectMapper(); + @Test public void testNameOnly() throws IOException { final Marker expected = MarkerManager.getMarker("A"); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a2d3215a/log4j-core/src/test/java/org/apache/logging/log4j/MarkerMixInXmlTest.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/MarkerMixInXmlTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/MarkerMixInXmlTest.java new file mode 100644 index 0000000..8c63560 --- /dev/null +++ b/log4j-core/src/test/java/org/apache/logging/log4j/MarkerMixInXmlTest.java @@ -0,0 +1,31 @@ +/* +* 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; + +import org.apache.logging.log4j.core.jackson.Log4jXmlObjectMapper; + +import com.fasterxml.jackson.databind.ObjectMapper; + +public class MarkerMixInXmlTest extends MarkerMixInTest { + + @Override + protected ObjectMapper newObjectMapper() { + return new Log4jXmlObjectMapper(); + } + +}
