/**
* Error handling
*/
public void testErrorHandling()
{
RoleInfo roleInfo1 = null;
RoleInfo roleInfo2 = null;
RoleInfo[] roleInfos = null;
RelationTypeSupport support = null;
boolean caught = false;
try
{
roleInfo1 = new RoleInfo("roleInfo1", RelationSupport.class.getName());
roleInfo2 = new RoleInfo("roleInfo2", RelationSupport.class.getName());
roleInfos = new RoleInfo[] { roleInfo1, roleInfo2 };
support = new RelationTypeSupport(null, roleInfos);
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Constructor accepts null relation type name");
caught = false;
try
{
support = new RelationTypeSupport("name", null);
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Constructor accepts null role infos");
caught = false;
try
{
support = new RelationTypeSupport("name", new RoleInfo[0]);
}
catch (InvalidRelationTypeException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Constructor accepts no role infos");
caught = false;
try
{
roleInfo1 = new RoleInfo("roleInfo1", RelationSupport.class.getName());
roleInfos = new RoleInfo[] { roleInfo1, null };
support = new RelationTypeSupport("name", roleInfos);
}
catch (InvalidRelationTypeException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("Constructor accepts null role");
caught = false;
try
{
roleInfo1 = new RoleInfo("roleInfo1", RelationSupport.class.getName());
roleInfos = new RoleInfo[] { roleInfo1 };
support = new RelationTypeSupport("name", roleInfos);
support.getRoleInfo(null);
}
catch (IllegalArgumentException e)
{
caught = true;
}
catch (Exception e)
{
fail(e.toString());
}
if (caught == false)
fail("getRoleInfo allows a null role info name");
caught = false;
try
{
roleInfo1 = new RoleInfo("roleInfo1", RelationSupport.class.getName());
roleInfos = new RoleInfo[] { roleInfo1 };
support = new RelationTypeSupport("name", roleInfos);
support.getRoleInfo("rubbish");
}
catch (RoleInfoNotFoundException e)