You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Ralph Goers <ra...@dslextreme.com> on 2015/10/01 08:12:34 UTC

Re: logging-log4j2 git commit: Add org.apache.logging.log4j.core.layout.PatternLayoutTest.testRegexEmptyMarker().

I guess this unit test needs comments at the top.  There are tests that are sensitive to the line number of where they are being logged. So adding or removing lines will break those tests.

Ralph

> On Sep 30, 2015, at 10:03 PM, ggregory@apache.org wrote:
> 
> Repository: logging-log4j2
> Updated Branches:
>  refs/heads/master 231241c3f -> dd658d916
> 
> 
> Add
> org.apache.logging.log4j.core.layout.PatternLayoutTest.testRegexEmptyMarker().
> 
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/dd658d91
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/dd658d91
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/dd658d91
> 
> Branch: refs/heads/master
> Commit: dd658d916d9ada02d8140971a7f22e3d97b46bc0
> Parents: 231241c
> Author: ggregory <gg...@apache.org>
> Authored: Wed Sep 30 22:03:48 2015 -0700
> Committer: ggregory <gg...@apache.org>
> Committed: Wed Sep 30 22:03:48 2015 -0700
> 
> ----------------------------------------------------------------------
> .../log4j/core/layout/PatternLayoutTest.java    | 22 ++++++++++++++++++++
> 1 file changed, 22 insertions(+)
> ----------------------------------------------------------------------
> 
> 
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/dd658d91/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
> ----------------------------------------------------------------------
> diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
> index 0b372bb..19a6111 100644
> --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
> +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
> @@ -179,6 +179,28 @@ public class PatternLayoutTest {
>     }
> 
>     @Test
> +    public void testRegexEmptyMarker() throws Exception {
> +        // replace "[]" with the empty string
> +        final PatternLayout layout = PatternLayout.newBuilder().withPattern("[%logger]%replace{[%marker]}{\\[\\]}{} %msg")
> +                .withConfiguration(ctx.getConfiguration()).build();
> +        // Not empty marker
> +        final LogEvent event1 = Log4jLogEvent.newBuilder() //
> +                .setLoggerName(this.getClass().getName()).setLoggerFqcn("org.apache.logging.log4j.core.Logger") //
> +                .setLevel(Level.INFO) //
> +                .setMarker(MarkerManager.getMarker("TestMarker")) //
> +                .setMessage(new SimpleMessage("Hello, world!")).build();
> +        final byte[] result1 = layout.toByteArray(event1);
> +        assertEquals("[org.apache.logging.log4j.core.layout.PatternLayoutTest][TestMarker] Hello, world!", new String(result1));
> +        // empty marker
> +        final LogEvent event2 = Log4jLogEvent.newBuilder() //
> +                .setLoggerName(this.getClass().getName()).setLoggerFqcn("org.apache.logging.log4j.core.Logger") //
> +                .setLevel(Level.INFO) //
> +                .setMessage(new SimpleMessage("Hello, world!")).build();
> +        final byte[] result2 = layout.toByteArray(event2);
> +        assertEquals("[org.apache.logging.log4j.core.layout.PatternLayoutTest] Hello, world!", new String(result2));
> +    }
> +
> +    @Test
>     public void testSpecialChars() throws Exception {
>         final PatternLayout layout = PatternLayout.newBuilder().withPattern("\\\\%level\\t%msg\\n\\t%logger\\r\\n\\f")
>                 .withConfiguration(ctx.getConfiguration()).build();
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Re: logging-log4j2 git commit: Add org.apache.logging.log4j.core.layout.PatternLayoutTest.testRegexEmptyMarker().

Posted by Remko Popma <re...@gmail.com>.
For some reason Jenkins is still not happy with that test after the line change to 303. 

https://builds.apache.org/job/Log4j%202.x/lastBuild/org.apache.logging.log4j$log4j-core/testReport/org.apache.logging.log4j.core.layout/PatternLayoutTest/testPatternSelector/

Sent from my iPhone

> On 2015/10/01, at 8:46, Gary Gregory <ga...@gmail.com> wrote:
> 
> Oops, my bad, fixed.
> 
> Thank you,
> Gary
> 
>> On Wed, Sep 30, 2015 at 11:12 PM, Ralph Goers <ra...@dslextreme.com> wrote:
>> I guess this unit test needs comments at the top.  There are tests that are sensitive to the line number of where they are being logged. So adding or removing lines will break those tests.
>> 
>> Ralph
>> 
>> > On Sep 30, 2015, at 10:03 PM, ggregory@apache.org wrote:
>> >
>> > Repository: logging-log4j2
>> > Updated Branches:
>> >  refs/heads/master 231241c3f -> dd658d916
>> >
>> >
>> > Add
>> > org.apache.logging.log4j.core.layout.PatternLayoutTest.testRegexEmptyMarker().
>> >
>> > Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>> > Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/dd658d91
>> > Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/dd658d91
>> > Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/dd658d91
>> >
>> > Branch: refs/heads/master
>> > Commit: dd658d916d9ada02d8140971a7f22e3d97b46bc0
>> > Parents: 231241c
>> > Author: ggregory <gg...@apache.org>
>> > Authored: Wed Sep 30 22:03:48 2015 -0700
>> > Committer: ggregory <gg...@apache.org>
>> > Committed: Wed Sep 30 22:03:48 2015 -0700
>> >
>> > ----------------------------------------------------------------------
>> > .../log4j/core/layout/PatternLayoutTest.java    | 22 ++++++++++++++++++++
>> > 1 file changed, 22 insertions(+)
>> > ----------------------------------------------------------------------
>> >
>> >
>> > http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/dd658d91/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
>> > ----------------------------------------------------------------------
>> > diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
>> > index 0b372bb..19a6111 100644
>> > --- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
>> > +++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
>> > @@ -179,6 +179,28 @@ public class PatternLayoutTest {
>> >     }
>> >
>> >     @Test
>> > +    public void testRegexEmptyMarker() throws Exception {
>> > +        // replace "[]" with the empty string
>> > +        final PatternLayout layout = PatternLayout.newBuilder().withPattern("[%logger]%replace{[%marker]}{\\[\\]}{} %msg")
>> > +                .withConfiguration(ctx.getConfiguration()).build();
>> > +        // Not empty marker
>> > +        final LogEvent event1 = Log4jLogEvent.newBuilder() //
>> > +                .setLoggerName(this.getClass().getName()).setLoggerFqcn("org.apache.logging.log4j.core.Logger") //
>> > +                .setLevel(Level.INFO) //
>> > +                .setMarker(MarkerManager.getMarker("TestMarker")) //
>> > +                .setMessage(new SimpleMessage("Hello, world!")).build();
>> > +        final byte[] result1 = layout.toByteArray(event1);
>> > +        assertEquals("[org.apache.logging.log4j.core.layout.PatternLayoutTest][TestMarker] Hello, world!", new String(result1));
>> > +        // empty marker
>> > +        final LogEvent event2 = Log4jLogEvent.newBuilder() //
>> > +                .setLoggerName(this.getClass().getName()).setLoggerFqcn("org.apache.logging.log4j.core.Logger") //
>> > +                .setLevel(Level.INFO) //
>> > +                .setMessage(new SimpleMessage("Hello, world!")).build();
>> > +        final byte[] result2 = layout.toByteArray(event2);
>> > +        assertEquals("[org.apache.logging.log4j.core.layout.PatternLayoutTest] Hello, world!", new String(result2));
>> > +    }
>> > +
>> > +    @Test
>> >     public void testSpecialChars() throws Exception {
>> >         final PatternLayout layout = PatternLayout.newBuilder().withPattern("\\\\%level\\t%msg\\n\\t%logger\\r\\n\\f")
>> >                 .withConfiguration(ctx.getConfiguration()).build();
>> >
>> >
>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
>> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>> 
> 
> 
> 
> -- 
> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
> Java Persistence with Hibernate, Second Edition
> JUnit in Action, Second Edition
> Spring Batch in Action
> Blog: http://garygregory.wordpress.com 
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory

Re: logging-log4j2 git commit: Add org.apache.logging.log4j.core.layout.PatternLayoutTest.testRegexEmptyMarker().

Posted by Gary Gregory <ga...@gmail.com>.
Oops, my bad, fixed.

Thank you,
Gary

On Wed, Sep 30, 2015 at 11:12 PM, Ralph Goers <ra...@dslextreme.com>
wrote:

> I guess this unit test needs comments at the top.  There are tests that
> are sensitive to the line number of where they are being logged. So adding
> or removing lines will break those tests.
>
> Ralph
>
> > On Sep 30, 2015, at 10:03 PM, ggregory@apache.org wrote:
> >
> > Repository: logging-log4j2
> > Updated Branches:
> >  refs/heads/master 231241c3f -> dd658d916
> >
> >
> > Add
> >
> org.apache.logging.log4j.core.layout.PatternLayoutTest.testRegexEmptyMarker().
> >
> > Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> > Commit:
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/dd658d91
> > Tree:
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/dd658d91
> > Diff:
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/dd658d91
> >
> > Branch: refs/heads/master
> > Commit: dd658d916d9ada02d8140971a7f22e3d97b46bc0
> > Parents: 231241c
> > Author: ggregory <gg...@apache.org>
> > Authored: Wed Sep 30 22:03:48 2015 -0700
> > Committer: ggregory <gg...@apache.org>
> > Committed: Wed Sep 30 22:03:48 2015 -0700
> >
> > ----------------------------------------------------------------------
> > .../log4j/core/layout/PatternLayoutTest.java    | 22 ++++++++++++++++++++
> > 1 file changed, 22 insertions(+)
> > ----------------------------------------------------------------------
> >
> >
> >
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/dd658d91/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
> > ----------------------------------------------------------------------
> > diff --git
> a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
> b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
> > index 0b372bb..19a6111 100644
> > ---
> a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
> > +++
> b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutTest.java
> > @@ -179,6 +179,28 @@ public class PatternLayoutTest {
> >     }
> >
> >     @Test
> > +    public void testRegexEmptyMarker() throws Exception {
> > +        // replace "[]" with the empty string
> > +        final PatternLayout layout =
> PatternLayout.newBuilder().withPattern("[%logger]%replace{[%marker]}{\\[\\]}{}
> %msg")
> > +                .withConfiguration(ctx.getConfiguration()).build();
> > +        // Not empty marker
> > +        final LogEvent event1 = Log4jLogEvent.newBuilder() //
> > +
> .setLoggerName(this.getClass().getName()).setLoggerFqcn("org.apache.logging.log4j.core.Logger")
> //
> > +                .setLevel(Level.INFO) //
> > +                .setMarker(MarkerManager.getMarker("TestMarker")) //
> > +                .setMessage(new SimpleMessage("Hello, world!")).build();
> > +        final byte[] result1 = layout.toByteArray(event1);
> > +
> assertEquals("[org.apache.logging.log4j.core.layout.PatternLayoutTest][TestMarker]
> Hello, world!", new String(result1));
> > +        // empty marker
> > +        final LogEvent event2 = Log4jLogEvent.newBuilder() //
> > +
> .setLoggerName(this.getClass().getName()).setLoggerFqcn("org.apache.logging.log4j.core.Logger")
> //
> > +                .setLevel(Level.INFO) //
> > +                .setMessage(new SimpleMessage("Hello, world!")).build();
> > +        final byte[] result2 = layout.toByteArray(event2);
> > +
> assertEquals("[org.apache.logging.log4j.core.layout.PatternLayoutTest]
> Hello, world!", new String(result2));
> > +    }
> > +
> > +    @Test
> >     public void testSpecialChars() throws Exception {
> >         final PatternLayout layout =
> PatternLayout.newBuilder().withPattern("\\\\%level\\t%msg\\n\\t%logger\\r\\n\\f")
> >                 .withConfiguration(ctx.getConfiguration()).build();
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-dev-help@logging.apache.org
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
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