AttributeTest.java revision 2043
445N/A/*
445N/A * Copyright 2006-2010 Sun Microsystems, Inc. All Rights Reserved.
445N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
445N/A *
445N/A * This code is free software; you can redistribute it and/or modify it
445N/A * under the terms of the GNU General Public License version 2 only, as
445N/A * published by the Free Software Foundation.
445N/A *
445N/A * This code is distributed in the hope that it will be useful, but WITHOUT
445N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
445N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
445N/A * version 2 for more details (a copy is included in the LICENSE file that
445N/A * accompanied this code).
445N/A *
445N/A * You should have received a copy of the GNU General Public License version
445N/A * 2 along with this work; if not, write to the Free Software Foundation,
445N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
445N/A *
445N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
445N/A * CA 95054 USA or visit www.sun.com if you need additional information or
445N/A * have any questions.
445N/A */
445N/A
445N/A/*
445N/A * @test
445N/A * @bug 6387255
445N/A * @summary Tests conflict of Media values returned by isAttrValueSupported and getSupportedAttrValues. No runtime exception should be thrown.
445N/A * @run main AttributeTest
445N/A */
445N/Aimport javax.print.*;
445N/Aimport javax.print.attribute.standard.*;
445N/Aimport javax.print.attribute.*;
445N/A
445N/Apublic class AttributeTest {
445N/A
445N/A public AttributeTest() {
482N/A
482N/A PrintService service[] = PrintServiceLookup.lookupPrintServices(null, null);
482N/A
482N/A if (service.length == 0) {
482N/A throw new RuntimeException("No printer found. TEST ABORTED");
482N/A }
482N/A
482N/A for (int x = 0; x < service.length; x ++) {
445N/A DocFlavor flavors[] = service[x].getSupportedDocFlavors();
445N/A
445N/A for (int y = 0; y < flavors.length; y ++) {
788N/A Object attrVal = service[x].getSupportedAttributeValues(Media.class, flavors[y], null);
788N/A if (attrVal == null) {
788N/A continue;
788N/A }
788N/A Media attr[] = (Media[]) attrVal;
788N/A for (int z = 0; z < attr.length; z ++) {
788N/A if (!service[x].isAttributeValueSupported(attr[z], flavors[y], null)) {
788N/A throw new RuntimeException("ERROR: There is a conflict between getSupportedAttrValues " +
788N/A " and isAttributeValueSupported, for the attribute: " + attr[z] +
445N/A ", where the flavor is: " + flavors[y] + " and the print service is: " +
445N/A service[x] + "\n");
445N/A }
445N/A }
445N/A }
445N/A }
445N/A
445N/A System.out.println("Test Passed");
445N/A }
445N/A
445N/A public static void main (String args[]) {
445N/A AttributeTest test = new AttributeTest();
445N/A }
445N/A}
445N/A