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 Igor A. Pyankov
19: * @version $Revision: 1.2 $
20: */package javax.print;
21:
22: import javax.print.attribute.HashAttributeSet;
23: import javax.print.attribute.standard.Finishings;
24: import javax.print.attribute.standard.MediaSizeName;
25: import javax.print.attribute.standard.OrientationRequested;
26:
27: import junit.framework.TestCase;
28:
29: public class GetSupportedAttributeValuesTest extends TestCase {
30:
31: public void testGetSupportedAttributeValues() {
32: System.out
33: .println("============= START testGetSupportedAttributeValues ================");
34:
35: PrintService[] services;
36: DocFlavor[] flavors = new DocFlavor[] {
37: DocFlavor.INPUT_STREAM.GIF,
38: DocFlavor.INPUT_STREAM.POSTSCRIPT,
39: DocFlavor.INPUT_STREAM.TEXT_PLAIN_US_ASCII };
40:
41: services = PrintServiceLookup.lookupPrintServices(null, null);
42: TestUtil.checkServices(services);
43: for (int i = 0, ii = services.length; i < ii; i++) {
44: System.out.println("\n----------- " + services[i].getName()
45: + "----------");
46:
47: Class[] cats = services[i]
48: .getSupportedAttributeCategories();
49: HashAttributeSet aset = new HashAttributeSet();
50: aset.add(MediaSizeName.ISO_A0);
51: aset.add(OrientationRequested.LANDSCAPE);
52: aset.add(Finishings.SADDLE_STITCH);
53:
54: for (int l = 0, ll = flavors.length; l < ll; l++) {
55: if (services[i].isDocFlavorSupported(flavors[l])) {
56: System.out.println(" " + flavors[l]);
57:
58: for (int j = 0, jj = cats.length; j < jj; j++) {
59: System.out.println(" " + cats[j]);
60:
61: Object obj = services[i]
62: .getSupportedAttributeValues(cats[j],
63: flavors[l], aset);
64: if (obj != null && obj.getClass().isArray()) {
65: Object[] a = (Object[]) obj;
66: for (int k = 0, kk = a.length; k < kk; k++) {
67: System.out.println(" "
68: + a[k]);
69: }
70: } else {
71: System.out.println(" " + obj);
72: }
73: }
74: }
75: }
76: }
77:
78: System.out
79: .println("============= END testGetSupportedAttributeValues ================");
80: }
81:
82: }
|