Package org.drools.core.command.impl

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


            //something unexpected happened
            throw new RuntimeException("Something wrong initializing manual process persistor interceptor", e);
          }
        }
       
        return new CommandBasedStatefulKnowledgeSession( commandService );
    }
View Full Code Here


            //something unexpected happened
            throw new RuntimeException("Something wrong initializing manual process persistor interceptor", e);
          }
        }
       
        return new CommandBasedStatefulKnowledgeSession( commandService );
    }
View Full Code Here

  }

    @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

        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

  }

    @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

  }
   
    @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

    }
   
    @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

  }

    @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

        CommandService commandService = (CommandService) buildCommandService( kbase,
                                                                              mergeConfig( configuration ),
                                                                              environment );
        commandService.getContext().set(EntryPointCreator.class.getName(),
                                        new CommandBasedEntryPointCreator(commandService));
        return new CommandBasedStatefulKnowledgeSession( commandService );
    }
View Full Code Here

                                                                              kbase,
                                                                              mergeConfig( configuration ),
                                                                              environment );
        commandService.getContext().set(EntryPointCreator.class.getName(),
                                        new CommandBasedEntryPointCreator(commandService));
        return new CommandBasedStatefulKnowledgeSession( commandService );
    }
View Full Code Here

TOP

Related Classes of org.drools.core.command.impl.CommandBasedStatefulKnowledgeSession

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.