Skip to content

Commit

Permalink
[#1932] disable System.exit tests on JRE 18-21
Browse files Browse the repository at this point in the history
prevent UnsupportedOperationException in SystemLambda.withSecurityManager
  • Loading branch information
remkop committed Feb 5, 2023
1 parent e65f94f commit a868658
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@


import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledForJreRange;
import org.junit.jupiter.api.condition.JRE;

import java.io.File;
import java.io.FileInputStream;
Expand Down Expand Up @@ -507,6 +509,7 @@ private String expectedCompletionScriptForNonDefault() {
}

@Test
@DisabledForJreRange(min = JRE.JAVA_18, max = JRE.JAVA_21, disabledReason = "UnsupportedOperationException in SystemLambda.withSecurityManager")
public void testAutoCompleteAppHelp() throws Exception {
String[][] argsList = new String[][] {
{"-h"},
Expand Down Expand Up @@ -544,6 +547,7 @@ public void testAutoCompleteAppHelp_NoSystemExit() throws Exception {
}

@Test
@DisabledForJreRange(min = JRE.JAVA_18, max = JRE.JAVA_21, disabledReason = "UnsupportedOperationException in SystemLambda.withSecurityManager")
public void testAutoCompleteRequiresCommandLineFQCN() throws Exception {
int statusCode = catchSystemExit(() -> {
restoreSystemProperties(() -> {
Expand All @@ -568,6 +572,7 @@ public void testAutoCompleteRequiresCommandLineFQCN_NoSystemExit() throws Except
}

@Test
@DisabledForJreRange(min = JRE.JAVA_18, max = JRE.JAVA_21, disabledReason = "UnsupportedOperationException in SystemLambda.withSecurityManager")
public void testAutoCompleteAppCannotInstantiate() throws Exception {
@CommandLine.Command(name = "test")
class TestApp {
Expand Down Expand Up @@ -602,6 +607,7 @@ class TestApp {
}

@Test
@DisabledForJreRange(min = JRE.JAVA_18, max = JRE.JAVA_21, disabledReason = "UnsupportedOperationException in SystemLambda.withSecurityManager")
public void testAutoCompleteAppCompletionScriptFileWillNotOverwrite() throws Exception {
File dir = new File(System.getProperty("java.io.tmpdir"));
final File completionScript = new File(dir, "App_completion");
Expand Down Expand Up @@ -650,6 +656,7 @@ public void testAutoCompleteAppCompletionScriptFileWillNotOverwrite_NoSystemExit
}

@Test
@DisabledForJreRange(min = JRE.JAVA_18, max = JRE.JAVA_21, disabledReason = "UnsupportedOperationException in SystemLambda.withSecurityManager")
public void testAutoCompleteAppCommandScriptFileWillNotOverwrite() throws Exception {
File dir = new File(System.getProperty("java.io.tmpdir"));
final File commandScript = new File(dir, "picocli.AutoComplete");
Expand Down Expand Up @@ -702,6 +709,7 @@ public void testAutoCompleteAppCommandScriptFileWillNotOverwrite_NoSystemExit()
}

@Test
@DisabledForJreRange(min = JRE.JAVA_18, max = JRE.JAVA_21, disabledReason = "UnsupportedOperationException in SystemLambda.withSecurityManager")
public void testAutoCompleteAppCommandScriptFileWillOverwriteIfRequested() throws Exception {
File dir = new File(System.getProperty("java.io.tmpdir"));
final File commandScript = new File(dir, "picocli.AutoComplete");
Expand Down Expand Up @@ -731,6 +739,7 @@ public void testAutoCompleteAppCommandScriptFileWillOverwriteIfRequested() throw
}

@Test
@DisabledForJreRange(min = JRE.JAVA_18, max = JRE.JAVA_21, disabledReason = "UnsupportedOperationException in SystemLambda.withSecurityManager")
public void testAutoCompleteAppBothScriptFilesForceOverwrite() throws Exception {
File dir = new File(System.getProperty("java.io.tmpdir"));
final File commandScript = new File(dir, "picocli.AutoComplete");
Expand Down Expand Up @@ -816,6 +825,7 @@ public void testAutoCompleteAppBothScriptFilesForceOverwrite_NoSystemExit() thro
}

@Test
@DisabledForJreRange(min = JRE.JAVA_18, max = JRE.JAVA_21, disabledReason = "UnsupportedOperationException in SystemLambda.withSecurityManager")
public void testAutoCompleteAppGeneratesScriptNameBasedOnCommandName() throws Exception {

final String commandName = "bestCommandEver";
Expand Down Expand Up @@ -871,6 +881,7 @@ public <K> K create(Class<K> cls) {
}

@Test
@DisabledForJreRange(min = JRE.JAVA_18, max = JRE.JAVA_21, disabledReason = "UnsupportedOperationException in SystemLambda.withSecurityManager")
public void testAutoCompleteAppUsesCustomFactory() throws Exception {

final String commandName = "nondefault";
Expand Down Expand Up @@ -902,6 +913,7 @@ public void testAutoCompleteAppUsesCustomFactory() throws Exception {
private static class PrivateCommandClass { }
//Support generating autocompletion scripts for non-public @Command classes #306
@Test
@DisabledForJreRange(min = JRE.JAVA_18, max = JRE.JAVA_21, disabledReason = "UnsupportedOperationException in SystemLambda.withSecurityManager")
public void test306_SupportGeneratingAutocompletionScriptForNonPublicCommandClasses() throws Exception {
File dir = new File(System.getProperty("java.io.tmpdir"));
final File completionScript = new File(dir, "App_completion");
Expand Down

0 comments on commit a868658

Please sign in to comment.