Examples of Importer


Examples of org.drools.spi.Importer

public class DefaultImporterTest extends TestCase
{

    public void testStaticImport()
    {
        Importer importer = new DefaultImporter( );
        importer.addImport( new DefaultImportEntry( "java.util.HashMap" ) );

        /* static import, should work */
        ClassLoader cl = getClass( ).getClassLoader( );
        try
        {
            Class clazz = importer.importClass( cl,
                                                "HashMap" );
            assertSame( java.util.HashMap.class,
                        clazz );
        }
        catch ( ClassNotFoundException e )
        {
            fail( e.getMessage( ) );
        }
        catch ( Error e )
        {
            fail( e.getMessage( ) );
        }

        /* static import, should fail */
        try
        {
            Class clazz = importer.importClass( cl,
                                                "ArrayList" );
            fail( "Class ArrayList should not be found" );
        }
        catch ( ClassNotFoundException e )
        {
View Full Code Here

Examples of org.drools.spi.Importer

        }
    }

    public void testDynamicImport()
    {
        Importer importer = new DefaultImporter( );
        importer.addImport( new DefaultImportEntry( "java.util.*" ) );

        ClassLoader cl = getClass( ).getClassLoader( );

        /* dynamic import, should work */
        try
        {
            Class clazz = importer.importClass( cl,
                                                "HashMap" );
            assertSame( java.util.HashMap.class,
                        clazz );
        }
        catch ( ClassNotFoundException e )
        {
            fail( e.getMessage( ) );
        }
        catch ( Error e )
        {
            fail( e.getMessage( ) );
        }

        /* dynamic import, should throw ClassNotFoundException */
        try
        {
            Class clazz = importer.importClass( cl,
                                                "NoneExistingClass" );
            fail( "Class NoneExistingClass should not be found" );
        }
        catch ( ClassNotFoundException e )
        {
            // correct exception, so pass
        }
        catch ( Error e )
        {
            fail( "Incorrect Error exception, should have been ClassNotFound" );
        }

        /* dynamic import, should fail and throw Error */
        importer.addImport( new DefaultImportEntry( "java.awt.*" ) );
        try
        {
            Class clazz = importer.importClass( cl,
                                                "List" );
            fail( "Should fail as imports are ambiguous for List" );
        }
        catch ( ClassNotFoundException e )
        {
            fail( "Incorrect ClassNotFoundException exception, should have been Error" );
        }
        catch ( Error e )
        {
            // correct exception, so pass
        }

        /* recheck that HashMap still works */
        try
        {
            Class clazz = importer.importClass( cl,
                                                "HashMap" );
            assertSame( java.util.HashMap.class,
                        clazz );
        }
        catch ( ClassNotFoundException e )
View Full Code Here

Examples of org.drools.spi.Importer

    }

    public void testgetImports()
    {
        Importer importer = new DefaultImporter( );

        // assertSame(importer.)

        importer.addImport( new DefaultImportEntry( "java.awt.*" ) );
        importer.addImport( new DefaultImportEntry( "java.util.Map" ) );

        Set set;
        set = importer.getImports( );
        assertTrue( set.contains( "java.awt.*" ) );
        assertTrue( set.contains( "java.util.Map" ) );
        assertEquals( 2,
                      set.size( ) );
    }
View Full Code Here

Examples of org.drools.spi.Importer

        ImportEntryFactory factory = module.getImportEntryFactory( localName );

        Configuration config = ruleSetReader.endConfiguration( );
        ImportEntry importEntry;
        Importer importer = ruleSetReader.getRuleSet().getImporter();
        try
        {
            importEntry = factory.newImportEntry( this.ruleSetReader.getRuleSet( ),
                                                  this.ruleSetReader.getFactoryContext( ),
                                                  config );
            importer.addImport( importEntry );
        }
        catch ( FactoryException e )
        {
            throw new SAXParseException( "error constructing import",
                    ruleSetReader.getLocator( ), e );
View Full Code Here

Examples of org.drools.spi.Importer

                                    "map" );

        final RuleSet ruleSet = new RuleSet( "test RuleSet",
                                             ruleBaseContext );

        Importer importer = new DefaultImporter( );
        ruleSet.setImporter( importer );

        ApplicationDataFactory factory = new BaseApplicationDataFactory( );

        ApplicationData applicationData = factory.newApplicationData( ruleSet,
View Full Code Here

Examples of org.drools.spi.Importer

                                    "map" );

        final RuleSet ruleSet = new RuleSet( "test RuleSet",
                                             ruleBaseContext );

        Importer importer = new DefaultImporter( );
        importer.addImport( new DefaultImportEntry( "java.util.HashMap" ) );
        ruleSet.setImporter( importer );

        ApplicationDataFactory factory = new BaseApplicationDataFactory( );

        ApplicationData applicationData = factory.newApplicationData( ruleSet,
View Full Code Here

Examples of org.drools.spi.Importer

                                    "map" );

        final RuleSet ruleSet = new RuleSet( "test RuleSet",
                                             ruleBaseContext );

        Importer importer = new DefaultImporter( );
        importer.addImport( new DefaultImportEntry( "java.util.*" ) );
        ruleSet.setImporter( importer );

        ApplicationDataFactory factory = new BaseApplicationDataFactory( );

        ApplicationData applicationData = factory.newApplicationData( ruleSet,
View Full Code Here

Examples of org.drools.spi.Importer

                                             ruleBaseContext );

        final Rule rule = new Rule( "Test Rule 1",
                                    ruleSet );

        Importer importer = new DefaultImporter( );
        rule.setImporter( importer );

        ObjectTypeFactory factory = new ClassFieldObjectTypeFactory( );

        try
View Full Code Here

Examples of org.drools.spi.Importer

                                             ruleBaseContext );

        final Rule rule = new Rule( "Test Rule 1",
                                    ruleSet );

        Importer importer = new DefaultImporter( );
        rule.setImporter( importer );

        ObjectTypeFactory factory = new ClassFieldObjectTypeFactory( );

        ClassFieldObjectType type = (ClassFieldObjectType) factory.newObjectType( rule,
View Full Code Here

Examples of org.drools.spi.Importer

                                             ruleBaseContext );

        final Rule rule = new Rule( "Test Rule 1",
                                    ruleSet );

        Importer importer = new DefaultImporter( );
        importer.addImport( new DefaultImportEntry( "org.drools.semantics.base.Person" ) );
        rule.setImporter( importer );

        ObjectTypeFactory factory = new ClassFieldObjectTypeFactory( );

        ClassFieldObjectType type = (ClassFieldObjectType) factory.newObjectType( rule,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.