}
public void testEquals()
throws Exception
{
OpenMBeanOperationInfoSupport info = new OpenMBeanOperationInfoSupport(
"name", "description", null, SimpleType.STRING, OpenMBeanOperationInfoSupport.ACTION_INFO);
assertTrue("Null should not be equal", info.equals(null) == false);
assertTrue("Only OpenMBeanOperationInfo should be equal", info.equals(new Object()) == false);
OpenMBeanOperationInfoSupport info2 = new OpenMBeanOperationInfoSupport(
"name", "description", null, SimpleType.STRING, OpenMBeanOperationInfoSupport.ACTION_INFO);
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 OpenMBeanOperationInfoSupport(
"name", "description2", null, SimpleType.STRING, OpenMBeanOperationInfoSupport.ACTION_INFO);
assertTrue("Different instances with different descriptions are equal", info.equals(info2));
assertTrue("Different instances with different descritpions are equal", info2.equals(info));
info2 = new OpenMBeanOperationInfoSupport(
"name2", "description", null, SimpleType.STRING, OpenMBeanOperationInfoSupport.ACTION_INFO);
assertTrue("Instances with different names are not equal", info.equals(info2) == false);
assertTrue("Instances with different names are not equal", info2.equals(info) == false);
OpenMBeanParameterInfoSupport param1 = new OpenMBeanParameterInfoSupport(
"name", "description", SimpleType.STRING);
OpenMBeanParameterInfoSupport param2 = new OpenMBeanParameterInfoSupport(
"name2", "description", SimpleType.STRING);
info = new OpenMBeanOperationInfoSupport(
"name", "description", new OpenMBeanParameterInfoSupport[] { param1, param2 },
SimpleType.STRING, OpenMBeanOperationInfoSupport.ACTION_INFO);
info2 = new OpenMBeanOperationInfoSupport(
"name", "description", new OpenMBeanParameterInfoSupport[] { param1, param2 },
SimpleType.STRING, OpenMBeanOperationInfoSupport.ACTION_INFO);
assertTrue("Different instances with the same parameters are equal", info.equals(info2));
assertTrue("Different instances with the same parameters are equal", info2.equals(info));
info = new OpenMBeanOperationInfoSupport(
"name", "description", new OpenMBeanParameterInfoSupport[] { param1, param2 },
SimpleType.STRING, OpenMBeanOperationInfoSupport.ACTION_INFO);
info2 = new OpenMBeanOperationInfoSupport(
"name", "description", new OpenMBeanParameterInfoSupport[] { param2, param1 },
SimpleType.STRING, OpenMBeanOperationInfoSupport.ACTION_INFO);
assertTrue("Different instances with the same signature but different parameters are not equal",
info.equals(info2) == false);
assertTrue("Different instances with the same signature but different parameters are not equal",
info2.equals(info) == false);
param2 = new OpenMBeanParameterInfoSupport(
"name2", "description", SimpleType.INTEGER);
info2 = new OpenMBeanOperationInfoSupport(
"name", "description", new OpenMBeanParameterInfoSupport[] { param1, param2 },
SimpleType.STRING, OpenMBeanOperationInfoSupport.ACTION_INFO);
assertTrue("Different instances with different signatures are not equal",
info.equals(info2) == false);
assertTrue("Different instances with different signatures are not equal",
info2.equals(info) == false);
info2 = new OpenMBeanOperationInfoSupport(
"name", "description", new OpenMBeanParameterInfoSupport[] { param1 },
SimpleType.STRING, OpenMBeanOperationInfoSupport.ACTION_INFO);
assertTrue("Different instances with different numbers of paramters are not equal",
info.equals(info2) == false);
assertTrue("Different instances with different numbers of parameters are not equal",
info2.equals(info) == false);
info2 = new OpenMBeanOperationInfoSupport(
"name", "description", new OpenMBeanParameterInfoSupport[] { param1, param2 },
SimpleType.INTEGER, OpenMBeanOperationInfoSupport.ACTION_INFO);
assertTrue("Different instances with different return types are not equal",
info.equals(info2) == false);
assertTrue("Different instances with different return types are not equal",
info2.equals(info) == false);
info2 = new OpenMBeanOperationInfoSupport(
"name", "description", new OpenMBeanParameterInfoSupport[] { param1, param2 },
SimpleType.STRING, OpenMBeanOperationInfoSupport.ACTION);
assertTrue("Different instances with different impacts are not equal",
info.equals(info2) == false);
assertTrue("Different instances with different impacts are not equal",
info2.equals(info) == false);
}