jdk/test/com/sun/jmx/snmp/SnmpOidHashCode.java
author sherman
Tue, 22 Jun 2010 14:04:36 -0400
changeset 5962 0913689fd3a0
parent 5506 202f599c92aa
permissions -rw-r--r--
6963156: TEST_BUG: Several tests under sun/nio/cs failed Summary: Updated the test cases and removed them from ProblemList.txt Reviewed-by: alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2285
diff changeset
     2
 * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2285
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2285
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2285
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * @test
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * @summary Test that SnmpOid hashCode is consistent with equals.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * @bug     4955105
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * @build   SnmpOidHashCode
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * @run     main SnmpOidHashCode
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
2285
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    31
import java.lang.reflect.Constructor;
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    32
import java.lang.reflect.InvocationTargetException;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
public class SnmpOidHashCode {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
    public static final String[] oids = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
        "1.1.1.1.1.1.1.1.1",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
        "1.1.1.1.1.1.1.1",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
        "1.1.1.1.2.1.1.1.1",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
        "1.1.1.1.1.2.1.1.1",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
        "1.3.2",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        "2.3.1",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
        "1.2.67."+Integer.MAX_VALUE+"."+Integer.MAX_VALUE+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
        "."+Integer.MAX_VALUE+"."+Integer.MAX_VALUE+"."+Integer.MAX_VALUE+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        "1",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
        "1.2."+0xFFFFFFFFL+".3."+0xFFFFFFFFL+".4."+0xFFFFFFFFL+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
        ".5."+0xFFFFFFFFL+".6."+0xFFFFFFFFL+".7."+0xFFFFFFFFL+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
        ".8."+0xFFFFFFFFL+".9."+0xFFFFFFFFL+".10."+0xFFFFFFFFL+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        ".11."+0xFFFFFFFFL+".12."+0xFFFFFFFFL+".13."+0xFFFFFFFFL+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
        ".14."+0xFFFFFFFFL+".15."+0xFFFFFFFFL+".16."+0xFFFFFFFFL+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        ".17."+0xFFFFFFFFL+".18."+0xFFFFFFFFL+".19."+0xFFFFFFFFL+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        ".20."+0xFFFFFFFFL+".21."+0xFFFFFFFFL+".22."+0xFFFFFFFFL+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
        ".23."+0xFFFFFFFFL+".24."+0xFFFFFFFFL+".25."+0xFFFFFFFFL+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        ".26."+0xFFFFFFFFL+".27."+0xFFFFFFFFL+".28."+0xFFFFFFFFL+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
        ".29."+0xFFFFFFFFL+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
        ".30."+0xFFFFFFFFL+".31."+0xFFFFFFFFL+".32."+0xFFFFFFFFL+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
        ".33."+0xFFFFFFFFL+".34."+0xFFFFFFFFL+".35."+0xFFFFFFFFL+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
        ".36."+0xFFFFFFFFL+".37."+0xFFFFFFFFL+".38."+0xFFFFFFFFL+
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        ".39."+0xFFFFFFFFL
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
2285
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    61
    // We use an SnmpOidBuilder in order to adapt this test case to a
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    62
    // configuration where the SNMP packages are not present in rt.jar.
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    63
    //
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    64
    public static final class SnmpOidBuilder {
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    65
        public static final String SNMP_OID_CLASS_NAME =
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    66
            "com.sun.jmx.snmp.SnmpOid";
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    67
        private static final Class<?> SNMP_OID_CLASS;
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    68
        private static final Constructor<?> SNMP_OID_CTOR;
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    69
        static {
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    70
            Class<?> snmpOidClass;
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    71
            try {
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    72
                snmpOidClass =
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    73
                    Class.forName(SNMP_OID_CLASS_NAME, true, null);
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    74
            } catch (ClassNotFoundException x) {
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    75
                snmpOidClass = null;
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    76
                System.err.println("WARNING: can't load "+SNMP_OID_CLASS_NAME);
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    77
            } catch (NoClassDefFoundError x) {
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    78
                snmpOidClass = null;
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    79
                System.err.println("WARNING: can't load "+SNMP_OID_CLASS_NAME);
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    80
            }
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    81
            SNMP_OID_CLASS = snmpOidClass;
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    82
            if (SNMP_OID_CLASS != null) {
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    83
                try {
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    84
                  SNMP_OID_CTOR = snmpOidClass.getConstructor(String.class);
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    85
                } catch (Exception x) {
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    86
                    throw new ExceptionInInitializerError(x);
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    87
                }
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    88
            } else {
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    89
                SNMP_OID_CTOR = null;
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    90
            }
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    91
        }
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    92
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    93
        public static boolean isSnmpPresent() {
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    94
            System.out.println(SnmpOidHashCode.class.getName()+
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    95
                    ": Testing for SNMP Packages...");
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    96
            return SNMP_OID_CLASS != null;
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    97
        }
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    98
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
    99
        public static Object newSnmpOid(String oid)
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   100
            throws InstantiationException,
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   101
                   IllegalAccessException,
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   102
                   InvocationTargetException {
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   103
            return SNMP_OID_CTOR.newInstance(oid);
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   104
        }
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   105
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   106
    }
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   107
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   108
    private static Object newSnmpOid(String oid) throws Exception {
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   109
        try {
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   110
            return SnmpOidBuilder.newSnmpOid(oid);
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   111
        } catch (InvocationTargetException x) {
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   112
            final Throwable cause = x.getCause();
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   113
            if (cause instanceof Exception) throw (Exception)cause;
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   114
            if (cause instanceof Error) throw (Error)cause;
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   115
            throw x;
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   116
        }
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   117
    }
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   118
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    public static void main(String args[]) {
2285
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   120
        if (!SnmpOidBuilder.isSnmpPresent()) {
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   121
            System.err.println("WARNING: "+
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   122
                    SnmpOidBuilder.SNMP_OID_CLASS_NAME+" not present.");
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   123
            System.err.println(SnmpOidHashCode.class.getName()+
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   124
                    ": test skipped.");
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   125
            return;
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   126
        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            int errCount=0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            int collisions=0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            for (int i=0;i<oids.length;i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                System.out.println("Testing " + oids[i]);
2285
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   132
                final Object o1 = newSnmpOid(oids[i]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                final int startCount=errCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                for (int j=0;j<oids.length;j++) {
2285
37fdbed8178f 6661448: Make the SNMP agent optional when OPENJDK=true and IMPORT_BINARY_PLUGS=false
dfuchs
parents: 2
diff changeset
   135
                    final Object o2 = newSnmpOid(oids[j]);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                    if (o1.equals(o2)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                        if (!(oids[i].equals(oids[j]))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                            System.err.println("OIDs differ but " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                                               "equals yields true: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                                               "\n\to1="+oids[i]+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                                               "\n\to2="+oids[j]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                            errCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                        if (o1.hashCode() != o2.hashCode()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                            System.err.println("OIDs are equal but " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                                               "hashCode differ:" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                                               "\n\thashCode("+o1+")="+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                                               o1.hashCode()+", "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                                               "\n\thashCode("+o2+")="+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                                               o2.hashCode());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                            errCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                        if (oids[i].equals(oids[j])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                            System.err.println("OIDs are equal but " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                                               "equals yields false: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                                               "\n\to1="+oids[i]+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                                               "\n\to2="+oids[j]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                            errCount++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                        if (o1.hashCode() == o2.hashCode()) collisions++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                if (errCount == startCount)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                    System.out.println("*** Test Passed for: " + o1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                    System.out.println("*** Test Failed (" +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                                       (errCount - startCount) + ") for: "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                                       + o1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            if (errCount == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                System.out.println("*** -----------------------------------");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                System.out.println("*** Test SnmpOidHashCode " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                                   "succesfully passed (" + collisions +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                                   " collisions).");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                System.out.println("*** -----------------------------------");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                System.err.println("*** -----------------------------------");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                System.err.println("*** Test SnmpOidHashCode failed: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                                   errCount + " failures (" + collisions +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                                   " collisions).");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                System.err.println("*** -----------------------------------");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                System.exit(1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        } catch(Exception x) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            x.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            System.exit(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
}