}
public void testEquals()
throws Exception
{
OpenMBeanAttributeInfoSupport info = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.STRING, true, true, false);
assertTrue("Null should not be equal", info.equals(null) == false);
assertTrue("Only OpenMBeanAttributeInfo should be equal", info.equals(new Object()) == false);
OpenMBeanAttributeInfoSupport info2 = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.STRING, true, true, false);
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 OpenMBeanAttributeInfoSupport(
"name", "description2", SimpleType.STRING, true, true, false);
assertTrue("Different instances with different descriptions are equal", info.equals(info2));
assertTrue("Different instances with different descritpions are equal", info2.equals(info));
info2 = new OpenMBeanAttributeInfoSupport(
"name2", "description", SimpleType.STRING, true, true, false);
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 OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false);
assertTrue("Instances with different types are not equal", info.equals(info2) == false);
assertTrue("Instances with different types are not equal", info2.equals(info) == false);
info2 = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, false, true, false);
assertTrue("Instances with different read are not equal", info.equals(info2) == false);
assertTrue("Instances with different read are not equal", info2.equals(info) == false);
info2 = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, false, false);
assertTrue("Instances with different write are not equal", info.equals(info2) == false);
assertTrue("Instances with different write are not equal", info2.equals(info) == false);
info2 = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.BOOLEAN, true, true, true);
info2 = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.BOOLEAN, true, true, true);
assertTrue("Instances with different write are not equal", info.equals(info2) == false);
assertTrue("Instances with different write are not equal", info2.equals(info) == false);
info = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
new Integer(3), new Integer(2), new Integer(4));
info2 = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
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 OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
new Integer(3), new Integer(2), new Integer(4));
info2 = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
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 OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false, new Integer(3));
info2 = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false, 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 OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
null, new Integer(2), null);
info2 = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
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 OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
null, null, new Integer(2));
info2 = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
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 OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
new Integer(3), new Integer(2), new Integer(4));
info2 = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
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 OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
new Integer(3), new Integer(2), new Integer(4));
info2 = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
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 OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
new Integer(3), new Integer(2), new Integer(4));
info2 = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
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 OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
new Integer(3), new Integer(2), new Integer(4));
info2 = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
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 OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
null, new Object[] { new Integer(2), new Integer(3) });
info2 = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
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 OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
null, new Object[] { new Integer(2), new Integer(3) });
info2 = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
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 OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
null, new Object[] { new Integer(2), new Integer(3) });
info2 = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
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 OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
null, new Object[] { new Integer(2), new Integer(3) });
info2 = new OpenMBeanAttributeInfoSupport(
"name", "description", SimpleType.INTEGER, true, true, false,
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);
}