You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2015/09/02 18:46:24 UTC

[1/2] logging-log4j2 git commit: Format: Remove dead space.

Repository: logging-log4j2
Updated Branches:
  refs/heads/master d9daa31f3 -> e74f12d02


Format: Remove dead space.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/d6132ea2
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/d6132ea2
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/d6132ea2

Branch: refs/heads/master
Commit: d6132ea2d131ca2ba3f84c531eeaf2eabf8e4fec
Parents: d9daa31
Author: ggregory <gg...@apache.org>
Authored: Wed Sep 2 08:43:12 2015 -0700
Committer: ggregory <gg...@apache.org>
Committed: Wed Sep 2 08:43:12 2015 -0700

----------------------------------------------------------------------
 .../org/apache/logging/log4j/core/layout/PatternLayoutTest.java     | 1 -
 1 file changed, 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/d6132ea2/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 4cffa6f..60d3d56 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
@@ -66,7 +66,6 @@ public class PatternLayoutTest {
     @After
     public void after() {
         ThreadContext.clearMap();
-
     }
 
     @Test


[2/2] logging-log4j2 git commit: Test LOG4J2-962. Update API signature for MainMapLookup.setMainArguments from String[] to String... for simpler call sites.

Posted by gg...@apache.org.
Test LOG4J2-962. Update API signature for MainMapLookup.setMainArguments
from String[] to String... for simpler call sites.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/e74f12d0
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/e74f12d0
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/e74f12d0

Branch: refs/heads/master
Commit: e74f12d029f8afe90935ae7cc5c9d68156f7f622
Parents: d6132ea
Author: ggregory <gg...@apache.org>
Authored: Wed Sep 2 09:46:19 2015 -0700
Committer: ggregory <gg...@apache.org>
Committed: Wed Sep 2 09:46:19 2015 -0700

----------------------------------------------------------------------
 .../log4j/core/lookup/MainMapLookup.java        |  2 +-
 .../logging/log4j/core/lookup/MapLookup.java    |  2 +-
 .../layout/PatternLayoutMainMapLookupTest.java  | 56 ++++++++++++++++++++
 .../log4j/core/layout/PatternLayoutTest.java    |  2 +-
 log4j-core/src/test/resources/log4j2-962.xml    | 31 +++++++++++
 5 files changed, 90 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e74f12d0/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/MainMapLookup.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/MainMapLookup.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/MainMapLookup.java
index c3f82e2..cd6d18f 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/MainMapLookup.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/MainMapLookup.java
@@ -60,7 +60,7 @@ public class MainMapLookup extends MapLookup {
      * @param args
      *        An application's {@code public static main(String[])} arguments.
      */
-    public static void setMainArguments(final String[] args) {
+    public static void setMainArguments(final String... args) {
         if (args == null) {
             return;
         }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e74f12d0/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/MapLookup.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/MapLookup.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/MapLookup.java
index db5efd9..5889dcc 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/MapLookup.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/MapLookup.java
@@ -71,7 +71,7 @@ public class MapLookup implements StrLookup {
      * @deprecated As of 2.4, use {@link MainMapLookup#setMainArguments(String[])}
      */
     @Deprecated
-    public static void setMainArguments(final String[] args) {
+    public static void setMainArguments(final String... args) {
         MainMapLookup.setMainArguments(args);
     }
 

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e74f12d0/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutMainMapLookupTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutMainMapLookupTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutMainMapLookupTest.java
new file mode 100644
index 0000000..a33663b
--- /dev/null
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/PatternLayoutMainMapLookupTest.java
@@ -0,0 +1,56 @@
+/*
+ * 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.layout;
+
+import java.util.List;
+
+import org.apache.logging.log4j.Logger;
+import org.apache.logging.log4j.core.lookup.MainMapLookup;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+
+/**
+ * Tests LOG4j2-962.
+ */
+public class PatternLayoutMainMapLookupTest {
+
+    static {
+        // Must be set before Log4j writes the header to the appenders.
+        MainMapLookup.setMainArguments("value0", "value1", "value2");
+    }
+    
+    private ListAppender listApp;
+
+    @Rule
+    public LoggerContextRule context = new LoggerContextRule("log4j2-962.xml");
+
+    @Test
+    public void testHeader() {
+        listApp = context.getListAppender("List");
+        Logger logger = context.getLogger(this.getClass().getName());
+        logger.info("Hello World");
+        final List<String> messages = listApp.getMessages();
+        Assert.assertFalse(messages.isEmpty());
+        Assert.assertEquals("Header: value0", messages.get(0));
+        listApp.stop();
+        Assert.assertEquals("Footer: value1", messages.get(2));
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e74f12d0/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 60d3d56..bac234c 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
@@ -98,7 +98,7 @@ public class PatternLayoutTest {
      */
     @Test
     public void testHeaderFooterMainLookup() {
-        MainMapLookup.setMainArguments(new String[] { "value0", "value1", "value2" });
+        MainMapLookup.setMainArguments("value0", "value1", "value2");
         final PatternLayout layout = PatternLayout.newBuilder().withConfiguration(ctx.getConfiguration())
                 .withHeader("${main:0}").withFooter("${main:2}").build();
         final byte[] header = layout.getHeader();

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/e74f12d0/log4j-core/src/test/resources/log4j2-962.xml
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/resources/log4j2-962.xml b/log4j-core/src/test/resources/log4j2-962.xml
new file mode 100644
index 0000000..2617ec8
--- /dev/null
+++ b/log4j-core/src/test/resources/log4j2-962.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+
+-->
+<!-- https://issues.apache.org/jira/browse/LOG4J2-962 -->
+<Configuration status="ALL">
+  <Appenders>
+    <List name="List">
+      <PatternLayout pattern="%d %msg%n" header="Header: ${main:0}" footer="Footer: ${main:1}" />
+    </List>
+  </Appenders>
+  <Loggers>
+    <Root level="TRACE">
+      <AppenderRef ref="List" />
+    </Root>
+  </Loggers>
+</Configuration>
\ No newline at end of file