author | duke |
Wed, 05 Jul 2017 17:52:05 +0200 | |
changeset 10620 | 9df40a1578ef |
parent 5506 | 202f599c92aa |
child 46151 | 5fa789776f7d |
permissions | -rw-r--r-- |
2697
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
1 |
/* |
5506 | 2 |
* Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved. |
2697
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
4 |
* |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
8 |
* |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
13 |
* accompanied this code). |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
14 |
* |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
18 |
* |
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
2697
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
22 |
*/ |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
23 |
|
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
24 |
/* |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
25 |
* @test |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
26 |
* @bug 4762773 6289206 6324049 6362765 |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
27 |
* @summary Tests that get non-null return list of printable areas. |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
28 |
* @run main SupportedPrintableAreas |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
29 |
*/ |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
30 |
|
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
31 |
|
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
32 |
import javax.print.*; |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
33 |
import javax.print.event.*; |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
34 |
import javax.print.attribute.*; |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
35 |
import javax.print.attribute.standard.*; |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
36 |
|
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
37 |
public class SupportedPrintableAreas { |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
38 |
|
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
39 |
public static void main(String[] args) { |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
40 |
PrintService[] svc; |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
41 |
PrintService printer = PrintServiceLookup.lookupDefaultPrintService(); |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
42 |
if (printer == null) { |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
43 |
svc = PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE, null); |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
44 |
if (svc.length == 0) { |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
45 |
throw new RuntimeException("Printer is required for this test. TEST ABORTED"); |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
46 |
} |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
47 |
printer = svc[0]; |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
48 |
} |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
49 |
System.out.println("PrintService found : "+printer); |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
50 |
|
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
51 |
if (!printer.isAttributeCategorySupported(MediaPrintableArea.class)) { |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
52 |
return; |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
53 |
} |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
54 |
Object value = printer.getSupportedAttributeValues( |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
55 |
MediaPrintableArea.class, null, null); |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
56 |
if (!value.getClass().isArray()) { |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
57 |
throw new RuntimeException("unexpected value"); |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
58 |
} |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
59 |
|
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
60 |
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
61 |
value = printer.getSupportedAttributeValues( |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
62 |
MediaPrintableArea.class, null, aset); |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
63 |
if (!value.getClass().isArray()) { |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
64 |
throw new RuntimeException("unexpected value"); |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
65 |
} |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
66 |
|
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
67 |
Media media = (Media)printer.getDefaultAttributeValue(Media.class); |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
68 |
aset.add(media); |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
69 |
value = printer.getSupportedAttributeValues( |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
70 |
MediaPrintableArea.class, null, aset); |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
71 |
if (!value.getClass().isArray()) { |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
72 |
throw new RuntimeException("unexpected value"); |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
73 |
} |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
74 |
|
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
75 |
// test for 6289206 |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
76 |
aset.add(MediaTray.MANUAL); |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
77 |
value = printer.getSupportedAttributeValues( |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
78 |
MediaPrintableArea.class, null, aset); |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
79 |
if ((value != null) && !value.getClass().isArray()) { |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
80 |
throw new RuntimeException("unexpected value"); |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
81 |
} |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
82 |
} |
b27edaf0767e
6821495: test/java/awt/print/PrinterJob/PrtException.java fails
jgodinez
parents:
diff
changeset
|
83 |
} |