33import org .junit .jupiter .api .Assertions ;
44import org .junit .jupiter .api .BeforeAll ;
55import 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 ;
87
98import java .io .IOException ;
109import java .util .List ;
1312/**
1413 * Unit tests for GNOME keyring access via DBUS.
1514 */
16- @ EnabledOnOs (OS .LINUX )
1715public class SecretServiceKeychainAccessTest {
1816
1917 private static boolean isInstalled ;
2018
2119 @ BeforeAll
2220 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" );
2422 ProcessBuilder grep = new ProcessBuilder ("grep" , "org.gnome.keyring" );
2523 try {
2624 Process end = ProcessBuilder .startPipeline (List .of (dbusSend , grep )).get (1 );
@@ -36,10 +34,13 @@ public static void checkSystemAndSetup() throws IOException {
3634
3735
3836 @ Test
39- public void testIsSupported (){
37+ @ EnabledIf ("isXdgDisplayEnvVarSet" )
38+ public void testIsSupported () {
4039 SecretServiceKeychainAccess secretService = new SecretServiceKeychainAccess ();
4140 Assertions .assertEquals (isInstalled , secretService .isSupported ());
4241 }
4342
44-
45- }
43+ public boolean isXdgDisplayEnvVarSet () {
44+ return System .getenv ("DISPLAY" ) != null ;
45+ }
46+ }
0 commit comments