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: * @author Irina A. Arkhipets
19: * @version $Revision: 1.3 $
20: */package javax.print;
21:
22: import javax.print.attribute.HashPrintRequestAttributeSet;
23:
24: import junit.framework.TestCase;
25:
26: public class ServiceUITest extends TestCase {
27:
28: private PrintService[] services = null;
29: private HashPrintRequestAttributeSet attrs = null;
30:
31: protected void setUp() throws Exception {
32: services = PrintServiceLookup.lookupPrintServices(
33: DocFlavor.INPUT_STREAM.GIF, null);
34: attrs = new HashPrintRequestAttributeSet();
35: }
36:
37: /*
38: * Throws IllegalArgumentException if services array is null
39: */
40: public void testPrintDialog1() {
41: try {
42: ServiceUI.printDialog(null, 5, 5, null, null, null, attrs);
43: fail();
44: } catch (IllegalArgumentException e) {
45: /* IllegalArgimentException is expected here, so the test passes */
46: }
47: }
48:
49: /*
50: * Throws IllegalArgumentException if services array is or empty
51: */
52: public void testPrintDialog2() {
53: try {
54: ServiceUI.printDialog(null, 5, 5, new PrintService[] {},
55: null, null, attrs);
56: fail();
57: } catch (IllegalArgumentException e) {
58: /* IllegalArgimentException is expected here, so the test passes */
59: }
60: }
61:
62: /*
63: * Throws IllegalArgumentException if attributes is null
64: */
65: public void testPrintDialog3() {
66: try {
67: ServiceUI.printDialog(null, 5, 5, services, null, null,
68: null);
69: fail();
70: } catch (IllegalArgumentException e) {
71: /* IllegalArgimentException is expected here, so the test passes */
72: }
73: }
74:
75: /*
76: * Throws IllegalArgumentException if initial PrintService
77: * is not in the list of browsable services
78: */
79: public void testPrintDialog4() {
80: if ((services != null) && (services.length > 1)) {
81: PrintService[] s1 = new PrintService[services.length - 1];
82: for (int i = 0; i < services.length - 1; i++) {
83: s1[i] = services[i];
84: }
85: try {
86: ServiceUI.printDialog(null, 5, 5, s1,
87: services[services.length - 1], null, null);
88: fail();
89: } catch (IllegalArgumentException e) {
90: /* IllegalArgimentException is expected here, so the test passes */
91: }
92: }
93: }
94:
95: } /* End of ServiceUITests */
|