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 2022/01/15 23:49:41 UTC

[logging-log4j2] branch master updated (bf987be -> 0fc8421)

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git.


    from bf987be  Add Interpolator#getDefaultLookup().
     new fd923e8  Add PropertiesLookup#getProperties().
     new 0fc8421  Add PropertiesLookup#getProperties().

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ...ntLookupTest.java => PropertiesLookupTest.java} | 22 +++++++++++++---------
 .../log4j/core/lookup/PropertiesLookup.java        | 19 ++++++++++++++++---
 2 files changed, 29 insertions(+), 12 deletions(-)
 copy log4j-core-test/src/test/java/org/apache/logging/log4j/core/lookup/{EnvironmentLookupTest.java => PropertiesLookupTest.java} (70%)

[logging-log4j2] 02/02: Add PropertiesLookup#getProperties().

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit 0fc8421916dc017f954ff9dddcc2e5724f0b5613
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jan 15 18:49:38 2022 -0500

    Add PropertiesLookup#getProperties().
---
 .../log4j/core/lookup/PropertiesLookupTest.java    | 37 ++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/log4j-core-test/src/test/java/org/apache/logging/log4j/core/lookup/PropertiesLookupTest.java b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/lookup/PropertiesLookupTest.java
new file mode 100644
index 0000000..2c708f0
--- /dev/null
+++ b/log4j-core-test/src/test/java/org/apache/logging/log4j/core/lookup/PropertiesLookupTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.lookup;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.HashMap;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link PropertiesLookup}.
+ */
+public class PropertiesLookupTest {
+
+    @Test
+    public void testGetProperties() {
+        final HashMap<String, String> properties = new HashMap<>();
+        properties.put("A", "1");
+        assertEquals(properties, new PropertiesLookup(properties).getProperties());
+    }
+}

[logging-log4j2] 01/02: Add PropertiesLookup#getProperties().

Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git

commit fd923e8bb96ce5a1e432d74d01d6264816afa57e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jan 15 18:45:37 2022 -0500

    Add PropertiesLookup#getProperties().
    
    Commit 1/2 for cherry-picking to master.
---
 .../logging/log4j/core/lookup/PropertiesLookup.java   | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/PropertiesLookup.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/PropertiesLookup.java
index 995a71b..3066792 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/PropertiesLookup.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/lookup/PropertiesLookup.java
@@ -34,16 +34,28 @@ public final class PropertiesLookup implements StrLookup {
      */
     private final Map<String, String> properties;
 
+    /**
+     * Constructs a new instance for the given map.
+     *
+     * @param properties map these.
+     */
     public PropertiesLookup(final Map<String, String> properties) {
         this.properties = properties == null
                 ? Collections.emptyMap()
                 : properties;
     }
 
+    /**
+     * Gets the property map.
+     *
+     * @return the property map.
+     */
+    public Map<String, String> getProperties() {
+        return properties;
+    }
+
     @Override
-    public String lookup(
-            @SuppressWarnings("ignored") final LogEvent event,
-            final String key) {
+    public String lookup(@SuppressWarnings("ignored") final LogEvent event, final String key) {
         return lookup(key);
     }
 
@@ -65,4 +77,5 @@ public final class PropertiesLookup implements StrLookup {
     public String toString() {
         return "PropertiesLookup{properties=" + properties + '}';
     }
+
 }