Skip to content

Commit dce04a2

Browse files
Jonathan DowlandRealCLanger
authored andcommitted
8272342: [TEST_BUG] java/awt/print/PrinterJob/PageDialogMarginTest.java catches all exceptions
Backport-of: a5ad7720d235610ad45fc341c61f164805f82a54
1 parent 89d4ef2 commit dce04a2

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

test/jdk/java/awt/print/PrinterJob/PageDialogMarginTest.java

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -28,9 +28,10 @@
2828
* entry is working
2929
* @run main/manual PageDialogMarginTest
3030
*/
31-
import java.awt.Component;
31+
3232
import java.awt.print.PageFormat;
3333
import java.awt.print.PrinterJob;
34+
import java.util.Locale;
3435
import javax.print.attribute.HashPrintRequestAttributeSet;
3536
import javax.print.attribute.PrintRequestAttributeSet;
3637
import javax.print.attribute.standard.MediaPrintableArea;
@@ -39,35 +40,31 @@
3940

4041
public class PageDialogMarginTest {
4142

42-
public static void main(String args[]) throws Exception {
43+
public static void main(String[] args) throws Exception {
44+
Locale.setDefault(Locale.US);
4345
String[] instructions
4446
= {
4547
"Page Dialog will be shown.",
4648
"Change top(in) margin value from 1.0 to 2.0",
4749
"Then select OK."
4850
};
49-
SwingUtilities.invokeAndWait(() -> {
50-
JOptionPane.showMessageDialog((Component) null,
51-
instructions, "Instructions",
52-
JOptionPane.INFORMATION_MESSAGE);
53-
});
51+
SwingUtilities.invokeAndWait(() -> JOptionPane.showMessageDialog(null,
52+
instructions, "Instructions",
53+
JOptionPane.INFORMATION_MESSAGE));
5454
PrinterJob pj = PrinterJob.getPrinterJob();
55-
try {
56-
HashPrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
57-
PageFormat pf;
58-
pf = pj.pageDialog(aset);
59-
double left = pf.getImageableX();
60-
double top = pf.getImageableY();
61-
System.out.println("pageDialog - left/top from pageFormat: " + left / 72
62-
+ " " + top / 72);
63-
System.out.println("pageDialog - left/top from attribute set: "
64-
+ getPrintableXFromASet(aset) + " "
65-
+ getPrintableYFromASet(aset));
66-
if (top / 72 != 2.0f || getPrintableYFromASet(aset) != 2.0f) {
67-
throw new RuntimeException("Top margin value not updated");
68-
}
69-
} catch (Exception e) {
70-
e.printStackTrace();
55+
56+
HashPrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
57+
PageFormat pf = pj.pageDialog(aset);
58+
double left = pf.getImageableX();
59+
double top = pf.getImageableY();
60+
61+
System.out.println("pageDialog - left/top from pageFormat: " + left / 72
62+
+ " " + top / 72);
63+
System.out.println("pageDialog - left/top from attribute set: "
64+
+ getPrintableXFromASet(aset) + " "
65+
+ getPrintableYFromASet(aset));
66+
if (top / 72 != 2.0f || getPrintableYFromASet(aset) != 2.0f) {
67+
throw new RuntimeException("Top margin value not updated");
7168
}
7269
}
7370

0 commit comments

Comments
 (0)