Repository: logging-log4j2
Updated Branches:
  refs/heads/LOG4J2-1597 cd570f830 -> f8482f1ba


[LOG4J2-1597] Rename ScriptSelectorAppender to ScriptAppenderSelector.

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

Branch: refs/heads/LOG4J2-1597
Commit: f8482f1ba6c83c3345f247d396c62a853fe093e7
Parents: cd570f8
Author: Gary Gregory <ggreg...@apache.org>
Authored: Mon Sep 19 17:06:51 2016 -0700
Committer: Gary Gregory <ggreg...@apache.org>
Committed: Mon Sep 19 17:06:51 2016 -0700

----------------------------------------------------------------------
 .../core/appender/ScriptAppenderSelector.java   | 137 +++++++++++++++++++
 .../log4j/core/appender/ScriptSelector.java     | 137 -------------------
 .../appender/ScriptAppenderSelectorTest.java    | 100 ++++++++++++++
 .../appender/ScriptSelectorAppenderTest.java    | 100 --------------
 .../log4j-appender-selector-groovy.xml          |   4 +-
 .../log4j-appender-selector-javascript.xml      |   4 +-
 6 files changed, 241 insertions(+), 241 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f8482f1b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ScriptAppenderSelector.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ScriptAppenderSelector.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ScriptAppenderSelector.java
