[jboss-svn-commits] JBL Code SVN: r24610 - in labs/jbossrules/trunk: drools-compiler/src/test/resources/org/drools/integrationtests and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Jan 8 16:41:57 EST 2009
Author: tirelli
Date: 2009-01-08 16:41:57 -0500 (Thu, 08 Jan 2009)
New Revision: 24610
Modified:
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/CepEspTest.java
labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_CEP_SimpleEventAssertion.drl
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/TypeDeclaration.java
Log:
JBRULES-1795: fixing regression where types could not be declared in a different package
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/CepEspTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/CepEspTest.java 2009-01-08 17:58:51 UTC (rev 24609)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/CepEspTest.java 2009-01-08 21:41:57 UTC (rev 24610)
@@ -26,6 +26,7 @@
import org.drools.compiler.DrlParser;
import org.drools.compiler.DroolsParserException;
import org.drools.compiler.PackageBuilder;
+import org.drools.integrationtests.eventgenerator.PseudoSessionClock;
import org.drools.lang.descr.PackageDescr;
import org.drools.rule.Package;
import org.drools.time.SessionPseudoClock;
@@ -872,6 +873,60 @@
}
+ public void FIXME_testDelayingNot() throws Exception {
+ // read in the source
+ final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_CEP_DelayingNot.drl" ) );
+ final RuleBaseConfiguration rbconf = new RuleBaseConfiguration();
+ rbconf.setEventProcessingMode( EventProcessingMode.STREAM );
+ final RuleBase ruleBase = loadRuleBase( reader,
+ rbconf );
+
+ SessionConfiguration conf = new SessionConfiguration();
+ conf.setClockType( ClockType.PSEUDO_CLOCK );
+ StatefulSession wm = ruleBase.newStatefulSession( conf );
+
+ final List results = new ArrayList();
+
+ wm.setGlobal( "results",
+ results );
+
+ SessionPseudoClock clock = (SessionPseudoClock) wm.getSessionClock();
+
+ clock.advanceTime( 10, TimeUnit.SECONDS );
+
+ EventFactHandle st1 = (EventFactHandle) wm.insert( new StockTick( 1, "DROO", 100, clock.getCurrentTime() ) );
+
+ wm.fireAllRules();
+
+ // should not fire, because it must wait 10 seconds
+ assertEquals( 0,
+ results.size() );
+
+ clock.advanceTime( 5, TimeUnit.SECONDS );
+
+ EventFactHandle st2 = (EventFactHandle) wm.insert( new StockTick( 1, "DROO", 80, clock.getCurrentTime() ) );
+
+ wm.fireAllRules();
+
+ // should still not fire, because it must wait 5 more seconds, and st2 has lower price (80)
+ assertEquals( 0,
+ results.size() );
+ // assert new data
+ wm.fireAllRules();
+
+ clock.advanceTime( 6, TimeUnit.SECONDS );
+
+ wm.fireAllRules();
+
+ // should fire, because waited for 10 seconds and no other event arrived with a price increase
+ assertEquals( 1,
+ results.size() );
+
+ assertEquals( st1.getObject(),
+ results.get( 0 ) );
+
+ }
+
// public void FIXME_testTransactionCorrelation() throws Exception {
// // read in the source
// final Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_TransactionCorrelation.drl" ) );
Modified: labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_CEP_SimpleEventAssertion.drl
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_CEP_SimpleEventAssertion.drl 2009-01-08 17:58:51 UTC (rev 24609)
+++ labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/integrationtests/test_CEP_SimpleEventAssertion.drl 2009-01-08 21:41:57 UTC (rev 24610)
@@ -1,4 +1,4 @@
-package org.drools;
+package org.drools.test;
import org.drools.StockTick;
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java 2009-01-08 17:58:51 UTC (rev 24609)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/common/AbstractRuleBase.java 2009-01-08 21:41:57 UTC (rev 24610)
@@ -286,7 +286,7 @@
this.classTypeDeclaration = new HashMap<Class< ? >, TypeDeclaration>();
for ( Package pkg : this.pkgs.values() ) {
for ( TypeDeclaration type : pkg.getTypeDeclarations().values() ) {
- type.setTypeClass( this.rootClassLoader.loadClass( pkg.getName() + "." + type.getTypeName() ) );
+ type.setTypeClass( this.rootClassLoader.loadClass( type.getTypeClassName() ) );
this.classTypeDeclaration.put( type.getTypeClass(),
type );
}
@@ -463,7 +463,7 @@
// add type declarations
for ( TypeDeclaration type : newPkg.getTypeDeclarations().values() ) {
lastType = type;
- type.setTypeClass( this.rootClassLoader.loadClass( pkg.getName() + "." + type.getTypeName() ) );
+ type.setTypeClass( this.rootClassLoader.loadClass( type.getTypeClassName() ) );
// @TODO should we allow overrides? only if the class is not in use.
if ( !this.classTypeDeclaration.containsKey( type.getTypeClass() ) ) {
// add to rulebase list of type declarations
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/TypeDeclaration.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/TypeDeclaration.java 2009-01-08 17:58:51 UTC (rev 24609)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/rule/TypeDeclaration.java 2009-01-08 21:41:57 UTC (rev 24610)
@@ -89,6 +89,7 @@
private InternalReadAccessor durationExtractor;
private InternalReadAccessor timestampExtractor;
private transient Class< ? > typeClass;
+ private String typeClassName;
private FactTemplate typeTemplate;
private ClassDefinition typeClassDef;
private Resource resource;
@@ -105,7 +106,6 @@
this.format = Format.POJO;
this.durationAttribute = null;
this.timestampAttribute = null;
- //this.typeClass = null;
this.typeTemplate = null;
}
@@ -116,7 +116,7 @@
this.format = (Format) in.readObject();
this.durationAttribute = (String) in.readObject();
this.timestampAttribute = (String) in.readObject();
- //this.typeClass = (Class< ? >) in.readObject();
+ this.typeClassName = (String) in.readObject();
this.typeTemplate = (FactTemplate) in.readObject();
this.typeClassDef = (ClassDefinition) in.readObject();
this.durationExtractor = (InternalReadAccessor) in.readObject();
@@ -131,7 +131,7 @@
out.writeObject( format );
out.writeObject( durationAttribute );
out.writeObject( timestampAttribute );
- //out.writeObject( typeClass );
+ out.writeObject( typeClassName );
out.writeObject( typeTemplate );
out.writeObject( typeClassDef );
out.writeObject( durationExtractor );
@@ -218,6 +218,9 @@
if ( this.typeClassDef != null ) {
this.typeClassDef.setDefinedClass( this.typeClass );
}
+ if( this.typeClass != null ) {
+ this.typeClassName = this.typeClass.getName();
+ }
}
/**
@@ -349,4 +352,12 @@
this.expirationOffset = expirationOffset;
}
+ public String getTypeClassName() {
+ return typeClassName;
+ }
+
+ public void setTypeClassName(String typeClassName) {
+ this.typeClassName = typeClassName;
+ }
+
}
More information about the jboss-svn-commits
mailing list