在 Eclipse 中运行 JUnit 测试会引发 SecurityException

Posted

技术标签:

【中文标题】在 Eclipse 中运行 JUnit 测试会引发 SecurityException【英文标题】:Running JUnit test in eclipse throws SecurityException 【发布时间】:2022-01-02 00:28:06 【问题描述】:

当我尝试在 Eclipse 中运行 JUnit 测试时,我得到一个 java.lang.SecurityException

我有一个基于 tycho 的 maven 构建,用于相同的测试代码,效果很好。

这是堆栈跟踪:

java.lang.IllegalArgumentException: Error: test loader org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader not found:
java.lang.SecurityException: class "org.junit.platform.commons.util.ClassNamePatternFilterUtils"'s signer information does not match signer information of other classes in the same package
    at java.base/java.lang.ClassLoader.checkCerts(ClassLoader.java:1150)
    at java.base/java.lang.ClassLoader.preDefineClass(ClassLoader.java:905)
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1014)
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:802)
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:700)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at org.junit.platform.launcher.core.LauncherFactory.loadAndFilterTestExecutionListeners(LauncherFactory.java:122)
    at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:108)
    at org.junit.platform.launcher.core.LauncherFactory.create(LauncherFactory.java:75)
    at org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader.<init>(JUnit5TestLoader.java:34)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at java.base/java.lang.Class.newInstance(Class.java:584)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(RemoteTestRunner.java:371)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createLoader(RemoteTestRunner.java:366)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(RemoteTestRunner.java:310)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.init(RemoteTestRunner.java:225)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)

    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createRawTestLoader(RemoteTestRunner.java:376)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.createLoader(RemoteTestRunner.java:366)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.defaultInit(RemoteTestRunner.java:310)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.init(RemoteTestRunner.java:225)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)

测试类:

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.mockito.Mockito;

import com.xxx.infop.common.entity.auftrag.UebersichtInfo;
import com.xxx.infop.common.entity.auftrag.UebersichtInfo.UebersichtInfoBuilder;
import com.xxx.infop.rcp.auftrag.internal.ui.suche.UebersichtInfoChild;
import com.xxx.infop.rcp.auftrag.internal.ui.suche.UebersichtInfoParent;

public class AuftragStatePropertyTesterUnitTest 

    public static Stream<Arguments> test() 

        return Stream.of( /* test-data */);
    

    @ParameterizedTest
    @MethodSource
    public void test(Object receiver, String property, boolean expectedResult) 
        // test code
    


eclipse运行配置命令行:

C:\devxxx\eaio-ng\jdk\openjdk11\bin\javaw.exe
-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:49479
-ea "-javaagent:C:\devxxx\eaio-ng\eclipse\jee-2021-09-R\configuration\org.eclipse.osgi\415\0\.cp\lib\javaagent-shaded.jar"
-Dfile.encoding=UTF-8
-classpath "C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.e4.ui.workbench_1.13.0.v20210521-0741.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.ui_3.119.100.v20210830-0942.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.swt_3.117.0.v20210906-0842.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.swt.nl_it_4.18.0.v20201226020001.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.swt.nl_fr_4.18.0.v20201226020001.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.swt.nl_de_4.18.0.v20201226020001.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.swt.win32.win32.x86_64_3.117.0.v20210906-0842.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.jface_3.23.0.v20210723-1324.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.core.commands_3.10.100.v20210722-1426.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.ui.workbench_3.123.0.v20210817-0704.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.e4.ui.workbench3_0.16.0.v20210619-0956.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.ui.forms_3.11.200.v20210622-0925.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.core.runtime_3.23.0.v20210730-2035.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.osgi_3.17.0.v20210823-1805.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.equinox.transforms.hook_1.3.0.v20210202-1256.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.equinox.region_1.5.100.v20210212-1143.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.equinox.weaving.hook_1.3.0.v20210202-1256.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.osgi.nl_de_4.18.0.v20201226020001.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.osgi.nl_it_4.18.0.v20201226020001.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.osgi.compatibility.state_1.2.500.v20210730-0750.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.osgi.nl_fr_4.18.0.v20201226020001.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.equinox.common_3.15.0.v20210518-0604.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.core.jobs_3.12.0.v20210723-1034.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.equinox.registry_3.11.0.v20210723-1953.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.equinox.registry.nl_it_4.18.0.v20201226020001.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.equinox.registry.nl_de_4.18.0.v20201226020001.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.equinox.registry.nl_fr_4.18.0.v20201226020001.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.equinox.preferences_3.9.0.v20210726-0943.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.core.contenttype_3.8.0.v20210621-0954.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.equinox.app_1.6.0.v20210723-1130.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.core.expressions_3.8.0.v20210723-1034.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.core.databinding_1.10.100.v20200926-1123.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.core.databinding.observable_1.11.0.v20210722-1426.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.core.databinding.beans_1.8.0.v20210619-1111.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.core.databinding.property_1.9.0.v20210619-1129.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.jface.databinding_1.13.0.v20210619-1146.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\jakarta.validation.jakarta.validation-api_2.0.2.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\com.google.guava_29.0.0.jre.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\com.fasterxml.jackson.core.jackson-core_2.11.3.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\com.fasterxml.jackson.core.jackson-databind_2.11.3.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\com.fasterxml.jackson.datatype.jackson-datatype-jsr310_2.11.3.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\io.github.openfeign.feign-core_10.10.1.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\io.github.openfeign.feign-jackson_10.10.1.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.apache.httpcomponents.httpclient_4.5.13.v20210128-2225.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.apache.httpcomponents.httpcore_4.4.14.v20210128-2225.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.apache.commons.logging_1.2.2.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.springframework.cloud.openfeign_2.2.5.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.springframework.aop_5.3.1.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.springframework.beans_5.3.1.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.springframework.expression_5.3.1.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.springframework.context_5.3.1.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.springframework.core_5.3.1.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.springframework.web_5.3.1.jar;C:\devxxx\projekte\infop-all\infop-cloud\infop-common-entity\target\classes;C:\devxxx\projekte\infop-all\infop-cloud\infop-common-entity\target\test-classes;C:\devxxx\projekte\infop-all\infop-cloud\infop-common-utility\target\classes;C:\devxxx\projekte\infop-all\infop-cloud\infop-common-utility\target\test-classes;C:\devxxx\eaio-ng\m2\com\fasterxml\jackson\core\jackson-annotations\2.11.3\jackson-annotations-2.11.3.jar;C:\devxxx\eaio-ng\m2\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\devxxx\eaio-ng\m2\jakarta\persistence\jakarta.persistence-api\2.2.3\jakarta.persistence-api-2.2.3.jar;C:\devxxx\eaio-ng\m2\com\google\guava\guava\29.0-jre\guava-29.0-jre.jar;C:\devxxx\eaio-ng\m2\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;C:\devxxx\eaio-ng\m2\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;C:\devxxx\eaio-ng\m2\com\google\code\findbugs\jsr305\3.0.2\jsr305-3.0.2.jar;C:\devxxx\eaio-ng\m2\org\checkerframework\checker-qual\2.11.1\checker-qual-2.11.1.jar;C:\devxxx\eaio-ng\m2\com\google\errorprone\error_prone_annotations\2.3.4\error_prone_annotations-2.3.4.jar;C:\devxxx\eaio-ng\m2\com\google\j2objc\j2objc-annotations\1.3\j2objc-annotations-1.3.jar;C:\devxxx\eaio-ng\m2\com\fasterxml\jackson\core\jackson-databind\2.11.3\jackson-databind-2.11.3.jar;C:\devxxx\eaio-ng\m2\com\fasterxml\jackson\core\jackson-core\2.11.3\jackson-core-2.11.3.jar;C:\devxxx\eaio-ng\m2\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;C:\devxxx\eaio-ng\m2\org\springframework\cloud\spring-cloud-starter-sleuth\2.2.5.RELEASE\spring-cloud-starter-sleuth-2.2.5.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\springframework\cloud\spring-cloud-starter\2.2.5.RELEASE\spring-cloud-starter-2.2.5.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\springframework\cloud\spring-cloud-context\2.2.5.RELEASE\spring-cloud-context-2.2.5.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\springframework\security\spring-security-crypto\5.3.5.RELEASE\spring-security-crypto-5.3.5.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\springframework\cloud\spring-cloud-commons\2.2.5.RELEASE\spring-cloud-commons-2.2.5.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\springframework\security\spring-security-rsa\1.0.9.RELEASE\spring-security-rsa-1.0.9.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\springframework\boot\spring-boot-starter-aop\2.3.5.RELEASE\spring-boot-starter-aop-2.3.5.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\springframework\spring-aop\5.2.10.RELEASE\spring-aop-5.2.10.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\springframework\spring-beans\5.2.10.RELEASE\spring-beans-5.2.10.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\aspectj\aspectjweaver\1.9.6\aspectjweaver-1.9.6.jar;C:\devxxx\eaio-ng\m2\org\springframework\cloud\spring-cloud-sleuth-core\2.2.5.RELEASE\spring-cloud-sleuth-core-2.2.5.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\springframework\spring-context\5.2.10.RELEASE\spring-context-5.2.10.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\springframework\spring-expression\5.2.10.RELEASE\spring-expression-5.2.10.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\aspectj\aspectjrt\1.9.6\aspectjrt-1.9.6.jar;C:\devxxx\eaio-ng\m2\io\zipkin\brave\brave\5.12.3\brave-5.12.3.jar;C:\devxxx\eaio-ng\m2\io\zipkin\reporter2\zipkin-reporter-brave\2.15.0\zipkin-reporter-brave-2.15.0.jar;C:\devxxx\eaio-ng\m2\io\zipkin\brave\brave-context-slf4j\5.12.3\brave-context-slf4j-5.12.3.jar;C:\devxxx\eaio-ng\m2\io\zipkin\brave\brave-instrumentation-messaging\5.12.3\brave-instrumentation-messaging-5.12.3.jar;C:\devxxx\eaio-ng\m2\io\zipkin\brave\brave-instrumentation-rpc\5.12.3\brave-instrumentation-rpc-5.12.3.jar;C:\devxxx\eaio-ng\m2\io\zipkin\brave\brave-instrumentation-spring-web\5.12.3\brave-instrumentation-spring-web-5.12.3.jar;C:\devxxx\eaio-ng\m2\io\zipkin\brave\brave-instrumentation-http\5.12.3\brave-instrumentation-http-5.12.3.jar;C:\devxxx\eaio-ng\m2\io\zipkin\brave\brave-instrumentation-spring-rabbit\5.12.3\brave-instrumentation-spring-rabbit-5.12.3.jar;C:\devxxx\eaio-ng\m2\io\zipkin\brave\brave-instrumentation-kafka-clients\5.12.3\brave-instrumentation-kafka-clients-5.12.3.jar;C:\devxxx\eaio-ng\m2\io\zipkin\brave\brave-instrumentation-kafka-streams\5.12.3\brave-instrumentation-kafka-streams-5.12.3.jar;C:\devxxx\eaio-ng\m2\io\zipkin\brave\brave-instrumentation-httpclient\5.12.3\brave-instrumentation-httpclient-5.12.3.jar;C:\devxxx\eaio-ng\m2\io\zipkin\brave\brave-instrumentation-httpasyncclient\5.12.3\brave-instrumentation-httpasyncclient-5.12.3.jar;C:\devxxx\eaio-ng\m2\io\zipkin\brave\brave-instrumentation-spring-webmvc\5.12.3\brave-instrumentation-spring-webmvc-5.12.3.jar;C:\devxxx\eaio-ng\m2\io\zipkin\brave\brave-instrumentation-servlet\5.12.3\brave-instrumentation-servlet-5.12.3.jar;C:\devxxx\eaio-ng\m2\io\zipkin\brave\brave-instrumentation-jms\5.12.3\brave-instrumentation-jms-5.12.3.jar;C:\devxxx\eaio-ng\m2\io\zipkin\reporter2\zipkin-reporter-metrics-micrometer\2.15.0\zipkin-reporter-metrics-micrometer-2.15.0.jar;C:\devxxx\eaio-ng\m2\io\zipkin\reporter2\zipkin-reporter\2.15.0\zipkin-reporter-2.15.0.jar;C:\devxxx\eaio-ng\m2\io\zipkin\zipkin2\zipkin\2.21.1\zipkin-2.21.1.jar;C:\devxxx\eaio-ng\m2\org\springframework\boot\spring-boot-starter-validation\2.3.5.RELEASE\spring-boot-starter-validation-2.3.5.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\springframework\boot\spring-boot-starter\2.3.5.RELEASE\spring-boot-starter-2.3.5.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\springframework\boot\spring-boot\2.3.5.RELEASE\spring-boot-2.3.5.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\springframework\boot\spring-boot-autoconfigure\2.3.5.RELEASE\spring-boot-autoconfigure-2.3.5.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\springframework\boot\spring-boot-starter-logging\2.3.5.RELEASE\spring-boot-starter-logging-2.3.5.RELEASE.jar;C:\devxxx\eaio-ng\m2\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\devxxx\eaio-ng\m2\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\devxxx\eaio-ng\m2\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;C:\devxxx\eaio-ng\m2\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;C:\devxxx\eaio-ng\m2\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;C:\devxxx\eaio-ng\m2\org\yaml\snakeyaml\1.26\snakeyaml-1.26.jar;C:\devxxx\eaio-ng\m2\org\glassfish\jakarta.el\3.0.3\jakarta.el-3.0.3.jar;C:\devxxx\eaio-ng\m2\org\hibernate\validator\hibernate-validator\6.1.6.Final\hibernate-validator-6.1.6.Final.jar;C:\devxxx\eaio-ng\m2\jakarta\validation\jakarta.validation-api\2.0.2\jakarta.validation-api-2.0.2.jar;C:\devxxx\eaio-ng\m2\org\jboss\logging\jboss-logging\3.4.1.Final\jboss-logging-3.4.1.Final.jar;C:\devxxx\eaio-ng\m2\com\fasterxml\classmate\1.5.1\classmate-1.5.1.jar;C:\devxxx\eaio-ng\m2\org\springframework\boot\spring-boot-starter-test\2.3.5.RELEASE\spring-boot-starter-test-2.3.5.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\springframework\boot\spring-boot-test\2.3.5.RELEASE\spring-boot-test-2.3.5.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\springframework\boot\spring-boot-test-autoconfigure\2.3.5.RELEASE\spring-boot-test-autoconfigure-2.3.5.RELEASE.jar;C:\devxxx\eaio-ng\m2\com\jayway\jsonpath\json-path\2.4.0\json-path-2.4.0.jar;C:\devxxx\eaio-ng\m2\net\minidev\json-smart\2.3\json-smart-2.3.jar;C:\devxxx\eaio-ng\m2\net\minidev\accessors-smart\1.2\accessors-smart-1.2.jar;C:\devxxx\eaio-ng\m2\org\ow2\asm\asm\5.0.4\asm-5.0.4.jar;C:\devxxx\eaio-ng\m2\jakarta\xml\bind\jakarta.xml.bind-api\2.3.3\jakarta.xml.bind-api-2.3.3.jar;C:\devxxx\eaio-ng\m2\jakarta\activation\jakarta.activation-api\1.2.2\jakarta.activation-api-1.2.2.jar;C:\devxxx\eaio-ng\m2\org\assertj\assertj-core\3.16.1\assertj-core-3.16.1.jar;C:\devxxx\eaio-ng\m2\org\hamcrest\hamcrest\2.2\hamcrest-2.2.jar;C:\devxxx\eaio-ng\m2\org\junit\jupiter\junit-jupiter\5.6.3\junit-jupiter-5.6.3.jar;C:\devxxx\eaio-ng\m2\org\junit\jupiter\junit-jupiter-api\5.6.3\junit-jupiter-api-5.6.3.jar;C:\devxxx\eaio-ng\m2\org\apiguardian\apiguardian-api\1.1.0\apiguardian-api-1.1.0.jar;C:\devxxx\eaio-ng\m2\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;C:\devxxx\eaio-ng\m2\org\junit\platform\junit-platform-commons\1.6.3\junit-platform-commons-1.6.3.jar;C:\devxxx\eaio-ng\m2\org\junit\jupiter\junit-jupiter-params\5.6.3\junit-jupiter-params-5.6.3.jar;C:\devxxx\eaio-ng\m2\org\junit\jupiter\junit-jupiter-engine\5.6.3\junit-jupiter-engine-5.6.3.jar;C:\devxxx\eaio-ng\m2\org\junit\platform\junit-platform-engine\1.6.3\junit-platform-engine-1.6.3.jar;C:\devxxx\eaio-ng\m2\org\mockito\mockito-core\3.3.3\mockito-core-3.3.3.jar;C:\devxxx\eaio-ng\m2\net\bytebuddy\byte-buddy\1.10.17\byte-buddy-1.10.17.jar;C:\devxxx\eaio-ng\m2\net\bytebuddy\byte-buddy-agent\1.10.17\byte-buddy-agent-1.10.17.jar;C:\devxxx\eaio-ng\m2\org\objenesis\objenesis\2.6\objenesis-2.6.jar;C:\devxxx\eaio-ng\m2\org\mockito\mockito-junit-jupiter\3.3.3\mockito-junit-jupiter-3.3.3.jar;C:\devxxx\eaio-ng\m2\org\skyscreamer\jsonassert\1.5.0\jsonassert-1.5.0.jar;C:\devxxx\eaio-ng\m2\com\vaadin\external\google\android-json\0.0.20131108.vaadin1\android-json-0.0.20131108.vaadin1.jar;C:\devxxx\eaio-ng\m2\org\springframework\spring-core\5.2.10.RELEASE\spring-core-5.2.10.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\springframework\spring-jcl\5.2.10.RELEASE\spring-jcl-5.2.10.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\springframework\spring-test\5.2.10.RELEASE\spring-test-5.2.10.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\xmlunit\xmlunit-core\2.7.0\xmlunit-core-2.7.0.jar;C:\devxxx\eaio-ng\m2\com\xxx\infop\infop-database\99.0.0-SNAPSHOT\infop-database-99.0.0-SNAPSHOT.jar;C:\devxxx\eaio-ng\m2\jakarta\el\jakarta.el-api\3.0.3\jakarta.el-api-3.0.3.jar;C:\devxxx\eaio-ng\m2\org\hibernate\hibernate-jpamodelgen\5.4.22.Final\hibernate-jpamodelgen-5.4.22.Final.jar;C:\devxxx\eaio-ng\m2\javax\xml\bind\jaxb-api\2.3.1\jaxb-api-2.3.1.jar;C:\devxxx\eaio-ng\m2\javax\activation\javax.activation-api\1.2.0\javax.activation-api-1.2.0.jar;C:\devxxx\eaio-ng\m2\org\glassfish\jaxb\jaxb-runtime\2.3.3\jaxb-runtime-2.3.3.jar;C:\devxxx\eaio-ng\m2\org\glassfish\jaxb\txw2\2.3.3\txw2-2.3.3.jar;C:\devxxx\eaio-ng\m2\com\sun\istack\istack-commons-runtime\3.0.11\istack-commons-runtime-3.0.11.jar;C:\devxxx\eaio-ng\m2\com\sun\activation\jakarta.activation\1.2.2\jakarta.activation-1.2.2.jar;C:\devxxx\projekte\infop-all\infop-cloud\infop-rcp-api\target\classes;C:\devxxx\projekte\infop-all\infop-cloud\infop-rcp-api\target\test-classes;C:\devxxx\eaio-ng\m2\org\springframework\spring-web\5.2.10.RELEASE\spring-web-5.2.10.RELEASE.jar;C:\devxxx\eaio-ng\m2\org\reflections\reflections\0.9.12\reflections-0.9.12.jar;C:\devxxx\eaio-ng\m2\org\javassist\javassist\3.26.0-GA\javassist-3.26.0-GA.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\com.fasterxml.jackson.core.jackson-annotations_2.11.3.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.apache.logging.log4j.api_2.14.0.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.apache.logging.log4j.core_2.14.0.jar;C:\devxxx\projekte\infop\infop-client\com.xxx.infop.rcp.core\target\classes;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.draw2d_3.10.100.201606061308.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\jakarta.annotation-api_1.3.5.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.hibernate.validator_6.1.6.Final.jar;C:\devxxx\projekte\infop\infop-client\com.xxx.infop.rcp.common.ui\target\classes;C:\devxxx\projekte\infop\infop-client\com.xxx.infop.rcp.auftrag.ui\target\classes;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.swtbot.eclipse.finder_3.1.0.202106041005.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.swtbot.swt.finder_3.1.0.202106041005.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.eclipse.swtbot.junit4_x_3.1.0.202106041005.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.junit.jupiter.api_5.7.1.v20210222-1948.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.junit.jupiter.params_5.7.1.v20210222-1948.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.junit_4.13.0.v20200204-1500.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.hamcrest.core_1.3.0.v20180420-1519.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.mockito.mockito-all_1.10.19.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.apache.log4j_1.2.15.v201012070815.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.junit.platform.engine_1.7.1.v20210222-1948.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.opentest4j_1.2.0.v20190826-0900.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.junit.jupiter.engine_5.7.1.v20210222-1948.jar;C:\devxxx\projekte\infop\.metadata\.plugins\org.eclipse.pde.core\.bundle_pool\plugins\org.junit.platform.commons_1.7.1.v20210222-1948.jar;C:\devxxx\projekte\infop\infop-client\com.xxx.infop.rcp.test.swtbot\target\classes;C:\devxxx\projekte\infop\infop-client\com.xxx.infop.rcp.ui\target\classes;C:\devxxx\projekte\infop\infop-client\com.xxx.infop.rcp.auftrag.ui.test\target\classes;C:\devxxx\eaio-ng\m2\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;C:\devxxx\eaio-ng\m2\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;C:\devxxx\eaio-ng\m2\org\springframework\spring-web\5.3.1\spring-web-5.3.1.jar;C:\devxxx\eaio-ng\m2\org\springframework\spring-beans\5.3.1\spring-beans-5.3.1.jar;C:\devxxx\eaio-ng\m2\org\springframework\spring-core\5.3.1\spring-core-5.3.1.jar;C:\devxxx\eaio-ng\m2\org\springframework\spring-jcl\5.3.1\spring-jcl-5.3.1.jar;C:\devxxx\eaio-ng\m2\com\xxx\infop\infop-rcp-server\99.0.0-SNAPSHOT\infop-rcp-server-99.0.0-SNAPSHOT.jar;C:\devxxx\eaio-ng\eclipse\jee-2021-09-R\configuration\org.eclipse.osgi\414\0\.cp;C:\devxxx\eaio-ng\eclipse\jee-2021-09-R\configuration\org.eclipse.osgi\412\0\.cp;C:\devxxx\eaio-ng\eclipse\jee-2021-09-R\configuration\org.eclipse.osgi\917\0\.cp" org.eclipse.jdt.internal.junit.runner.RemoteTestRunner
-version 3
-port 49478
-testLoaderClass org.eclipse.jdt.internal.junit5.runner.JUnit5TestLoader
-loaderpluginname org.eclipse.jdt.junit5.runtime
-classNames com.xxx.infop.rcp.auftrag.internal.ui.handler.AuftragStatePropertyTesterUnitTest

