Examples of CommandBasedStatefulKnowledgeSession


Examples of org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession

  }

    @Test 
  public void testRuleFlowGroupRollback() throws Exception {
   
    CommandBasedStatefulKnowledgeSession ksession = createSession();
   
    List<String> list = new ArrayList<String>();
    list.add("Test");
   
    ksession.insert(list);
    ksession.execute(new ActivateRuleFlowCommand("ruleflow-group"));
    assertEquals(1, ksession.fireAllRules());
   
    try {
      ksession.execute(new ExceptionCommand());
      fail("Process must throw an exception");
    } catch (Exception e) {
      e.printStackTrace();
    }
   
    ksession.insert(list);
    ksession.execute(new ActivateRuleFlowCommand("ruleflow-group"));
    assertEquals(1, ksession.fireAllRules());
   
  }
View Full Code Here

Examples of org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession

        System.out.println("Process instance completed");
    }

    private void validatePessimisticLockingUse(KieSession ksession) throws Exception {
        // do an ugly hack to get the info
       CommandBasedStatefulKnowledgeSession cmdBasedKsession = (CommandBasedStatefulKnowledgeSession) ksession;
       SingleSessionCommandService sscs = (SingleSessionCommandService) cmdBasedKsession.getCommandService();
       // yes, this will break some day, and when it does, just delete this entire test, which isn't that good anyways.. :/
       Field envField = SingleSessionCommandService.class.getDeclaredField("env");
       envField.setAccessible(true);
       Environment env = (Environment) envField.get(sscs);
      
View Full Code Here

Examples of org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession

  }

    @Test 
  public void testRuleFlowGroupOnly() throws Exception {
   
    CommandBasedStatefulKnowledgeSession ksession = createSession(-1, "ruleflow-groups.drl");
   
    org.drools.core.spi.AgendaGroup[] groups = ((InternalAgenda)stripSession(ksession).getAgenda()).getAgendaGroups();
    // only main is available
    assertEquals(1, groups.length);
    assertEquals("MAIN", groups[0].getName());
    int id = ksession.getId();
    List<String> list = new ArrayList<String>();
    list.add("Test");
   
    ksession.insert(list);
    ksession.execute(new ActivateRuleFlowCommand("ruleflow-group"));
   
    ksession.dispose();       
        ksession = createSession(id, "ruleflow-groups.drl");
       
        groups = ((InternalAgenda)stripSession(ksession).getAgenda()).getAgendaGroups();
        // main and rule flow is now on the agenda
        assertEquals(2, groups.length);
View Full Code Here

Examples of org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession

  }
   
    @Test  
    public void testAgendaGroupOnly() throws Exception {
       
        CommandBasedStatefulKnowledgeSession ksession = createSession(-1, "agenda-groups.drl");
       
        org.drools.core.spi.AgendaGroup[] groups = ((InternalAgenda)stripSession(ksession).getAgenda()).getAgendaGroups();
        // only main is available
        assertEquals(1, groups.length);
        assertEquals("MAIN", groups[0].getName());
        int id = ksession.getId();
        List<String> list = new ArrayList<String>();
        list.add("Test");
       
        ksession.insert(list);
        ksession.execute(new ActivateAgendaGroupCommand("agenda-group"));
       
        ksession.dispose();       
        ksession = createSession(id, "agenda-groups.drl");
       
        groups = ((InternalAgenda)stripSession(ksession).getAgenda()).getAgendaGroups();
        // main and agenda group is now on the agenda
        assertEquals(2, groups.length);
View Full Code Here

Examples of org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession

    }
   
    @Test  
    public void testAgendaGroupAndRuleFlowGroup() throws Exception {
       
        CommandBasedStatefulKnowledgeSession ksession = createSession(-1, "agenda-groups.drl", "ruleflow-groups.drl");
       
        org.drools.core.spi.AgendaGroup[] groups = ((InternalAgenda)stripSession(ksession).getAgenda()).getAgendaGroups();
        // only main is available
        assertEquals(1, groups.length);
        assertEquals("MAIN", groups[0].getName());
        int id = ksession.getId();
        List<String> list = new ArrayList<String>();
        list.add("Test");
       
        ksession.insert(list);
        ksession.execute(new ActivateAgendaGroupCommand("agenda-group"));
        ksession.execute(new ActivateRuleFlowCommand("ruleflow-group"));
       
        ksession.dispose();       
        ksession = createSession(id, "agenda-groups.drl", "ruleflow-groups.drl");
       
        groups = ((InternalAgenda)stripSession(ksession).getAgenda()).getAgendaGroups();
        // main and agenda group is now on the agenda
        assertEquals(3, groups.length);
View Full Code Here

Examples of org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession

  }

    @Test 
  public void testRuleFlowGroupRollback() throws Exception {
   
    CommandBasedStatefulKnowledgeSession ksession = createSession();
   
    List<String> list = new ArrayList<String>();
    list.add("Test");
   
    ksession.insert(list);
    ksession.execute(new ActivateRuleFlowCommand("ruleflow-group"));
    assertEquals(1, ksession.fireAllRules());
   
    try {
      ksession.execute(new ExceptionCommand());
      fail("Process must throw an exception");
    } catch (Exception e) {
      e.printStackTrace();
    }
   
    ksession.insert(list);
    ksession.execute(new ActivateRuleFlowCommand("ruleflow-group"));
    assertEquals(1, ksession.fireAllRules());
   
  }
View Full Code Here

Examples of org.drools.process.command.impl.CommandBasedStatefulKnowledgeSession

            environment = EnvironmentFactory.newEnvironment();
        }
       
      CommandService commandService = ((SessionConfiguration) conf).getCommandService(this, environment);
      if (commandService != null) {
      return new CommandBasedStatefulKnowledgeSession(commandService);
      } else {
        ReteooStatefulSession session = (ReteooStatefulSession) this.ruleBase.newStatefulSession( (SessionConfiguration) conf,
                                                                                                  environment );
        return new StatefulKnowledgeSessionImpl( session, this );
      }
View Full Code Here

Examples of org.drools.process.command.impl.CommandBasedStatefulKnowledgeSession

    }
   
    public StatefulKnowledgeSession newStatefulKnowledgeSession(KnowledgeSessionConfiguration conf) {
      CommandService commandService = ((SessionConfiguration) conf).getCommandService(this.ruleBase);
      if (commandService != null) {
      return new CommandBasedStatefulKnowledgeSession(commandService);
      } else {
        ReteooStatefulSession session = (ReteooStatefulSession) this.ruleBase.newStatefulSession( (SessionConfiguration) conf );
        return new StatefulKnowledgeSessionImpl( session, this );
      }
    }   
View Full Code Here

Examples of org.drools.process.command.impl.CommandBasedStatefulKnowledgeSession

            environment = EnvironmentFactory.newEnvironment();
        }
       
      CommandService commandService = ((SessionConfiguration) conf).getCommandService(this, environment);
      if (commandService != null) {
      return new CommandBasedStatefulKnowledgeSession(commandService);
      } else {
        ReteooStatefulSession session = (ReteooStatefulSession) this.ruleBase.newStatefulSession( (SessionConfiguration) conf,
                                                                                                  environment );
        return new StatefulKnowledgeSessionImpl( session, this );
      }
View Full Code Here

Examples of org.drools.process.command.impl.CommandBasedStatefulKnowledgeSession

        ((SessionConfiguration)configuration).addProperties( props );

        CommandService commandService = new SingleSessionCommandService( kbase,
                                                                         configuration,
                                                                         environment );
        return new CommandBasedStatefulKnowledgeSession( commandService );
    }
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.