[jboss-svn-commits] JBL Code SVN: r11340 - in labs/jbossrules/trunk/drools-compiler/src: main/java/org/drools/rule/builder and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Apr 25 21:49:15 EDT 2007
Author: mark.proctor at jboss.com
Date: 2007-04-25 21:49:15 -0400 (Wed, 25 Apr 2007)
New Revision: 11340
Added:
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DroolsError.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/FactTemplateError.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/FunctionError.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/GlobalError.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilderErrors.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/ParserError.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaDialectError.java
Removed:
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DroolsError.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/FactTemplateError.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/FunctionError.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/GlobalError.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/ParserError.java
Modified:
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/RuleBaseLoader.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/RuleError.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/FunctionBuilder.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuilder.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaConsequenceBuilder.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaDialect.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaFunctionBuilder.java
labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/PackageStore.java
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderTest.java
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/DslTest.java
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/DynamicRulesTest.java
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/FirstOrderLogicTest.java
labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java
Log:
JBRULES-713 Make Dialects Pluggeable
-PackageStore now writes out error messages
-Changes some of the runtime exceptiosn to add a DroolsError to the results List
Deleted: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DroolsError.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DroolsError.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DroolsError.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -1,26 +0,0 @@
-package org.drools.compiler;
-
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public abstract class DroolsError {
-
- /**
- * Classes that extend this must provide a printable message,
- * which summarises the error.
- */
- public abstract String getMessage();
-}
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DroolsError.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DroolsError.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/DroolsError.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -0,0 +1,26 @@
+package org.drools.compiler;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public abstract class DroolsError {
+
+ /**
+ * Classes that extend this must provide a printable message,
+ * which summarises the error.
+ */
+ public abstract String getMessage();
+}
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/FactTemplateError.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/FactTemplateError.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/FactTemplateError.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -1,76 +0,0 @@
-package org.drools.compiler;
-
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.commons.jci.problems.CompilationProblem;
-import org.drools.lang.descr.BaseDescr;
-import org.drools.rule.Package;
-
-public class FactTemplateError extends DroolsError {
- private Package pkg;
- private BaseDescr descr;
- private Object object;
- private String message;
-
- public FactTemplateError(final Package pkg,
- final BaseDescr descr,
- final Object object,
- final String message) {
- super();
- this.pkg = pkg;
- this.descr = descr;
- this.object = object;
- this.message = message;
- }
-
- public Package getPackage() {
- return this.pkg;
- }
-
- public BaseDescr getDescr() {
- return this.descr;
- }
-
- public Object getObject() {
- return this.object;
- }
-
- /**
- * This will return the line number of the error, if possible
- * Otherwise it will be -1
- */
- public int getLine() {
- if ( this.descr != null ) {
- return this.descr.getLine();
- } else {
- return -1;
- }
- }
-
- public String getMessage() {
- String summary = this.message;
- if ( this.object instanceof CompilationProblem[] ) {
- final CompilationProblem[] problem = (CompilationProblem[]) this.object;
- for ( int i = 0; i < problem.length; i++ ) {
- summary = summary + " " + problem[i].getMessage();
- }
-
- }
- return summary;
- }
-
-}
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/FactTemplateError.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/FactTemplateError.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/FactTemplateError.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -0,0 +1,76 @@
+package org.drools.compiler;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.commons.jci.problems.CompilationProblem;
+import org.drools.lang.descr.BaseDescr;
+import org.drools.rule.Package;
+
+public class FactTemplateError extends DroolsError {
+ private Package pkg;
+ private BaseDescr descr;
+ private Object object;
+ private String message;
+
+ public FactTemplateError(final Package pkg,
+ final BaseDescr descr,
+ final Object object,
+ final String message) {
+ super();
+ this.pkg = pkg;
+ this.descr = descr;
+ this.object = object;
+ this.message = message;
+ }
+
+ public Package getPackage() {
+ return this.pkg;
+ }
+
+ public BaseDescr getDescr() {
+ return this.descr;
+ }
+
+ public Object getObject() {
+ return this.object;
+ }
+
+ /**
+ * This will return the line number of the error, if possible
+ * Otherwise it will be -1
+ */
+ public int getLine() {
+ if ( this.descr != null ) {
+ return this.descr.getLine();
+ } else {
+ return -1;
+ }
+ }
+
+ public String getMessage() {
+ String summary = this.message;
+ if ( this.object instanceof CompilationProblem[] ) {
+ final CompilationProblem[] problem = (CompilationProblem[]) this.object;
+ for ( int i = 0; i < problem.length; i++ ) {
+ summary = summary + " " + problem[i].getMessage();
+ }
+
+ }
+ return summary;
+ }
+
+}
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/FunctionError.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/FunctionError.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/FunctionError.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -1,47 +0,0 @@
-package org.drools.compiler;
-
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.drools.lang.descr.FunctionDescr;
-
-public class FunctionError extends DroolsError {
- private FunctionDescr functionDescr;
- private Object object;
- private String message;
-
- public FunctionError(final FunctionDescr functionDescr,
- final Object object,
- final String message) {
- super();
- this.functionDescr = functionDescr;
- this.object = object;
- this.message = message;
- }
-
- public FunctionDescr getFunctionDescr() {
- return this.functionDescr;
- }
-
- public Object getObject() {
- return this.object;
- }
-
- public String getMessage() {
- return this.message;
- }
-
-}
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/FunctionError.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/FunctionError.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/FunctionError.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -0,0 +1,47 @@
+package org.drools.compiler;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.lang.descr.FunctionDescr;
+
+public class FunctionError extends DroolsError {
+ private FunctionDescr functionDescr;
+ private Object object;
+ private String message;
+
+ public FunctionError(final FunctionDescr functionDescr,
+ final Object object,
+ final String message) {
+ super();
+ this.functionDescr = functionDescr;
+ this.object = object;
+ this.message = message;
+ }
+
+ public FunctionDescr getFunctionDescr() {
+ return this.functionDescr;
+ }
+
+ public Object getObject() {
+ return this.object;
+ }
+
+ public String getMessage() {
+ return this.message;
+ }
+
+}
\ No newline at end of file
Deleted: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/GlobalError.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/GlobalError.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/GlobalError.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -1,34 +0,0 @@
-package org.drools.compiler;
-
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class GlobalError extends DroolsError {
- private String global;
-
- public GlobalError(final String global) {
- this.global = global;
- }
-
- public String getGlobal() {
- return this.global;
- }
-
- public String getMessage() {
- return this.global;
- }
-
-}
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/GlobalError.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/GlobalError.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/GlobalError.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -0,0 +1,34 @@
+package org.drools.compiler;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class GlobalError extends DroolsError {
+ private String global;
+
+ public GlobalError(final String global) {
+ this.global = global;
+ }
+
+ public String getGlobal() {
+ return this.global;
+ }
+
+ public String getMessage() {
+ return this.global;
+ }
+
+}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilder.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -368,7 +368,7 @@
public Package getPackage() {
if ( hasErrors() ) {
- this.pkg.setError( this.printErrors() );
+ this.pkg.setError( getErrors().toString() );
}
return this.pkg;
}
@@ -385,24 +385,11 @@
* @return A list of Error objects that resulted from building and compiling
* the package.
*/
- public DroolsError[] getErrors() {
- return (DroolsError[]) this.results.toArray( new DroolsError[this.results.size()] );
+ public PackageBuilderErrors getErrors() {
+ return new PackageBuilderErrors( (DroolsError[]) this.results.toArray( new DroolsError[this.results.size()] ) );
}
/**
- * This will pretty print the errors (from getErrors()) into lines.
- */
- public String printErrors() {
- final StringBuffer buf = new StringBuffer();
- for ( final Iterator iter = this.results.iterator(); iter.hasNext(); ) {
- final DroolsError err = (DroolsError) iter.next();
- buf.append( err.getMessage() );
- buf.append( "\n" );
- }
- return buf.toString();
- }
-
- /**
* Reset the error list. This is useful when incrementally building
* packages. Care should be used when building this, if you clear this when
* there were errors on items that a rule depends on (eg functions), then
@@ -486,7 +473,7 @@
this.message = message;
}
- public DroolsError getError() {
+ public DroolsError getError() {
return new RuleError( this.rule,
this.descr,
collectCompilerProblems(),
Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilderErrors.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilderErrors.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/PackageBuilderErrors.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -0,0 +1,24 @@
+package org.drools.compiler;
+
+
+public class PackageBuilderErrors {
+ private DroolsError[] errors;
+
+ public PackageBuilderErrors(DroolsError[] errors) {
+ this.errors = errors;
+ }
+
+ public DroolsError[] getErrors() {
+ return errors;
+ }
+
+ public String toString() {
+ final StringBuffer buf = new StringBuffer();
+ for ( int i = 0, length = this.errors.length; i < length; i++) {
+ buf.append( errors[i] );
+ }
+ return buf.toString();
+ }
+
+
+}
Deleted: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/ParserError.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/ParserError.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/ParserError.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -1,49 +0,0 @@
-package org.drools.compiler;
-
-/*
- * Copyright 2005 JBoss Inc
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-public class ParserError extends DroolsError {
- private int row;
- private int col;
- private String message;
-
- public ParserError(final String message,
- final int row,
- final int col) {
- super();
- this.message = message;
- this.row = row;
- this.col = col;
- }
-
- public String getMessage() {
- return this.message;
- }
-
- public int getCol() {
- return this.col;
- }
-
- public int getRow() {
- return this.row;
- }
-
- public String toString() {
- return "[" + this.row + "," + this.col + "]: " + this.message;
- }
-
-}
\ No newline at end of file
Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/ParserError.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/ParserError.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/ParserError.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -0,0 +1,49 @@
+package org.drools.compiler;
+
+/*
+ * Copyright 2005 JBoss Inc
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class ParserError extends DroolsError {
+ private int row;
+ private int col;
+ private String message;
+
+ public ParserError(final String message,
+ final int row,
+ final int col) {
+ super();
+ this.message = message;
+ this.row = row;
+ this.col = col;
+ }
+
+ public String getMessage() {
+ return this.message;
+ }
+
+ public int getCol() {
+ return this.col;
+ }
+
+ public int getRow() {
+ return this.row;
+ }
+
+ public String toString() {
+ return "[" + this.row + "," + this.col + "]: " + this.message;
+ }
+
+}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/RuleBaseLoader.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/RuleBaseLoader.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/RuleBaseLoader.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -59,7 +59,7 @@
private RuleBase makeRuleBase(final PackageBuilder builder) throws CheckedDroolsException {
if ( builder.hasErrors() ) {
- throw new CheckedDroolsException( "There were errors in the rule source: " + builder.printErrors() );
+ throw new CheckedDroolsException( "There were errors in the rule source: " + builder.getErrors().toString() );
}
final Package binaryPackage = builder.getPackage();
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/RuleError.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/RuleError.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/compiler/RuleError.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -86,7 +86,7 @@
buf.append( problem[i] );
buf.append( "\n" );
}
- } else {
+ } else if ( this.object != null ) {
buf.append( this.object );
}
return buf.toString();
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/FunctionBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/FunctionBuilder.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/FunctionBuilder.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -16,6 +16,7 @@
* limitations under the License.
*/
+import java.util.List;
import java.util.Map;
import org.codehaus.jfdi.interpreter.TypeResolver;
@@ -26,5 +27,6 @@
public String build(final Package pkg,
final FunctionDescr functionDescr,
final TypeResolver typeResolver,
- final Map lineMappings);
+ final Map lineMappings,
+ final List errors);
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuilder.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/RuleBuilder.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -26,7 +26,6 @@
import org.drools.lang.descr.QueryDescr;
import org.drools.lang.descr.RuleDescr;
import org.drools.rule.GroupElement;
-import org.drools.rule.Package;
import org.drools.rule.Rule;
/**
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaConsequenceBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaConsequenceBuilder.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaConsequenceBuilder.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -22,6 +22,7 @@
import org.antlr.stringtemplate.StringTemplate;
import org.drools.RuntimeDroolsException;
+import org.drools.compiler.RuleError;
import org.drools.lang.descr.RuleDescr;
import org.drools.rule.Declaration;
import org.drools.rule.builder.RuleBuildContext;
@@ -105,8 +106,7 @@
new Integer( list.indexOf( declarations[i] ) ) );
notPatterns[i] = (declarations[i].getExtractor() instanceof PatternExtractor) ? null : "true";
if ( ((Integer) indexes.get( i )).intValue() == -1 ) {
- // some defensive code, this should never happen
- throw new RuntimeDroolsException( "Unable to find declaration in list while generating the consequence invoker" );
+ context.getErrors().add( new RuleError(context.getRule(), ruleDescr, null, "Internal Error : Unable to find declaration in list while generating the consequence invoker" ) );
}
}
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaDialect.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaDialect.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaDialect.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -84,6 +84,7 @@
private final JavaConsequenceBuilder consequence = new JavaConsequenceBuilder();
private final JavaRuleClassBuilder rule = new JavaRuleClassBuilder();
private final MVELFromBuilder from = new MVELFromBuilder();
+ private final JavaFunctionBuilder function = new JavaFunctionBuilder();
//
private final KnowledgeHelperFixer knowledgeHelperFixer;
@@ -101,11 +102,10 @@
private Map errorHandlers;
private List results;
// the class name for the rule
- private String ruleClass;
-
+ private String ruleClass;
+
private final TypeResolver typeResolver;
private final ClassFieldExtractorCache classFieldExtractorCache;
-
// a map of registered builders
private Map builders;
@@ -177,20 +177,21 @@
public void init(final Package pkg) {
this.pkg = pkg;
this.errorHandlers = new HashMap();
+ this.results = new ArrayList();
this.src = new MemoryResourceReader();
if ( pkg != null ) {
- this.packageStoreWrapper = new PackageStore( pkg.getPackageCompilationData() );
+ this.packageStoreWrapper = new PackageStore( pkg.getPackageCompilationData(),
+ this.results );
this.lineMappings = pkg.getPackageCompilationData().getLineMappings();
}
this.generatedClassList = new ArrayList();
- this.packageStoreWrapper = new PackageStore( pkg.getPackageCompilationData() );
+ this.packageStoreWrapper = new PackageStore( pkg.getPackageCompilationData(),
+ this.results );
this.lineMappings = new HashMap();
pkg.getPackageCompilationData().setLineMappings( this.lineMappings );
-
- this.results = new ArrayList();
}
public void init(final RuleDescr ruleDescr) {
@@ -200,7 +201,7 @@
this.src );
ruleDescr.setClassName( ucFirst( ruleClassName ) );
}
-
+
public void setRuleClass(String ruleClass) {
this.ruleClass = ruleClass;
}
@@ -300,6 +301,10 @@
return this.rule;
}
+ public FunctionBuilder getFunctionBuilder() {
+ return this.function;
+ }
+
public FromBuilder getFromBuilder() {
return this.from;
}
@@ -401,6 +406,9 @@
}
}
}
+
+ // We've compiled everthing, so clear it for the next set of additions
+ this.generatedClassList.clear();
}
/**
@@ -412,9 +420,9 @@
if ( this.ruleClass == null ) {
return;
}
-
+
Rule rule = context.getRule();
- RuleDescr ruleDescr = context.getRuleDescr();
+ RuleDescr ruleDescr = context.getRuleDescr();
// The compilation result is for th entire rule, so difficult to associate with any descr
addClassCompileTask( this.pkg.getName() + "." + ruleDescr.getClassName(),
@@ -465,15 +473,17 @@
this.pkg.addStaticImport( functionClassName + "." + functionDescr.getName() );
functionDescr.setClassName( functionClassName );
- final FunctionBuilder builder = new JavaFunctionBuilder();
this.pkg.addFunction( functionDescr.getName() );
+
+ String functionSrc = getFunctionBuilder().build( this.pkg,
+ functionDescr,
+ typeResolver,
+ this.lineMappings,
+ this.results );
addClassCompileTask( functionClassName,
functionDescr,
- builder.build( this.pkg,
- functionDescr,
- typeResolver,
- this.lineMappings ),
+ functionSrc,
this.src,
new FunctionErrorHandler( functionDescr,
"Function Compilation error" ) );
Added: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaDialectError.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaDialectError.java (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaDialectError.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -0,0 +1,21 @@
+package org.drools.rule.builder.dialect.java;
+
+import org.drools.compiler.DroolsError;
+
+public class JavaDialectError extends DroolsError {
+ private String message;
+
+ public JavaDialectError(String message) {
+ super();
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public String toString() {
+ return "[JavaDialectError message='" + this.message + "']";
+ }
+
+}
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaFunctionBuilder.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaFunctionBuilder.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/JavaFunctionBuilder.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -13,10 +13,12 @@
import org.antlr.stringtemplate.language.AngleBracketTemplateLexer;
import org.codehaus.jfdi.interpreter.TypeResolver;
import org.drools.RuntimeDroolsException;
+import org.drools.compiler.FunctionError;
import org.drools.lang.descr.FunctionDescr;
import org.drools.rule.LineMappings;
import org.drools.rule.Package;
import org.drools.rule.builder.FunctionBuilder;
+import org.drools.util.StringUtils;
public class JavaFunctionBuilder
implements
@@ -35,7 +37,8 @@
public String build(final Package pkg,
final FunctionDescr functionDescr,
final TypeResolver typeResolver,
- final Map lineMappings) {
+ final Map lineMappings,
+ final List errors) {
final StringTemplate st = JavaFunctionBuilder.functionGroup.getInstanceOf( "function" );
st.setAttribute( "package",
@@ -45,7 +48,7 @@
pkg.getImports() );
st.setAttribute( "className",
- ucFirst( functionDescr.getName() ) );
+ StringUtils.ucFirst( functionDescr.getName() ) );
st.setAttribute( "methodName",
functionDescr.getName() );
@@ -66,9 +69,8 @@
params.put( names.get( i ),
typeResolver.resolveType( (String) types.get( i ) ) );
}
- } catch ( final ClassNotFoundException e ) {
- // todo : must be a better way so we don't have to try/catch each resolveType call
- throw new RuntimeDroolsException( e );
+ } catch ( final ClassNotFoundException e ) {
+ errors.add( new FunctionError(functionDescr, e, "unable to resolve type while building function") );
}
st.setAttribute( "text",
@@ -93,19 +95,15 @@
throw new RuntimeDroolsException( "Error determining start offset with function" );
}
- final String name = pkg.getName() + "." + ucFirst( functionDescr.getName() );
+ final String name = pkg.getName() + "." + StringUtils.ucFirst( functionDescr.getName() );
final LineMappings mapping = new LineMappings( name );
mapping.setStartLine( functionDescr.getLine() );
mapping.setOffset( functionDescr.getOffset() );
lineMappings.put( name,
- lineMappings );
+ mapping );
return text;
}
- private String ucFirst(final String name) {
- return name.toUpperCase().charAt( 0 ) + name.substring( 1 );
- }
-
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/PackageStore.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/PackageStore.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/rule/builder/dialect/java/PackageStore.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -16,6 +16,8 @@
* limitations under the License.
*/
+import java.util.List;
+
import org.apache.commons.jci.stores.ResourceStore;
import org.drools.rule.PackageCompilationData;
@@ -24,11 +26,13 @@
ResourceStore {
private PackageCompilationData packageCompilationData;
+ private List errors;
public PackageStore() {
}
- public PackageStore(final PackageCompilationData packageCompiationData) {
+ public PackageStore(final PackageCompilationData packageCompiationData, List errors) {
this.packageCompilationData = packageCompiationData;
+ this.errors = errors;
}
public void setPackageCompilationData(final PackageCompilationData packageCompiationData) {
@@ -41,7 +45,8 @@
this.packageCompilationData.write( resourceName,
clazzData );
} catch ( final Exception e ) {
-
+ e.printStackTrace();
+ this.errors.add( new JavaDialectError( "PackageStore was unable to write resourceName='" + resourceName + "'" ) );
}
}
@@ -50,7 +55,7 @@
try {
clazz = this.packageCompilationData.read( resourceName );
} catch ( final Exception e ) {
-
+ this.errors.add( new JavaDialectError( "PackageStore was unable to read resourceName='" + resourceName + "'" ) );
}
return clazz;
}
@@ -59,7 +64,8 @@
try {
this.packageCompilationData.remove( resourceName );
} catch ( final Exception e ) {
-
+ this.errors.add( new JavaDialectError( "PackageStore was unable to remove resourceName='" + resourceName + "'" ) );
}
}
+
}
\ No newline at end of file
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderTest.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/compiler/PackageBuilderTest.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -119,7 +119,7 @@
builder.addPackage( packageDescr );
assertLength( 1,
- builder.getErrors() );
+ builder.getErrors().getErrors() );
}
public void testErrorsInParser() throws Exception {
@@ -149,7 +149,7 @@
Rule rule = pkg.getRule( "rule-1" );
assertLength( 0,
- builder.getErrors() );
+ builder.getErrors().getErrors() );
final ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
ruleBase.getGlobals().put( "map",
@@ -218,7 +218,7 @@
final Rule rule = pkg.getRule( "rule-1" );
assertLength( 0,
- builder.getErrors() );
+ builder.getErrors().getErrors() );
final byte[] bytes = serializeOut( pkg );
@@ -384,7 +384,7 @@
builder.addPackage( packageDescr );
assertLength( 0,
- builder.getErrors() );
+ builder.getErrors().getErrors() );
}
public void testReturnValue() throws Exception {
@@ -489,7 +489,7 @@
builder.addPackage( packageDescr );
assertLength( 0,
- builder.getErrors() );
+ builder.getErrors().getErrors() );
}
public void testPredicateMethodCompare() {
@@ -555,7 +555,7 @@
builder.addPackage( packageDescr );
assertLength( 0,
- builder.getErrors() );
+ builder.getErrors().getErrors() );
final Package pkg = builder.getPackage();
final Rule rule = pkg.getRule( "rule-1" );
@@ -598,7 +598,7 @@
builder,
"modify(stilton);" );
assertLength( 0,
- builder.getErrors() );
+ builder.getErrors().getErrors() );
final GroupElement lhs = rule.getLhs();
assertLength( 1,
@@ -618,7 +618,7 @@
builder,
"modify(stilton);" );
assertLength( 0,
- builder.getErrors() );
+ builder.getErrors().getErrors() );
final GroupElement lhs = rule.getLhs();
assertLength( 1,
@@ -640,14 +640,14 @@
builder,
"modify(stilton);" );
assertEquals( 1,
- builder.getErrors().length );
+ builder.getErrors().getErrors().length );
builder = new PackageBuilder();
rule = createRule( new NotDescr(),
builder,
"" );
assertEquals( 0,
- builder.getErrors().length );
+ builder.getErrors().getErrors().length );
final GroupElement lhs = rule.getLhs();
assertLength( 1,
@@ -669,14 +669,14 @@
builder,
"modify(stilton);" );
assertEquals( 1,
- builder.getErrors().length );
+ builder.getErrors().getErrors().length );
builder = new PackageBuilder();
rule = createRule( new ExistsDescr(),
builder,
"" );
assertEquals( 0,
- builder.getErrors().length );
+ builder.getErrors().getErrors().length );
final GroupElement lhs = rule.getLhs();
assertLength( 1,
@@ -833,7 +833,7 @@
final Rule rule = pkg.getRule( "rule-1" );
assertLength( 0,
- builder.getErrors() );
+ builder.getErrors().getErrors() );
}
public void testDuplicateRuleNames() throws Exception {
@@ -887,8 +887,8 @@
builder.addPackage( packageDescr );
assertLength( 1,
- builder.getErrors() );
- final ParserError err = (ParserError) builder.getErrors()[0];
+ builder.getErrors().getErrors() );
+ final ParserError err = (ParserError) builder.getErrors().getErrors()[0];
assertEquals( 42,
err.getRow() );
assertEquals( 43,
@@ -928,7 +928,7 @@
builder.addPackage( packageDescr );
assertLength( 2,
- builder.getErrors() );
+ builder.getErrors().getErrors() );
}
public void FIXME_testCompilerConfiguration() throws Exception {
@@ -1080,7 +1080,7 @@
builder.addPackage( packageDescr );
assertLength( 0,
- builder.getErrors() );
+ builder.getErrors().getErrors() );
}
private Rule createRule(final ConditionalElementDescr ceDescr,
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/DslTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/DslTest.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/DslTest.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -43,12 +43,12 @@
assertEquals( null,
pkg.getErrorSummary() );
// Check errors
- final String err = builder.printErrors();
+ final String err = builder.getErrors().toString();
assertEquals( "",
err );
assertEquals( 0,
- builder.getErrors().length );
+ builder.getErrors().getErrors().length );
final RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
@@ -83,11 +83,11 @@
assertEquals( null,
pkg.getErrorSummary() );
// Check errors
- final String err = builder.printErrors();
+ final String err = builder.getErrors().toString();
assertEquals( "",
err );
assertEquals( 0,
- builder.getErrors().length );
+ builder.getErrors().getErrors().length );
final RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/DynamicRulesTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/DynamicRulesTest.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/DynamicRulesTest.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -33,7 +33,7 @@
return RuleBaseFactory.newRuleBase( RuleBase.RETEOO,
config );
}
-
+
public void testDynamicRuleAdditions() throws Exception {
Reader reader = new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic1.drl" ) );
@@ -141,14 +141,7 @@
org.drools.reteoo.ReteooRuleBase reteooRuleBase = null;
// org.drools.leaps.LeapsRuleBase leapsRuleBase = null;
final RuleBase ruleBase = getRuleBase();
- // org.drools.reteoo.RuleBaseImpl ruleBase = new
- // org.drools.reteoo.RuleBaseImpl();
- if ( ruleBase instanceof org.drools.reteoo.ReteooRuleBase ) {
- reteooRuleBase = (org.drools.reteoo.ReteooRuleBase) ruleBase;
- // } else if ( ruleBase instanceof org.drools.leaps.LeapsRuleBase )
- // {
- // leapsRuleBase = (org.drools.leaps.LeapsRuleBase) ruleBase;
- }
+ reteooRuleBase = (org.drools.reteoo.ReteooRuleBase) ruleBase;
ruleBase.addPackage( pkg );
final PackageBuilder builder2 = new PackageBuilder();
builder2.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic2.drl" ) ) );
@@ -180,56 +173,29 @@
final Cheese cheddar = new Cheese( "cheddar",
5 );
workingMemory.assertObject( cheddar );
- //
- // workingMemory.get
- //
- // workingMemory.fireAllRules();
assertEquals( 11,
workingMemory.getAgenda().getActivations().length );
- if ( reteooRuleBase != null ) {
- reteooRuleBase.removeRule( "org.drools.test",
- "Who likes Stilton" );
- assertEquals( 8,
- workingMemory.getAgenda().getActivations().length );
+ reteooRuleBase.removeRule( "org.drools.test",
+ "Who likes Stilton" );
+ assertEquals( 8,
+ workingMemory.getAgenda().getActivations().length );
- reteooRuleBase.removeRule( "org.drools.test",
- "like cheese" );
+ reteooRuleBase.removeRule( "org.drools.test",
+ "like cheese" );
- final Cheese muzzarela = new Cheese( "muzzarela",
- 5 );
- workingMemory.assertObject( muzzarela );
+ final Cheese muzzarela = new Cheese( "muzzarela",
+ 5 );
+ workingMemory.assertObject( muzzarela );
- assertEquals( 4,
- workingMemory.getAgenda().getActivations().length );
+ assertEquals( 4,
+ workingMemory.getAgenda().getActivations().length );
- reteooRuleBase.removePackage( "org.drools.test" );
+ reteooRuleBase.removePackage( "org.drools.test" );
- assertEquals( 0,
- workingMemory.getAgenda().getActivations().length );
- // } else if ( leapsRuleBase != null ) {
- // leapsRuleBase.removeRule( "org.drools.test",
- // "Who likes Stilton" );
- // assertEquals( 8,
- // workingMemory.getAgenda().getActivations().length );
- //
- // leapsRuleBase.removeRule( "org.drools.test",
- // "like cheese" );
- //
- // final Cheese muzzarela = new Cheese( "muzzarela",
- // 5 );
- // workingMemory.assertObject( muzzarela );
- //
- // assertEquals( 4,
- // workingMemory.getAgenda().getActivations().length );
- //
- // leapsRuleBase.removePackage( "org.drools.test" );
- //
- // assertEquals( 0,
- // workingMemory.getAgenda().getActivations().length );
- //
- }
+ assertEquals( 0,
+ workingMemory.getAgenda().getActivations().length );
}
public void testDynamicRuleRemovalsUnusedWorkingMemory() throws Exception {
@@ -296,7 +262,7 @@
// leapsRuleBase.getPackages().length );
}
}
-
+
public void testDynamicFunction() throws Exception {
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_DynamicFunction1.drl" ) ) );
@@ -362,7 +328,7 @@
assertEquals( new Integer( 5 ),
list.get( 2 ) );
}
-
+
public void testRemovePackage() throws Exception {
final PackageBuilder builder = new PackageBuilder();
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_RemovePackage.drl" ) ) );
@@ -390,7 +356,7 @@
ruleBaseWM.removePackage( packageName );
ruleBaseWM.addPackage( builder1.getPackage() );
}
-
+
public void testDynamicRules() throws Exception {
final RuleBase ruleBase = getRuleBase();
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
@@ -432,26 +398,24 @@
ruleBase.addPackage( pkg );
workingMemory.fireAllRules();
- }
-
- public void testRuleBaseAddRemove() throws Exception
- {
+ }
+
+ public void testRuleBaseAddRemove() throws Exception {
RuleBase ruleBase = RuleBaseFactory.newRuleBase();
-
+
//add and remove
PackageBuilder builder = new PackageBuilder();
- builder.addPackageFromDrl(new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic1.drl" ) ));
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic1.drl" ) ) );
Package pkg = builder.getPackage();
- ruleBase.addPackage(pkg);
- ruleBase.removePackage(pkg.getName());
-
+ ruleBase.addPackage( pkg );
+ ruleBase.removePackage( pkg.getName() );
+
//add and remove again
builder = new PackageBuilder();
- builder.addPackageFromDrl(new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic1.drl" ) ));
+ builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "test_Dynamic1.drl" ) ) );
pkg = builder.getPackage();
- ruleBase.addPackage(pkg);
- ruleBase.removePackage(pkg.getName());
+ ruleBase.addPackage( pkg );
+ ruleBase.removePackage( pkg.getName() );
}
-
}
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/FirstOrderLogicTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/FirstOrderLogicTest.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/FirstOrderLogicTest.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -287,7 +287,7 @@
final Rule rule = pkg.getRules()[0];
assertTrue( rule.isValid() );
assertEquals( 0,
- builder.getErrors().length );
+ builder.getErrors().getErrors().length );
final RuleBase ruleBase = getRuleBase();
ruleBase.addPackage( pkg );
final WorkingMemory workingMemory = ruleBase.newStatefulSession();
Modified: labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java 2007-04-26 00:42:42 UTC (rev 11339)
+++ labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/MiscTest.java 2007-04-26 01:49:15 UTC (rev 11340)
@@ -927,9 +927,9 @@
assertNotNull( e.getMessage() );
runtime = e;
}
- assertTrue( builder.getErrors().length > 0 );
+ assertTrue( builder.getErrors().getErrors().length > 0 );
- final String pretty = builder.printErrors();
+ final String pretty = builder.getErrors().toString();
assertFalse( pretty.equals( "" ) );
assertEquals( pretty,
runtime.getMessage() );
@@ -943,15 +943,15 @@
builder.addPackageFromDrl( new InputStreamReader( getClass().getResourceAsStream( "errors_in_rule.drl" ) ) );
final Package pkg = builder.getPackage();
- final DroolsError err = builder.getErrors()[0];
+ final DroolsError err = builder.getErrors().getErrors()[0];
final RuleError ruleErr = (RuleError) err;
assertNotNull( ruleErr.getDescr() );
assertTrue( ruleErr.getLine() != -1 );
- final DroolsError errs[] = builder.getErrors();
+ final DroolsError errs[] = builder.getErrors().getErrors();
assertEquals( 3,
- builder.getErrors().length );
+ builder.getErrors().getErrors().length );
// check that its getting it from the ruleDescr
assertEquals( ruleErr.getLine(),
@@ -962,7 +962,7 @@
// now check the RHS, not being too specific yet, as long as it has the
// rules line number, not zero
- final RuleError rhs = (RuleError) builder.getErrors()[2];
+ final RuleError rhs = (RuleError) builder.getErrors().getErrors()[2];
assertTrue( rhs.getLine() > 7 ); // not being too specific - may need to
// change this when we rework the error
// reporting
@@ -1456,7 +1456,7 @@
final Package pkg = builder.getPackage();
assertEquals( 0,
- builder.getErrors().length );
+ builder.getErrors().getErrors().length );
RuleBase ruleBase = getRuleBase();// RuleBaseFactory.newRuleBase();
@@ -2214,6 +2214,7 @@
final Package pkg = builder.getPackage();
assertFalse( pkg.isValid() );
+ System.out.println(pkg.getErrorSummary());
assertEquals( 6,
pkg.getErrorSummary().split( "\n" ).length );
}
More information about the jboss-svn-commits
mailing list