ruleSet );
Importer importer = new DefaultImporter( );
rule.setImporter( importer );
ObjectTypeFactory factory = new SemaphoreFactory( );
try
{
ClassObjectType type = (ClassObjectType) factory.newObjectType( rule,
ruleBaseContext,
configuration );
fail( "SemaphoreFactory should throw an exception as no type is specified" );
}
catch ( FactoryException e )
{
assertEquals( "no Semaphore type specified",
e.getMessage( ) );
}
configuration.setAttribute( "type",
"Person" );
try
{
ClassObjectType type = (ClassObjectType) factory.newObjectType( rule,
ruleBaseContext,
configuration );
fail( "SemaphoreFactory should throw an exception as no identifier is specified" );
}
catch ( FactoryException e )
{
assertEquals( "no Semaphore identifier specified",
e.getMessage( ) );
}
configuration.setAttribute( "type",
"NoneExistingClass" );
configuration.setAttribute( "identifier",
"state" );
try
{
ClassObjectType type = (ClassObjectType) factory.newObjectType( rule,
ruleBaseContext,
configuration );
fail( "SemaphoreFactory should throw an exception as class NoneExistingClass does not exist." );
}
catch ( FactoryException e )
{
assertEquals( "Unable create Semaphore for type 'NoneExistingClass'",
e.getMessage( ) );
}
configuration.setAttribute( "type",
"Person" );
configuration.setAttribute( "identifier",
"state" );
try
{
ClassObjectType type = (ClassObjectType) factory.newObjectType( rule,
ruleBaseContext,
configuration );
fail( "SemaphoreFactory should throw an exception as class Person has no identifier field." );
}
catch ( FactoryException e )