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 javax.print;
19:
20: import javax.print.attribute.PrintServiceAttribute;
21: import javax.print.attribute.standard.Destination;
22: import javax.print.attribute.standard.DocumentName;
23: import javax.print.attribute.standard.JobName;
24: import javax.print.attribute.standard.Media;
25: import javax.print.attribute.standard.RequestingUserName;
26: import junit.framework.TestCase;
27:
28: public class GetDefaultAttributeValueTest extends TestCase {
29: @SuppressWarnings("unchecked")
30: public void testGetDefaultAttributeValue() {
31: PrintService[] services;
32: Object probe;
33: services = PrintServiceLookup.lookupPrintServices(null, null);
34: TestUtil.checkServices(services);
35: for (int i = 0, ii = services.length; i < ii; i++) {
36: probe = services[i].getDefaultAttributeValue(Media.class);
37: assertNotNull(probe);
38: probe = services[i]
39: .getDefaultAttributeValue(Destination.class);
40: assertNotNull(probe);
41: probe = services[i].getDefaultAttributeValue(JobName.class);
42: assertNotNull(probe);
43: probe = services[i]
44: .getDefaultAttributeValue(RequestingUserName.class);
45: assertNotNull(probe);
46: probe = services[i]
47: .getDefaultAttributeValue(DocumentName.class);
48: assertNotNull(probe);
49: try {
50: probe = services[i].getDefaultAttributeValue(null);
51: fail("NullPointerException must be thrown - the category is null");
52: } catch (Exception e) {
53: // OK
54: }
55: try {
56: Class<?> invalidClass = this .getClass();
57: probe = services[i]
58: .getDefaultAttributeValue((Class<? extends PrintServiceAttribute>) invalidClass);
59: fail("IllegalArgumentException must be thrown - category is not a Class that implements interface Attribute.");
60: } catch (IllegalArgumentException e) {
61: // OK
62: }
63: }
64: }
65: }
|