01: package org.drools.compiler;
02:
03: import org.drools.commons.jci.problems.CompilationProblem;
04: import org.drools.lang.descr.AndDescr;
05: import org.drools.rule.Rule;
06:
07: import junit.framework.TestCase;
08:
09: public class RuleErrorTest extends TestCase {
10:
11: public void testNewLineInMessage() {
12: CompilationProblem[] probs = new CompilationProblem[3];
13: probs[0] = new MockCompilationProblem();
14: probs[1] = new MockCompilationProblem();
15: probs[2] = new MockCompilationProblem();
16:
17: RuleError err = new RuleError(new Rule("ruleName"),
18: new AndDescr(), probs, "IM IN YR EROR");
19: assertNotNull(err.toString());
20: String msg = err.getMessage();
21:
22: assertTrue(msg.indexOf("IM IN YR EROR") != -1);
23: System.err.println(msg);
24: assertEquals("IM IN YR EROR problem\nproblem\nproblem", msg);
25:
26: }
27:
28: class MockCompilationProblem implements CompilationProblem {
29:
30: public int getEndColumn() {
31: return 0;
32: }
33:
34: public int getEndLine() {
35: return 0;
36: }
37:
38: public String getFileName() {
39: return "X";
40: }
41:
42: public String getMessage() {
43: return "problem";
44: }
45:
46: public int getStartColumn() {
47: return 0;
48: }
49:
50: public int getStartLine() {
51: return 0;
52: }
53:
54: public boolean isError() {
55: return true;
56: }
57:
58: }
59:
60: }
|