}
public void testEquals()
throws Exception
{
OpenMBeanParameterInfoSupport info = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.STRING);
assertTrue("Null should not be equal", info.equals(null) == false);
assertTrue("Only OpenMBeanParameterInfo should be equal", info.equals(new Object()) == false);
OpenMBeanParameterInfoSupport info2 = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.STRING);
assertTrue("Different instances of the same data are equal", info.equals(info2));
assertTrue("Different instances of the same data are equal", info2.equals(info));
info2 = new OpenMBeanParameterInfoSupport(
"name", "description2", SimpleType.STRING);
assertTrue("Different instances with different descriptions are equal", info.equals(info2));
assertTrue("Different instances with different descritpions are equal", info2.equals(info));
info2 = new OpenMBeanParameterInfoSupport(
"name2", "description", SimpleType.STRING);
assertTrue("Instances with different names are not equal", info.equals(info2) == false);
assertTrue("Instances with different names are not equal", info2.equals(info) == false);
info2 = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER);
assertTrue("Instances with different types are not equal", info.equals(info2) == false);
assertTrue("Instances with different types are not equal", info2.equals(info) == false);
info = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, new Integer(3), new Integer(2), new Integer(4));
info2 = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, new Integer(2), new Integer(2), new Integer(4));
assertTrue("Instances with different default values are not equal", info.equals(info2) == false);
assertTrue("Instances with different default values are not equal", info2.equals(info) == false);
info = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, new Integer(3), new Integer(2), new Integer(4));
info2 = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, new Integer(2), null, new Integer(4));
assertTrue("Instances with different default values are not equal", info.equals(info2) == false);
assertTrue("Instances with different default values are not equal", info2.equals(info) == false);
info = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, new Integer(3));
info2 = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, new Integer(3));
assertTrue("Different instances of the same default value are equal", info.equals(info2));
assertTrue("Different instances of the same default value are equal", info2.equals(info));
info = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, null, new Integer(2), null);
info2 = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, null, new Integer(2), null);
assertTrue("Different instances of the same minimum are equal", info.equals(info2));
assertTrue("Different instances of the same minimum are equal", info2.equals(info));
info = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, null, null, new Integer(2));
info2 = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, null, null, new Integer(2));
assertTrue("Different instances of the same maximum are equal", info.equals(info2));
assertTrue("Different instances of the same maximum are equal", info2.equals(info));
info = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, new Integer(3), new Integer(2), new Integer(4));
info2 = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, new Integer(3), new Integer(1), new Integer(4));
assertTrue("Instances with different minimums are not equal", info.equals(info2) == false);
assertTrue("Instances with different minimums are not equal", info2.equals(info) == false);
info = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, new Integer(3), new Integer(2), new Integer(4));
info2 = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, new Integer(3), null, new Integer(4));
assertTrue("Instances with different minimums are not equal", info.equals(info2) == false);
assertTrue("Instances with different minimums are not equal", info2.equals(info) == false);
info = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, new Integer(3), new Integer(2), new Integer(4));
info2 = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, new Integer(3), new Integer(2), new Integer(5));
assertTrue("Instances with different maximums are not equal", info.equals(info2) == false);
assertTrue("Instances with different maximums are not equal", info2.equals(info) == false);
info = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, new Integer(3), new Integer(2), new Integer(4));
info2 = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, new Integer(3), new Integer(2), null);
assertTrue("Instances with different maximums are not equal", info.equals(info2) == false);
assertTrue("Instances with different maximums are not equal", info2.equals(info) == false);
info = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, null, new Object[] { new Integer(2), new Integer(3) });
info2 = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, null, new Object[] { new Integer(2), new Integer(3) });
assertTrue("Different instances of the same legal values are equal", info.equals(info2));
assertTrue("Different instances of the same legal values are equal", info2.equals(info));
info = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, null, new Object[] { new Integer(2), new Integer(3) });
info2 = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, null, new Object[] { new Integer(2), new Integer(4) });
assertTrue("Different instances with different legal values are equal", info.equals(info2) == false);
assertTrue("Different instances with different legal values are equal", info2.equals(info) == false);
info = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, null, new Object[] { new Integer(2), new Integer(3) });
info2 = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, null, new Object[] { new Integer(2) });
assertTrue("Different instances with different legal values are equal", info.equals(info2) == false);
assertTrue("Different instances with different legal values are equal", info2.equals(info) == false);
info = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, null, new Object[] { new Integer(2), new Integer(3) });
info2 = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.INTEGER, null, null);
assertTrue("Different instances with different legal values are equal", info.equals(info2) == false);
assertTrue("Different instances with different legal values are equal", info2.equals(info) == false);
}