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 .EnabledIf ;
6
+ import org .junit .jupiter .api .condition .EnabledIfEnvironmentVariable ;
7
7
import org .junit .jupiter .api .condition .EnabledOnOs ;
8
8
import org .junit .jupiter .api .condition .OS ;
9
9
15
15
* Unit tests for KWallet access via DBUS.
16
16
*/
17
17
@ EnabledOnOs (OS .LINUX )
18
- @ EnabledIf ( "osEnvironmentSuitable " )
18
+ @ EnabledIfEnvironmentVariable ( named = "DISPLAY" , matches = ".* " )
19
19
public class KDEWalletKeychainAccessTest {
20
20
21
21
private static boolean isInstalled ;
22
22
23
23
@ BeforeAll
24
24
public static void checkSystemAndSetup () throws IOException {
25
- ProcessBuilder dbusSend = new ProcessBuilder ("dbus-send" ,"--print-reply" ,"--dest=org.freedesktop.DBus" , "/org/freedesktop/DBus" , "org.freedesktop.DBus.ListNames " );
26
- ProcessBuilder grep = new ProcessBuilder ("grep" , "org.kde.kwallet" );
25
+ ProcessBuilder dbusSend = new ProcessBuilder ("dbus-send" , "--print-reply" , "--dest=org.freedesktop.DBus" , "/org/freedesktop/DBus" , "org.freedesktop.DBus.ListActivatableNames " );
26
+ ProcessBuilder grep = new ProcessBuilder ("grep" , "-q" , " org.kde.kwallet" );
27
27
try {
28
28
Process end = ProcessBuilder .startPipeline (List .of (dbusSend , grep )).get (1 );
29
29
if (end .waitFor (1000 , TimeUnit .MILLISECONDS )) {
@@ -42,9 +42,4 @@ public void testIsSupported() {
42
42
KDEWalletKeychainAccess keychainAccess = new KDEWalletKeychainAccess ();
43
43
Assertions .assertEquals (isInstalled , keychainAccess .isSupported ());
44
44
}
45
-
46
-
47
- private static boolean osEnvironmentSuitable () {
48
- return System .getenv ().containsKey ("DISPLAY" );
49
- }
50
45
}
0 commit comments