slawekjaranowski commented on a change in pull request #422:
URL: https://github.com/apache/maven-surefire/pull/422#discussion_r777108931
##########
File path:
surefire-providers/surefire-junit3/src/test/java/org/apache/maven/surefire/junit/JUnitTestSetTest.java
##########
@@ -22,15 +22,19 @@
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.apache.maven.surefire.api.testset.TestSetFailedException;
import org.apache.maven.surefire.common.junit3.JUnit3Reflector;
import org.apache.maven.surefire.api.report.ReportEntry;
import org.apache.maven.surefire.api.report.RunListener;
import org.apache.maven.surefire.api.report.RunMode;
import org.apache.maven.surefire.api.report.TestSetReportEntry;
+import org.apache.maven.surefire.shared.lang3.JavaVersion;
Review comment:
In test classes we can use direct comons - not shaded
##########
File path:
surefire-providers/surefire-junit3/src/test/java/org/apache/maven/surefire/junit/JUnitTestSetTest.java
##########
@@ -54,6 +58,32 @@ public void testExecuteSuiteClass()
succeededTests.get( 0 ).getName() );
}
+ public void testSystemManager()
+ {
+ float javaVersion = Float.parseFloat(
JavaVersion.JAVA_RECENT.toString() );
+ boolean isDeprecated = javaVersion >= 17;
+ try
+ {
+ JUnit3Provider.setSystemManager( "java.lang.SecurityManager" );
+
+ if ( isDeprecated )
+ {
+ fail();
+ }
+
+ Object sm = invokeGetter( System.class, null, "getSecurityManager"
);
Review comment:
System.getSecurityManager() is public ... why by reflections
##########
File path:
surefire-api/src/main/java/org/apache/maven/surefire/api/util/internal/ObjectUtils.java
##########
@@ -44,4 +46,11 @@ private ObjectUtils()
{
return ManagementFactory.getRuntimeMXBean().getSystemProperties();
}
+
+ public static boolean isSecurityManagerSupported()
+ {
+ ClassLoader classLoader = ObjectUtils.class.getClassLoader();
+ Class<?> smClass = tryLoadClass( classLoader,
"java.lang.SecurityManager" );
+ return smClass != null && !smClass.isAnnotationPresent(
Deprecated.class );
+ }
Review comment:
Is checking java version >= 17 not enough?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]