Package javax.rules

Examples of javax.rules.RuleRuntime


    /**
     * Test createRuleSession.
     */
    @Test
    public void testCreateRuleStatefulRuleSession() throws Exception {
        final RuleRuntime ruleRuntime = this.ruleServiceProvider.getRuleRuntime();
        assertNotNull( "cannot obtain RuleRuntime",
                       ruleRuntime );

        // expect RuleExecutionSetNotFoundException
        try {
            ruleRuntime.createRuleSession( "someUri",
                                           null,
                                           RuleRuntime.STATEFUL_SESSION_TYPE );
            fail( "RuleExecutionSetNotFoundException expected" );
        } catch ( final RuleExecutionSetNotFoundException ex ) {
            // ignore exception
        }

        // read rules and register with administrator
        final Reader ruleReader = new InputStreamReader( RuleRuntimeTest.class.getResourceAsStream( this.RULES_RESOURCE ) );
        final RuleExecutionSet ruleSet = this.ruleSetProvider.createRuleExecutionSet( ruleReader,
                                                                                      null );
        this.ruleAdministrator.registerRuleExecutionSet( this.RULES_RESOURCE,
                                                         ruleSet,
                                                         null );

        final StatefulRuleSession statefulRuleSession = (StatefulRuleSession) ruleRuntime.createRuleSession( this.RULES_RESOURCE,
                                                                                                             null,
                                                                                                             RuleRuntime.STATEFUL_SESSION_TYPE );
        assertNotNull( "cannot obtain StatefulRuleSession",
                       statefulRuleSession );

View Full Code Here


    /**
     * Test getRegistrations.
     */
    @Test
    public void testGetRegistrations() throws Exception {
        final RuleRuntime ruleRuntime = this.ruleServiceProvider.getRuleRuntime();
        assertNotNull( "cannot obtain RuleRuntime",
                       ruleRuntime );

        // read rules and register with administrator
        final Reader ruleReader = new InputStreamReader( RuleRuntimeTest.class.getResourceAsStream( this.RULES_RESOURCE ) );
        final RuleExecutionSet ruleSet = this.ruleSetProvider.createRuleExecutionSet( ruleReader,
                                                                                      null );
        this.ruleAdministrator.registerRuleExecutionSet( this.RULES_RESOURCE,
                                                         ruleSet,
                                                         null );

        final List list = ruleRuntime.getRegistrations();
        assertTrue( "no registrations found",
                    list.size() > 0 );

        this.ruleAdministrator.deregisterRuleExecutionSet( this.RULES_RESOURCE,
                                                           null );
View Full Code Here

        properties.clear();
        final List list = new ArrayList();
        properties.put( "list",
                        list );
       
        RuleRuntime ruleRuntime = ruleServiceProvider.getRuleRuntime();
        StatefulRuleSession session = (StatefulRuleSession) ruleRuntime.createRuleSession( "IntegrationExampleTest.xls",
                                                                                           properties,
                                                                                           RuleRuntime.STATEFUL_SESSION_TYPE );

        //ASSERT AND FIRE
        session.addObject( new Cheese( "stilton",
View Full Code Here

        properties.clear();
        final List list = new ArrayList();
        properties.put( "list",
                        list );
       
        RuleRuntime ruleRuntime = ruleServiceProvider.getRuleRuntime();
        StatefulRuleSession session = (StatefulRuleSession) ruleRuntime.createRuleSession( "IntegrationExampleTest.xls",
                                                                                           properties,
                                                                                           RuleRuntime.STATEFUL_SESSION_TYPE );

        //ASSERT AND FIRE
        session.addObject( new Cheese( "stilton",
View Full Code Here

    /**
     * Test createRuleSession.
     */
    public void testCreateRuleStatelessRuleSession() throws Exception {
        final RuleRuntime ruleRuntime = this.ruleServiceProvider.getRuleRuntime();
        assertNotNull( "cannot obtain RuleRuntime",
                       ruleRuntime );

        // expect RuleExecutionSetNotFoundException
        try {
            ruleRuntime.createRuleSession( "someUri",
                                           null,
                                           RuleRuntime.STATELESS_SESSION_TYPE );
            fail( "RuleExecutionSetNotFoundException expected" );
        } catch ( final RuleExecutionSetNotFoundException ex ) {
            // ignore exception
        }

        // read rules and register with administrator
        final Reader ruleReader = new InputStreamReader( RuleRuntimeTest.class.getResourceAsStream( this.RULES_RESOURCE ) );
        final RuleExecutionSet ruleSet = this.ruleSetProvider.createRuleExecutionSet( ruleReader,
                                                                                      null );
        this.ruleAdministrator.registerRuleExecutionSet( this.RULES_RESOURCE,
                                                         ruleSet,
                                                         null );

        final StatelessRuleSession statelessRuleSession = (StatelessRuleSession) ruleRuntime.createRuleSession( this.RULES_RESOURCE,
                                                                                                                null,
                                                                                                                RuleRuntime.STATELESS_SESSION_TYPE );
        assertNotNull( "cannot obtain StatelessRuleSession",
                       statelessRuleSession );

View Full Code Here

    /**
     * Test createRuleSession.
     */
    public void testCreateRuleStatefulRuleSession() throws Exception {
        final RuleRuntime ruleRuntime = this.ruleServiceProvider.getRuleRuntime();
        assertNotNull( "cannot obtain RuleRuntime",
                       ruleRuntime );

        // expect RuleExecutionSetNotFoundException
        try {
            ruleRuntime.createRuleSession( "someUri",
                                           null,
                                           RuleRuntime.STATEFUL_SESSION_TYPE );
            fail( "RuleExecutionSetNotFoundException expected" );
        } catch ( final RuleExecutionSetNotFoundException ex ) {
            // ignore exception
        }

        // read rules and register with administrator
        final Reader ruleReader = new InputStreamReader( RuleRuntimeTest.class.getResourceAsStream( this.RULES_RESOURCE ) );
        final RuleExecutionSet ruleSet = this.ruleSetProvider.createRuleExecutionSet( ruleReader,
                                                                                      null );
        this.ruleAdministrator.registerRuleExecutionSet( this.RULES_RESOURCE,
                                                         ruleSet,
                                                         null );

        final StatefulRuleSession statefulRuleSession = (StatefulRuleSession) ruleRuntime.createRuleSession( this.RULES_RESOURCE,
                                                                                                             null,
                                                                                                             RuleRuntime.STATEFUL_SESSION_TYPE );
        assertNotNull( "cannot obtain StatefulRuleSession",
                       statefulRuleSession );

View Full Code Here

    /**
     * Test getRegistrations.
     */
    public void testGetRegistrations() throws Exception {
        final RuleRuntime ruleRuntime = this.ruleServiceProvider.getRuleRuntime();
        assertNotNull( "cannot obtain RuleRuntime",
                       ruleRuntime );

        // read rules and register with administrator
        final Reader ruleReader = new InputStreamReader( RuleRuntimeTest.class.getResourceAsStream( this.RULES_RESOURCE ) );
        final RuleExecutionSet ruleSet = this.ruleSetProvider.createRuleExecutionSet( ruleReader,
                                                                                      null );
        this.ruleAdministrator.registerRuleExecutionSet( this.RULES_RESOURCE,
                                                         ruleSet,
                                                         null );

        final List list = ruleRuntime.getRegistrations();
        assertTrue( "no registrations found",
                    list.size() > 0 );

        this.ruleAdministrator.deregisterRuleExecutionSet( this.RULES_RESOURCE,
                                                           null );
View Full Code Here

     */
    public void testRuleRuntime() throws Exception {
        Class.forName("org.drools.jsr94.rules.RuleServiceProviderImpl");
        RuleServiceProvider ruleServiceProvider = RuleServiceProviderManager.getRuleServiceProvider("http://drools.org/");
       
        final RuleRuntime ruleRuntime = ruleServiceProvider.getRuleRuntime();
        assertNotNull( "cannot obtain RuleRuntime",
                       ruleRuntime );
        assertTrue( "not a class instance",
                    ruleRuntime == ruleServiceProvider.getRuleRuntime() );
    }
View Full Code Here

     *
     * @throws Exception
     */
    public void testMultipleInstances() throws Exception {
        // create 2 different runtimes with different rulesets
        final RuleRuntime ruleRuntime1 = getServiceProvider( "engine1",
                                                             "multiple-engine1.drl" ).getRuleRuntime();
        final RuleRuntime ruleRuntime2 = getServiceProvider( "engine2",
                                                             "multiple-engine2.drl" ).getRuleRuntime();

        // there should be only 1
        System.out.println( ruleRuntime1.getRegistrations().size() );
        assertTrue( ruleRuntime1.getRegistrations().size() == 1 );

        // there should be only 1
        System.out.println( ruleRuntime2.getRegistrations().size() );
        assertTrue( ruleRuntime2.getRegistrations().size() == 1 );

        // execute them both for good measure...
        execute( ruleRuntime1,
                 "Engine1",
                 new Object[]{"value1"} );
View Full Code Here

    private RuleRuntime createRuleRuntime(RuleServiceProvider ruleServiceProvider) {

        try {
            // get the run time which will be the access point for runtime execution
            // of RuleExecutionSets
            RuleRuntime ruleRuntime = ruleServiceProvider.getRuleRuntime();
            if (ruleRuntime == null) {
                throw new LoggedRuntimeException("The created rule runtime is null", log);
            }
            return ruleRuntime;
View Full Code Here

TOP

Related Classes of javax.rules.RuleRuntime

Copyright © 2018 www.massapicom. 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.