use of javax.print.PrintServiceLookup in project camel by apache.
the class PrinterPrintTest method setupJavaPrint.
protected void setupJavaPrint() {
// "install" another default printer
PrintService psDefault = mock(PrintService.class);
when(psDefault.getName()).thenReturn("DefaultPrinter");
when(psDefault.isDocFlavorSupported(any(DocFlavor.class))).thenReturn(Boolean.TRUE);
PrintServiceLookup psLookup = mock(PrintServiceLookup.class);
when(psLookup.getPrintServices()).thenReturn(new PrintService[] { psDefault });
when(psLookup.getDefaultPrintService()).thenReturn(psDefault);
DocPrintJob docPrintJob = mock(DocPrintJob.class);
when(psDefault.createPrintJob()).thenReturn(docPrintJob);
MediaTray[] trays = new MediaTray[] { MediaTray.TOP, MediaTray.MIDDLE, MediaTray.BOTTOM };
when(psDefault.getSupportedAttributeValues(Media.class, null, null)).thenReturn(trays);
PrintServiceLookup.registerServiceProvider(psLookup);
}
Aggregations