Skip to content

Commit

Permalink
[#1503] set sysprop "java.security.manager=allow" in Gradle build
Browse files Browse the repository at this point in the history
  • Loading branch information
remkop committed Dec 6, 2021
1 parent a273583 commit 5d7ccc2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ if (JavaVersion.current().isJava11Compatible()) {
apply from: "gradle/jacoco.gradle"
}

test { // https://github.com/remkop/picocli/issues/1503
systemProperty "java.security.manager", "allow"
}

// javadoc and asciidoc customization
apply from: "${rootProject.projectDir}/gradle/docs.gradle"

Expand Down
14 changes: 1 addition & 13 deletions src/test/java/picocli/AutoCompleteTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package picocli;

import org.hamcrest.CoreMatchers;
import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.Assertion;
Expand All @@ -25,7 +23,6 @@
import org.junit.contrib.java.lang.system.RestoreSystemProperties;
import org.junit.contrib.java.lang.system.SystemErrRule;
import org.junit.contrib.java.lang.system.SystemOutRule;
import org.junit.rules.RuleChain;
import org.junit.rules.TestRule;
import picocli.CommandLine.Command;
import picocli.CommandLine.Model.CommandSpec;
Expand All @@ -52,8 +49,6 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.ListResourceBundle;
import java.util.PropertyResourceBundle;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;

Expand All @@ -69,15 +64,8 @@
// https://apple.stackexchange.com/a/13019
public class AutoCompleteTest {

//@Rule
// https://github.com/remkop/picocli/issues/1503
public final ProvideSystemProperty allowSecurityManager = new ProvideSystemProperty("java.security.manager", "allow");

//@Rule
public final ExpectedSystemExit exit = ExpectedSystemExit.none();

@Rule
public RuleChain chain = RuleChain.outerRule(allowSecurityManager).around(exit);
public final ExpectedSystemExit exit = ExpectedSystemExit.none();

@Rule
public final ProvideSystemProperty ansiOFF = new ProvideSystemProperty("picocli.ansi", "false");
Expand Down
35 changes: 23 additions & 12 deletions src/test/java/picocli/ExecuteLegacyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
*/
package picocli;

import org.junit.BeforeClass;
import org.junit.Rule;
import org.junit.Test;
import org.junit.contrib.java.lang.system.*;
import org.junit.rules.RuleChain;
import org.junit.contrib.java.lang.system.Assertion;
import org.junit.contrib.java.lang.system.ExpectedSystemExit;
import org.junit.contrib.java.lang.system.ProvideSystemProperty;
import org.junit.contrib.java.lang.system.RestoreSystemProperties;
import org.junit.contrib.java.lang.system.SystemErrRule;
import org.junit.contrib.java.lang.system.SystemOutRule;
import org.junit.rules.TestRule;
import picocli.CommandLine.Model.CommandSpec;

Expand All @@ -33,19 +36,27 @@

import static java.lang.String.format;
import static org.junit.Assert.*;
import static picocli.CommandLine.*;
import static picocli.CommandLine.Command;
import static picocli.CommandLine.DefaultExceptionHandler;
import static picocli.CommandLine.ExecutionException;
import static picocli.CommandLine.Help;
import static picocli.CommandLine.IExceptionHandler2;
import static picocli.CommandLine.IParseResultHandler;
import static picocli.CommandLine.IParseResultHandler2;
import static picocli.CommandLine.InitializationException;
import static picocli.CommandLine.Option;
import static picocli.CommandLine.ParameterException;
import static picocli.CommandLine.Parameters;
import static picocli.CommandLine.ParseResult;
import static picocli.CommandLine.RunAll;
import static picocli.CommandLine.RunFirst;
import static picocli.CommandLine.RunLast;
import static picocli.CommandLine.Spec;

@SuppressWarnings("deprecation")
public class ExecuteLegacyTest {
//@Rule
// https://github.com/remkop/picocli/issues/1503
public final ProvideSystemProperty allowSecurityManager = new ProvideSystemProperty("java.security.manager", "allow");

//@Rule
public final ExpectedSystemExit exit = ExpectedSystemExit.none();

@Rule
public RuleChain chain = RuleChain.outerRule(allowSecurityManager).around(exit);
public final ExpectedSystemExit exit = ExpectedSystemExit.none();

// allows tests to set any kind of properties they like, without having to individually roll them back
@Rule
Expand Down

0 comments on commit 5d7ccc2

Please sign in to comment.