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