1
1
/*
2
- * Copyright (c) 2000, 2022 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2000, 2025 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
63
63
64
64
import jdk .test .lib .UIBuilder ;
65
65
66
- import javax .swing .*;
66
+ import javax .swing .JDialog ;
67
+ import javax .swing .SwingUtilities ;
68
+ import javax .swing .JTextArea ;
69
+ import javax .swing .JButton ;
70
+ import javax .swing .JPanel ;
71
+ import javax .swing .JScrollPane ;
72
+ import javax .swing .JFrame ;
73
+ import java .awt .FlowLayout ;
74
+ import java .awt .BorderLayout ;
67
75
import java .io .ByteArrayOutputStream ;
68
76
import java .io .PrintStream ;
69
77
import java .util .Locale ;
70
78
79
+ import static javax .swing .BorderFactory .createEmptyBorder ;
80
+
71
81
public class i18n {
72
82
private static final String [][] TABLE = new String [][]{
73
83
{"-help" , "All the output in this test should be in ${LANG}. "
@@ -238,11 +248,12 @@ public class i18n {
238
248
"Output in ${LANG}. Check keytool error: java.lang"
239
249
+ ".IllegalArgumentException: if -protected is "
240
250
+ "specified, then -storepass, -keypass, and -new "
241
- + "must not be specified." },
251
+ + "must not be specified." }
242
252
};
243
253
private static String TEST_SRC = System .getProperty ("test.src" );
244
254
private static int TIMEOUT_MS = 120000 ;
245
255
private volatile boolean failed = false ;
256
+ private volatile String failureReason = "" ;
246
257
private volatile boolean aborted = false ;
247
258
private Thread currentThread = null ;
248
259
@@ -334,6 +345,7 @@ public boolean validate(String command, String instruction, String message) {
334
345
335
346
if (failed ) {
336
347
System .out .println (command + ": TEST FAILED" );
348
+ System .out .println ("REASON: " + failureReason );
337
349
System .out .println (message );
338
350
} else {
339
351
System .out .println (command + ": TEST PASSED" );
@@ -352,11 +364,46 @@ public void pass() {
352
364
353
365
public void fail () {
354
366
failed = true ;
367
+ failureReason = requestFailDescription ();
355
368
currentThread .interrupt ();
356
369
}
357
370
358
371
public void abort () {
359
372
aborted = true ;
360
373
currentThread .interrupt ();
361
374
}
375
+
376
+ /**
377
+ * Opens a prompt to enter a failure reason to be filled by the tester
378
+ */
379
+ private String requestFailDescription () {
380
+
381
+ final JDialog dialogWindow = new JDialog (new JFrame (), "Failure Description" , true );
382
+ final JTextArea reasonTextArea = new JTextArea (5 , 20 );
383
+
384
+ final JButton okButton = new JButton ("OK" );
385
+ okButton .addActionListener (_ -> dialogWindow .setVisible (false ));
386
+
387
+ final JPanel okayBtnPanel = new JPanel (
388
+ new FlowLayout (FlowLayout .CENTER ,
389
+ 4 ,
390
+ 0 ));
391
+ okayBtnPanel .setBorder (createEmptyBorder (4 ,
392
+ 0 ,
393
+ 0 ,
394
+ 0 ));
395
+ okayBtnPanel .add (okButton );
396
+
397
+ final JPanel mainPanel = new JPanel (new BorderLayout ());
398
+ mainPanel .add (new JScrollPane (reasonTextArea ), BorderLayout .CENTER );
399
+ mainPanel .add (okayBtnPanel , BorderLayout .SOUTH );
400
+
401
+ dialogWindow .add (mainPanel );
402
+ dialogWindow .pack ();
403
+ dialogWindow .setVisible (true );
404
+
405
+ dialogWindow .dispose ();
406
+
407
+ return reasonTextArea .getText ();
408
+ }
362
409
}
0 commit comments