/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @summary Test that SnmpOid hashCode is consistent with equals.
* @bug 4955105
* @build SnmpOidHashCode
* @run main SnmpOidHashCode
*/
public class SnmpOidHashCode {
"1.1.1.1.1.1.1.1.1",
"1.1.1.1.1.1.1.1",
"1.1.1.1.2.1.1.1.1",
"1.1.1.1.1.2.1.1.1",
"1.3.2",
"2.3.1",
"1",
"1.2."+0xFFFFFFFFL+".3."+0xFFFFFFFFL+".4."+0xFFFFFFFFL+
".5."+0xFFFFFFFFL+".6."+0xFFFFFFFFL+".7."+0xFFFFFFFFL+
".8."+0xFFFFFFFFL+".9."+0xFFFFFFFFL+".10."+0xFFFFFFFFL+
".11."+0xFFFFFFFFL+".12."+0xFFFFFFFFL+".13."+0xFFFFFFFFL+
".14."+0xFFFFFFFFL+".15."+0xFFFFFFFFL+".16."+0xFFFFFFFFL+
".17."+0xFFFFFFFFL+".18."+0xFFFFFFFFL+".19."+0xFFFFFFFFL+
".20."+0xFFFFFFFFL+".21."+0xFFFFFFFFL+".22."+0xFFFFFFFFL+
".23."+0xFFFFFFFFL+".24."+0xFFFFFFFFL+".25."+0xFFFFFFFFL+
".26."+0xFFFFFFFFL+".27."+0xFFFFFFFFL+".28."+0xFFFFFFFFL+
".29."+0xFFFFFFFFL+
".30."+0xFFFFFFFFL+".31."+0xFFFFFFFFL+".32."+0xFFFFFFFFL+
".33."+0xFFFFFFFFL+".34."+0xFFFFFFFFL+".35."+0xFFFFFFFFL+
".36."+0xFFFFFFFFL+".37."+0xFFFFFFFFL+".38."+0xFFFFFFFFL+
".39."+0xFFFFFFFFL
};
// We use an SnmpOidBuilder in order to adapt this test case to a
// configuration where the SNMP packages are not present in rt.jar.
//
public static final class SnmpOidBuilder {
"com.sun.jmx.snmp.SnmpOid";
static {
Class<?> snmpOidClass;
try {
} catch (ClassNotFoundException x) {
snmpOidClass = null;
} catch (NoClassDefFoundError x) {
snmpOidClass = null;
}
if (SNMP_OID_CLASS != null) {
try {
} catch (Exception x) {
throw new ExceptionInInitializerError(x);
}
} else {
}
}
public static boolean isSnmpPresent() {
": Testing for SNMP Packages...");
return SNMP_OID_CLASS != null;
}
throws InstantiationException,
}
}
try {
} catch (InvocationTargetException x) {
throw x;
}
}
if (!SnmpOidBuilder.isSnmpPresent()) {
": test skipped.");
return;
}
try {
int errCount=0;
int collisions=0;
final int startCount=errCount;
"equals yields true: " +
"\n\to1="+oids[i]+
"\n\to2="+oids[j]);
errCount++;
}
"hashCode differ:" +
errCount++;
}
} else {
"equals yields false: " +
"\n\to1="+oids[i]+
"\n\to2="+oids[j]);
errCount++;
}
}
}
if (errCount == startCount)
else
+ o1);
}
if (errCount == 0) {
"succesfully passed (" + collisions +
" collisions).");
} else {
" collisions).");
}
} catch(Exception x) {
x.printStackTrace();
}
}
}