[jboss-svn-commits] JBL Code SVN: r12914 - labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jun 28 04:54:13 EDT 2007
Author: mark.proctor at jboss.com
Date: 2007-06-28 04:54:13 -0400 (Thu, 28 Jun 2007)
New Revision: 12914
Modified:
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/StatelessSessionTest.java
Log:
JBRULES-957 Async method calls don't work
-added more stateless method call tests
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/StatelessSessionTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/StatelessSessionTest.java 2007-06-28 08:40:52 UTC (rev 12913)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/StatelessSessionTest.java 2007-06-28 08:54:13 UTC (rev 12914)
@@ -9,6 +9,7 @@
import org.drools.RuleBaseConfiguration;
import org.drools.RuleBaseFactory;
import org.drools.StatelessSession;
+import org.drools.StatelessSessionResult;
import org.drools.WorkingMemory;
import org.drools.compiler.PackageBuilder;
import org.drools.rule.Package;
@@ -17,7 +18,7 @@
public class StatelessSessionTest extends TestCase {
final List list = new ArrayList();
-
+
protected RuleBase getRuleBase() throws Exception {
return RuleBaseFactory.newRuleBase( RuleBase.RETEOO,
@@ -29,34 +30,34 @@
return RuleBaseFactory.newRuleBase( RuleBase.RETEOO,
config );
}
-
+
public void testSingleObjectAssert() throws Exception {
StatelessSession session = getSession();
-
+
final Cheese stilton = new Cheese( "stilton",
5 );
session.execute( stilton );
assertEquals( "stilton",
- list.get( 0 ) );
+ list.get( 0 ) );
}
-
+
public void testArrayObjectAssert() throws Exception {
StatelessSession session = getSession();
-
+
final Cheese stilton = new Cheese( "stilton",
5 );
- session.execute( new Object[] { stilton } );
+ session.execute( new Object[]{stilton} );
assertEquals( "stilton",
- list.get( 0 ) );
- }
-
+ list.get( 0 ) );
+ }
+
public void testCollectionObjectAssert() throws Exception {
StatelessSession session = getSession();
-
+
final Cheese stilton = new Cheese( "stilton",
5 );
@@ -65,53 +66,91 @@
session.execute( collection );
assertEquals( "stilton",
- list.get( 0 ) );
- }
-
+ list.get( 0 ) );
+ }
+
+ public void testSingleObjectAssertWithResults() throws Exception {
+ StatelessSession session = getSession();
+
+ final Cheese stilton = new Cheese( "stilton",
+ 5 );
+
+ StatelessSessionResult result = session.executeWithResults( stilton );
+
+ assertSame( stilton,
+ result.iterateObjects().next() );
+ }
+
+ public void testArrayObjectAssertWithResults() throws Exception {
+ StatelessSession session = getSession();
+
+ final Cheese stilton = new Cheese( "stilton",
+ 5 );
+
+ StatelessSessionResult result = session.executeWithResults( new Object[]{stilton} );
+
+ assertSame( stilton,
+ result.iterateObjects().next() );
+ }
+
+ public void testCollectionObjectAssertWithResults() throws Exception {
+ StatelessSession session = getSession();
+
+ final Cheese stilton = new Cheese( "stilton",
+ 5 );
+
+ List collection = new ArrayList();
+ collection.add( stilton );
+ StatelessSessionResult result = session.executeWithResults( collection );
+
+ assertSame( stilton,
+ result.iterateObjects().next() );
+ }
+
public void testAsynSingleOjbectcAssert() throws Exception {
StatelessSession session = getSession();
-
+
final Cheese stilton = new Cheese( "stilton",
5 );
session.asyncExecute( stilton );
-
+
Thread.sleep( 100 );
assertEquals( "stilton",
- list.get( 0 ) );
+ list.get( 0 ) );
}
-
+
public void testAsynArrayOjbectcAssert() throws Exception {
StatelessSession session = getSession();
-
+
final Cheese stilton = new Cheese( "stilton",
5 );
- session.asyncExecute( new Object[] { stilton } );
-
+ session.asyncExecute( new Object[]{stilton} );
+
Thread.sleep( 100 );
assertEquals( "stilton",
- list.get( 0 ) );
- }
-
+ list.get( 0 ) );
+ }
+
public void testAsynCollectionOjbectcAssert() throws Exception {
StatelessSession session = getSession();
-
+
final Cheese stilton = new Cheese( "stilton",
5 );
List collection = new ArrayList();
collection.add( stilton );
session.execute( collection );
-
+
Thread.sleep( 100 );
assertEquals( "stilton",
- list.get( 0 ) );
- }
-
+ list.get( 0 ) );
+ }
+
private StatelessSession getSession() throws Exception {
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "literal_rule_test.drl" ) ) );
More information about the jboss-svn-commits
mailing list