1 /* 2 @test 3 @bug 7023011 4 @library ../../../regtesthelpers 5 @build Sysout 6 @summary Toolkit.getPrintJob() throws wrong exceptions 7 @author andrei dmitriev: area=awt.headless 8 @run main GetPrintJob 9 */ 10 11 import java.awt.*; 12 import java.util.Properties; 13 import test.java.awt.regtesthelpers.Sysout; 14 /* 15 * In headfull mode we should always getting NPE on the getPrintJob() call if frame == null. 16 */ 17 18 public class GetPrintJob { 19 20 public static void main(String[] s) { 21 boolean stage1Passed = false; 22 boolean stage2Passed = false; 23 24 try { 25 Toolkit.getDefaultToolkit().getPrintJob( 26 (Frame) null, "title", new Properties()); 27 } catch (NullPointerException e) { 28 stage1Passed = true; 29 Sysout.println("Stage 1 passed. getPrintJob(null, String, property) has thrown NPE."); 30 } 31 if (!stage1Passed) { 32 throw new RuntimeException("getPrintJob() should have thrown NPE but didn't."); 33 } 34 35 try { 36 Toolkit.getDefaultToolkit().getPrintJob( 37 (Frame) null, "title", new JobAttributes(), new PageAttributes()); 38 } catch (NullPointerException e) { 39 stage2Passed = true; 40 Sysout.println("Stage 2 passed. getPrintJob(null, String, jobAttrs, pageAttr) has thrown NPE."); 41 } 42 if (!stage2Passed) { 43 throw new RuntimeException("getPrintJob() should have thrown NPE but didn't."); 44 } 45 46 Sysout.println("Test PASSED"); 47 } 48 }