8343219: Manual clientlibs test failures after SM removal
Reviewed-by: azvegint, aivanov, prr
This commit is contained in:
parent
dde6230751
commit
1eb38c8eb7
@ -823,8 +823,3 @@ java/awt/Checkbox/CheckboxBoxSizeTest.java 8340870 windows-all
|
|||||||
java/awt/Checkbox/CheckboxIndicatorSizeTest.java 8340870 windows-all
|
java/awt/Checkbox/CheckboxIndicatorSizeTest.java 8340870 windows-all
|
||||||
java/awt/Checkbox/CheckboxNullLabelTest.java 8340870 windows-all
|
java/awt/Checkbox/CheckboxNullLabelTest.java 8340870 windows-all
|
||||||
java/awt/dnd/WinMoveFileToShellTest.java 8341665 windows-all
|
java/awt/dnd/WinMoveFileToShellTest.java 8341665 windows-all
|
||||||
java/awt/print/PrinterJob/CheckPrivilege.java 8343219 generic-all
|
|
||||||
javax/print/PrintSE/PrintSE.sh 8343219 generic-all
|
|
||||||
java/awt/print/PrinterJob/SecurityDialogTest.java 8343219 generic-all
|
|
||||||
java/awt/Dialog/PrintToFileTest/PrintToFileGranted.java 8343219 generic-all
|
|
||||||
java/awt/Dialog/PrintToFileTest/PrintToFileRevoked.java 8343219 generic-all
|
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
import java.awt.Button;
|
|
||||||
import java.awt.FlowLayout;
|
|
||||||
import java.awt.Frame;
|
|
||||||
import java.awt.PrintJob;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
|
|
||||||
class PrintToFileFrame extends Frame implements ActionListener {
|
|
||||||
Button nativeDlg = new Button("Show print dialog");
|
|
||||||
|
|
||||||
public PrintToFileFrame() {
|
|
||||||
this.setLayout(new FlowLayout());
|
|
||||||
add(nativeDlg);
|
|
||||||
nativeDlg.addActionListener(this);
|
|
||||||
|
|
||||||
setSize(300, 300);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("removal")
|
|
||||||
public void actionPerformed(ActionEvent ae) {
|
|
||||||
if (System.getSecurityManager() == null) {
|
|
||||||
throw new RuntimeException("Security manager isn't installed.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
System.getSecurityManager().checkPrintJobAccess();
|
|
||||||
System.out.println("checkPrintJobAccess - OK");
|
|
||||||
} catch (SecurityException e) {
|
|
||||||
System.out.println("checkPrintJobAccess - ERROR " + e);
|
|
||||||
}
|
|
||||||
|
|
||||||
PrintJob printJob = getToolkit().getPrintJob(this, null, null);
|
|
||||||
|
|
||||||
if (printJob != null) {
|
|
||||||
System.out.println("Print Job: " + printJob);
|
|
||||||
} else {
|
|
||||||
System.out.println("Print Job is null.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2005, 2024, 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
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.awt.print.PrinterJob;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @test
|
|
||||||
* @bug 6275359
|
|
||||||
* @summary Test to verify system menu of a dialog on win32
|
|
||||||
* @requires (os.family == "windows")
|
|
||||||
* @library /java/awt/regtesthelpers
|
|
||||||
* @build PassFailJFrame
|
|
||||||
* @compile PrintToFileFrame.java
|
|
||||||
* @compile PrintToFileGranted.java
|
|
||||||
* @run main/manual/policy=granted/othervm PrintToFileGranted
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class PrintToFileGranted {
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
String INSTRUCTIONS;
|
|
||||||
if (isPrintSupport()) {
|
|
||||||
INSTRUCTIONS = """
|
|
||||||
1. Click on 'Show file dialog' button A print dialog will come up
|
|
||||||
2. If checkbox 'Print to file' is enabled then the test passed
|
|
||||||
else the test failed
|
|
||||||
3. Close the print dialog before pressing PASS or FAIL buttons
|
|
||||||
""";
|
|
||||||
} else {
|
|
||||||
INSTRUCTIONS = """
|
|
||||||
1. The test requires printer installed in your system,
|
|
||||||
but there is no printers found
|
|
||||||
Please install one and re-run the test
|
|
||||||
""";
|
|
||||||
}
|
|
||||||
|
|
||||||
PassFailJFrame.builder()
|
|
||||||
.title("Test Instructions")
|
|
||||||
.instructions(INSTRUCTIONS)
|
|
||||||
.rows((int) INSTRUCTIONS.lines().count() + 2)
|
|
||||||
.columns(35)
|
|
||||||
.testUI(new PrintToFileFrame())
|
|
||||||
.build()
|
|
||||||
.awaitAndCheck();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isPrintSupport() {
|
|
||||||
PrinterJob pj = PrinterJob.getPrinterJob();
|
|
||||||
return pj.getPrintService() != null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2005, 2024, 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
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.awt.print.PrinterJob;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @test
|
|
||||||
* @bug 6275359
|
|
||||||
* @summary Test to verify Printing ignores Security permissions
|
|
||||||
* using native dialog
|
|
||||||
* @requires (os.family == "windows")
|
|
||||||
* @library /java/awt/regtesthelpers
|
|
||||||
* @build PassFailJFrame
|
|
||||||
* @compile PrintToFileRevoked.java
|
|
||||||
* @run main/manual/policy=revoked/othervm PrintToFileRevoked
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class PrintToFileRevoked {
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
String INSTRUCTIONS;
|
|
||||||
if (isPrintSupport()) {
|
|
||||||
INSTRUCTIONS = """
|
|
||||||
1. Click on 'Show file dialog' button A print dialog will come up
|
|
||||||
2. If checkbox 'Print to file' is disabled then the test passed
|
|
||||||
else the test failed
|
|
||||||
3. Close the print dialog before pressing PASS or FAIL buttons
|
|
||||||
""";
|
|
||||||
} else {
|
|
||||||
INSTRUCTIONS = """
|
|
||||||
1. The test requires printer installed in your system,
|
|
||||||
but there is no printers found
|
|
||||||
Please install one and re-run the test
|
|
||||||
""";
|
|
||||||
}
|
|
||||||
PassFailJFrame.builder()
|
|
||||||
.title("Test Instructions")
|
|
||||||
.instructions(INSTRUCTIONS)
|
|
||||||
.rows((int) INSTRUCTIONS.lines().count() + 2)
|
|
||||||
.columns(35)
|
|
||||||
.testUI(new PrintToFileFrame())
|
|
||||||
.build()
|
|
||||||
.awaitAndCheck();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isPrintSupport() {
|
|
||||||
PrinterJob pj = PrinterJob.getPrinterJob();
|
|
||||||
return pj.getPrintService() != null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,10 +0,0 @@
|
|||||||
/* AUTOMATICALLY GENERATED ON Thu Jan 03 15:48:39 PST 2002*/
|
|
||||||
/* DO NOT EDIT */
|
|
||||||
|
|
||||||
grant {
|
|
||||||
permission java.lang.RuntimePermission "queuePrintJob";
|
|
||||||
permission java.util.PropertyPermission "*", "read";
|
|
||||||
permission java.io.FilePermission "<<ALL FILES>>", "read";
|
|
||||||
permission java.io.FilePermission "<<ALL FILES>>", "write";
|
|
||||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.util.locale.provider";
|
|
||||||
};
|
|
@ -1,9 +0,0 @@
|
|||||||
/* AUTOMATICALLY GENERATED ON Thu Jan 03 15:48:39 PST 2002*/
|
|
||||||
/* DO NOT EDIT */
|
|
||||||
|
|
||||||
grant {
|
|
||||||
permission java.lang.RuntimePermission "queuePrintJob";
|
|
||||||
permission java.util.PropertyPermission "*", "read";
|
|
||||||
permission java.lang.RuntimePermission "accessClassInPackage.sun.util.locale.provider";
|
|
||||||
};
|
|
||||||
|
|
@ -1,132 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2007, 2017, 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
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @test
|
|
||||||
* @key printer
|
|
||||||
* @bug 4151151
|
|
||||||
* @summary Confirm that low-level print code does doPrivilege.
|
|
||||||
* @author Graham Hamilton
|
|
||||||
* @run main/othervm -Djava.security.manager=allow CheckPrivilege
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.awt.print.*;
|
|
||||||
|
|
||||||
public class CheckPrivilege implements Printable {
|
|
||||||
|
|
||||||
static boolean verbose;
|
|
||||||
|
|
||||||
private static void println(String mess) {
|
|
||||||
if (verbose) {
|
|
||||||
System.err.println(mess);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SecurityManager that allows print requests, but
|
|
||||||
* causes things like "exec" to get checked.
|
|
||||||
*/
|
|
||||||
static class PrintLover extends SecurityManager {
|
|
||||||
public void checkPrintJobAccess() {
|
|
||||||
}
|
|
||||||
public void checkPackageAccess(String pkg) {
|
|
||||||
}
|
|
||||||
public void checkPropertyAccess(String key) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Internal exception to boucne us out of the print code
|
|
||||||
*/
|
|
||||||
class Printing extends RuntimeException {
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void main(String argv[]) {
|
|
||||||
|
|
||||||
System.out.println( "-----------------------------------------------------------------------");
|
|
||||||
System.out.println( "INSTRUCTIONS: You should have a printer configured in your system to do this test. Test fails if you get this error message:");
|
|
||||||
System.out.println(" \"Regression: printing causes a NullPointerException\"");
|
|
||||||
System.out.println( "-----------------------------------------------------------------------");
|
|
||||||
|
|
||||||
if (argv.length > 0 && argv[0].equals("-v")) {
|
|
||||||
verbose = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We need to make sure AWT is initialized. This is bug #4162674
|
|
||||||
java.awt.Toolkit.getDefaultToolkit();
|
|
||||||
|
|
||||||
// Try to install our own security manager.
|
|
||||||
try {
|
|
||||||
SecurityManager sm = new PrintLover();
|
|
||||||
println("Installing PrintLover security manager");
|
|
||||||
System.setSecurityManager(sm);
|
|
||||||
println("Installed security manager OK");
|
|
||||||
|
|
||||||
} catch (Throwable th) {
|
|
||||||
System.err.println("Failed to install SecurityManager");
|
|
||||||
th.printStackTrace();
|
|
||||||
throw new RuntimeException("Failed to install SecurityManager");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
println("calling getPrinterJob");
|
|
||||||
PrinterJob pj = PrinterJob.getPrinterJob();
|
|
||||||
if ((pj == null) || (pj.getPrintService() == null)){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
println("PrinterJob class is " + pj.getClass());
|
|
||||||
println("calling pj.setPrintable");
|
|
||||||
pj.setPrintable(new CheckPrivilege());
|
|
||||||
println("calling pj.print");
|
|
||||||
pj.print();
|
|
||||||
println("done pj.print");
|
|
||||||
|
|
||||||
} catch (Printing ex) {
|
|
||||||
// We get here if the print request started OK.
|
|
||||||
println("Caught \"Printing\" exception OK");
|
|
||||||
|
|
||||||
} catch (PrinterException ex) {
|
|
||||||
System.err.println("Caught " + ex);
|
|
||||||
throw new RuntimeException("" + ex);
|
|
||||||
|
|
||||||
} catch (NullPointerException ex) {
|
|
||||||
// This is the bug:
|
|
||||||
System.err.println("Caught " + ex);
|
|
||||||
System.err.println("Regression: printing causes a NullPointerException");
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
|
|
||||||
//System.exit(0);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Back-call from the new print APIs.
|
|
||||||
// We always say we have bothing to print.
|
|
||||||
public int print(java.awt.Graphics g, PageFormat pf, int index) {
|
|
||||||
println("Started printing " + index);
|
|
||||||
return Printable.NO_SUCH_PAGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,130 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2007, 2024, 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
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.awt.Frame;
|
|
||||||
import java.awt.print.PageFormat;
|
|
||||||
import java.awt.print.PrinterJob;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
import javax.print.PrintService;
|
|
||||||
import javax.print.attribute.HashPrintRequestAttributeSet;
|
|
||||||
import javax.print.attribute.PrintRequestAttributeSet;
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.Box;
|
|
||||||
import javax.swing.JComponent;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @test
|
|
||||||
* @bug 4937672 5100706 6252456
|
|
||||||
* @key printer
|
|
||||||
* @summary Verifies "Print to file" option is disable if reading/writing files
|
|
||||||
* is not allowed by Security Manager.
|
|
||||||
* @library /java/awt/regtesthelpers
|
|
||||||
* @build PassFailJFrame
|
|
||||||
* @run main/manual/othervm -Djava.security.manager=allow SecurityDialogTest
|
|
||||||
*/
|
|
||||||
public class SecurityDialogTest {
|
|
||||||
private static final String INSTRUCTIONS =
|
|
||||||
"This test brings up a native and cross-platform page and print dialogs.\n" +
|
|
||||||
"\n" +
|
|
||||||
"If the dialog has an option to save to file, the option ought " +
|
|
||||||
"to be disabled.\n" +
|
|
||||||
"\n" +
|
|
||||||
"Press the Pass button if the \"Print to file\" option was disabled in\n" +
|
|
||||||
"all the dialogs where it was present.\n" +
|
|
||||||
"Otherwise, press the Fail button.\n" +
|
|
||||||
"\n" +
|
|
||||||
"The dialogs should be displayed even when " +
|
|
||||||
"there is no queuePrintJob permission.";
|
|
||||||
|
|
||||||
private static JLabel dialogType;
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
if (PrinterJob.lookupPrintServices().length == 0) {
|
|
||||||
throw new RuntimeException("Printer not configured or available.");
|
|
||||||
}
|
|
||||||
|
|
||||||
PassFailJFrame passFailJFrame = PassFailJFrame.builder()
|
|
||||||
.instructions(INSTRUCTIONS)
|
|
||||||
.splitUIBottom(SecurityDialogTest::createTestUI)
|
|
||||||
.rows((int) INSTRUCTIONS.lines().count() + 1)
|
|
||||||
.columns(45)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
displayDialogs();
|
|
||||||
|
|
||||||
passFailJFrame.awaitAndCheck();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static JComponent createTestUI() {
|
|
||||||
dialogType = new JLabel(" ");
|
|
||||||
|
|
||||||
Box main = Box.createVerticalBox();
|
|
||||||
main.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
|
|
||||||
main.add(new JLabel("Current Dialog:"));
|
|
||||||
main.add(Box.createVerticalStrut(4));
|
|
||||||
main.add(dialogType);
|
|
||||||
return main;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void displayDialogs()
|
|
||||||
throws InterruptedException, InvocationTargetException {
|
|
||||||
final PrinterJob pj = PrinterJob.getPrinterJob();
|
|
||||||
|
|
||||||
// Install a security manager which does not allow reading and
|
|
||||||
// writing of files.
|
|
||||||
SecurityManager ptsm = new SecurityManager();
|
|
||||||
System.setSecurityManager(ptsm);
|
|
||||||
|
|
||||||
PrintService[] services = PrinterJob.lookupPrintServices();
|
|
||||||
for (int i = 0; i < services.length; i++) {
|
|
||||||
System.out.println("SecurityDialogTest service " + i + " : " + services[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("SecurityDialogTest default service : " + pj.getPrintService());
|
|
||||||
|
|
||||||
setDialogType("Native Page Dialog");
|
|
||||||
pj.pageDialog(new PageFormat());
|
|
||||||
|
|
||||||
setDialogType("Swing Page Dialog");
|
|
||||||
PrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
|
|
||||||
pj.pageDialog(attributes);
|
|
||||||
|
|
||||||
// With the security manager installed, save to file should now
|
|
||||||
// be denied.
|
|
||||||
setDialogType("Native Print Dialog");
|
|
||||||
pj.printDialog();
|
|
||||||
|
|
||||||
setDialogType("Swing Print Dialog");
|
|
||||||
pj.printDialog(attributes);
|
|
||||||
|
|
||||||
setDialogType("Test completed");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void setDialogType(String type)
|
|
||||||
throws InterruptedException, InvocationTargetException {
|
|
||||||
SwingUtilities.invokeAndWait(() -> dialogType.setText(type));
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2008, 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
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.print.*;
|
|
||||||
import javax.print.*;
|
|
||||||
import javax.print.attribute.*;
|
|
||||||
|
|
||||||
public class PrintSE implements Printable {
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
|
||||||
|
|
||||||
PrintService service = PrintServiceLookup.lookupDefaultPrintService();
|
|
||||||
if (service == null) {
|
|
||||||
System.out.println("No print service found.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
SimpleDoc doc =
|
|
||||||
new SimpleDoc(new PrintSE(),
|
|
||||||
DocFlavor.SERVICE_FORMATTED.PRINTABLE,
|
|
||||||
new HashDocAttributeSet());
|
|
||||||
DocPrintJob job = service.createPrintJob();
|
|
||||||
job.print(doc, new HashPrintRequestAttributeSet());
|
|
||||||
}
|
|
||||||
|
|
||||||
public int print(Graphics g, PageFormat pf, int pg) {
|
|
||||||
if (pg > 0) return NO_SUCH_PAGE;
|
|
||||||
g.drawString("Test passes.", 100, 100);
|
|
||||||
return PAGE_EXISTS;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
#
|
|
||||||
# Copyright (c) 2008, 2017, 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
|
|
||||||
# under the terms of the GNU General Public License version 2 only, as
|
|
||||||
# published by the Free Software Foundation.
|
|
||||||
#
|
|
||||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
# version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
# accompanied this code).
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License version
|
|
||||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
#
|
|
||||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
# or visit www.oracle.com if you need additional information or have any
|
|
||||||
# questions.
|
|
||||||
#
|
|
||||||
|
|
||||||
# @test
|
|
||||||
# @key printer
|
|
||||||
# @bug 6662775
|
|
||||||
# @summary Tests queuePrintJob is sufficient permission for printing. This test
|
|
||||||
# prints a page to a printer. If a document printer is installed, a
|
|
||||||
# popup can appear (to select the file location).
|
|
||||||
# @run clean PrintSE
|
|
||||||
# @run build PrintSE
|
|
||||||
# @run compile PrintSE.java
|
|
||||||
# @run shell/timeout=300 PrintSE.sh
|
|
||||||
|
|
||||||
echo -------------------------------------------------------------
|
|
||||||
echo Launching test for `basename $0 .sh`
|
|
||||||
echo -------------------------------------------------------------
|
|
||||||
|
|
||||||
createJavaPolicyFile()
|
|
||||||
{
|
|
||||||
cat << EOF > ${TESTCLASSES}/print.policy
|
|
||||||
grant {
|
|
||||||
permission java.lang.RuntimePermission "queuePrintJob";
|
|
||||||
};
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
|
|
||||||
createJavaPolicyFile
|
|
||||||
|
|
||||||
${TESTJAVA}/bin/java ${TESTVMOPTS} \
|
|
||||||
-Djava.security.manager \
|
|
||||||
-Djava.security.policy=${TESTCLASSES}/print.policy \
|
|
||||||
-cp ${TESTCLASSES} PrintSE
|
|
||||||
|
|
||||||
exit $?
|
|
Loading…
Reference in New Issue
Block a user