// policy file for tests

//// These permissions apply to the JDK itself
//// (actually only needed for "extensions")

grant codeBase "file:${{java.ext.dirs}}/*" {
  permission java.security.AllPermission;
};

//// permission for the junit4 jar
grant codeBase "${junit4.jar.url}" {
  // needed for io stream handling
  permission java.lang.RuntimePermission "setIO";
  // workaround for junit access control context bug in processing
  // class test request.
  permission java.lang.RuntimePermission "accessDeclaredMembers";
};

//// permissions for the randomized runner jar
grant codeBase "${randomizedtesting.jar.url}" {
  // optionally needed for access to private test methods (e.g. beforeClass)
  permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
  // needed to handle uncaught exceptions from other threads
  permission java.lang.RuntimePermission "setDefaultUncaughtExceptionHandler";
  // needed for getTopThreads
  permission java.lang.RuntimePermission "modifyThreadGroup";
  // needed for TestClass creation
  permission java.lang.RuntimePermission "accessDeclaredMembers";
  // needed for ThreadLeakControl
  permission java.lang.RuntimePermission "getStackTrace";
};

//// permissions for the junit jar
grant codeBase "${junit.jar.url}" {
  // needed for TestClass creation
  permission java.lang.RuntimePermission "accessDeclaredMembers";
};

//// Test class permission: we want this to be minimal!
grant {
  permission java.util.PropertyPermission "*", "read";

  //// Java7 and up.
  //// permission java.io.FilePermission "<<ALL FILES>>", "read,readlink,write,delete,execute";
  permission java.io.FilePermission "<<ALL FILES>>", "read,write,delete,execute";
};
