/**
* Test Error Handling.
*/
public void testErrorHandling()
{
RoleInfo roleInfo = null;
boolean caught = false;
try
{
roleInfo = new RoleInfo(null);
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Copy Constructor accepts null role info");
caught = false;
try
{
roleInfo = new RoleInfo(null, RelationSupport.class.getName());
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Constructor accepts null role name (1)");
caught = false;
try
{
roleInfo = new RoleInfo(null, RelationSupport.class.getName(), true, true);
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Constructor accepts null role name (2)");
caught = false;
try
{
roleInfo = new RoleInfo(null, RelationSupport.class.getName(), true, true,
1, 1, "blah");
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Constructor accepts null role name (3)");
caught = false;
try
{
roleInfo = new RoleInfo("RoleName", null);
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Constructor accepts null class name (1)");
caught = false;
try
{
roleInfo = new RoleInfo("RoleName", null, true, true);
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Constructor accepts null class name (2)");
caught = false;
try
{
roleInfo = new RoleInfo("RoleName", null, true, true,
1, 1, "blah");
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Constructor accepts null class name (3)");
caught = false;
try
{
roleInfo = new RoleInfo("RoleName", "Inv alid");
}
catch (ClassNotFoundException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Constructor accepts invalid class name (1)");
caught = false;
try
{
roleInfo = new RoleInfo("RoleName", "Inv alid", true, true);
}
catch (ClassNotFoundException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Constructor accepts invalid class name (2)");
caught = false;
try
{
roleInfo = new RoleInfo("RoleName", "Inv alid", true, true,
1, 1, "blah");
}
catch (ClassNotFoundException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Constructor accepts invalid class name (3)");
caught = false;
try
{
roleInfo = new RoleInfo("RoleName", RoleInfo.class.getName());
}
catch (NotCompliantMBeanException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Constructor accepts not compliant mbean (1)");
caught = false;
try
{
roleInfo = new RoleInfo("RoleName", RoleInfo.class.getName(), true, true);
}
catch (NotCompliantMBeanException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Constructor accepts not compliant mbean (2)");
caught = false;
try
{
roleInfo = new RoleInfo("RoleName", RoleInfo.class.getName(), true, true,
1, 1, "blah");
}
catch (NotCompliantMBeanException e)
{
caught = true;