Plus it would be easier to just use LoggerContextRule here.

On 29 June 2016 at 15:01, Gary Gregory <[email protected]> wrote:

> Almost -1: The test does not clean up after itself, specifically it does
> not restore the system property.
>
> Gary
>
> ---------- Forwarded message ----------
> From: <[email protected]>
> Date: Wed, Jun 29, 2016 at 12:39 PM
> Subject: logging-log4j2 git commit: Incomplete test to illustrate
> LOG4J2-1452
> To: [email protected]
>
>
> Repository: logging-log4j2
> Updated Branches:
>   refs/heads/master da3550d14 -> 723040dc9
>
>
> Incomplete test to illustrate LOG4J2-1452
>
>
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> Commit:
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/723040dc
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/723040dc
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/723040dc
>
> Branch: refs/heads/master
> Commit: 723040dc9d433e94eca9a147e629dc32a8bfb152
> Parents: da3550d
> Author: Mikael Ståldal <[email protected]>
> Authored: Wed Jun 29 21:39:24 2016 +0200
> Committer: Mikael Ståldal <[email protected]>
> Committed: Wed Jun 29 21:39:24 2016 +0200
>
> ----------------------------------------------------------------------
>  .../logging/log4j/core/FlowTracingTest.java     | 44 ++++++++++++++++++++
>  .../src/test/resources/FlowTracingTest.xml      | 16 +++++++
>  2 files changed, 60 insertions(+)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/723040dc/log4j-core/src/test/java/org/apache/logging/log4j/core/FlowTracingTest.java
> ----------------------------------------------------------------------
> diff --git
> a/log4j-core/src/test/java/org/apache/logging/log4j/core/FlowTracingTest.java
> b/log4j-core/src/test/java/org/apache/logging/log4j/core/FlowTracingTest.java
> new file mode 100644
> index 0000000..feef612
> --- /dev/null
> +++
> b/log4j-core/src/test/java/org/apache/logging/log4j/core/FlowTracingTest.java
> @@ -0,0 +1,44 @@
> +/*
> + * 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.core;
> +
> +import org.apache.logging.log4j.LogManager;
> +import org.apache.logging.log4j.core.config.ConfigurationFactory;
> +import org.apache.logging.log4j.message.EntryMessage;
> +import org.junit.BeforeClass;
> +import org.junit.Test;
> +
> +/**
> + * Incomplete test to illustrate LOG4J2-1452.
> + */
> +public class FlowTracingTest {
> +
> +    @BeforeClass
> +    public static void beforeClass() {
> +
> System.setProperty(ConfigurationFactory.CONFIGURATION_FILE_PROPERTY,
> "FlowTracingTest.xml");
> +    }
> +
> +    @Test
> +    public void testFlowTracing() throws Exception {
> +        final org.apache.logging.log4j.Logger logger =
> LogManager.getLogger("com.foo.Bar");
> +
> +        EntryMessage entryMessage =
> logger.traceEntry(logger.getMessageFactory().newMessage("the entry"));
> +        logger.info("something else");
> +        logger.traceExit(entryMessage);
> +    }
> +
> +}
>
>
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/723040dc/log4j-core/src/test/resources/FlowTracingTest.xml
> ----------------------------------------------------------------------
> diff --git a/log4j-core/src/test/resources/FlowTracingTest.xml
> b/log4j-core/src/test/resources/FlowTracingTest.xml
> new file mode 100644
> index 0000000..8b4c257
> --- /dev/null
> +++ b/log4j-core/src/test/resources/FlowTracingTest.xml
> @@ -0,0 +1,16 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<Configuration status="ERROR">
> +  <Appenders>
> +    <Console name="Console">
> +      <PatternLayout>
> +        <Pattern>%p %c{1} %m%n</Pattern>
> +      </PatternLayout>
> +    </Console>
> +  </Appenders>
> +
> +  <Loggers>
> +    <Root level="trace">
> +      <AppenderRef ref="Console"/>
> +    </Root>
> +  </Loggers>
> +</Configuration>
> \ No newline at end of file
>
>
>
>
> --
> E-Mail: [email protected] | [email protected]
> Java Persistence with Hibernate, Second Edition
> <http://www.manning.com/bauer3/>
> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
> Spring Batch in Action <http://www.manning.com/templier/>
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>



-- 
Matt Sicker <[email protected]>

Reply via email to