CheckDupFlavor.java revision 756
756N/A/*
756N/A * Copyright 2004-2008 Sun Microsystems, Inc. All Rights Reserved.
756N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
756N/A *
756N/A * This code is free software; you can redistribute it and/or modify it
756N/A * under the terms of the GNU General Public License version 2 only, as
756N/A * published by the Free Software Foundation.
756N/A *
756N/A * This code is distributed in the hope that it will be useful, but WITHOUT
756N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
756N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
756N/A * version 2 for more details (a copy is included in the LICENSE file that
756N/A * accompanied this code).
756N/A *
756N/A * You should have received a copy of the GNU General Public License version
756N/A * 2 along with this work; if not, write to the Free Software Foundation,
756N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
756N/A *
756N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
756N/A * CA 95054 USA or visit www.sun.com if you need additional information or
756N/A * have any questions.
756N/A */
756N/A
756N/A/*
756N/A * @test
756N/A * @bug 4996318 6731937
756N/A * @summary There should be no duplicates returned by getSupportedDocFlavors.
756N/A * @run main CheckDupFlavor
756N/A */
756N/Aimport javax.print.*;
756N/Aimport javax.print.attribute.*;
756N/Aimport javax.print.attribute.standard.*;
756N/Aimport java.util.ArrayList;
756N/A
756N/A
756N/Apublic class CheckDupFlavor {
756N/A public static void main(String[] args){
756N/A PrintService pservice =
756N/A PrintServiceLookup.lookupDefaultPrintService();
756N/A
756N/A if (pservice == null) {
756N/A System.out.println("No default PrintService found. Test ABORTED.");
756N/A return;
756N/A }
756N/A
756N/A System.out.println("Default service = "+pservice);
756N/A
756N/A DocFlavor[] flavors = pservice.getSupportedDocFlavors();
756N/A if (flavors==null) {
756N/A System.out.println("No flavors supported. Test PASSED.");
756N/A return;
756N/A }
756N/A
756N/A
756N/A ArrayList flavorList = new ArrayList();
756N/A for (int i=0; i<flavors.length; i++) {
756N/A if (flavors[i] == null) {
756N/A throw new RuntimeException("Null flavor. Test FAILED.");
756N/A } else if (flavorList.contains(flavors[i])) {
756N/A throw new RuntimeException("\n\tDuplicate flavor found : "+flavors[i]+" : Test FAILED.");
756N/A } else {
756N/A flavorList.add(flavors[i]);
756N/A }
756N/A }
756N/A System.out.println("No duplicate found. Test PASSED.");
756N/A }
756N/A}