stefanbirkner / system-rules

A collection of JUnit rules for testing code which uses java.lang.System.
http://stefanbirkner.github.io/system-rules
Other
547 stars 71 forks source link

System-Rules Security Manager feature with gradle #33

Open erkinun opened 9 years ago

erkinun commented 9 years ago

Hi,

When I try to use System-Rules' security manager property, gradle just hangs when trying to run the tests. The issue might be related to the gradle bug: https://issues.gradle.org/browse/GRADLE-2170 , but nevertheless is there any workaround for this problem?

example test:

public class UtilTest {

    private final BuildSecurityManager manager = new BuildSecurityManager();

    @Rule
    public final ProvideSecurityManager provideSecurityManager = new ProvideSecurityManager(manager);

I then run gradle clean test

The result:

FAILURE: Build failed with an exception.

* What went wrong:
Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.launcher.daemon.client.DaemonDisappearedException: Gradle build daemon disappeared unexpectedly (it may have been killed or may have crashed)
    at org.gradle.launcher.daemon.client.DaemonClient.handleDaemonDisappearance(DaemonClient.java:211)
    at org.gradle.launcher.daemon.client.DaemonClient.monitorBuild(DaemonClient.java:187)
    at org.gradle.launcher.daemon.client.DaemonClient.executeBuild(DaemonClient.java:151)
    at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:120)
    at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:78)
    at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
    at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
    at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
    at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    at org.gradle.launcher.Main.doAction(Main.java:33)
    at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    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:497)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
    at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
stefanbirkner commented 9 years ago

Relating Stack Overflow question: http://stackoverflow.com/questions/32584997/setting-a-custom-security-manager-when-running-junit-with-gradle

erkinun commented 9 years ago

I asked that question today unfortunately : )