<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
try the 4.0.x branch, as I believe that was fixed there and will be
part of the next release. The next release is just waiting for the next
bug fix for MVEL, which hopefully should be next week..<br>
<a class="moz-txt-link-freetext" href="http://anonsvn.labs.jboss.com/labs/jbossrules/branches/4.0.x/">http://anonsvn.labs.jboss.com/labs/jbossrules/branches/4.0.x/</a><br>
<br>
Mark<br>
Dennis Ryan wrote:
<blockquote cite="mid:941775.9858.qm@web30802.mail.mud.yahoo.com"
 type="cite">
  <style type="text/css"><!-- DIV {margin:0px;} --></style>
  <div style="font-family: arial,helvetica,sans-serif; font-size: 10pt;">
  <div>Hi, <br>
  <br>
I've migrated from 3.0.6 to 4.0.4 of drools and an existing test case
is now failing. The test case tests dynamically changing the rules by
adding a rule file to the existing rulesBase that is a completely new
package, then asserting that the existing rules fire and the newly
added rules fire. Up to this point it works as expected, the original
package of base rules fire and the newly added package of rules fires
also. Next it adds new rules that essentially replace the ones just
added and fires the rules again. This time only the newest rules added
fire and the existing rules that did not change at all and are in a
completely different package then the rules just added DIDN'T fire.
Upon some debugging it looks like the ruleBase has both packages, the
existing package and the latest updated rules package, in it.<br>
  <br>
any advice appreciated please!!!! <br>
  <br>
thanks in advance!<br>
  <br>
here the test:<br>
  <br>
public void testUpdatingPackage() throws Exception {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; logger.info("--------- testUpdatingPackage ----------");<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; //reinitialize ruleBaseBuilder - some base rules that i always
want to run<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
ruleBaseBuilder.setRuleFile("com/xxx/coreservice/um/rules/um.drl");<br>
  <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; String userName = "user";<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; CsUser user = Helpers.createUser(userName, userName, null);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Set the displayname to null. If the default rules fire, <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // it should be populated after running the rules.<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; user.setDisplayName(null);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; user.setDescription("base");<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Add product's rules on the fly - some new rules<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
ruleBaseBuilder.addRulesFile("com/xxx/coreservice/um/ext/rules/p1.drl");<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ruleInterceptor.addUser(user);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // assert that the default rule is invoked by checking the
display name<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; assertEquals(user.getSurname() + ", " + user.getGivenName(),
user.getDisplayName());<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Check that the product extension did run<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; logger.info("User's description: " + user.getDescription());<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; assertTrue(user.getDescription().indexOf("p1ext") &gt; 0);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // now update product's rules on the fly - change some of the
new rules!<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
ruleBaseBuilder.addRulesFile("com/xxx/coreservice/um/ext/rules/p1updated.drl");<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; user = Helpers.createUser(userName, userName, null);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Set the displayname to null. If the default rules fire, <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // it should be populated after running the rules.<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; user.setDisplayName(null);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; user.setDescription("base");<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ruleInterceptor.addUser(user);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // assert that the default rule is invoked by checking the
display name&nbsp; - ASSERTION FAILS HERE because the original base rules
dont fire and they are supposed to fill in displayName<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; assertEquals(user.getSurname() + ", " + user.getGivenName(),
user.getDisplayName());<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // Check that the updated product extension did run<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; logger.info("User's description: " + user.getDescription());<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; assertTrue(user.getDescription().indexOf("p1extupdated") &gt;
0);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; // This is to check that the old rule didn't run.<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; assertEquals(user.getDescription().indexOf("p1extupdated"), <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; user.getDescription().indexOf("p1ext"));<br>
&nbsp;&nbsp;&nbsp; }<br>
  <br>
and the rules:<br>
  <br>
//---------------------p1updated-------------------------<br>
package com.xxx.coreservice.um.ext.rules<br>
  <br>
import com.xxx.coreservice.persistence.user.CsUser;<br>
  <br>
import com.xxx.common.logging.client.Logger;<br>
  <br>
// TODO: Can these globals be inherited?<br>
global Logger logger;<br>
  <br>
// TODO: Can this method be put into a helper? <br>
// The disadvantage with that is that now we don't really know which
rule file the log<br>
// was coming from.<br>
function void log(Logger logger, String msg) {<br>
&nbsp;&nbsp;&nbsp; if (logger.isFineEnabled()) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; logger.fine(msg);<br>
&nbsp;&nbsp;&nbsp; }<br>
}<br>
  <br>
rule "testRule"<br>
&nbsp;&nbsp;&nbsp; no-loop true<br>
&nbsp;&nbsp;&nbsp; agenda-group "um_add"<br>
&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp; when<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; user : CsUser()<br>
&nbsp;&nbsp;&nbsp; then<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; log(logger, "P1 updated test rule");<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; user.setDescription(user.getDescription() + ".p1extupdated");<br>
end<br>
  </div>
  </div>
  <br>
  <hr size="1">Be a better friend, newshound, and know-it-all with
Yahoo! Mobile. <a moz-do-not-send="true"
 href="http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ%20">
Try it now.</a>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
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>