test/jdk/java/awt/print/PrinterJob/DummyPrintTest.java
author serb
Wed, 21 Feb 2018 12:49:00 -0800
changeset 49096 eaef201ec301
parent 47216 71c04702a3d5
permissions -rw-r--r--
8198333: ProblemList should be updated for headless mode Reviewed-by: psadhukhan, prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37690
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
     1
/*
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
     4
 *
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
     7
 * published by the Free Software Foundation.
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
     8
 *
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    13
 * accompanied this code).
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    14
 *
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    18
 *
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    21
 * questions.
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    22
 */
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    23
/*
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    24
 * @test
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    25
 * @bug      6921664
49096
eaef201ec301 8198333: ProblemList should be updated for headless mode
serb
parents: 47216
diff changeset
    26
 * @key printer
37690
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    27
 * @summary  Verifies number of copies and the job name are passed to a
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    28
 *           3rd party PrintService.
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    29
 * @run      main DummyPrintTest
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    30
 */
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    31
import java.awt.Graphics;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    32
import java.awt.print.PageFormat;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    33
import java.awt.print.Printable;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    34
import java.awt.print.PrinterException;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    35
import java.awt.print.PrinterJob;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    36
import java.util.HashSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    37
import java.util.Set;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    38
import javax.print.Doc;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    39
import javax.print.DocFlavor;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    40
import javax.print.DocPrintJob;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    41
import javax.print.PrintException;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    42
import javax.print.PrintService;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    43
import javax.print.PrintServiceLookup;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    44
import javax.print.ServiceUIFactory;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    45
import javax.print.attribute.Attribute;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    46
import javax.print.attribute.AttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    47
import javax.print.attribute.HashPrintJobAttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    48
import javax.print.attribute.HashPrintServiceAttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    49
import javax.print.attribute.PrintJobAttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    50
import javax.print.attribute.PrintRequestAttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    51
import javax.print.attribute.PrintServiceAttribute;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    52
import javax.print.attribute.PrintServiceAttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    53
import javax.print.attribute.standard.Copies;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    54
import javax.print.attribute.standard.JobName;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    55
import javax.print.attribute.standard.PrinterName;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    56
import javax.print.attribute.standard.PrinterState;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    57
import javax.print.event.PrintJobAttributeListener;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    58
import javax.print.event.PrintJobListener;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    59
import javax.print.event.PrintServiceAttributeListener;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    60
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    61
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    62
public class DummyPrintTest {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    63
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    64
    public static void main(String[] args) throws Exception {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    65
        // register custom print service implementation
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    66
        String printerName = "myDummyPrintService";
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    67
        PrintServiceLookup.registerService(new DummyPrintService(printerName));
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    68
        // calling third party print logic
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    69
        thirdPartyPrintLogic(printerName);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    70
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    71
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    72
    static void thirdPartyPrintLogic(String printerName) throws Exception {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    73
        PrinterJob printerjob = PrinterJob.getPrinterJob();
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    74
        printerjob.setCopies(2);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    75
        printerjob.setJobName("myJobName");
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    76
        printerjob.setPrintable(new DummyPrintable());
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    77
        for (PrintService printService : PrinterJob.lookupPrintServices()) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    78
            System.out.println("check printer name of service " + printService);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    79
            if (printerName.equals(printService.getName())) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    80
                System.out.println("correct printer service do print...");
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    81
                printerjob.setPrintService(printService);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    82
                printerjob.print();
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    83
                break;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    84
            }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    85
        }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    86
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    87
}
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    88
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    89
class DummyPrintService implements PrintService {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    90
    private final String _name;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    91
    private final Set<DocFlavor> _supportedFlavors;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    92
    private final PrintServiceAttributeSet _printServiceAttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    93
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    94
    public DummyPrintService(String name) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    95
        _name = name;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    96
        _supportedFlavors = new HashSet<DocFlavor>();
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    97
        _supportedFlavors.add(DocFlavor.SERVICE_FORMATTED.PAGEABLE);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    98
        _supportedFlavors.add(DocFlavor.SERVICE_FORMATTED.PRINTABLE);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
    99
        _printServiceAttributeSet = new HashPrintServiceAttributeSet();
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   100
        _printServiceAttributeSet.add(new PrinterName(name, null));
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   101
        _printServiceAttributeSet.add(PrinterState.IDLE);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   102
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   103
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   104
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   105
    public String toString() {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   106
        return "Dummy Printer : " + getName();
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   107
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   108
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   109
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   110
    public String getName() {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   111
        return _name;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   112
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   113
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   114
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   115
    public DocPrintJob createPrintJob() {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   116
        return new DummyDocPrintJob(this);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   117
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   118
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   119
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   120
    public boolean isDocFlavorSupported(DocFlavor flavor) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   121
        return _supportedFlavors.contains(flavor);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   122
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   123
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   124
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   125
    public <T extends PrintServiceAttribute> T getAttribute(Class<T> category) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   126
        return category.cast(_printServiceAttributeSet.get(category));
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   127
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   128
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   129
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   130
    public PrintServiceAttributeSet getAttributes() {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   131
        return _printServiceAttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   132
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   133
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   134
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   135
    public DocFlavor[] getSupportedDocFlavors() {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   136
        return _supportedFlavors.toArray(new DocFlavor[_supportedFlavors.size()]);
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   137
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   138
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   139
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   140
    public Object getDefaultAttributeValue(Class<? extends Attribute> category) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   141
        return null;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   142
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   143
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   144
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   145
    public ServiceUIFactory getServiceUIFactory() {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   146
        return null;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   147
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   148
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   149
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   150
    public Class<?>[] getSupportedAttributeCategories() {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   151
        return null;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   152
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   153
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   154
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   155
    public Object getSupportedAttributeValues(Class<? extends Attribute> category,
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   156
                                    DocFlavor flavor, AttributeSet attributes) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   157
        return null;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   158
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   159
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   160
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   161
    public AttributeSet getUnsupportedAttributes(DocFlavor flavor,
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   162
                                                 AttributeSet attributes) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   163
        return null;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   164
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   165
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   166
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   167
    public boolean isAttributeCategorySupported(Class<? extends Attribute> category) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   168
        return false;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   169
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   170
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   171
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   172
    public boolean isAttributeValueSupported(Attribute attrval,
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   173
                                             DocFlavor flavor,
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   174
                                             AttributeSet attributes) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   175
        return false;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   176
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   177
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   178
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   179
    public void addPrintServiceAttributeListener(PrintServiceAttributeListener listener) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   180
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   181
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   182
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   183
    public void removePrintServiceAttributeListener(PrintServiceAttributeListener listener) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   184
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   185
}
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   186
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   187
class DummyDocPrintJob implements DocPrintJob {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   188
    private static int _counter;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   189
    private final PrintService _printService;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   190
    private final PrintJobAttributeSet _printJobAttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   191
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   192
    public DummyDocPrintJob(PrintService printService) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   193
        _counter++;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   194
        _printService = printService;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   195
        _printJobAttributeSet = new HashPrintJobAttributeSet();
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   196
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   197
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   198
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   199
    public PrintService getPrintService() {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   200
        return _printService;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   201
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   202
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   203
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   204
    public PrintJobAttributeSet getAttributes() {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   205
        return _printJobAttributeSet;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   206
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   207
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   208
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   209
    public void addPrintJobAttributeListener(PrintJobAttributeListener listener,
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   210
                                    PrintJobAttributeSet printJobAttributeSet) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   211
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   212
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   213
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   214
    public void removePrintJobAttributeListener(PrintJobAttributeListener listener) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   215
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   216
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   217
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   218
    public void addPrintJobListener(PrintJobListener listener) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   219
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   220
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   221
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   222
    public void removePrintJobListener(PrintJobListener listener) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   223
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   224
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   225
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   226
    public void print(Doc doc,
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   227
                      PrintRequestAttributeSet printRequestAttributeSet)
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   228
          throws PrintException {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   229
        System.out.println("job name: " + printRequestAttributeSet.get(JobName.class));
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   230
        System.out.println("copies: " + printRequestAttributeSet.get(Copies.class));
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   231
        if(printRequestAttributeSet.get(JobName.class) == null ||
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   232
            printRequestAttributeSet.get(Copies.class) == null) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   233
            throw new RuntimeException("Copies and JobName is not passed correctly");
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   234
        }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   235
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   236
}
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   237
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   238
class DummyPrintable implements Printable {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   239
    @Override
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   240
    public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   241
            throws PrinterException {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   242
        if (pageIndex == 0) {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   243
            return Printable.PAGE_EXISTS;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   244
        } else {
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   245
            return Printable.NO_SUCH_PAGE;
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   246
        }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   247
    }
0e619f348ff7 6921664: The number of copies and the job name are not passed to a 3rd party PrintService
psadhukhan
parents:
diff changeset
   248
}