blob: 5bcab1a7e1bfd395b22984d7d11472f1182df785 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
package org.openslx.runvirt.plugin.qemu;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.config.Configurator;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.openslx.runvirt.plugin.qemu.cmdln.CommandLineArgs.CmdLnOption;
import com.ginsberg.junit.exit.ExpectSystemExitWithStatus;
public class AppTest
{
@BeforeAll
public static void setUp()
{
// disable logging with log4j
Configurator.setRootLevel( Level.OFF );
}
@Nested
public class CmdLnTest
{
private final ByteArrayOutputStream out = new ByteArrayOutputStream();
private final ByteArrayOutputStream err = new ByteArrayOutputStream();
private void setUp()
{
// redirect output and error stream content
System.setOut( new PrintStream( this.out ) );
System.setErr( new PrintStream( this.err ) );
}
@Test
@DisplayName( "Test exit status of application invoked with correct 'help' command line option (short version)" )
@ExpectSystemExitWithStatus( 0 )
public void testCmdLnOptionHelpShortCorrectExit()
{
String[] argsShortHelpOptionCorrect = { "-" + CmdLnOption.HELP.getShortOption() };
this.setUp();
App.main( argsShortHelpOptionCorrect );
}
@Test
@DisplayName( "Test exit status of application invoked with correct 'help' command line option (long version)" )
@ExpectSystemExitWithStatus( 0 )
public void testCmdLnOptionHelpLongCorrectExit()
{
String[] argsLongHelpOptionCorrect = { "--" + CmdLnOption.HELP.getLongOption() };
this.setUp();
App.main( argsLongHelpOptionCorrect );
}
@Test
@DisplayName( "Test exit status of application invoked with incorrect 'help' command line option (short version)" )
@ExpectSystemExitWithStatus( 1 )
public void testCmdLnOptionHelpShortIncorrectExit()
{
String[] argsShortHelpOptionCorrect = { "---" + CmdLnOption.HELP.getShortOption() };
this.setUp();
App.main( argsShortHelpOptionCorrect );
}
@Test
@DisplayName( "Test exit status of application invoked with incorrect 'help' command line option (long version)" )
@ExpectSystemExitWithStatus( 1 )
public void testCmdLnOptionHelpLongIncorrectExit()
{
String[] argsLongHelpOptionCorrect = { "---" + CmdLnOption.HELP.getLongOption() };
this.setUp();
App.main( argsLongHelpOptionCorrect );
}
}
}
|