我正在尝试使用本教程运行 EvoSuite 测试。
我能够生成测试类并使用 java 8 编译它们。但是,当尝试使用以下命令运行它时,会引发异常。
java -cp ".\log4j.jar;.\ojdbc6.jar;.\commons-codec-1.3.jar;.\slf4j-log4j12-1.7.16.jar;.\slf4j-api-1.7.16.jar;D:\proj\target\classes;.\evosuite-tests;.\evosuite-standalone-runtime-1.0.6.jar;.\junit-4.12.jar;.\hamcrest-core-1.3.jar;" org.junit.runner.JUnitCore com.u.g.KeyClient_ESTest
抛出异常:
java.lang.SecurityException: Security manager blocks ("java.sql.SQLPermission" "deregisterDriver")
java.lang.Thread.getStackTrace(Thread.java:1556)
org.evosuite.runtime.sandbox.MSecurityManager.checkPermission(MSecurityManager.java:434)
java.sql.DriverManager.deregisterDriver(DriverManager.java:402)
oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:467)
java.sql.DriverManager.getConnection(DriverManager.java:664)
java.sql.DriverManager.getConnection(DriverManager.java:247)
com.u.g.KeyClient.getFromJDBC(KeyClient.java:164)
com.u.g.KeyClient.fetchKey(KeyClient.java:95)
com.u.g.KeyClient.<init>(KeyClient.java:40)
com.u.g.KeyClient.getInstance(KeyClient.java:48)
com.u.g.KeyClient_ESTest.test1(KeyClient_ESTest.java:36)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:498)
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
java.util.concurrent.FutureTask.run(FutureTask.java:266)
java.lang.Thread.run(Thread.java:745)
at org.evosuite.runtime.sandbox.MSecurityManager.checkPermission(MSecurityManager.java:452)
at java.sql.DriverManager.deregisterDriver(DriverManager.java:402)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:467)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at com.u.g.KeyClient.getFromJDBC(KeyClient.java:164)
at com.u.g.KeyClient.fetchKey(KeyClient.java:95)
at com.u.g.KeyClient.<init>(KeyClient.java:40)
at com.u.g.KeyClient.getInstance(KeyClient.java:48)
at com.u.g.KeyClient_ESTest.test1(KeyClient_ESTest.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:298)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:292)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:745)
FAILURES!!!
Tests run: 2, Failures: 1
有人可以帮助/指导我解决这个问题吗?提前致谢。
附加信息:
测试类是一个单例,它使用 JDBC API 连接到数据库以检索某些值。