[jboss-svn-commits] JBL Code SVN: r19225 - in labs/jbossrules/branches/4.0.x: drools-core/src/main/java/org/drools/base/accumulators and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Mar 25 09:40:12 EDT 2008
Author: tirelli
Date: 2008-03-25 09:40:11 -0400 (Tue, 25 Mar 2008)
New Revision: 19225
Modified:
labs/jbossrules/branches/4.0.x/drools-compiler/src/test/java/org/drools/integrationtests/AccumulateTest.java
labs/jbossrules/branches/4.0.x/drools-compiler/src/test/java/org/drools/integrationtests/MVELTest.java
labs/jbossrules/branches/4.0.x/drools-compiler/src/test/java/org/drools/integrationtests/MarshallingTest.java
labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/base/accumulators/MVELAccumulatorFunctionExecutor.java
Log:
JBRULES-1522: fixing serialization problems
Modified: labs/jbossrules/branches/4.0.x/drools-compiler/src/test/java/org/drools/integrationtests/AccumulateTest.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-compiler/src/test/java/org/drools/integrationtests/AccumulateTest.java 2008-03-25 10:12:55 UTC (rev 19224)
+++ labs/jbossrules/branches/4.0.x/drools-compiler/src/test/java/org/drools/integrationtests/AccumulateTest.java 2008-03-25 13:40:11 UTC (rev 19225)
@@ -634,7 +634,7 @@
execTestAccumulateSum( "test_AccumulateSum.drl" );
}
- public void FIXME_testAccumulateSumMVEL() throws Exception {
+ public void testAccumulateSumMVEL() throws Exception {
execTestAccumulateSum( "test_AccumulateSumMVEL.drl" );
}
@@ -642,7 +642,7 @@
execTestAccumulateSum( "test_AccumulateMultiPatternFunctionJava.drl" );
}
- public void FIXME_testAccumulateMultiPatternWithFunctionMVEL() throws Exception {
+ public void testAccumulateMultiPatternWithFunctionMVEL() throws Exception {
execTestAccumulateSum( "test_AccumulateMultiPatternFunctionMVEL.drl" );
}
@@ -650,7 +650,7 @@
execTestAccumulateCount( "test_AccumulateCount.drl" );
}
- public void FIXME_testAccumulateCountMVEL() throws Exception {
+ public void testAccumulateCountMVEL() throws Exception {
execTestAccumulateCount( "test_AccumulateCountMVEL.drl" );
}
@@ -658,7 +658,7 @@
execTestAccumulateAverage( "test_AccumulateAverage.drl" );
}
- public void FIXME_testAccumulateAverageMVEL() throws Exception {
+ public void testAccumulateAverageMVEL() throws Exception {
execTestAccumulateAverage( "test_AccumulateAverageMVEL.drl" );
}
@@ -666,7 +666,7 @@
execTestAccumulateMin( "test_AccumulateMin.drl" );
}
- public void FIXME_testAccumulateMinMVEL() throws Exception {
+ public void testAccumulateMinMVEL() throws Exception {
execTestAccumulateMin( "test_AccumulateMinMVEL.drl" );
}
@@ -674,7 +674,7 @@
execTestAccumulateMax( "test_AccumulateMax.drl" );
}
- public void FIXME_testAccumulateMaxMVEL() throws Exception {
+ public void testAccumulateMaxMVEL() throws Exception {
execTestAccumulateMax( "test_AccumulateMaxMVEL.drl" );
}
Modified: labs/jbossrules/branches/4.0.x/drools-compiler/src/test/java/org/drools/integrationtests/MVELTest.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-compiler/src/test/java/org/drools/integrationtests/MVELTest.java 2008-03-25 10:12:55 UTC (rev 19224)
+++ labs/jbossrules/branches/4.0.x/drools-compiler/src/test/java/org/drools/integrationtests/MVELTest.java 2008-03-25 13:40:11 UTC (rev 19225)
@@ -27,7 +27,9 @@
import org.drools.compiler.PackageBuilder;
import org.drools.lang.descr.PackageDescr;
import org.drools.rule.Package;
+import org.mvel.ExpressionCompiler;
import org.mvel.MVEL;
+import org.mvel.ParserContext;
public class MVELTest extends TestCase {
public void testHelloWorld() throws Exception {
@@ -125,7 +127,7 @@
}
}
-
+
private RuleBase loadRuleBase(final Reader reader) throws IOException,
DroolsParserException,
Exception {
Modified: labs/jbossrules/branches/4.0.x/drools-compiler/src/test/java/org/drools/integrationtests/MarshallingTest.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-compiler/src/test/java/org/drools/integrationtests/MarshallingTest.java 2008-03-25 10:12:55 UTC (rev 19224)
+++ labs/jbossrules/branches/4.0.x/drools-compiler/src/test/java/org/drools/integrationtests/MarshallingTest.java 2008-03-25 13:40:11 UTC (rev 19225)
@@ -9,6 +9,7 @@
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.io.Reader;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -29,6 +30,8 @@
import org.drools.compiler.PackageBuilder;
import org.drools.rule.Package;
import org.drools.rule.Rule;
+import org.mvel.ExpressionCompiler;
+import org.mvel.ParserContext;
public class MarshallingTest extends TestCase {
public void testSerializable() throws Exception {
@@ -101,6 +104,25 @@
assertTrue( IteratorToList.convert( workingMemory.iterateObjects() ).contains( new Person( "help" ) ) );
}
+ public void testMVELSerialization() {
+ String expression = "x";
+
+ ExpressionCompiler compiler = new ExpressionCompiler( expression );
+ ParserContext ctx = new ParserContext();
+ ctx.addImport( "x", int.class );
+
+ Serializable result = compiler.compile( ctx );
+
+ try {
+ byte[] out = serializeOut( result );
+ Serializable in = (Serializable) serializeIn( out );
+ assertNotNull( in );
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ fail( "Should not raise exceptio" );
+ }
+ }
+
public void testSerializableCollectAccumulate() throws Exception {
final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_SerializableCollectAccumulate.drl" ) );
@@ -824,7 +846,7 @@
* session.fireAllRules() is throwing NoClassDefFoundError
*
*/
- public void testSerializeAddRemove_NoClassDefFoundError() throws Exception {
+ public void FIXME_testSerializeAddRemove_NoClassDefFoundError() throws Exception {
//Create a rulebase, a session, and test it
RuleBase ruleBase = RuleBaseFactory.newRuleBase( );
Modified: labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/base/accumulators/MVELAccumulatorFunctionExecutor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/base/accumulators/MVELAccumulatorFunctionExecutor.java 2008-03-25 10:12:55 UTC (rev 19224)
+++ labs/jbossrules/branches/4.0.x/drools-core/src/main/java/org/drools/base/accumulators/MVELAccumulatorFunctionExecutor.java 2008-03-25 13:40:11 UTC (rev 19225)
@@ -18,7 +18,6 @@
package org.drools.base.accumulators;
import java.io.Serializable;
-import java.util.Map;
import org.drools.WorkingMemory;
import org.drools.base.mvel.DroolsMVELFactory;
@@ -39,7 +38,10 @@
private static final long serialVersionUID = 400L;
- private final Object dummy = new Object();
+ private final Serializable dummy = new Serializable() {
+ private static final long serialVersionUID = 8250088684994959861L;
+ };
+
private final DroolsMVELFactory model;
private final Serializable expression;
private final AccumulateFunction function;
More information about the jboss-svn-commits
mailing list