jdk/test/javax/print/RegisterNullService.java
author tschatzl
Mon, 24 Aug 2015 16:32:50 +0200
changeset 32390 b0f6868d46ee
parent 27062 1ec810a4c3ec
permissions -rw-r--r--
8133456: HeapRegionManager::shrink_by() iterates suboptimally across regions Reviewed-by: brutisso, tbenson
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27062
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
     1
/*
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
     4
 *
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
     8
 *
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    13
 * accompanied this code).
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    14
 *
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    18
 *
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    21
 * questions.
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    22
 */
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    23
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    24
/*
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    25
 * @test
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    26
 * @bug 8059219
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    27
 * @summary Should not be able to register null service.
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    28
 * @run main RegisterNullService
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    29
*/
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    30
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    31
import javax.print.PrintService;
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    32
import javax.print.PrintServiceLookup;
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    33
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    34
public class RegisterNullService {
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    35
    public static void main (String [] args) throws RuntimeException {
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    36
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    37
        boolean registered = PrintServiceLookup.registerService(null);
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    38
        if (registered) {
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    39
           throw new RuntimeException("Null service was registered");
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    40
        }
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    41
        PrintService[] services =
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    42
            PrintServiceLookup.lookupPrintServices(null, null);
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    43
        for (int i = 0; i < services.length; i++) {
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    44
            if (services[i] == null) {
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    45
                throw new RuntimeException("Null service found.");
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    46
            }
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    47
        }
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    48
    }
1ec810a4c3ec 8059219: javax.print.PrintServiceLookup allows to register null service
prr
parents:
diff changeset
    49
}