jdk/test/java/util/Properties/Basic.java
author bpb
Fri, 13 Mar 2015 14:54:40 -0700
changeset 29486 3a37e8f12b94
permissions -rw-r--r--
8073214: javadoc of Properties methods should specify NullPointerExceptions Summary: Add test for null parameter and corresponding throws clause to load() methods Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29486
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
     1
/*
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
     4
 *
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
     8
 *
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    13
 * accompanied this code).
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    14
 *
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    18
 *
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    21
 * questions.
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    22
 */
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    23
import java.io.InputStream;
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    24
import java.io.OutputStream;
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    25
import java.io.Reader;
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    26
import java.io.Writer;
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    27
import java.util.Properties;
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    28
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    29
/*
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    30
 * @test
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    31
 * @bug 8073214
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    32
 * @summary Basic tests of Properties methods.
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    33
 */
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    34
public class Basic
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    35
{
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    36
    public static void main(String[] args) throws Exception
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    37
    {
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    38
        int failures = 0;
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    39
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    40
        Properties props = new Properties();
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    41
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    42
        try {
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    43
            props.store((OutputStream)null, "comments");
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    44
            failures++;
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    45
        } catch (NullPointerException e) {
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    46
            // do nothing
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    47
        }
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    48
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    49
        try {
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    50
            props.store((Writer)null, "comments");
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    51
            failures++;
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    52
        } catch (NullPointerException e) {
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    53
            // do nothing
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    54
        }
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    55
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    56
        try {
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    57
            props.load((InputStream)null);
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    58
            failures++;
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    59
        } catch (NullPointerException e) {
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    60
            // do nothing
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    61
        }
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    62
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    63
        try {
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    64
            props.load((Reader)null);
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    65
            failures++;
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    66
        } catch (NullPointerException e) {
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    67
            // do nothing
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    68
        }
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    69
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    70
        if (failures != 0) {
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    71
            throw new RuntimeException("Basic failed with "
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    72
                + failures + " errors!");
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    73
        }
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    74
    }
3a37e8f12b94 8073214: javadoc of Properties methods should specify NullPointerExceptions
bpb
parents:
diff changeset
    75
}