Skip to content

Commit 552566a

Browse files
committed
8334644: Automate javax/print/attribute/PageRangesException.java
Backport-of: 030149fec4f175e5571e053fa56d2921d95c6b13
1 parent b9b9d7f commit 552566a

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (c) 2001, 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
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.
22+
*/
23+
24+
import javax.print.attribute.standard.PageRanges;
25+
26+
/*
27+
* @test
28+
* @bug 4433126 4433096
29+
* @key printer
30+
* @summary The line "ERROR: <message>" should NOT appear.
31+
* @run main PageRangesException
32+
*/
33+
34+
public class PageRangesException {
35+
public static void main(String[] args) throws Exception {
36+
// test 4433126
37+
try {
38+
PageRanges pr = new PageRanges("0:22");
39+
throw new RuntimeException("ERROR: no exceptions");
40+
} catch (IllegalArgumentException ie) {
41+
System.out.println("OKAY: IllegalArgumentException " + ie);
42+
}
43+
44+
// test 4433096
45+
try {
46+
int[][] m = null;
47+
PageRanges pr = new PageRanges(m);
48+
throw new RuntimeException("ERROR: NullPointerException expected");
49+
} catch (IllegalArgumentException ie) {
50+
throw new RuntimeException("ERROR: IllegalArgumentException", ie);
51+
} catch (NullPointerException e) {
52+
System.out.println("OKAY: NullPointerException");
53+
}
54+
}
55+
}

0 commit comments

Comments
 (0)