You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/06/30 14:52:45 UTC
(commons-logging) branch master updated (50bc992 -> c4d0dca)
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/commons-logging.git
from 50bc992 Use generics
new 93c7195 Use generics
new c4d0dca Move declarations
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:
.../logging/pathable/ParentFirstTestCase.java | 30 ++++++++++------------
1 file changed, 13 insertions(+), 17 deletions(-)
(commons-logging) 01/02: Use generics
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/commons-logging.git
commit 93c7195cbb5dc14911b6ca531fbd402fefa7419b
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jun 30 10:45:15 2024 -0400
Use generics
---
.../logging/pathable/ParentFirstTestCase.java | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java b/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java
index d57f9b4..f68414c 100644
--- a/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java
+++ b/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java
@@ -55,7 +55,7 @@ public class ParentFirstTestCase extends TestCase {
* </ul>
*/
public static Test suite() throws Exception {
- final Class thisClass = ParentFirstTestCase.class;
+ final Class<ParentFirstTestCase> thisClass = ParentFirstTestCase.class;
final ClassLoader thisClassLoader = thisClass.getClassLoader();
// Make the parent a direct child of the bootloader to hide all
@@ -85,7 +85,7 @@ public class ParentFirstTestCase extends TestCase {
final PathableClassLoader context = new PathableClassLoader(child);
// reload this class via the child class loader
- final Class testClass = child.loadClass(thisClass.getName());
+ final Class<?> testClass = child.loadClass(thisClass.getName());
// and return our custom TestSuite class
return new PathableTestSuite(testClass, context);
@@ -165,30 +165,30 @@ public class ParentFirstTestCase extends TestCase {
// junit classes should be visible; their class loader is not
// in the hierarchy of parent class loaders for this class,
// though it is accessible due to trickery in the PathableClassLoader.
- final Class junitTest = contextLoader.loadClass("junit.framework.Test");
- final Set ancestorCLs = getAncestorCLs();
+ final Class<?> junitTest = contextLoader.loadClass("junit.framework.Test");
+ final Set<?> ancestorCLs = getAncestorCLs();
assertFalse("Junit not loaded by ancestor class loader",
ancestorCLs.contains(junitTest.getClassLoader()));
// jcl api classes should be visible only via the parent
- final Class logClass = contextLoader.loadClass("org.apache.commons.logging.Log");
+ final Class<?> logClass = contextLoader.loadClass("org.apache.commons.logging.Log");
assertSame("Log class not loaded via parent",
logClass.getClassLoader(), parentLoader);
// jcl adapter classes should be visible via both parent and child. However
// as the class loaders are parent-first we should see the parent one.
- final Class log4jClass = contextLoader.loadClass("org.apache.commons.logging.impl.Log4JLogger");
+ final Class<?> log4jClass = contextLoader.loadClass("org.apache.commons.logging.impl.Log4JLogger");
assertSame("Log4JLogger not loaded via parent",
log4jClass.getClassLoader(), parentLoader);
// test classes should be visible via the child only
- final Class testClass = contextLoader.loadClass("org.apache.commons.logging.PathableTestSuite");
+ final Class<?> testClass = contextLoader.loadClass("org.apache.commons.logging.PathableTestSuite");
assertSame("PathableTestSuite not loaded via child",
testClass.getClassLoader(), thisLoader);
// test loading of class that is not available
try {
- final Class noSuchClass = contextLoader.loadClass("no.such.class");
+ final Class<?> noSuchClass = contextLoader.loadClass("no.such.class");
fail("Class no.such.class is unexpectedly available");
assertNotNull(noSuchClass); // silence warning about unused var
} catch (final ClassNotFoundException ex) {
@@ -196,7 +196,7 @@ public class ParentFirstTestCase extends TestCase {
}
// String class class loader is null
- final Class stringClass = contextLoader.loadClass("java.lang.String");
+ final Class<?> stringClass = contextLoader.loadClass("java.lang.String");
assertNull("String class class loader is not null!",
stringClass.getClassLoader());
}
@@ -264,7 +264,7 @@ public class ParentFirstTestCase extends TestCase {
* Test that the various flavors of ClassLoader.getResources work as expected.
*/
public void testResources() throws Exception {
- Enumeration resources;
+ Enumeration<URL> resources;
URL[] urls;
// verify the class loader hierarchy
(commons-logging) 02/02: Move declarations
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/commons-logging.git
commit c4d0dca4611d04cd809fd868e4b215945fc0d31c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jun 30 10:46:52 2024 -0400
Move declarations
---
.../apache/commons/logging/pathable/ParentFirstTestCase.java | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java b/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java
index f68414c..91048ad 100644
--- a/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java
+++ b/src/test/java/org/apache/commons/logging/pathable/ParentFirstTestCase.java
@@ -18,6 +18,7 @@ package org.apache.commons.logging.pathable;
import static org.junit.Assert.assertNotEquals;
+import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
@@ -236,8 +237,6 @@ public class ParentFirstTestCase extends TestCase {
* Test that getResourceAsStream works.
*/
public void testResourceAsStream() throws Exception {
- java.io.InputStream is;
-
// verify the class loader hierarchy
final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
final ClassLoader childLoader = contextLoader.getParent();
@@ -246,7 +245,7 @@ public class ParentFirstTestCase extends TestCase {
assertNull("Unexpected class loader hierarchy", bootLoader);
// getResourceAsStream where no instances exist
- is = childLoader.getResourceAsStream("nosuchfile");
+ InputStream is = childLoader.getResourceAsStream("nosuchfile");
assertNull("Invalid resource returned non-null stream", is);
// getResourceAsStream where resource does exist
@@ -264,9 +263,6 @@ public class ParentFirstTestCase extends TestCase {
* Test that the various flavors of ClassLoader.getResources work as expected.
*/
public void testResources() throws Exception {
- Enumeration<URL> resources;
- URL[] urls;
-
// verify the class loader hierarchy
final ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
final ClassLoader childLoader = contextLoader.getParent();
@@ -275,8 +271,8 @@ public class ParentFirstTestCase extends TestCase {
assertNull("Unexpected class loader hierarchy", bootLoader);
// getResources where no instances exist
- resources = childLoader.getResources("nosuchfile");
- urls = toURLArray(resources);
+ Enumeration<URL> resources = childLoader.getResources("nosuchfile");
+ URL[] urls = toURLArray(resources);
assertEquals("Non-null URL returned for invalid resource name", 0, urls.length);
// getResources where the resource only exists in the parent