3
3
import org .junit .jupiter .api .Assertions ;
4
4
import org .junit .jupiter .api .BeforeAll ;
5
5
import org .junit .jupiter .api .Test ;
6
- import org .junit .jupiter .api .condition .EnabledOnOs ;
7
- import org .junit .jupiter .api .condition .OS ;
6
+ import org .junit .jupiter .api .condition .EnabledIf ;
8
7
9
8
import java .io .IOException ;
10
9
import java .util .List ;
13
12
/**
14
13
* Unit tests for GNOME keyring access via DBUS.
15
14
*/
16
- @ EnabledOnOs (OS .LINUX )
17
15
public class SecretServiceKeychainAccessTest {
18
16
19
17
private static boolean isInstalled ;
20
18
21
19
@ BeforeAll
22
20
public static void checkSystemAndSetup () throws IOException {
23
- ProcessBuilder dbusSend = new ProcessBuilder ("dbus-send" ,"--print-reply" ,"--dest=org.freedesktop.DBus" , "/org/freedesktop/DBus" , "org.freedesktop.DBus.ListNames" );
21
+ ProcessBuilder dbusSend = new ProcessBuilder ("dbus-send" , "--print-reply" , "--dest=org.freedesktop.DBus" , "/org/freedesktop/DBus" , "org.freedesktop.DBus.ListNames" );
24
22
ProcessBuilder grep = new ProcessBuilder ("grep" , "org.gnome.keyring" );
25
23
try {
26
24
Process end = ProcessBuilder .startPipeline (List .of (dbusSend , grep )).get (1 );
@@ -36,10 +34,13 @@ public static void checkSystemAndSetup() throws IOException {
36
34
37
35
38
36
@ Test
39
- public void testIsSupported (){
37
+ @ EnabledIf ("isXdgDisplayEnvVarSet" )
38
+ public void testIsSupported () {
40
39
SecretServiceKeychainAccess secretService = new SecretServiceKeychainAccess ();
41
40
Assertions .assertEquals (isInstalled , secretService .isSupported ());
42
41
}
43
42
44
-
45
- }
43
+ public boolean isXdgDisplayEnvVarSet () {
44
+ return System .getenv ("DISPLAY" ) != null ;
45
+ }
46
+ }
0 commit comments