mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-21 05:13:11 +00:00
8284993: Replace System.exit call in swing tests with RuntimeException
Reviewed-by: azvegint
This commit is contained in:
parent
d84b9c5489
commit
80219a48c3
@ -37,10 +37,24 @@ import javax.swing.SwingUtilities;
|
||||
public class Test8019180 implements Runnable {
|
||||
private static final CountDownLatch LATCH = new CountDownLatch(1);
|
||||
private static final String[] ITEMS = {"First", "Second", "Third", "Fourth"};
|
||||
private static JFrame frame;
|
||||
private static boolean selectionFail = false;
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
SwingUtilities.invokeLater(new Test8019180());
|
||||
LATCH.await();
|
||||
public static void main(String[] args) throws Exception {
|
||||
try {
|
||||
SwingUtilities.invokeLater(new Test8019180());
|
||||
LATCH.await();
|
||||
System.out.println("selectionFail " + selectionFail);
|
||||
if (selectionFail) {
|
||||
throw new RuntimeException("Combobox not selected");
|
||||
}
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private JComboBox<String> test;
|
||||
@ -50,8 +64,9 @@ public class Test8019180 implements Runnable {
|
||||
if (this.test == null) {
|
||||
this.test = new JComboBox<>(ITEMS);
|
||||
this.test.addActionListener(this.test);
|
||||
JFrame frame = new JFrame();
|
||||
frame = new JFrame();
|
||||
frame.add(test);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
SwingUtilities.invokeLater(this);
|
||||
@ -60,9 +75,8 @@ public class Test8019180 implements Runnable {
|
||||
this.test.setSelectedIndex(1 + index);
|
||||
if (0 > this.test.getSelectedIndex()) {
|
||||
System.err.println("ERROR: no selection");
|
||||
System.exit(8019180);
|
||||
selectionFail = true;
|
||||
}
|
||||
SwingUtilities.getWindowAncestor(this.test).dispose();
|
||||
LATCH.countDown();
|
||||
}
|
||||
}
|
||||
|
||||
@ -118,6 +118,6 @@ public class Test8013442 extends FileFilter implements Runnable, Thread.Uncaught
|
||||
|
||||
public void uncaughtException(Thread thread, Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
System.exit(1);
|
||||
throw new RuntimeException(throwable);
|
||||
}
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ public class Test6943780 implements Runnable, Thread.UncaughtExceptionHandler {
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
System.exit(1);
|
||||
throw new RuntimeException(throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -94,6 +94,6 @@ public class Test8015926 implements TreeModelListener, Runnable, Thread.Uncaught
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable exception) {
|
||||
exception.printStackTrace();
|
||||
System.exit(1);
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ public class Test6968363 implements Runnable, Thread.UncaughtExceptionHandler {
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
System.exit(1);
|
||||
throw new RuntimeException(throwable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -65,7 +65,7 @@ public class Test8017492 {
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable throwable) {
|
||||
throwable.printStackTrace();
|
||||
System.exit(1);
|
||||
throw new RuntimeException(throwable);
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user