【问题讨论】:

这有帮助吗?***.com/questions/9651784/hamcrest-tests-always-fail 当然。这些问题大约有 10 年的历史,答案不准确或参考当前 eclipse(2021-09 (4.21.0))中不可用的设置。 【参考方案1】:

我在 Eclipse 更新到 2021-12 后立即遇到了这个问题。发生这种情况是因为测试运行时路径上有两个版本的 JUnit 5,一个由 Eclipse (v5.8) 提供,一个由我的 Gradle 构建 (v5.7) 指定。 Eclipse 提供的 JAR 由他们签名,而 Gradle 获取的 JAR 是未签名的。我假设 Eclipse 更新更新了 JUnit JAR。

解决方案(对我而言)是按照@Woodsman 的建议,将 Eclipse“JUnit 5”条目放在“Order and Export”选项卡中的“Project and External Dependencies”之前。但我认为在 Gradle 和 Eclipse 中使用不同的版本会导致 IDE 和控制台之间出现不一致,因此我将在 Gradle 构建中调整版本。

这似乎是发生了什么。

Eclipse 测试运行程序导致类从包org.junit.jupiter.api 加载。这些请求从 v5.7 开始得到满足,它首先在路径上,但随后我们来到 org.junit.jupiter.api.Named,这是 v5.8 中的新功能。此时使用了另一个(Eclipse)JAR,这是新 JAR 上的签名者与目前使用的未签名 JAR 不匹配的地方,您会从 java.lang.ClassLoader.checkCerts 获得异常。

这两个 JAR 都出现在“JUnit 5”(Eclipse)和“项目和外部依赖项”(Gradle)下的 Java 构建路径(项目属性)中。在“库”选项卡下,您可以查看它们在磁盘上的位置,在“订购和导出”选项卡下,您可以选择它们被咨询的顺序。交换顺序使测试运行。

【讨论】:

是的,这就是答案!我花了几个小时试图弄清楚这一点,直到找到你的帖子【参考方案2】:

我添加了 JUnit 5,并将其放置在“依赖项”选项卡的 Classpath Entries 部分的底部。当我在项目文件夹和“项目和外部依赖项”之间移动它时,错误消失了。

【讨论】:

这个标签在哪里?

以上是关于在 Eclipse 中运行 JUnit 测试会引发 SecurityException的主要内容,如果未能解决你的问题,请参考以下文章

junit运行多个测试的方法

Eclipse/Maven:运行 JUnit 测试时未编译它们

Eclipse / Maven:JUnit测试在运行时未编译

当我在 Eclipse 中运行 Junit 测试用例时,出现错误

如何在没有 Maven 的情况下同时运行 Eclipse Java 项目的所有 JUnit 测试?

是否可以在 Eclipse 中从多个包运行 JUnit 测试?