[jboss-svn-commits] JBL Code SVN: r17023 - in labs/jbossrules/branches/Branch_4_0_2_SOA_4_2: drools-compiler/src/test/resources/org/drools/integrationtests and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Dec 4 12:16:30 EST 2007


Author: fmeyer
Date: 2007-12-04 12:16:30 -0500 (Tue, 04 Dec 2007)
New Revision: 17023

Modified:
   labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java
   labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-compiler/src/test/resources/org/drools/integrationtests/test_ConsequenceBuilderException.drl
   labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/base/evaluators/ObjectFactory.java
Log:
SOA-208 - NullPointerException at JavaConsequenceBuilder.java:54 on RHS for simplest of consequences related to JBRULES-1313 


Modified: labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java
===================================================================
--- labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java	2007-12-04 16:53:57 UTC (rev 17022)
+++ labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java	2007-12-04 17:16:30 UTC (rev 17023)
@@ -57,6 +57,7 @@
 import org.drools.PersonFinal;
 import org.drools.PersonInterface;
 import org.drools.PersonWithEquals;
+import org.drools.PolymorphicFact;
 import org.drools.Primitives;
 import org.drools.QueryResult;
 import org.drools.QueryResults;
@@ -4386,4 +4387,29 @@
         
         assertTrue( builder.hasErrors() );
     }
+    
+    public void testRuntimeTypeCoercion() throws Exception {
+        final PackageBuilder builder = new PackageBuilder();
+        builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_RuntimeTypeCoercion.drl" ) ) );
+        final Package pkg = builder.getPackage();
+
+        final RuleBase ruleBase = getRuleBase();
+        ruleBase.addPackage( pkg );
+        final WorkingMemory workingMemory = ruleBase.newStatefulSession();
+
+        final List list = new ArrayList();
+        workingMemory.setGlobal( "results",
+                                 list );
+        
+        final PolymorphicFact fact = new PolymorphicFact( new Integer( 10 ) );
+        final FactHandle handle = workingMemory.insert( fact );
+        
+        workingMemory.fireAllRules();
+        
+        assertEquals( 1, list.size() );
+        assertEquals( fact.getData(), list.get( 0 ) );
+
+    }
+
+    
 }
\ No newline at end of file

Modified: labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-compiler/src/test/resources/org/drools/integrationtests/test_ConsequenceBuilderException.drl
===================================================================
--- labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-compiler/src/test/resources/org/drools/integrationtests/test_ConsequenceBuilderException.drl	2007-12-04 16:53:57 UTC (rev 17022)
+++ labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-compiler/src/test/resources/org/drools/integrationtests/test_ConsequenceBuilderException.drl	2007-12-04 17:16:30 UTC (rev 17023)
@@ -8,3 +8,12 @@
 	    // this must generate a compile error, but not NPE
 	    results.add(message without quotes);
 end
+
+rule "another test"
+    salience 10
+
+   when
+    eval( true ) 
+then
+    System.out.println(1);
+end
\ No newline at end of file

Modified: labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/base/evaluators/ObjectFactory.java
===================================================================
--- labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/base/evaluators/ObjectFactory.java	2007-12-04 16:53:57 UTC (rev 17022)
+++ labs/jbossrules/branches/Branch_4_0_2_SOA_4_2/drools-core/src/main/java/org/drools/base/evaluators/ObjectFactory.java	2007-12-04 17:16:30 UTC (rev 17023)
@@ -565,16 +565,6 @@
             if( arg0 instanceof String ) {
                 return arg0.equals( arg1.toString() );
             }
-            if( arg0 instanceof Boolean ) {
-                if( arg1 instanceof String ) {
-                    return ((Boolean)arg0).booleanValue() == Boolean.valueOf( (String)arg1 ).booleanValue();
-                }
-            }
-            if( arg0 instanceof Character ) {
-                if( arg1 instanceof String && ((String) arg1).length() == 1 ) {
-                    return ((Character)arg0).charValue() == ((String)arg1).charAt( 0 );
-                }
-            }
             return arg0.equals( arg1 );
         }
     }
@@ -625,11 +615,7 @@
                 }
                 
             }
-            try {
-                return ((Comparable)arg0).compareTo( arg1 );
-            } catch ( ClassCastException cce ) {
-                throw new ClassCastException( "Not possible to compare a "+arg0.getClass()+" with a "+arg1.getClass());
-            }
+            return ((Comparable)arg0).compareTo( arg1 );
         }
     }
     




More information about the jboss-svn-commits mailing list