Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/print/attribute/TestOrientationSupportForStreamPrnSrv.java
41149 views
1
/*
2
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
/*
24
* @test
25
* @bug 4882305
26
* @summary Verifies if StreamPrintServ.getSupportedAttributeValues returns
27
* valid Orientation attribute and not null for image/jpeg DocFlavor.
28
* @run main TestOrientationSupportForStreamPrnSrv
29
*/
30
import java.io.File;
31
import java.io.FileOutputStream;
32
import javax.print.DocFlavor;
33
import javax.print.PrintService;
34
import javax.print.PrintServiceLookup;
35
import javax.print.StreamPrintServiceFactory;
36
import javax.print.attribute.standard.OrientationRequested;
37
38
public class TestOrientationSupportForStreamPrnSrv {
39
40
public static void main(java.lang.String[] args) throws Exception {
41
PrintService service = null;
42
PrintService defService = PrintServiceLookup.lookupDefaultPrintService();
43
File f = null;
44
FileOutputStream fos = null;
45
String mType = "application/postscript";
46
DocFlavor flavors[] = null;
47
48
f = new File("streamexample1.ps");
49
fos = new FileOutputStream(f);
50
StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.
51
lookupStreamPrintServiceFactories(DocFlavor.INPUT_STREAM.JPEG,
52
mType);
53
if (factories.length > 0) {
54
System.out.println("output format "+factories[0].getOutputFormat());
55
service = factories[0].getPrintService(fos);
56
flavors = factories[0].getSupportedDocFlavors();
57
}
58
System.out.println("Stream Print Service "+service);
59
60
if (service == null) {
61
throw new RuntimeException("No Stream Print Service found");
62
}
63
System.out.println("is OrientationRequested supported? "+
64
service.isAttributeCategorySupported(OrientationRequested.class));
65
66
for (int k = 0; k < flavors.length; k ++) {
67
Object obj = service.getSupportedAttributeValues(OrientationRequested.class,
68
flavors[k], null);
69
if (flavors[k].equals(DocFlavor.INPUT_STREAM.JPEG)) {
70
if (obj == null) {
71
throw new RuntimeException(""
72
+ "StreamPrintServ.getSupportedAttributeValues "
73
+ "returns null for image/jpeg DocFlavor for "
74
+ "supported Orientation category");
75
}
76
}
77
}
78
}
79
}
80
81
82