You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by tc...@apache.org on 2005/09/25 04:37:43 UTC
svn commit: r291369 - in /jakarta/commons/sandbox/jci/trunk/src:
java/org/apache/commons/jci/compilers/groovy/
test/org/apache/commons/jci/compilers/
test/org/apache/commons/jci/compilers/eclipse/
test/org/apache/commons/jci/compilers/groovy/ test/org/...
Author: tcurdt
Date: Sat Sep 24 19:37:30 2005
New Revision: 291369
URL: http://svn.apache.org/viewcvs?rev=291369&view=rev
Log:
fixed the testcases, fixed groovy error handling (does not produce any warnings at all)
Modified:
jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/groovy/GroovyJavaCompiler.java
jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/JavaSources.java
jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompilerTestCase.java
jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/groovy/GroovyJavaCompilerTestCase.java
jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/janino/JaninoJavaCompilerTestCase.java
jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/stores/MemoryResourceStoreTestCase.java
jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/stores/TransactinonalResourceStoreTestCase.java
Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/groovy/GroovyJavaCompiler.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/groovy/GroovyJavaCompiler.java?rev=291369&r1=291368&r2=291369&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/groovy/GroovyJavaCompiler.java (original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/groovy/GroovyJavaCompiler.java Sat Sep 24 19:37:30 2005
@@ -15,6 +15,7 @@
import org.codehaus.groovy.control.CompilationUnit;
import org.codehaus.groovy.control.CompilerConfiguration;
import org.codehaus.groovy.control.ErrorCollector;
+import org.codehaus.groovy.control.MultipleCompilationErrorsException;
import org.codehaus.groovy.control.SourceUnit;
import org.codehaus.groovy.control.messages.Message;
import org.codehaus.groovy.control.messages.WarningMessage;
@@ -61,21 +62,27 @@
final byte[] bytes = clazz.getBytes();
store.write(name, bytes);
}
- } catch (final CompilationFailedException e) {
- e.printStackTrace();
- final ErrorCollector col = e.getUnit().getErrorCollector();
+ } catch (final MultipleCompilationErrorsException e) {
+ final ErrorCollector col = e.getErrorCollector();
final Collection warnings = col.getWarnings();
- for (final Iterator it = warnings.iterator(); it.hasNext();) {
- final WarningMessage warning = (WarningMessage) it.next();
- problems.add(new GroovyCompilationProblem(warning));
+ if (warnings != null) {
+ for (final Iterator it = warnings.iterator(); it.hasNext();) {
+ final WarningMessage warning = (WarningMessage) it.next();
+ problems.add(new GroovyCompilationProblem(warning));
+ }
}
final Collection errors = col.getErrors();
- for (final Iterator it = errors.iterator(); it.hasNext();) {
- final Message message = (Message) it.next();
- problems.add(new GroovyCompilationProblem(message));
+ if (errors != null) {
+ for (final Iterator it = errors.iterator(); it.hasNext();) {
+ final Message message = (Message) it.next();
+ problems.add(new GroovyCompilationProblem(message));
+ }
}
+ } catch (CompilationFailedException e) {
+ e.printStackTrace();
+ throw new RuntimeException("no expected");
}
return new CompilationResult(problems);
Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/JavaSources.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/JavaSources.java?rev=291369&r1=291368&r2=291369&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/JavaSources.java (original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/JavaSources.java Sat Sep 24 19:37:30 2005
@@ -26,11 +26,24 @@
+ " } \n"
+ "} \n";
- String warning =
+ String warning1 =
"package jci;\n"
+ "public class Simple { \n"
+ " public int generateWarning() { \n"
+ " return new java.util.Date().getHours(); \n"
+ + " }\n"
+ + " public String toString() { \n"
+ + " return \"Simple\"; \n"
+ + " } \n"
+ + "} \n";
+
+ String warning2 =
+ "package jci;\n"
+ + "public class Simple { \n"
+ + " public static void generate() { \n"
+ + " }\n"
+ + " public static void generate2() { \n"
+ + " generate();\n"
+ " }\n"
+ " public String toString() { \n"
+ " return \"Simple\"; \n"
Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompilerTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompilerTestCase.java?rev=291369&r1=291368&r2=291369&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompilerTestCase.java (original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompilerTestCase.java Sat Sep 24 19:37:30 2005
@@ -23,7 +23,7 @@
public void testCompilationWarning() throws Exception {
final JavaCompiler compiler = new EclipseJavaCompiler();
- final CompilationResult result = compileWith(compiler, JavaSources.warning);
+ final CompilationResult result = compileWith(compiler, JavaSources.warning1);
assertTrue(result.getWarnings().length == 1);
assertTrue(result.getErrors().length == 0);
}
Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/groovy/GroovyJavaCompilerTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/groovy/GroovyJavaCompilerTestCase.java?rev=291369&r1=291368&r2=291369&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/groovy/GroovyJavaCompilerTestCase.java (original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/groovy/GroovyJavaCompilerTestCase.java Sat Sep 24 19:37:30 2005
@@ -21,9 +21,11 @@
assertTrue(result.getErrors().length == 1);
}
- public void testCompilationWarning() throws Exception {
- final JavaCompiler compiler = new GroovyJavaCompiler();
- final CompilationResult result = compileWith(compiler, GroovySources.warning);
- assertTrue(result.getWarnings().length == 1);
- assertTrue(result.getErrors().length == 0);
- }}
+// as for now Groovy does not support any warnings at all
+// public void testCompilationWarning() throws Exception {
+// final JavaCompiler compiler = new GroovyJavaCompiler();
+// final CompilationResult result = compileWith(compiler, GroovySources.warning);
+// assertTrue(result.getWarnings().length == 1);
+// assertTrue(result.getErrors().length == 0);
+// }
+}
Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/janino/JaninoJavaCompilerTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/janino/JaninoJavaCompilerTestCase.java?rev=291369&r1=291368&r2=291369&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/janino/JaninoJavaCompilerTestCase.java (original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/janino/JaninoJavaCompilerTestCase.java Sat Sep 24 19:37:30 2005
@@ -23,7 +23,7 @@
public void testCompilationWarning() throws Exception {
final JavaCompiler compiler = new JaninoJavaCompiler();
- final CompilationResult result = compileWith(compiler, JavaSources.warning);
+ final CompilationResult result = compileWith(compiler, JavaSources.warning2);
assertTrue(result.getWarnings().length == 1);
assertTrue(result.getErrors().length == 0);
}
Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/stores/MemoryResourceStoreTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/stores/MemoryResourceStoreTestCase.java?rev=291369&r1=291368&r2=291369&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/stores/MemoryResourceStoreTestCase.java (original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/stores/MemoryResourceStoreTestCase.java Sat Sep 24 19:37:30 2005
@@ -22,7 +22,6 @@
public void testStore() {
final ResourceStore store = new MemoryResourceStore();
super.testStore(store);
- assertTrue("[key]".equals(store.toString()));
}
public void testRemove() {
Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/stores/TransactinonalResourceStoreTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/stores/TransactinonalResourceStoreTestCase.java?rev=291369&r1=291368&r2=291369&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/stores/TransactinonalResourceStoreTestCase.java (original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/stores/TransactinonalResourceStoreTestCase.java Sat Sep 24 19:37:30 2005
@@ -20,23 +20,12 @@
public final class TransactinonalResourceStoreTestCase extends AbstractStoreTestCase {
public void testStore() {
- final TransactionalResourceStore store = new TransactionalResourceStore(new MemoryResourceStore()) {
- public void onStart() {
- }
- public void onStop() {
- }
- };
+ final TransactionalResourceStore store = new TransactionalResourceStore(new MemoryResourceStore());
super.testStore(store);
- assertTrue("[key]".equals(store.toString()));
}
public void testRemove() {
- final TransactionalResourceStore store = new TransactionalResourceStore(new MemoryResourceStore()) {
- public void onStart() {
- }
- public void onStop() {
- }
- };
+ final TransactionalResourceStore store = new TransactionalResourceStore(new MemoryResourceStore());
super.testRemove(store);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org