public void testClassOFieldbjectTypeFactoryExceptions() throws Exception
{
RuleBaseContext ruleBaseContext = new RuleBaseContext( );
DefaultConfiguration configuration = new DefaultConfiguration( "test1" );
final RuleSet ruleSet = new RuleSet( "test RuleSet",
ruleBaseContext );
final Rule rule = new Rule( "Test Rule 1",
ruleSet );
Importer importer = new DefaultImporter( );
rule.setImporter( importer );
ObjectTypeFactory factory = new ClassFieldObjectTypeFactory( );
try
{
ClassObjectType type = (ClassObjectType) factory.newObjectType( rule,
ruleBaseContext,
configuration );
fail( "Should fail, no field name has been specified" );
}
catch ( FactoryException e )
{
assertEquals( "no class name specified",
e.getMessage( ) );
}
configuration.setText( "org.drools.semantics.base.Person" );
try
{
ClassObjectType type = (ClassObjectType) factory.newObjectType( rule,
ruleBaseContext,
configuration );
fail( "Should fail, no field name has been specified" );
}
catch ( FactoryException e )
{
assertEquals( "no field name specified",
e.getMessage( ) );
}
configuration.setAttribute( "field",
"name" );
try
{
ClassObjectType type = (ClassObjectType) factory.newObjectType( rule,
ruleBaseContext,