01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: package java.awt.print;
19:
20: import java.awt.Graphics;
21:
22: import junit.framework.TestCase;
23:
24: public class BookTest extends TestCase {
25:
26: public static void main(String[] args) {
27: junit.textui.TestRunner.run(BookTest.class);
28: }
29:
30: /**
31: * Test method for
32: * {@link java.awt.print.Book#setPage(int, java.awt.print.Printable, java.awt.print.PageFormat)}.
33: */
34: public void testSetPage() {
35: // Regression test for HARMONY-2433
36: final Book d = new Book();
37: final PageFormat pf = new PageFormat();
38: final Printable p = new Printable() {
39: public int print(Graphics g, PageFormat pf, int i) {
40: return PAGE_EXISTS;
41: }
42: };
43:
44: try {
45: d.setPage(1, p, pf);
46: fail("IndexOutOfBoundsException was not thrown"); //$NON-NLS-1$
47: } catch (IndexOutOfBoundsException ex) {
48: // expected
49: }
50:
51: try {
52: d.setPage(1, null, pf);
53: fail("NullPointerException was not thrown"); //$NON-NLS-1$
54: } catch (NullPointerException ex) {
55: // expected
56: }
57:
58: try {
59: d.setPage(1, p, null);
60: fail("NullPointerException was not thrown"); //$NON-NLS-1$
61: } catch (NullPointerException ex) {
62: // expected
63: }
64: }
65: }
|