01: package org.drools.compiler;
02:
03: import java.io.StringReader;
04:
05: import junit.framework.TestCase;
06:
07: public class DrlParserTest extends TestCase {
08:
09: public void testExpandDRL() throws Exception {
10: String dsl = "[condition]Something=Something()\n[then]another=another();";
11: String drl = "rule 'foo' \n when \n Something \n then \n another \nend";
12:
13: DrlParser parser = new DrlParser();
14: String result = parser.getExpandedDRL(drl,
15: new StringReader(dsl));
16: assertEqualsIgnoreWhitespace(
17: "rule 'foo' \n when \n Something() \n then \n another(); \nend",
18: result);
19: }
20:
21: private void assertEqualsIgnoreWhitespace(final String expected,
22: final String actual) {
23: final String cleanExpected = expected.replaceAll("\\s+", "");
24: final String cleanActual = actual.replaceAll("\\s+", "");
25:
26: assertEquals(cleanExpected, cleanActual);
27: }
28: }
|