jdk/test/javax/management/MBeanInfo/MBeanInfoHashCodeNPETest.java
author stefank
Fri, 17 Apr 2015 17:10:38 +0000
changeset 30266 ef82cd1f2db3
parent 19852 f8e5a6c5d379
child 30376 2ccf2cf7ea48
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19852
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
     1
/*
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
     4
 *
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
     8
 *
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    13
 * accompanied this code).
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    14
 *
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    18
 *
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    21
 * questions.
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    22
 */
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    23
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    24
import javax.management.MBeanAttributeInfo;
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    25
import javax.management.MBeanConstructorInfo;
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    26
import javax.management.MBeanInfo;
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    27
import javax.management.MBeanNotificationInfo;
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    28
import javax.management.MBeanOperationInfo;
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    29
import javax.management.MBeanParameterInfo;
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    30
import javax.management.modelmbean.DescriptorSupport;
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    31
import javax.management.openmbean.SimpleType;
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    32
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    33
/*
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    34
 * @test
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    35
 * @bug 8023669
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    36
 * @summary Test that hashCode()throws NullPointerException
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    37
 * @author Shanliang JIANG
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    38
 * @run clean MBeanInfoHashCodeNPETest
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    39
 * @run build MBeanInfoHashCodeNPETest
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    40
 * @run main MBeanInfoHashCodeNPETest
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    41
 */
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    42
public class MBeanInfoHashCodeNPETest {
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    43
    private static int failed = 0;
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    44
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    45
    public static void main(String[] args) throws Exception {
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    46
        System.out.println("---MBeanInfoHashCodeNPETest-main ...");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    47
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    48
        // ----
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    49
        System.out.println("\n---Testing on MBeanAttributeInfo...");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    50
        MBeanAttributeInfo mbeanAttributeInfo = new MBeanAttributeInfo(
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    51
                null, SimpleType.INTEGER.getClassName(), "description", true, true, false);
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    52
        test(mbeanAttributeInfo, "class name");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    53
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    54
        mbeanAttributeInfo = new MBeanAttributeInfo(
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    55
                "name", null, "description", true, true, false);
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    56
        test(mbeanAttributeInfo, "type");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    57
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    58
        mbeanAttributeInfo = new MBeanAttributeInfo(
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    59
                "name", SimpleType.INTEGER.getClassName(), null, true, true, false);
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    60
        test(mbeanAttributeInfo, "description");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    61
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    62
        // ----
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    63
        System.out.println("\n---Testing on MBeanConstructorInfo...");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    64
        MBeanConstructorInfo mbeanConstructorInfo = new MBeanConstructorInfo(
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    65
                null, "", new MBeanParameterInfo[]{}, new DescriptorSupport());
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    66
        test(mbeanConstructorInfo, "name");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    67
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    68
        mbeanConstructorInfo = new MBeanConstructorInfo(
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    69
                "", null, new MBeanParameterInfo[]{}, new DescriptorSupport());
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    70
        test(mbeanConstructorInfo, "description");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    71
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    72
        mbeanConstructorInfo = new MBeanConstructorInfo(
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    73
                "", "", null, new DescriptorSupport());
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    74
        test(mbeanConstructorInfo, "MBeanParameterInfo");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    75
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    76
        mbeanConstructorInfo = new MBeanConstructorInfo(
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    77
                "", "", new MBeanParameterInfo[]{}, null);
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    78
        test(mbeanConstructorInfo, "descriptor");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    79
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    80
        // ----
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    81
        System.out.println("\n---Testing on MBeanOperationInfo...");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    82
        MBeanOperationInfo mbeanOperationInfo = new MBeanOperationInfo(
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    83
                null, "description", new MBeanParameterInfo[]{}, "type", 1, new DescriptorSupport());
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    84
        test(mbeanOperationInfo, "name");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    85
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    86
        mbeanOperationInfo = new MBeanOperationInfo(
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    87
                "name", null, new MBeanParameterInfo[]{}, "type", 1, new DescriptorSupport());
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    88
        test(mbeanOperationInfo, "description");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    89
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    90
        mbeanOperationInfo = new MBeanOperationInfo(
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    91
                "name", "description", null, "type", 1, new DescriptorSupport());
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    92
        test(mbeanOperationInfo, "MBeanParameterInfo");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    93
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    94
        mbeanOperationInfo = new MBeanOperationInfo(
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    95
                "name", "description", new MBeanParameterInfo[]{}, null, 1, new DescriptorSupport());
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    96
        test(mbeanOperationInfo, "type");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    97
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    98
        mbeanOperationInfo = new MBeanOperationInfo(
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
    99
                "name", "description", new MBeanParameterInfo[]{}, "type", -1, new DescriptorSupport());
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   100
        test(mbeanOperationInfo, "native impact");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   101
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   102
        mbeanOperationInfo = new MBeanOperationInfo(
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   103
                "name", "description", new MBeanParameterInfo[]{}, "type", 1, null);
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   104
        test(mbeanOperationInfo, "Descriptor");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   105
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   106
        // ----
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   107
        System.out.println("\n---Testing on MBeanParameterInfo...");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   108
        MBeanParameterInfo mbeanParameterInfo = new MBeanParameterInfo(
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   109
                null, "type", "description", new DescriptorSupport());
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   110
        test(mbeanParameterInfo, "name");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   111
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   112
        mbeanParameterInfo = new MBeanParameterInfo(
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   113
                "name", null, "description", new DescriptorSupport());
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   114
        test(mbeanParameterInfo, "description");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   115
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   116
        mbeanParameterInfo = new MBeanParameterInfo(
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   117
                "name", "type", null, new DescriptorSupport());
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   118
        test(mbeanParameterInfo, "description");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   119
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   120
        mbeanParameterInfo = new MBeanParameterInfo(
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   121
                "name", "type", "description", null);
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   122
        test(mbeanParameterInfo, "Descriptor");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   123
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   124
        // ----
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   125
        System.out.println("\n---Testing on MBeanInfo...");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   126
        String className = "toto";
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   127
        String description = "titi";
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   128
        MBeanAttributeInfo[] attrInfos = new MBeanAttributeInfo[]{};
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   129
        MBeanConstructorInfo[] constrInfos = new MBeanConstructorInfo[]{};
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   130
        MBeanOperationInfo[] operaInfos = new MBeanOperationInfo[]{};
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   131
        MBeanNotificationInfo[] notifInfos = new MBeanNotificationInfo[]{};
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   132
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   133
        MBeanInfo minfo = new MBeanInfo(null, description, attrInfos, constrInfos, operaInfos, notifInfos);
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   134
        test(minfo, "class name");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   135
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   136
        minfo = new MBeanInfo(className, description, attrInfos, constrInfos, operaInfos, notifInfos);
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   137
        test(minfo, "name");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   138
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   139
        minfo = new MBeanInfo(className, null, attrInfos, constrInfos, operaInfos, notifInfos);
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   140
        test(minfo, "description");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   141
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   142
        minfo = new MBeanInfo(className, description, null, constrInfos, operaInfos, notifInfos);
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   143
        test(minfo, "attrInfos");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   144
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   145
        minfo = new MBeanInfo(className, description, attrInfos, constrInfos, null, notifInfos);
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   146
        test(minfo, "operaInfos");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   147
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   148
        minfo = new MBeanInfo(className, description, attrInfos, constrInfos, operaInfos, null);
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   149
        test(minfo, "notifInfos");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   150
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   151
        Thread.sleep(100);
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   152
        if (failed > 0) {
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   153
            throw new RuntimeException("Test failed: "+failed);
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   154
        } else {
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   155
            System.out.println("---Test: PASSED");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   156
        }
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   157
    }
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   158
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   159
    private static void test(Object obj, String param) {
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   160
        try {
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   161
            obj.hashCode();
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   162
            System.out.println("OK: "+obj.getClass().getSimpleName()+".hashCode worked with a null "+param);
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   163
        } catch (NullPointerException npe) {
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   164
            System.out.println("--->KO!!! "+obj.getClass().getSimpleName()+".hashCode got NPE with a null "+param);
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   165
            failed++;
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   166
        }
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   167
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   168
        try {
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   169
            obj.toString();
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   170
            System.out.println("OK: "+obj.getClass().getSimpleName()+".toString worked with a null "+param);
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   171
        } catch (NullPointerException npe) {
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   172
            System.out.println("--->KO!!! "+obj.getClass().getSimpleName()+".toString got NPE.");
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   173
            failed++;
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   174
        }
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   175
    }
f8e5a6c5d379 8023669: MBean*Info.hashCode : NPE
sjiang
parents:
diff changeset
   176
}