Skip to content

Commit

Permalink
8025439: [TEST BUG] [macosx] PrintServiceLookup.lookupPrintServices d…
Browse files Browse the repository at this point in the history
…oesn't work properly since jdk8b105

Reviewed-by: andrew
Backport-of: a53e8ddcad8c34fc9906e083c5933d0d1c3e9f4e
  • Loading branch information
mrserb committed Feb 26, 2024
1 parent 824dbfb commit a798523
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions jdk/test/javax/print/PrintServiceLookup/GetPrintServices.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -29,30 +29,37 @@

/*
* @test
* @bug 8013810
* @summary Test that print service returned without filter are of the same class as with name filter
* @bug 8013810 8025439
* @summary Test that print service returned without filter are of the same class
* as with name filter
*/
public class GetPrintServices {

public static void main(String[] args) throws Exception {
for (PrintService service : PrintServiceLookup.lookupPrintServices(null, null)) {
String serviceName = service.getName();
PrintService serviceByName = lookupByName(serviceName);
if (!service.equals(serviceByName)) {
throw new RuntimeException("NOK " + serviceName
public static void main(String[] args) throws Exception {
for (PrintService service : PrintServiceLookup.lookupPrintServices(null, null)) {
String serviceName = service.getName();
PrinterName name = service.getAttribute(PrinterName.class);
String printerName = name.getValue();

PrintService serviceByName = lookupByName(printerName);
System.out.println("service " + service);
System.out.println("serviceByName " + serviceByName);
if (!service.equals(serviceByName)) {
throw new RuntimeException("NOK " + serviceName
+ " expected: " + service.getClass().getName()
+ " got: " + serviceByName.getClass().getName());
}
}
}
System.out.println("Test PASSED");
}
System.out.println("Test PASSED");
}

private static PrintService lookupByName(String name) {
AttributeSet attributes = new HashAttributeSet();
attributes.add(new PrinterName(name, null));
for (PrintService service : PrintServiceLookup.lookupPrintServices(null, attributes)) {
return service;
private static PrintService lookupByName(String name) {
AttributeSet attributes = new HashAttributeSet();
attributes.add(new PrinterName(name, null));
for (PrintService service :
PrintServiceLookup.lookupPrintServices(null, attributes)) {
return service;
}
return null;
}
return null;
}
}

1 comment on commit a798523

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.