[jboss-svn-commits] JBL Code SVN: r25390 - labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/jbossts/orchestration/test.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Feb 23 10:48:25 EST 2009
Author: adinn
Date: 2009-02-23 10:48:25 -0500 (Mon, 23 Feb 2009)
New Revision: 25390
Modified:
labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/jbossts/orchestration/test/TestScript.java
Log:
corrected erroneous error text and added final error count printout in offline rule type checker program
Modified: labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/jbossts/orchestration/test/TestScript.java
===================================================================
--- labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/jbossts/orchestration/test/TestScript.java 2009-02-23 15:37:36 UTC (rev 25389)
+++ labs/jbosstm/workspace/adinn/orchestration/src/org/jboss/jbossts/orchestration/test/TestScript.java 2009-02-23 15:48:25 UTC (rev 25390)
@@ -67,7 +67,7 @@
for (String script : scriptFiles) {
try {
FileInputStream fis = new FileInputStream(new File(script));
- System.out.println("checking classes in " + script);
+ System.out.println("checking rules in " + script);
List<String> rules = processRules(fis);
checkRules(rules);
} catch (IOException ioe) {
@@ -86,22 +86,20 @@
byte[] bytes = new byte[stream.available()];
stream.read(bytes);
String text = new String(bytes);
- int length = text.length();
- while (length > 0) {
- int end = text.indexOf("ENDRULE");
- if (end >= 0) {
- end += "ENDRULE".length();
- if (end < length && text.charAt(end) == '\n') {
- end++;
- }
- rules.add(text.substring(0, end));
- text = text.substring(end).trim();
- } else {
- rules.add(text);
- text = "";
+ String[] lines = text.split("\n");
+ int length = lines.length;
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < length; i++) {
+ buffer.append(lines[i]);
+ buffer.append("\n");
+ if (lines[i].trim().equals("ENDRULE")) {
+ rules.add(buffer.toString());
+ buffer = new StringBuffer();
}
- length = text.length();
}
+ if (buffer.length() > 0) {
+ rules.add(buffer.toString());
+ }
return rules;
}
@@ -109,7 +107,11 @@
private void checkRules(List<String> ruleScripts)
{
ClassLoader loader = getClass().getClassLoader();
-
+ int errorCount = 0;
+ int parseErrorCount = 0;
+ int typeErrorCount = 0;
+ int compileErrorCount = 0;
+
for (String script : ruleScripts) {
String ruleName = "";
try {
@@ -125,6 +127,9 @@
while (lines[idx].trim().equals("") || lines[idx].trim().startsWith("#")) {
idx++;
+ if (idx == len) {
+ throw new ParseException("Rule contains no text : " + script);
+ }
}
if (lines[idx].startsWith("RULE ")) {
ruleName = lines[idx].substring(5).trim();
@@ -134,6 +139,9 @@
}
while (lines[idx].trim().equals("") || lines[idx].trim().startsWith("#")) {
idx++;
+ if (idx == len) {
+ throw new ParseException("Rule does not specify CLASS : " + script);
+ }
}
if (lines[idx].startsWith("CLASS ")) {
targetClassName = lines[idx].substring(6).trim();
@@ -143,6 +151,9 @@
}
while (lines[idx].trim().equals("") || lines[idx].trim().startsWith("#")) {
idx++;
+ if (idx == len) {
+ throw new ParseException("Rule does not specify METHOD : " + script);
+ }
}
if (lines[idx].startsWith("METHOD ")) {
targetMethodName = lines[idx].substring(7).trim();
@@ -152,6 +163,9 @@
}
while (lines[idx].trim().equals("") || lines[idx].trim().startsWith("#")) {
idx++;
+ if (idx == len) {
+ throw new ParseException("Rule is incomplete : " + script);
+ }
}
locationType = LocationType.type(lines[idx]);
if (locationType != null) {
@@ -172,6 +186,10 @@
text += sepr + lines[idx];
sepr = "\n";
}
+ if (idx == len) {
+ throw new ParseException("Missing ENDRULE : " + script);
+ }
+
Rule rule = Rule.create(ruleName, targetClassName, targetMethodName, targetLocation, text, loader);
System.err.println("TestScript: parsed rule " + rule.getName());
System.err.println(rule);
@@ -189,7 +207,7 @@
String candidateDesc = makeDescriptor(candidate);
if (targetName.equals(candidateName)) {
if (targetDesc.equals("") || TypeHelper.equalDescriptors(targetDesc, candidateDesc)) {
- System.err.println("TestJar: checking rule " + ruleName);
+ System.err.println("TestScript: checking rule " + ruleName);
if (found) {
multiple = true;
break;
@@ -207,7 +225,7 @@
}
rule.setTypeInfo(targetClassName, access, candidateName, candidateDesc, exceptionNames);
rule.typeCheck();
- System.err.println("TestJar: type checked rule " + ruleName);
+ System.err.println("TestScript: type checked rule " + ruleName);
}
}
}
@@ -218,7 +236,7 @@
String candidateDesc = makeDescriptor(constructor);
if (targetName.equals("<init>")) {
if (targetDesc.equals("") || TypeHelper.equalDescriptors(targetDesc, candidateDesc)) {
- System.err.println("TestJar: checking rule " + ruleName);
+ System.err.println("TestScript: checking rule " + ruleName);
if (found) {
multiple = true;
break;
@@ -236,30 +254,47 @@
}
rule.setTypeInfo(targetClassName, access, candidateName, candidateDesc, exceptionNames);
rule.typeCheck();
- System.err.println("TestJar: type checked rule " + ruleName);
+ System.err.println("TestScript: type checked rule " + ruleName);
}
}
}
}
} catch(ClassNotFoundException cfe) {
+ errorCount++;
System.err.println("TestScript: unable to load class " + targetClassName);
}
if (!found) {
- System.err.println("TestJar: no matching method for rule " + ruleName);
+ errorCount++;
+ System.err.println("TestScript: no matching method for rule " + ruleName);
} else if (multiple) {
- System.err.println("TestJar: multiple matching methods for rule " + ruleName);
+ errorCount++;
+ System.err.println("TestScript: multiple matching methods for rule " + ruleName);
}
} catch (ParseException e) {
+ errorCount++;
+ parseErrorCount++;
System.err.println("TestScript: parse exception for rule " + ruleName + " : " + e);
e.printStackTrace(System.err);
} catch (TypeException e) {
+ typeErrorCount++;
+ errorCount++;
System.err.println("TestScript: type exception for rule " + ruleName + " : " + e);
e.printStackTrace(System.err);
} catch (CompileException e) {
+ compileErrorCount++;
+ errorCount++;
System.err.println("TestScript: compile exception for rule " + " : " + ruleName + e);
e.printStackTrace(System.err);
}
}
+ if (errorCount != 0) {
+ System.err.println("TestScript: " + errorCount + " total errors");
+ System.err.println(" " + parseErrorCount + " parse errors");
+ System.err.println(" " + typeErrorCount + "type errors");
+
+ } else {
+ System.err.println("TestScript: no errors");
+ }
}
static String makeDescriptor(Method method)
More information about the jboss-svn-commits
mailing list