forked from assertj/assertj-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ApplicationLauncherExamples.java
42 lines (33 loc) · 1.56 KB
/
ApplicationLauncherExamples.java
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
package org.assertj.swing.junit.examples;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.swing.junit.util.Assumptions.assumeThat;
import org.assertj.swing.aut.main.SystemPropertiesStore;
import org.assertj.swing.aut.util.SystemPropertiesUtil;
import org.assertj.swing.junit.SwingJUnitExamples;
import org.assertj.swing.launcher.ApplicationLauncher;
import org.junit.Test;
/** Tests that you can run an application with AssertJ - without UI. */
public class ApplicationLauncherExamples extends SwingJUnitExamples {
@Override
protected void onSetUp() {
// precondition - when not executed, the system properties are null
SystemPropertiesStore.setProperties(null);
}
@Test
public void application_launching_without_arguments_example() {
assumeThat(SystemPropertiesStore.getProperties()).isNull();
// start application
ApplicationLauncher.application(SystemPropertiesStore.class).start();
// check result of running application
assertThat(SystemPropertiesStore.getProperties()).isEmpty();
}
@Test
public void application_launching_with_arguments_example() {
assumeThat(SystemPropertiesStore.getProperties()).isNull();
String[] arguments = new String[] { "java.version", "line.separator", "os.arch", "os.name", "os.version" };
// start application
ApplicationLauncher.application(SystemPropertiesStore.class).withArgs(arguments).start();
// check result of running application
assertThat(SystemPropertiesStore.getProperties()).isEqualTo(SystemPropertiesUtil.fetchProperties(arguments));
}
}