Search in sources :

Example 1 with PrintServiceLookup

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);
}
Also used : PrintServiceLookup(javax.print.PrintServiceLookup) DocPrintJob(javax.print.DocPrintJob) MediaTray(javax.print.attribute.standard.MediaTray) DocFlavor(javax.print.DocFlavor) PrintService(javax.print.PrintService)

Aggregations

DocFlavor (javax.print.DocFlavor)1 DocPrintJob (javax.print.DocPrintJob)1 PrintService (javax.print.PrintService)1 PrintServiceLookup (javax.print.PrintServiceLookup)1 MediaTray (javax.print.attribute.standard.MediaTray)1