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 java.io.FileInputStream;
23:
24: import javax.print.attribute.HashDocAttributeSet;
25: import javax.print.attribute.HashPrintRequestAttributeSet;
26: import javax.print.attribute.PrintRequestAttributeSet;
27: import javax.print.attribute.standard.Copies;
28: import javax.print.attribute.standard.MediaName;
29: import javax.print.attribute.standard.MediaSizeName;
30: import javax.print.attribute.standard.Sides;
31:
32: import junit.framework.TestCase;
33:
34: public class LookupMultiDocPrintServicesTest extends TestCase {
35: public void testLookupMultiDocPrintServices() throws Exception {
36: System.out
37: .println("============= START LookupMultiDocPrintServicesTest ================");
38:
39: DocFlavor psFlavor = DocFlavor.INPUT_STREAM.GIF;
40: MultiDocPrintService[] services;
41: FileInputStream fis;
42: PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
43: HashDocAttributeSet daset = new HashDocAttributeSet();
44: DocPrintJob pj;
45: Doc doc;
46:
47: aset.add(new Copies(2));
48: aset.add(MediaSizeName.ISO_A4);
49: daset.add(MediaName.ISO_A4_WHITE);
50: daset.add(Sides.TWO_SIDED_LONG_EDGE);
51:
52: services = PrintServiceLookup.lookupMultiDocPrintServices(
53: new DocFlavor[] { psFlavor }, aset);
54: if (services != null && services.length > 0) {
55: fis = new FileInputStream("/Resources/1M.GIF");
56: doc = new SimpleDoc(fis, psFlavor, daset);
57:
58: pj = services[0].createPrintJob();
59: pj.print(doc, aset);
60: System.out.println(fis.toString() + " printed on "
61: + services[0].getName());
62: } else {
63: System.out.println("services not found");
64: }
65:
66: System.out
67: .println("============= END LookupMultiDocPrintServicesTest ================");
68: }
69:
70: }
|