Running JUnit tests with IntelliJ IDEA - "java.security.AccessControlException"

I am trying to run JUnit tests using IntelliJ Idea 11.1. But tests give different AccessControlExceptions. One of them is below. But these tests run without problems in Eclipse.

Exception in thread "main" java.security.AccessControlException: access denied (java.lang.RuntimePermission setIO) at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374) at java.security.AccessController.checkPermission(AccessController.java:546) at java.lang.SecurityManager.checkPermission(SecurityManager.java:532) at java.lang.System.checkIO(System.java:225) at java.lang.System.setOut(System.java:147) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) 

Do I need to set special permissions for the IDEA tester? If so, how?

+4
source share
1 answer

I myself ran into this problem in order to at least run everything, I copied the java.policy file from <jdk>/jre/lib/security and added the following permissions in the standard grant to get the tests running in IntelliJ IDEA 2016.2:

  // To get tests working under IntelliJ 2016.2 permission java.util.PropertyPermission "idea.launcher.bin.path", "read"; permission java.lang.RuntimePermission "loadLibrary.C:\\Program Files (x86)\\JetBrains\\IntelliJ IDEA 2016.2\\bin\\breakgen64.dll"; permission java.util.PropertyPermission "idea.launcher.port", "read"; permission java.lang.reflect.ReflectPermission "suppressAccessChecks"; permission java.util.PropertyPermission "idea.is.junit5", "read"; permission java.net.SocketPermission "127.0.0.1:*", "connect,resolve"; permission java.util.PropertyPermission "user.home", "read"; permission java.io.FilePermission "C:\\Users\\Mark\\junit.properties", "read"; permission java.lang.RuntimePermission "setIO"; permission java.io.FilePermission "C:\\Users\\Mark\\AppData\\Local\\Temp\\*", "read"; permission java.lang.RuntimePermission "accessDeclaredMembers"; 

You will need to change some paths to suit your specific user needs. I have not completely done these changes yet: it still seems to me that I do not have some permissions specific to my own code (in particular: reading several property files from my own code).

+1
source

All Articles