PSCopiesFlavorTest.java revision 1183:c3aaa11e4eb6
1224135Sdim/* 2224135Sdim * Copyright 2007-2009 Sun Microsystems, Inc. All Rights Reserved. 3224135Sdim * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4224135Sdim * 5224135Sdim * This code is free software; you can redistribute it and/or modify it 6224135Sdim * under the terms of the GNU General Public License version 2 only, as 7224135Sdim * published by the Free Software Foundation. 8224135Sdim * 9224135Sdim * This code is distributed in the hope that it will be useful, but WITHOUT 10224135Sdim * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11224135Sdim * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12224135Sdim * version 2 for more details (a copy is included in the LICENSE file that 13224135Sdim * accompanied this code). 14224135Sdim * 15224135Sdim * You should have received a copy of the GNU General Public License version 16224135Sdim * 2 along with this work; if not, write to the Free Software Foundation, 17224135Sdim * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18235633Sdim * 19224135Sdim * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 20224135Sdim * CA 95054 USA or visit www.sun.com if you need additional information or 21224135Sdim * have any questions. 22224135Sdim */ 23224135Sdim 24224135Sdim/** 25224135Sdim * @test 26224135Sdim * @bug 6527316 6732647 27224135Sdim * @summary Copies isn't supported for PS flavors. 28224135Sdim * @run main PSCopiesFlavorTest 29224135Sdim */ 30224135Sdim 31235633Sdimimport javax.print.*; 32224135Sdimimport javax.print.attribute.*; 33224135Sdimimport javax.print.attribute.standard.*; 34224135Sdim 35224135Sdimpublic class PSCopiesFlavorTest { 36224135Sdim 37224135Sdim public static void main(String args[]) { 38224135Sdim 39226890Sdim DocFlavor flavor = DocFlavor.INPUT_STREAM.POSTSCRIPT; 40235633Sdim PrintService[] ps = PrintServiceLookup.lookupPrintServices(flavor, null); 41235633Sdim if (ps.length > 0) { 42235633Sdim System.out.println("found PrintService: "+ps[0]); 43235633Sdim Copies c = new Copies(1); 44235633Sdim PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); 45226890Sdim aset.add(c); 46226890Sdim boolean suppVal = ps[0].isAttributeValueSupported(c, flavor, null); 47226890Sdim AttributeSet us = ps[0].getUnsupportedAttributes(flavor, aset); 48226890Sdim if (suppVal || us == null) { 49226890Sdim throw new RuntimeException("Copies should be unsupported value"); 50224135Sdim } 51224135Sdim 52224135Sdim Object value = ps[0].getSupportedAttributeValues(Copies.class, 53226890Sdim flavor, null); 54226890Sdim 55226890Sdim //Copies Supported 56226890Sdim if(value instanceof CopiesSupported) { 57226890Sdim throw new RuntimeException("Copies should have no supported values."); 58224135Sdim } 59224135Sdim } 60224135Sdim 61 } 62} 63