28
28
* @summary AWT_Desktop/Automated/Exceptions/BasicTest loads incorrect GTK
29
29
* version when jdk.gtk.version=3
30
30
* @requires (os.family == "linux")
31
+ * @library /test/lib
31
32
* @run main DesktopGtkLoadTest
32
33
*/
33
34
35
+ import jdk .test .lib .process .OutputAnalyzer ;
36
+ import jdk .test .lib .process .ProcessTools ;
34
37
35
38
import java .awt .*;
36
39
import java .io .*;
@@ -43,26 +46,14 @@ public static void main(String[] args) {
43
46
}
44
47
45
48
public static void main (String [] args ) throws Exception {
46
- Process p = Runtime .getRuntime ().exec (System .getProperty ("java.home" ) +
47
- "/bin/java -Djdk.gtk.version=3 -Djdk.gtk.verbose=true " +
48
- "-cp " + System .getProperty ("java.class.path" , "." ) +
49
- " DesktopGtkLoadTest$RunDesktop" );
50
- p .waitFor ();
51
- try (BufferedReader br = new BufferedReader (
52
- new InputStreamReader (p .getErrorStream ()))) {
53
- String line ;
54
- while ((line = br .readLine ()) != null ) {
55
- System .out .println (line );
56
- if (line .contains ("Looking for GTK2 library" )) {
57
- break ;
58
- }
59
- if (line .contains ("Looking for GTK3 library" )) {
60
- return ;
61
- }
62
- }
63
- throw new RuntimeException ("Wrong GTK library version: \n " + line );
64
- }
65
-
49
+ final ProcessBuilder pbJava = ProcessTools .createTestJavaProcessBuilder (
50
+ "-Djdk.gtk.version=3" ,
51
+ "-Djdk.gtk.verbose=true" ,
52
+ RunDesktop .class .getName ()
53
+ );
54
+ final OutputAnalyzer output = ProcessTools .executeProcess (pbJava );
55
+ output .shouldNotContain ("Looking for GTK2 library" );
56
+ output .shouldContain ("Looking for GTK3 library" );
66
57
}
67
58
68
59
}
0 commit comments