/**
* Test Update Error Handling
*/
public void testUpdateErrors()
{
RelationNotification rn = null;
ObjectName objectName = null;
try
{
objectName = new ObjectName(":a=a");
}
catch (Exception e)
{
fail(e.toString());
}
ArrayList newRoles = new ArrayList();
ArrayList oldRoles = new ArrayList();
boolean caught = false;
try
{
rn = new RelationNotification("blah",
new RelationService(true), 21, 23, "message", "relationId",
"relationTypeName", objectName, "roleInfo", newRoles, oldRoles);
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Update accepts an invalid type");
caught = false;
try
{
rn = new RelationNotification(RelationNotification.RELATION_BASIC_CREATION,
new RelationService(true), 21, 23, "message", "relationId",
"relationTypeName", objectName, "roleInfo", newRoles, oldRoles);
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Update accepts basic create");
caught = false;
try
{
rn = new RelationNotification(RelationNotification.RELATION_MBEAN_CREATION,
new RelationService(true), 21, 23, "message", "relationId",
"relationTypeName", objectName, "roleInfo", newRoles, oldRoles);
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Creation/Removal accepts mean create");
caught = false;
try
{
rn = new RelationNotification(RelationNotification.RELATION_BASIC_REMOVAL,
new RelationService(true), 21, 23, "message", "relationId",
"relationTypeName", objectName, "roleInfo", newRoles, oldRoles);
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Update accepts basic remove");
caught = false;
try
{
rn = new RelationNotification(RelationNotification.RELATION_MBEAN_REMOVAL,
new RelationService(true), 21, 23, "message", "relationId",
"relationTypeName", objectName, "roleInfo", newRoles, oldRoles);
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Update accepts mean remove");
caught = false;
try
{
rn = new RelationNotification(RelationNotification.RELATION_BASIC_UPDATE,
null, 21, 23, "message", "relationId",
"relationTypeName", objectName, "roleInfo", newRoles, oldRoles);
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Update accepts null source");
caught = false;
try
{
rn = new RelationNotification(RelationNotification.RELATION_BASIC_UPDATE,
new RelationService(true), 21, 23, "message", null,
"relationTypeName", objectName, "roleInfo", newRoles, oldRoles);
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Update accepts null relation id");
caught = false;
try
{
rn = new RelationNotification(RelationNotification.RELATION_BASIC_UPDATE,
new RelationService(true), 21, 23, "message", "relation id",
null, objectName, "roleInfo", newRoles, oldRoles);
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Update accepts null relation type name");
caught = false;
try
{
rn = new RelationNotification(RelationNotification.RELATION_BASIC_UPDATE,
new RelationService(true), 21, 23, "message", "relation id",
null, objectName, null, newRoles, oldRoles);
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Update accepts null role info");
caught = false;
try
{
rn = new RelationNotification(RelationNotification.RELATION_BASIC_UPDATE,
new RelationService(true), 21, 23, "message", "relation id",
"relationTypeName", objectName, "roleInfo", null, oldRoles);
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Creation/Removal accepts null new role value");
caught = false;
try
{
rn = new RelationNotification(RelationNotification.RELATION_BASIC_UPDATE,
new RelationService(true), 21, 23, "message", "relation id",
"relationTypeName", objectName, "roleInfo", newRoles, null);
}
catch (IllegalArgumentException e)
{