6150N/A/*
6150N/A * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
6150N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6150N/A *
6150N/A * This code is free software; you can redistribute it and/or modify it
6150N/A * under the terms of the GNU General Public License version 2 only, as
6150N/A * published by the Free Software Foundation.
6150N/A *
6150N/A * This code is distributed in the hope that it will be useful, but WITHOUT
6150N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6150N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6150N/A * version 2 for more details (a copy is included in the LICENSE file that
6150N/A * accompanied this code).
6150N/A *
6150N/A * You should have received a copy of the GNU General Public License version
6150N/A * 2 along with this work; if not, write to the Free Software Foundation,
6150N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6150N/A *
6150N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6150N/A * or visit www.oracle.com if you need additional information or have any
6150N/A * questions.
6150N/A */
6150N/A
6150N/Aimport javax.print.PrintService;
6150N/Aimport javax.print.PrintServiceLookup;
6150N/Aimport javax.print.attribute.AttributeSet;
6150N/Aimport javax.print.attribute.HashAttributeSet;
6150N/Aimport javax.print.attribute.standard.PrinterName;
6150N/A
6150N/A/*
6150N/A * @test
6150N/A * @bug 8013810
6150N/A * @summary Test that print service returned without filter are of the same class as with name filter
6150N/A */
6150N/Apublic class GetPrintServices {
6150N/A
6150N/A public static void main(String[] args) throws Exception {
6150N/A for (PrintService service : PrintServiceLookup.lookupPrintServices(null, null)) {
6150N/A String serviceName = service.getName();
6150N/A PrintService serviceByName = lookupByName(serviceName);
6150N/A if (!service.equals(serviceByName)) {
6150N/A throw new RuntimeException("NOK " + serviceName
6150N/A + " expected: " + service.getClass().getName()
6150N/A + " got: " + serviceByName.getClass().getName());
6150N/A }
6150N/A }
6150N/A System.out.println("Test PASSED");
6150N/A }
6150N/A
6150N/A private static PrintService lookupByName(String name) {
6150N/A AttributeSet attributes = new HashAttributeSet();
6150N/A attributes.add(new PrinterName(name, null));
6150N/A for (PrintService service : PrintServiceLookup.lookupPrintServices(null, attributes)) {
6150N/A return service;
6150N/A }
6150N/A return null;
6150N/A }
6150N/A}