<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body text="#000000" bgcolor="#ffffff">
    On 17/05/2011 08:44, Leonardo Gomes wrote:
    <blockquote
      cite="mid:BANLkTinONK3bV5NX5YieFyDCqp6cZS6iLw@mail.gmail.com"
      type="cite">I totally agree, except for the inline DRL :)<br>
      <br>
      If it's a big enough DRL (let's say +3 rules), isn't it easier to
      have something on the lines of the existing integration tests
      inside drools-compiler? With the drl in the resources folder.<br>
    </blockquote>
    Once the rule(s) gets larger yes. The problem we have now though is
    look at the integration tests resource folder, it gets big pretty
    quick. And ofcourse there is no automatic button to go from the java
    test to the drl test file, so it's extra key presses. When you are
    doing a lot of reviewing, or checking old regressions, it can can be
    nice to have everything in a single place. Personally I just wish
    Java had multi-line strings and then this wouldn't be an issue :(<br>
    <blockquote
      cite="mid:BANLkTinONK3bV5NX5YieFyDCqp6cZS6iLw@mail.gmail.com"
      type="cite">
      <br>
      I know that people say "a test is not a unit test if it touches
      the filesystem", but as long as Java doesn't support a proper way
      of <span id="goog_448678280"></span><a moz-do-not-send="true"
        href="/">inlining XML<span id="goog_448678281"></span></a> (or
      DRL in this case, or different text formats in the general case),
      like Scala does, I personally think it's easier and more readable
      to have a separate file.<br>
    </blockquote>
    It's nothign to do with being a proper unit test, and more just
    making edson and my life easier.<br>
    <br>
    Mark<br>
    <blockquote
      cite="mid:BANLkTinONK3bV5NX5YieFyDCqp6cZS6iLw@mail.gmail.com"
      type="cite">
      <br>
      My 5 cents.<br>
      <br>
      Leo.<br>
      <br>
      <br>
      <div class="gmail_quote">On Tue, May 17, 2011 at 4:16 AM, Mark
        Proctor <span dir="ltr">&lt;<a moz-do-not-send="true"
            href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>&gt;</span>
        wrote:<br>
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">
          It's great when people attach unit tests to jiras, it would be
          ever<br>
          better if they are just cut nad paste single files, rather
          than entire<br>
          projects, which take more time for us to fiddle with. Also
          please do try<br>
          and pair your actual program "main" examples down to minimal
          unit tests<br>
          of the actual problem. If you suspect the problem is MVEL,
          then please<br>
          do a minimal MVEL test, without Drools.<br>
          <br>
          Put static classes in the same file, put rules in a
          concatenated string.<br>
          This means testing is as easy as cut and paste for us, and it
          can be<br>
          easily added to existing test classes. For example, from
          MiscTest.<br>
          <br>
          <br>
          &nbsp; &nbsp; public static class A {<br>
          &nbsp; &nbsp; &nbsp; &nbsp; private String field1;<br>
          &nbsp; &nbsp; &nbsp; &nbsp; private String field2;<br>
          <br>
          &nbsp; &nbsp; &nbsp; &nbsp; public A(String field1,<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;String field2) {<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.field1 = field1;<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.field2 = field2;<br>
          &nbsp; &nbsp; &nbsp; &nbsp; }<br>
          <br>
          &nbsp; &nbsp; &nbsp; &nbsp; public String getField1() {<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return field1;<br>
          &nbsp; &nbsp; &nbsp; &nbsp; }<br>
          <br>
          &nbsp; &nbsp; &nbsp; &nbsp; public void setField1( String field1 ) {<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.field1 = field1;<br>
          &nbsp; &nbsp; &nbsp; &nbsp; }<br>
          <br>
          &nbsp; &nbsp; &nbsp; &nbsp; public String getField2() {<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return field2;<br>
          &nbsp; &nbsp; &nbsp; &nbsp; }<br>
          <br>
          &nbsp; &nbsp; &nbsp; &nbsp; public void setField2( String field2 ) {<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.field2 = field2;<br>
          &nbsp; &nbsp; &nbsp; &nbsp; }<br>
          <br>
          &nbsp; &nbsp; &nbsp; &nbsp; public String toString() {<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return "A) " + field1 + ":" + field2;<br>
          &nbsp; &nbsp; &nbsp; &nbsp; }<br>
          &nbsp; &nbsp; }<br>
          <br>
          &nbsp; &nbsp; @Test<br>
          &nbsp; &nbsp; public void testExistsIterativeModifyBug() {<br>
          &nbsp; &nbsp; &nbsp; &nbsp; // JBRULES-2809<br>
          &nbsp; &nbsp; &nbsp; &nbsp; // This bug occurs when a tuple is modified, the
          remove/add<br>
          puts it onto the memory end<br>
          &nbsp; &nbsp; &nbsp; &nbsp; // However before this was done it would attempt to
          find the<br>
          next tuple, starting from itself<br>
          &nbsp; &nbsp; &nbsp; &nbsp; // This meant it would just re-add itself as the
          blocker, but<br>
          then be moved to end of the memory<br>
          &nbsp; &nbsp; &nbsp; &nbsp; // If this tuple was then removed or changed, the
          blocked was<br>
          unable to check previous tuples.<br>
          <br>
          &nbsp; &nbsp; &nbsp; &nbsp; String str = "";<br>
          &nbsp; &nbsp; &nbsp; &nbsp; str += "package org.simple \n";<br>
          &nbsp; &nbsp; &nbsp; &nbsp; str += "import " + A.class.getCanonicalName() + "\n";<br>
          &nbsp; &nbsp; &nbsp; &nbsp; str += "global java.util.List list \n";<br>
          &nbsp; &nbsp; &nbsp; &nbsp; str += "rule xxx \n";<br>
          &nbsp; &nbsp; &nbsp; &nbsp; str += "when \n";<br>
          &nbsp; &nbsp; &nbsp; &nbsp; str += " &nbsp;$f1 : A() \n";<br>
          &nbsp; &nbsp; &nbsp; &nbsp; str += " &nbsp; &nbsp;exists A(this != $f1, eval(field2 ==<br>
          $f1.getField2())) \n";<br>
          &nbsp; &nbsp; &nbsp; &nbsp; str += " &nbsp; &nbsp;eval( !$f1.getField1().equals(\"1\") )
          \n";<br>
          &nbsp; &nbsp; &nbsp; &nbsp; str += "then \n";<br>
          &nbsp; &nbsp; &nbsp; &nbsp; str += " &nbsp;list.add($f1); \n";<br>
          &nbsp; &nbsp; &nbsp; &nbsp; str += "end &nbsp;\n";<br>
          <br>
          &nbsp; &nbsp; &nbsp; &nbsp; KnowledgeBase kbase = loadKnowledgeBaseFromString( str
          );<br>
          <br>
          &nbsp; &nbsp; &nbsp; &nbsp; StatefulKnowledgeSession ksession =<br>
          kbase.newStatefulKnowledgeSession();<br>
          &nbsp; &nbsp; &nbsp; &nbsp; List list = new ArrayList();<br>
          &nbsp; &nbsp; &nbsp; &nbsp; ksession.setGlobal( "list",<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; list );<br>
          <br>
          &nbsp; &nbsp; &nbsp; &nbsp; A a1 = new A( "2",<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "2" );<br>
          &nbsp; &nbsp; &nbsp; &nbsp; A a2 = new A( "1",<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "2" );<br>
          &nbsp; &nbsp; &nbsp; &nbsp; A a3 = new A( "1",<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "2" );<br>
          <br>
          &nbsp; &nbsp; &nbsp; &nbsp; FactHandle fa1 = (FactHandle) ksession.insert( a1 );<br>
          &nbsp; &nbsp; &nbsp; &nbsp; FactHandle fa2 = (FactHandle) ksession.insert( a2 );<br>
          &nbsp; &nbsp; &nbsp; &nbsp; FactHandle fa3 = (FactHandle) ksession.insert( a3 );<br>
          <br>
          &nbsp; &nbsp; &nbsp; &nbsp; // a2, a3 are blocked by a1<br>
          &nbsp; &nbsp; &nbsp; &nbsp; // modify a1, so that a1,a3 are now blocked by a2<br>
          &nbsp; &nbsp; &nbsp; &nbsp; a1.setField2( "1" ); // Do<br>
          &nbsp; &nbsp; &nbsp; &nbsp; ksession.update( fa1,<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a1 );<br>
          &nbsp; &nbsp; &nbsp; &nbsp; a1.setField2( "2" ); // Undo<br>
          &nbsp; &nbsp; &nbsp; &nbsp; ksession.update( fa1,<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a1 );<br>
          <br>
          &nbsp; &nbsp; &nbsp; &nbsp; // modify a2, so that a1,a2 are now blocked by a3<br>
          &nbsp; &nbsp; &nbsp; &nbsp; a2.setField2( "1" ); // Do<br>
          &nbsp; &nbsp; &nbsp; &nbsp; ksession.update( fa2,<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a2 );<br>
          &nbsp; &nbsp; &nbsp; &nbsp; a2.setField2( "2" ); // Undo<br>
          &nbsp; &nbsp; &nbsp; &nbsp; ksession.update( fa2,<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a2 );<br>
          <br>
          &nbsp; &nbsp; &nbsp; &nbsp; // modify a3 to cycle, so that it goes on the memory
          end, but<br>
          in a previous bug still blocked a1<br>
          &nbsp; &nbsp; &nbsp; &nbsp; ksession.update( fa3,<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a3 );<br>
          <br>
          &nbsp; &nbsp; &nbsp; &nbsp; a3.setField2( "1" ); // Do<br>
          &nbsp; &nbsp; &nbsp; &nbsp; ksession.update( fa3,<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;a3 );<br>
          &nbsp; &nbsp; &nbsp; &nbsp; ksession.fireAllRules();<br>
          &nbsp; &nbsp; &nbsp; &nbsp; assertEquals( 1,<br>
          &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; list.size() ); // a2 should still be
          blocked by<br>
          a1, but bug from previous update hanging onto blocked<br>
          <br>
          &nbsp; &nbsp; &nbsp; &nbsp; ksession.dispose();<br>
          &nbsp; &nbsp; }<br>
          <br>
          _______________________________________________<br>
          rules-dev mailing list<br>
          <a moz-do-not-send="true"
            href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
          <a moz-do-not-send="true"
            href="https://lists.jboss.org/mailman/listinfo/rules-dev"
            target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
        </blockquote>
      </div>
      <br>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
rules-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>