]
Edson Tirelli closed JBRULES-586.
---------------------------------
Fix Version/s: 3.1-m2
Resolution: Done
$ svn log -r 9538 -v
------------------------------------------------------------------------
r9538 | tirelli | 2007-02-15 17:49:28 -0300 (Thu, 15 Feb 2007) | 12 lines
Changed paths:
M
/labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DrlParser.java
M
/labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/ParserError.java
M /labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/DRLLexer.java
M /labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/DRLParser.java
M /labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/Expander.java
M
/labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/ExpanderException.java
A
/labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMapping.java
A
/labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMappingEntry.java
A
/labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMappingFile.java
A
/labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DSLMappingParseException.java
A
/labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultDSLMappingEntry.java
M
/labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultExpander.java
M
/labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/DefaultExpanderResolver.java
D
/labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/LineBasedExpander.java
D /labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/lang/dsl/template
M /labs/jbossrules/trunk/drools-compiler/src/main/resources/org/drools/lang/DRL.g
M
/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/IntegrationCases.java
M
/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/MockExpander.java
M
/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/RuleParserTest.java
A
/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/DSLMappingFileTest.java
A
/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/DefaultDSLMappingEntryTest.java
A
/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/DefaultExpanderTest.java
D
/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/LineExpanderTest.java
D /labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/lang/dsl/template
A
/labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/lang/dsl/test_expansion.drl
A
/labs/jbossrules/trunk/drools-compiler/src/test/resources/org/drools/lang/dsl/test_metainfo.dsl
JBRULES-268 JBRULES-274 JBRULES-351 JBRULES-476 JBRULES-586:
* Removed DSL parsing from the DRL parser (JBRULES-351)
* Implemented a DSL preprocessor ( Expander ) based on regexp (JBRULES-351)
* Implemented a new DSL file parser for map readings
* Added ability to expand a DSL and get the result without parsing DRL (JBRULES-268)
* Fixed problems with empty lines (JBRULES-274)
* Made DSL preprocessor space insentive (JBRULES-476)
* Fixed problems with capturing spaces (JBRULES-586)
* Added unit tests and integration tests
------------------------------------------------------------------------
DefaultExpander incorrectly strips leading and trailing spaces
--------------------------------------------------------------
Key: JBRULES-586
URL:
http://jira.jboss.com/jira/browse/JBRULES-586
Project: JBoss Rules
Issue Type: Bug
Security Level: Public(Everyone can see)
Components: Drl Parser/Builder
Affects Versions: 3.0.5
Reporter: Adam Lewandowski
Assigned To: Edson Tirelli
Fix For: 3.1-m2
When using a DSL expander, token values with leading or trailing spaces get the spaces
stripped when inserted into the target template. This causes the resulting rule definition
to be incorrect.
Example:
DSL: [when]String is "{value}"=SomeFact(value=="{value}")
Input string (note the trailing space): String is "blah "
Expanded string (note the lack of a trailing space): SomeFact(value=="blah")
The same thing occurs for leading spaces as well. Internal spaces are fine.
Also interesting is that if there are more than one leading/trailing space,
NLExpressionCompiler throws an IllegalArgumentException: Expression was not expandable:
String is " blah"
The problem seems to be in the org.drools.lang.dsl.template.Chunk class. It is stripping
the leading/trailing spaces from values in the map populated by buildValueMap().
Unit Test:
import java.io.StringReader;
import org.drools.lang.dsl.DefaultExpander;
import junit.framework.TestCase;
public class DroolsDslTemplateTest extends TestCase {
private DefaultExpander expander;
public void setUp() {
String DSL = "[when]String is
\"{value}\"=SomeFact(value==\"{value}\")";
StringReader dslSrc = new StringReader(DSL);
expander = new DefaultExpander(dslSrc);
}
public void testExpandNoSpaces() {
String result = expander.expand("when", "String is
\"blah\"");
assertEquals("SomeFact(value==\"blah\")", result);
}
public void testExpandWithLeadingSpace() {
String result = expander.expand("when", "String is \"
blah\"");
assertEquals("SomeFact(value==\" blah\")", result);
}
public void testExpandWithMultipleLeadingSpaces() {
String result = expander.expand("when", "String is \"
blah\"");
assertEquals("SomeFact(value==\" blah\")", result);
}
public void testExpandWithTrailingSpace() {
String result = expander.expand("when", "String is \" blah
\"");
assertEquals("SomeFact(value==\"blah \")", result);
}
public void testExpandWithMultipleTrailingSpaces() {
String result = expander.expand("when", "String is \"blah
\"");
assertEquals("SomeFact(value==\"blah \")", result);
}
public void testExpandWithInternalSpace() {
String result = expander.expand("when", "String is \"bl
ah\"");
assertEquals("SomeFact(value==\"bl ah\")", result);
}
public void testExpandWithMultipleInternalSpaces() {
String result = expander.expand("when", "String is \"bl
ah\"");
assertEquals("SomeFact(value==\"bl ah\")", result);
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: