jdk/test/javax/print/TextFlavorTest.java
author dbuck
Tue, 18 Aug 2015 04:29:28 -0700
changeset 32417 6859107fc6c3
parent 21224 58a31574ac84
permissions -rw-r--r--
8133666: OperatingSystemMXBean reports abnormally high machine CPU consumption on Linux Reviewed-by: sla, mgronlun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21224
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
     1
/*
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
     4
 *
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
     7
 * published by the Free Software Foundation.
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
     8
 *
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    13
 * accompanied this code).
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    14
 *
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    18
 *
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    21
 * questions.
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    22
 */
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    23
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    24
/*
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    25
  @test
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    26
  @bug 6334074 8022536
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    27
  @summary test supported text flavors reported properly
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    28
  @run main TextFlavorTest
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    29
*/
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    30
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    31
import javax.print.*;
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    32
import javax.print.attribute.standard.*;
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    33
import javax.print.attribute.*;
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    34
import java.io.*;
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    35
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    36
public class TextFlavorTest {
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    37
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    38
    public static void main(String[] args) throws Exception {
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    39
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    40
        PrintService service[] =
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    41
            PrintServiceLookup.lookupPrintServices(null, null);
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    42
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    43
        if (service.length == 0) {
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    44
            System.out.println("No print service found.");
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    45
            return;
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    46
        }
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    47
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    48
        for (int y = 0; y < service.length; y ++) {
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    49
            DocFlavor flavors[] = service[y].getSupportedDocFlavors();
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    50
            if (flavors == null) continue;
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    51
            for (int x = 0; x < flavors.length; x ++) {
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    52
                if (!service[y].isDocFlavorSupported(flavors[x])) {
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    53
                    String msg = "DocFlavor " + flavors[x] +
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    54
                        " is not supported by service "+ service[y];
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    55
                    throw new RuntimeException(msg);
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    56
                }
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    57
            }
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    58
        }
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    59
        System.out.println("Test passed.");
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    60
    }
58a31574ac84 8022536: closed/javax/print/TextFlavorTest.java fails
jgodinez
parents:
diff changeset
    61
}