new file mode 100644
index 0000000..ae6da0a
--- /dev/null
+++ 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ScriptAppenderSelector.java
@@ -0,0 +1,137 @@
+/*
+ * 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.appender;
+
+import java.io.Serializable;
+import java.util.Objects;
+
+import javax.script.Bindings;
+
+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.core.Filter;
+import org.apache.logging.log4j.core.Layout;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.config.Configuration;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
+import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
+import org.apache.logging.log4j.core.config.plugins.PluginElement;
+import 
org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
+import org.apache.logging.log4j.core.script.AbstractScript;
+import org.apache.logging.log4j.core.script.ScriptManager;
+
+@Plugin(name = "ScriptAppenderSelector", category = "Core", elementType = 
"appender", printObject = true)
+public class ScriptAppenderSelector extends AbstractAppender {
+
+    /**
+     * Builds an appender.
+     */
+    public static final class Builder implements 
org.apache.logging.log4j.core.util.Builder<Appender> {
+
+        @PluginElement("AppenderSet")
+        @Required
+        private AppenderSet appenderSet;
+
+        @PluginConfiguration
+        @Required
+        private Configuration configuration;
+
+        @PluginBuilderAttribute
+        @Required
+        private String name;
+
+        @PluginElement("Script")
+        @Required
+        private AbstractScript script;
+
+        @Override
+        public Appender build() {
+            if (name == null) {
+                LOGGER.error("Name missing.");
+            }
+            if (script == null) {
+                LOGGER.error("Script missing for ScriptAppenderSelector 
appender {}", name);
+            }
+            if (appenderSet == null) {
+                LOGGER.error("AppenderSet missing for ScriptAppenderSelector 
appender {}", name);
+            }
+            if (configuration == null) {
+                LOGGER.error("Configuration missing for ScriptAppenderSelector 
appender {}", name);
+            }
+            final ScriptManager scriptManager = 
configuration.getScriptManager();
+            scriptManager.addScript(script);
+            final Bindings bindings = scriptManager.createBindings(script);
+            final Object object = scriptManager.execute(script.getName(), 
bindings);
+            final String appenderName = Objects.toString(object, null);
+            final Appender appender = appenderSet.createAppender(appenderName, 
name);
+            return appender;
+        }
+
+        public AppenderSet getAppenderSet() {
+            return appenderSet;
+        }
+
+        public Configuration getConfiguration() {
+            return configuration;
+        }
+
+        public String getName() {
+            return name;
+        }
+
+        public AbstractScript getScript() {
+            return script;
+        }
+
+        public Builder withAppenderNodeSet(@SuppressWarnings("hiding") final 
AppenderSet appenderSet) {
+            this.appenderSet = appenderSet;
+            return this;
+        }
+
+        public Builder withConfiguration(@SuppressWarnings("hiding") final 
Configuration configuration) {
+            this.configuration = configuration;
+            return this;
+        }
+
+        public Builder withName(@SuppressWarnings("hiding") final String name) 
{
+            this.name = name;
+            return this;
+        }
+
+        public Builder withScript(@SuppressWarnings("hiding") final 
AbstractScript script) {
+            this.script = script;
+            return this;
+        }
+
+    }
+
+    @PluginBuilderFactory
+    public static Builder newBuilder() {
+        return new Builder();
+    }
+
+    private ScriptAppenderSelector(final String name, final Filter filter, 
final Layout<? extends Serializable> layout) {
+        super(name, filter, layout);
+    }
+
+    @Override
+    public void append(final LogEvent event) {
+        // Do nothing: This appender is only used to discover and build 
another appender
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f8482f1b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ScriptSelector.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ScriptSelector.java
 
b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ScriptSelector.java
deleted file mode 100644
index 0088abf..0000000
--- 
a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/ScriptSelector.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * 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.appender;
-
-import java.io.Serializable;
-import java.util.Objects;
-
-import javax.script.Bindings;
-
-import org.apache.logging.log4j.core.Appender;
-import org.apache.logging.log4j.core.Filter;
-import org.apache.logging.log4j.core.Layout;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.config.Configuration;
-import org.apache.logging.log4j.core.config.plugins.Plugin;
-import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute;
-import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory;
-import org.apache.logging.log4j.core.config.plugins.PluginConfiguration;
-import org.apache.logging.log4j.core.config.plugins.PluginElement;
-import 
org.apache.logging.log4j.core.config.plugins.validation.constraints.Required;
-import org.apache.logging.log4j.core.script.AbstractScript;
-import org.apache.logging.log4j.core.script.ScriptManager;
-
-@Plugin(name = "ScriptSelector", category = "Core", elementType = "appender", 
printObject = true)
-public class ScriptSelector extends AbstractAppender {
-
-    /**
-     * Builds an appender.
-     */
-    public static final class Builder implements 
org.apache.logging.log4j.core.util.Builder<Appender> {
-
-        @PluginElement("AppenderSet")
-        @Required
-        private AppenderSet appenderSet;
-
-        @PluginConfiguration
-        @Required
-        private Configuration configuration;
-
-        @PluginBuilderAttribute
-        @Required
-        private String name;
-
-        @PluginElement("Script")
-        @Required
-        private AbstractScript script;
-
-        @Override
-        public Appender build() {
-            if (name == null) {
-                LOGGER.error("Name missing.");
-            }
-            if (script == null) {
-                LOGGER.error("Script missing for ScriptSelector appender {}", 
name);
-            }
-            if (appenderSet == null) {
-                LOGGER.error("AppenderSet missing for ScriptSelector appender 
{}", name);
-            }
-            if (configuration == null) {
-                LOGGER.error("Configuration missing for ScriptSelector 
appender {}", name);
-            }
-            final ScriptManager scriptManager = 
configuration.getScriptManager();
-            scriptManager.addScript(script);
-            final Bindings bindings = scriptManager.createBindings(script);
-            final Object object = scriptManager.execute(script.getName(), 
bindings);
-            final String appenderName = Objects.toString(object, null);
-            final Appender appender = appenderSet.createAppender(appenderName, 
name);
-            return appender;
-        }
-
-        public AppenderSet getAppenderSet() {
-            return appenderSet;
-        }
-
-        public Configuration getConfiguration() {
-            return configuration;
-        }
-
-        public String getName() {
-            return name;
-        }
-
-        public AbstractScript getScript() {
-            return script;
-        }
-
-        public Builder withAppenderNodeSet(@SuppressWarnings("hiding") final 
AppenderSet appenderSet) {
-            this.appenderSet = appenderSet;
-            return this;
-        }
-
-        public Builder withConfiguration(@SuppressWarnings("hiding") final 
Configuration configuration) {
-            this.configuration = configuration;
-            return this;
-        }
-
-        public Builder withName(@SuppressWarnings("hiding") final String name) 
{
-            this.name = name;
-            return this;
-        }
-
-        public Builder withScript(@SuppressWarnings("hiding") final 
AbstractScript script) {
-            this.script = script;
-            return this;
-        }
-
-    }
-
-    @PluginBuilderFactory
-    public static Builder newBuilder() {
-        return new Builder();
-    }
-
-    private ScriptSelector(final String name, final Filter filter, final 
Layout<? extends Serializable> layout) {
-        super(name, filter, layout);
-    }
-
-    @Override
-    public void append(final LogEvent event) {
-        // Do nothing: This appender is only used to discover and build 
another appender
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f8482f1b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ScriptAppenderSelectorTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ScriptAppenderSelectorTest.java
 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ScriptAppenderSelectorTest.java
new file mode 100644
index 0000000..2e80467
--- /dev/null
+++ 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ScriptAppenderSelectorTest.java
@@ -0,0 +1,100 @@
+/*
+ * 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.appender;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.List;
+
+import org.apache.logging.log4j.Marker;
+import org.apache.logging.log4j.MarkerManager;
+import org.apache.logging.log4j.core.LogEvent;
+import org.apache.logging.log4j.core.Logger;
+import org.apache.logging.log4j.junit.LoggerContextRule;
+import org.apache.logging.log4j.test.appender.ListAppender;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+/**
+ *
+ */
+@RunWith(Parameterized.class)
+public class ScriptAppenderSelectorTest {
+
+    @Parameterized.Parameters(name = "{0}")
+    public static Object[][] getParameters() {
+        // @formatter:off
+        return new Object[][] { 
+            { "log4j-appender-selector-groovy.xml" },
+            { "log4j-appender-selector-javascript.xml" },
+        };
+        // @formatter:on
+    }
+
+    @Rule
+    public final LoggerContextRule loggerContextRule;
+
+    public ScriptAppenderSelectorTest(final String configLocation) {
+        this.loggerContextRule = new LoggerContextRule(configLocation);
+    }
+
+    private ListAppender getListAppender() {
+        return loggerContextRule.getListAppender("SelectIt");
+    }
+
+    private void logAndCheck() {
+        Marker marker = MarkerManager.getMarker("HEXDUMP");
+        final Logger logger = 
loggerContextRule.getLogger(ScriptAppenderSelectorTest.class);
+        logger.error("Hello");
+        final ListAppender listAppender = getListAppender();
+        final List<LogEvent> list = listAppender.getEvents();
+        assertNotNull("No events generated", list);
+        assertTrue("Incorrect number of events. Expected 1, got " + 
list.size(), list.size() == 1);
+        logger.error("World");
+        assertTrue("Incorrect number of events. Expected 2, got " + 
list.size(), list.size() == 2);
+        logger.error(marker, "DEADBEEF");
+        assertTrue("Incorrect number of events. Expected 3, got " + 
list.size(), list.size() == 3);
+    }
+
+    @Test(expected = AssertionError.class)
+    public void testAppender1Absence() {
+        loggerContextRule.getListAppender("List1");
+    }
+
+    @Test(expected = AssertionError.class)
+    public void testAppender2Absence() {
+        loggerContextRule.getListAppender("List2");
+    }
+
+    @Test
+    public void testAppenderPresence() {
+        getListAppender();
+    }
+
+    @Test
+    public void testLogging1() {
+        logAndCheck();
+    }
+
+    @Test
+    public void testLogging2() {
+        logAndCheck();
+    }
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f8482f1b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ScriptSelectorAppenderTest.java
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ScriptSelectorAppenderTest.java
 
b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ScriptSelectorAppenderTest.java
deleted file mode 100644
index c5095c2..0000000
--- 
a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/ScriptSelectorAppenderTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.appender;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-import java.util.List;
-
-import org.apache.logging.log4j.Marker;
-import org.apache.logging.log4j.MarkerManager;
-import org.apache.logging.log4j.core.LogEvent;
-import org.apache.logging.log4j.core.Logger;
-import org.apache.logging.log4j.junit.LoggerContextRule;
-import org.apache.logging.log4j.test.appender.ListAppender;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-/**
- *
- */
-@RunWith(Parameterized.class)
-public class ScriptSelectorAppenderTest {
-
-    @Parameterized.Parameters(name = "{0}")
-    public static Object[][] getParameters() {
-        // @formatter:off
-        return new Object[][] { 
-            { "log4j-appender-selector-groovy.xml" },
-            { "log4j-appender-selector-javascript.xml" },
-        };
-        // @formatter:on
-    }
-
-    @Rule
-    public final LoggerContextRule loggerContextRule;
-
-    public ScriptSelectorAppenderTest(final String configLocation) {
-        this.loggerContextRule = new LoggerContextRule(configLocation);
-    }
-
-    private ListAppender getListAppender() {
-        return loggerContextRule.getListAppender("SelectIt");
-    }
-
-    private void logAndCheck() {
-        Marker marker = MarkerManager.getMarker("HEXDUMP");
-        final Logger logger = 
loggerContextRule.getLogger(ScriptSelectorAppenderTest.class);
-        logger.error("Hello");
-        final ListAppender listAppender = getListAppender();
-        final List<LogEvent> list = listAppender.getEvents();
-        assertNotNull("No events generated", list);
-        assertTrue("Incorrect number of events. Expected 1, got " + 
list.size(), list.size() == 1);
-        logger.error("World");
-        assertTrue("Incorrect number of events. Expected 2, got " + 
list.size(), list.size() == 2);
-        logger.error(marker, "DEADBEEF");
-        assertTrue("Incorrect number of events. Expected 3, got " + 
list.size(), list.size() == 3);
-    }
-
-    @Test(expected = AssertionError.class)
-    public void testAppender1Absence() {
-        loggerContextRule.getListAppender("List1");
-    }
-
-    @Test(expected = AssertionError.class)
-    public void testAppender2Absence() {
-        loggerContextRule.getListAppender("List2");
-    }
-
-    @Test
-    public void testAppenderPresence() {
-        getListAppender();
-    }
-
-    @Test
-    public void testLogging1() {
-        logAndCheck();
-    }
-
-    @Test
-    public void testLogging2() {
-        logAndCheck();
-    }
-}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f8482f1b/log4j-core/src/test/resources/log4j-appender-selector-groovy.xml
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/resources/log4j-appender-selector-groovy.xml 
b/log4j-core/src/test/resources/log4j-appender-selector-groovy.xml
index 4a15273..91ecfef 100644
--- a/log4j-core/src/test/resources/log4j-appender-selector-groovy.xml
+++ b/log4j-core/src/test/resources/log4j-appender-selector-groovy.xml
@@ -17,7 +17,7 @@
 -->
 <Configuration status="WARN" name="RoutingTest">
   <Appenders>
-    <ScriptSelector name="SelectIt">
+    <ScriptAppenderSelector name="SelectIt">
       <Script language="groovy"><![CDATA[
          return "OSNameFoo".contains("Foo") ? "List2": "List1";]]>
       </Script>
@@ -25,7 +25,7 @@
         <List name="List1" />
         <List name="List2" />
       </AppenderSet>
-    </ScriptSelector>
+    </ScriptAppenderSelector>
   </Appenders>
   <Loggers>
     <Root level="error">

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f8482f1b/log4j-core/src/test/resources/log4j-appender-selector-javascript.xml
----------------------------------------------------------------------
diff --git 
a/log4j-core/src/test/resources/log4j-appender-selector-javascript.xml 
b/log4j-core/src/test/resources/log4j-appender-selector-javascript.xml
index f45e43c..6cc732b 100644
--- a/log4j-core/src/test/resources/log4j-appender-selector-javascript.xml
+++ b/log4j-core/src/test/resources/log4j-appender-selector-javascript.xml
@@ -17,7 +17,7 @@
 -->
 <Configuration status="WARN" name="RoutingTest">
   <Appenders>
-    <ScriptSelector name="SelectIt">
+    <ScriptAppenderSelector name="SelectIt">
       <Script language="JavaScript"><![CDATA[
          "OSNameFoo".search("Foo") > -1 ? "List2" : "List1";]]>
       </Script>
@@ -25,7 +25,7 @@
         <List name="List1" />
         <List name="List2" />
       </AppenderSet>
-    </ScriptSelector>
+    </ScriptAppenderSelector>
   </Appenders>
   <Loggers>
     <Root level="error">

Reply via email to