示例#1
0
  @Test
  @Ignore
  public void testStatefulSessionsCreation() throws Exception {

    final PackageBuilder builder = new PackageBuilder();
    builder.addPackageFromDrl(
        new InputStreamReader(getClass().getResourceAsStream("test_OutOfMemoryError.drl")));
    final Package pkg = builder.getPackage();

    RuleBase ruleBase = getRuleBase();
    ruleBase.addPackage(pkg);
    ruleBase = SerializationHelper.serializeObject(ruleBase);

    int i = 0;

    SessionConfiguration conf = new SessionConfiguration();
    conf.setKeepReference(
        true); // this is just for documentation purposes, since the default value is "true"
    try {
      for (i = 0; i < 300000; i++) {
        final StatefulSession session = ruleBase.newStatefulSession(conf, null);
        session.dispose();
      }
    } catch (Throwable e) {
      System.out.println("Error at: " + i);
      e.printStackTrace();
      fail("Should not raise any error or exception.");
    }
  }
示例#2
0
  @Test
  @Ignore
  public void testAgendaLoop() throws Exception {
    final PackageBuilder builder = new PackageBuilder();
    builder.addPackageFromDrl(
        new InputStreamReader(getClass().getResourceAsStream("test_OutOfMemory.drl")));
    final Package pkg = builder.getPackage();

    RuleBase ruleBase = getRuleBase();
    ruleBase.addPackage(pkg);
    ruleBase = SerializationHelper.serializeObject(ruleBase);
    final WorkingMemory workingMemory = ruleBase.newStatefulSession();

    workingMemory.insert(new Cheese("stilton", 1));

    workingMemory.fireAllRules(3000000);

    // just for profiling
    // Thread.currentThread().wait();
  }