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 2016/09/13 19:30:22 UTC
[1/4] logging-log4j2 git commit: Use try-with-resources.
Repository: logging-log4j2
Updated Branches:
refs/heads/master 034eb3ca1 -> 789d74ad3
Use try-with-resources.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/0c53da65
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/0c53da65
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/0c53da65
Branch: refs/heads/master
Commit: 0c53da65973dac0ce17494b129ce1fc8c67615b6
Parents: 034eb3c
Author: Gary Gregory <gg...@apache.org>
Authored: Tue Sep 13 12:17:24 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Tue Sep 13 12:17:24 2016 -0700
----------------------------------------------------------------------
.../util/ResolverUtilCustomProtocolTest.java | 39 +++++++++++---------
1 file changed, 21 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/0c53da65/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java
index 18d502d..8891415 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java
@@ -22,12 +22,14 @@ import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.net.Proxy;
import java.net.URL;
+import java.net.URLClassLoader;
import java.net.URLConnection;
import java.net.URLStreamHandler;
import java.net.URLStreamHandlerFactory;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
+
import org.apache.logging.log4j.core.config.plugins.util.PluginRegistry.PluginTest;
import org.apache.logging.log4j.junit.URLStreamHandlerFactoryRule;
import org.junit.Rule;
@@ -42,7 +44,7 @@ public class ResolverUtilCustomProtocolTest {
public URLStreamHandlerFactoryRule rule = new URLStreamHandlerFactoryRule(new NoopURLStreamHandlerFactory());
static class NoopURLStreamHandlerFactory implements URLStreamHandlerFactory {
-
+
@Override
public URLStreamHandler createURLStreamHandler(final String protocol) {
return new URLStreamHandler() {
@@ -176,27 +178,28 @@ public class ResolverUtilCustomProtocolTest {
@Test
public void testFindInPackageFromVfsDirectoryURL() throws Exception {
- final ClassLoader cl = ResolverUtilTest.compileAndCreateClassLoader("3");
-
- final ResolverUtil resolverUtil = new ResolverUtil();
- resolverUtil.setClassLoader(new SingleURLClassLoader(new URL("vfs:/target/resolverutil3/customplugin3/"), cl));
- resolverUtil.findInPackage(new PluginTest(), "customplugin3");
- assertEquals("Class not found in packages", 1, resolverUtil.getClasses().size());
- assertEquals("Unexpected class resolved", cl.loadClass("customplugin3.FixedString3Layout"),
- resolverUtil.getClasses().iterator().next());
+ try (final URLClassLoader cl = ResolverUtilTest.compileAndCreateClassLoader("3")) {
+ final ResolverUtil resolverUtil = new ResolverUtil();
+ resolverUtil
+ .setClassLoader(new SingleURLClassLoader(new URL("vfs:/target/resolverutil3/customplugin3/"), cl));
+ resolverUtil.findInPackage(new PluginTest(), "customplugin3");
+ assertEquals("Class not found in packages", 1, resolverUtil.getClasses().size());
+ assertEquals("Unexpected class resolved", cl.loadClass("customplugin3.FixedString3Layout"),
+ resolverUtil.getClasses().iterator().next());
+ }
}
@Test
public void testFindInPackageFromVfsJarURL() throws Exception {
- final ClassLoader cl = ResolverUtilTest.compileJarAndCreateClassLoader("4");
-
- final ResolverUtil resolverUtil = new ResolverUtil();
- resolverUtil.setClassLoader(
- new SingleURLClassLoader(new URL("vfs:/target/resolverutil4/customplugin4.jar/customplugin4/"), cl));
- resolverUtil.findInPackage(new PluginTest(), "customplugin4");
- assertEquals("Class not found in packages", 1, resolverUtil.getClasses().size());
- assertEquals("Unexpected class resolved", cl.loadClass("customplugin4.FixedString4Layout"),
- resolverUtil.getClasses().iterator().next());
+ try (final URLClassLoader cl = ResolverUtilTest.compileJarAndCreateClassLoader("4")) {
+ final ResolverUtil resolverUtil = new ResolverUtil();
+ resolverUtil.setClassLoader(new SingleURLClassLoader(
+ new URL("vfs:/target/resolverutil4/customplugin4.jar/customplugin4/"), cl));
+ resolverUtil.findInPackage(new PluginTest(), "customplugin4");
+ assertEquals("Class not found in packages", 1, resolverUtil.getClasses().size());
+ assertEquals("Unexpected class resolved", cl.loadClass("customplugin4.FixedString4Layout"),
+ resolverUtil.getClasses().iterator().next());
+ }
}
}
[2/4] logging-log4j2 git commit: Use try-with-resources.
Posted by gg...@apache.org.
Use try-with-resources.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/f4b75c8b
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/f4b75c8b
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/f4b75c8b
Branch: refs/heads/master
Commit: f4b75c8bab45a6766b7ed179584e18cc7b4ea030
Parents: 0c53da6
Author: Gary Gregory <gg...@apache.org>
Authored: Tue Sep 13 12:19:35 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Tue Sep 13 12:19:35 2016 -0700
----------------------------------------------------------------------
.../config/plugins/util/ResolverUtilTest.java | 42 +++++++++++---------
1 file changed, 24 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/f4b75c8b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
index 1b16430..392da7b 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
@@ -37,13 +37,21 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.logging.log4j.core.config.plugins.util.PluginRegistry.PluginTest;
+import org.apache.logging.log4j.junit.CleanFolders;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.RuleChain;
/**
* Tests the ResolverUtil class.
*/
public class ResolverUtilTest {
+ static final String WORK_DIR = "target/testpluginsutil";
+
+ @Rule
+ public RuleChain chain = RuleChain.outerRule(new CleanFolders(WORK_DIR));
+
@Test
public void testExtractPathFromJarUrl() throws Exception {
final URL url = new URL("jar:file:/C:/Users/me/.m2/repository/junit/junit/4.11/junit-4.11.jar!/org/junit/Test.class");
@@ -141,28 +149,26 @@ public class ResolverUtilTest {
@Test
public void testFindInPackageFromDirectoryPath() throws Exception {
- final ClassLoader cl = compileAndCreateClassLoader("1");
-
- final ResolverUtil resolverUtil = new ResolverUtil();
- resolverUtil.setClassLoader(cl);
- resolverUtil.findInPackage(new PluginTest(), "customplugin1");
- assertEquals("Class not found in packages", 1, resolverUtil.getClasses().size());
- assertEquals("Unexpected class resolved",
- cl.loadClass("customplugin1.FixedString1Layout"),
- resolverUtil.getClasses().iterator().next());
+ try (final URLClassLoader cl = compileAndCreateClassLoader("1")) {
+ final ResolverUtil resolverUtil = new ResolverUtil();
+ resolverUtil.setClassLoader(cl);
+ resolverUtil.findInPackage(new PluginTest(), "customplugin1");
+ assertEquals("Class not found in packages", 1, resolverUtil.getClasses().size());
+ assertEquals("Unexpected class resolved", cl.loadClass("customplugin1.FixedString1Layout"),
+ resolverUtil.getClasses().iterator().next());
+ }
}
@Test
public void testFindInPackageFromJarPath() throws Exception {
- final ClassLoader cl = compileJarAndCreateClassLoader("2");
-
- final ResolverUtil resolverUtil = new ResolverUtil();
- resolverUtil.setClassLoader(cl);
- resolverUtil.findInPackage(new PluginTest(), "customplugin2");
- assertEquals("Class not found in packages", 1, resolverUtil.getClasses().size());
- assertEquals("Unexpected class resolved",
- cl.loadClass("customplugin2.FixedString2Layout"),
- resolverUtil.getClasses().iterator().next());
+ try (final URLClassLoader cl = compileJarAndCreateClassLoader("2")) {
+ final ResolverUtil resolverUtil = new ResolverUtil();
+ resolverUtil.setClassLoader(cl);
+ resolverUtil.findInPackage(new PluginTest(), "customplugin2");
+ assertEquals("Class not found in packages", 1, resolverUtil.getClasses().size());
+ assertEquals("Unexpected class resolved", cl.loadClass("customplugin2.FixedString2Layout"),
+ resolverUtil.getClasses().iterator().next());
+ }
}
static URLClassLoader compileJarAndCreateClassLoader(final String suffix) throws IOException, Exception {
[4/4] logging-log4j2 git commit: [LOG4J2-1320] Custom plugins are not
loaded, URL protocol vfs is not supported. Clean up resources.
Posted by gg...@apache.org.
[LOG4J2-1320] Custom plugins are not loaded, URL protocol vfs is not
supported. Clean up resources.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/789d74ad
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/789d74ad
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/789d74ad
Branch: refs/heads/master
Commit: 789d74ad3f2322e46b9e9b617108e36b49fae558
Parents: c4db4df
Author: Gary Gregory <gg...@apache.org>
Authored: Tue Sep 13 12:24:39 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Tue Sep 13 12:24:39 2016 -0700
----------------------------------------------------------------------
.../config/plugins/util/ResolverUtilCustomProtocolTest.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/789d74ad/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java
index 8891415..33e0ee1 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilCustomProtocolTest.java
@@ -31,9 +31,11 @@ import java.util.Collections;
import java.util.Enumeration;
import org.apache.logging.log4j.core.config.plugins.util.PluginRegistry.PluginTest;
+import org.apache.logging.log4j.junit.CleanFolders;
import org.apache.logging.log4j.junit.URLStreamHandlerFactoryRule;
import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.RuleChain;
/**
* Tests the ResolverUtil class for custom protocol like bundleresource, vfs, vfszip.
@@ -43,6 +45,9 @@ public class ResolverUtilCustomProtocolTest {
@Rule
public URLStreamHandlerFactoryRule rule = new URLStreamHandlerFactoryRule(new NoopURLStreamHandlerFactory());
+ @Rule
+ public RuleChain chain = RuleChain.outerRule(new CleanFolders(ResolverUtilTest.WORK_DIR));
+
static class NoopURLStreamHandlerFactory implements URLStreamHandlerFactory {
@Override
@@ -181,7 +186,7 @@ public class ResolverUtilCustomProtocolTest {
try (final URLClassLoader cl = ResolverUtilTest.compileAndCreateClassLoader("3")) {
final ResolverUtil resolverUtil = new ResolverUtil();
resolverUtil
- .setClassLoader(new SingleURLClassLoader(new URL("vfs:/target/resolverutil3/customplugin3/"), cl));
+ .setClassLoader(new SingleURLClassLoader(new URL("vfs:/" + ResolverUtilTest.WORK_DIR + "/resolverutil3/customplugin3/"), cl));
resolverUtil.findInPackage(new PluginTest(), "customplugin3");
assertEquals("Class not found in packages", 1, resolverUtil.getClasses().size());
assertEquals("Unexpected class resolved", cl.loadClass("customplugin3.FixedString3Layout"),
@@ -194,7 +199,7 @@ public class ResolverUtilCustomProtocolTest {
try (final URLClassLoader cl = ResolverUtilTest.compileJarAndCreateClassLoader("4")) {
final ResolverUtil resolverUtil = new ResolverUtil();
resolverUtil.setClassLoader(new SingleURLClassLoader(
- new URL("vfs:/target/resolverutil4/customplugin4.jar/customplugin4/"), cl));
+ new URL("vfs:/" + ResolverUtilTest.WORK_DIR + "/resolverutil4/customplugin4.jar/customplugin4/"), cl));
resolverUtil.findInPackage(new PluginTest(), "customplugin4");
assertEquals("Class not found in packages", 1, resolverUtil.getClasses().size());
assertEquals("Unexpected class resolved", cl.loadClass("customplugin4.FixedString4Layout"),
[3/4] logging-log4j2 git commit: Clean up resources.
Posted by gg...@apache.org.
Clean up resources.
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/c4db4df5
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/c4db4df5
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/c4db4df5
Branch: refs/heads/master
Commit: c4db4df592339610b0e1b6238bb35f2e61471472
Parents: f4b75c8
Author: Gary Gregory <gg...@apache.org>
Authored: Tue Sep 13 12:21:14 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Tue Sep 13 12:21:14 2016 -0700
----------------------------------------------------------------------
.../logging/log4j/core/config/plugins/util/ResolverUtilTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/c4db4df5/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
index 392da7b..1c6371b 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/config/plugins/util/ResolverUtilTest.java
@@ -187,7 +187,7 @@ public class ResolverUtilTest {
static File compile(final String suffix) throws IOException {
final File orig = new File("target/test-classes/customplugin/FixedStringLayout.java.source");
- final File workDir = new File("target/resolverutil" + suffix);
+ final File workDir = new File(WORK_DIR, "resolverutil" + suffix);
final File f = new File(workDir, "customplugin" + suffix + "/FixedString" + suffix + "Layout.java");
final File parent = f.getParentFile();
if (!parent.exists()) {