mirror of
https://codeberg.org/PGPainless/sop-java.git
synced 2025-09-14 12:49:44 +02:00
Remove deprecated junit5-system-exit
Replaced with custom test DSL that avoids System.exit
This commit is contained in:
parent
ac00b68694
commit
e7778cb0d2
13 changed files with 550 additions and 215 deletions
|
@ -6,12 +6,13 @@ package sop.cli.picocli;
|
|||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static sop.testsuite.assertions.SopExecutionAssertions.assertGenericError;
|
||||
import static sop.testsuite.assertions.SopExecutionAssertions.assertUnsupportedSubcommand;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.ginsberg.junit.exit.ExpectSystemExitWithStatus;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import sop.SOP;
|
||||
import sop.exception.SOPGPException;
|
||||
|
@ -34,20 +35,18 @@ import sop.operation.Version;
|
|||
public class SOPTest {
|
||||
|
||||
@Test
|
||||
@ExpectSystemExitWithStatus(SOPGPException.UnsupportedSubcommand.EXIT_CODE)
|
||||
public void assertExitOnInvalidSubcommand() {
|
||||
SOP sop = mock(SOP.class);
|
||||
SopCLI.setSopInstance(sop);
|
||||
|
||||
SopCLI.main(new String[] {"invalid"});
|
||||
assertUnsupportedSubcommand(() -> SopCLI.execute("invalid"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ExpectSystemExitWithStatus(1)
|
||||
public void assertThrowsIfNoSOPBackendSet() {
|
||||
SopCLI.setSopInstance(null);
|
||||
// At this point, no SOP backend is set, so an InvalidStateException triggers exit(1)
|
||||
SopCLI.main(new String[] {"armor"});
|
||||
// At this point, no SOP backend is set, so an InvalidStateException triggers error code 1
|
||||
assertGenericError(() -> SopCLI.execute("armor"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue