commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcu...@apache.org
Subject svn commit: r239667 - in /jakarta/commons/sandbox/jci/trunk/src: java/org/apache/commons/jci/ java/org/apache/commons/jci/compilers/eclipse/ java/org/apache/commons/jci/compilers/groovy/ java/org/apache/commons/jci/compilers/janino/ java/org/apache/com...
Date Wed, 24 Aug 2005 14:17:40 GMT
Author: tcurdt
Date: Wed Aug 24 07:17:25 2005
New Revision: 239667

URL: http://svn.apache.org/viewcvs?rev=239667&view=rev
Log:
provide compilation errors and warnings


Added:
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/DefaultCompilationProblemHandler.java
Modified:
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/CompilingClassLoader.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompiler.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/groovy/GroovyJavaCompiler.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/janino/JaninoJavaCompiler.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/listeners/CompilingListener.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/CompilationProblem.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/CompilationProblemHandler.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/ConsoleCompilationProblemHandler.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/LogCompilationProblemHandler.java
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/AbstractCompilerTestCase.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/problems/CompilationProblemTestCase.java
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/utils/ThreadUtilsTestCase.java

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/CompilingClassLoader.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/CompilingClassLoader.java?rev=239667&r1=239666&r2=239667&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/CompilingClassLoader.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/CompilingClassLoader.java
Wed Aug 24 07:17:25 2005
@@ -20,8 +20,6 @@
 import org.apache.commons.jci.compilers.eclipse.EclipseJavaCompiler;
 import org.apache.commons.jci.listeners.CompilingListener;
 import org.apache.commons.jci.monitor.FilesystemAlterationMonitor;
-import org.apache.commons.jci.problems.CompilationProblemHandler;
-import org.apache.commons.jci.problems.ConsoleCompilationProblemHandler;
 import org.apache.commons.jci.stores.MemoryResourceStore;
 import org.apache.commons.jci.stores.TransactionalResourceStore;
 
@@ -33,7 +31,6 @@
 
     private final TransactionalResourceStore transactionalStore;
     private final JavaCompiler compiler;
-    private final CompilationProblemHandler problemHandler;
 
     public CompilingClassLoader(final ClassLoader pParent, final File pRepository) {
         this(pParent, pRepository, new TransactionalResourceStore(
@@ -47,25 +44,23 @@
     }
 
     public CompilingClassLoader(final ClassLoader pParent, final File pRepository, final
TransactionalResourceStore pStore) {
-        this(pParent, pRepository, pStore, new EclipseJavaCompiler(), new ConsoleCompilationProblemHandler());
+        this(pParent, pRepository, pStore, new EclipseJavaCompiler());
     }
 
     public CompilingClassLoader(final ClassLoader pParent, final File pRepository,
-            final TransactionalResourceStore pStore, final JavaCompiler pCompiler,
-            final CompilationProblemHandler pProblemHandler) {
+            final TransactionalResourceStore pStore, final JavaCompiler pCompiler ) {
         super(pParent, pRepository, pStore);
         transactionalStore = pStore;
         compiler = pCompiler;
-        problemHandler = pProblemHandler;
     }
 
     public void start() {
         fam = new FilesystemAlterationMonitor();
+        // FIXME keep reference for accessing errors/warnings
         fam.addListener(new CompilingListener(
                 reader,
                 compiler,
-                transactionalStore,
-                problemHandler
+                transactionalStore
                 ) {
             public void reload() {
                 super.reload();

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompiler.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompiler.java?rev=239667&r1=239666&r2=239667&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompiler.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/eclipse/EclipseJavaCompiler.java
Wed Aug 24 07:17:25 2005
@@ -253,9 +253,17 @@
             }
         };
 
-        final Compiler compiler =
-            new Compiler(nameEnvironment, policy, settingsMap, compilerRequestor, problemFactory);
+        pProblemHandler.onStart();
 
-        compiler.compile(compilationUnits);
+        try {
+
+            final Compiler compiler =
+                new Compiler(nameEnvironment, policy, settingsMap, compilerRequestor, problemFactory);
+    
+            compiler.compile(compilationUnits);
+
+        } finally {
+            pProblemHandler.onStop();
+        }
     }
 }

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=239667&r1=239666&r2=239667&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
Wed Aug 24 07:17:25 2005
@@ -46,6 +46,8 @@
                     );
             unit.addSource(source[i]);
         }
+        
+        problemHandler.onStart();
         try {
             log.debug("compiling");
             unit.compile();
@@ -77,6 +79,8 @@
                         new GroovyCompilationProblem(message)
                         );                
             }
+        } finally {
+            problemHandler.onStop();
         }
         
     }

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/janino/JaninoJavaCompiler.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/janino/JaninoJavaCompiler.java?rev=239667&r1=239666&r2=239667&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/janino/JaninoJavaCompiler.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/janino/JaninoJavaCompiler.java
Wed Aug 24 07:17:25 2005
@@ -123,6 +123,7 @@
                         final ResourceStore pStore, final CompilationProblemHandler pProblemHandler)
{
         final Map classFilesByName = new HashMap();
         final IClassLoader icl = new CompilingIClassLoader(pResourceReader, pProblemHandler,
classFilesByName);
+        pProblemHandler.onStart();
         for (int i = 0; i < pClasses.length; i++) {
             log.debug("compiling " + pClasses[i]);
             icl.loadIClass(Descriptor.fromClassName(pClasses[i]));
@@ -132,6 +133,7 @@
             final Map.Entry entry = (Map.Entry)i.next();
             pStore.write((String)entry.getKey(), (byte[])entry.getValue());
         }
+        pProblemHandler.onStop();
     }
 
     private static final class CompilationProblemHandlerAdapter implements ErrorHandler,
WarningHandler {

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/listeners/CompilingListener.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/listeners/CompilingListener.java?rev=239667&r1=239666&r2=239667&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/listeners/CompilingListener.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/listeners/CompilingListener.java
Wed Aug 24 07:17:25 2005
@@ -22,7 +22,8 @@
 import org.apache.commons.jci.ReloadingClassLoader;
 import org.apache.commons.jci.compilers.JavaCompiler;
 import org.apache.commons.jci.monitor.FilesystemAlterationListener;
-import org.apache.commons.jci.problems.CompilationProblemHandler;
+import org.apache.commons.jci.problems.CompilationProblem;
+import org.apache.commons.jci.problems.DefaultCompilationProblemHandler;
 import org.apache.commons.jci.readers.ResourceReader;
 import org.apache.commons.jci.stores.TransactionalResourceStore;
 import org.apache.commons.logging.Log;
@@ -40,18 +41,20 @@
     private final JavaCompiler compiler;
     private final ResourceReader reader;
     private final TransactionalResourceStore transactionalStore;
-    private final CompilationProblemHandler problemHandler;
+    private final DefaultCompilationProblemHandler problemHandler = new DefaultCompilationProblemHandler();
     
     public CompilingListener(
             final ResourceReader pReader,
             final JavaCompiler pCompiler,
-            final TransactionalResourceStore pTransactionalStore,
-            final CompilationProblemHandler pProblemHandler
+            final TransactionalResourceStore pTransactionalStore
             ) {
         compiler = pCompiler;
         reader = pReader;
         transactionalStore = pTransactionalStore;
-        problemHandler = pProblemHandler;
+    }
+    
+    public DefaultCompilationProblemHandler getCompilationProblemHandler() {
+        return problemHandler;
     }
     
     public void onStart(final File pRepository) {
@@ -99,13 +102,15 @@
                     problemHandler
                     );
             
+            final CompilationProblem[] errors = problemHandler.getErrors();
+            final CompilationProblem[] warnings = problemHandler.getWarnings();
             
             log.debug(
-                    problemHandler.getErrorCount() + " errors, " +
-                    problemHandler.getWarningCount() + " warnings"
+                    errors.length + " errors, " +
+                    warnings.length + " warnings"
                     );
         
-            if (problemHandler.getErrorCount() > 0) {
+            if (errors.length > 0) {
                 for (int j = 0; j < clazzes.length; j++) {
                     transactionalStore.remove(clazzes[j]);
                 }

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/CompilationProblem.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/CompilationProblem.java?rev=239667&r1=239666&r2=239667&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/CompilationProblem.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/CompilationProblem.java
Wed Aug 24 07:17:25 2005
@@ -22,11 +22,9 @@
   String getFileName();
 
   int getStartLine();
-
   int getStartColumn();
 
   int getEndLine();
-
   int getEndColumn();
 
   String getMessage();

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/CompilationProblemHandler.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/CompilationProblemHandler.java?rev=239667&r1=239666&r2=239667&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/CompilationProblemHandler.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/CompilationProblemHandler.java
Wed Aug 24 07:17:25 2005
@@ -21,7 +21,7 @@
  *
  */
 public interface CompilationProblemHandler {
-    void handle( final CompilationProblem pProblem );    
-    int getErrorCount();    
-    int getWarningCount();
+    void onStart();
+    void handle( final CompilationProblem pProblem );
+    void onStop();
 }

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/ConsoleCompilationProblemHandler.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/ConsoleCompilationProblemHandler.java?rev=239667&r1=239666&r2=239667&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/ConsoleCompilationProblemHandler.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/ConsoleCompilationProblemHandler.java
Wed Aug 24 07:17:25 2005
@@ -19,26 +19,13 @@
  * @author tcurdt
  *
  */
-public class ConsoleCompilationProblemHandler implements CompilationProblemHandler {
-
-    private int errors;
-    private int warnings;
+public final class ConsoleCompilationProblemHandler extends DefaultCompilationProblemHandler
{
 
     public void handle( final CompilationProblem pProblem ) {
         if (pProblem.isError()) {
-            errors++;
-            System.err.println("error(" + errors + "):" + pProblem);
+            System.err.println("error:" + pProblem);
         } else {
-            warnings++;
-            System.err.println("warning(" + warnings + "):" + pProblem);
+            System.err.println("warning:" + pProblem);
         }
-    }
-
-    public int getErrorCount() {
-        return errors;
-    }
-
-    public int getWarningCount() {
-        return warnings;
     }
 }

Added: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/DefaultCompilationProblemHandler.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/DefaultCompilationProblemHandler.java?rev=239667&view=auto
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/DefaultCompilationProblemHandler.java
(added)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/DefaultCompilationProblemHandler.java
Wed Aug 24 07:17:25 2005
@@ -0,0 +1,39 @@
+package org.apache.commons.jci.problems;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+
+public class DefaultCompilationProblemHandler implements CompilationProblemHandler {
+
+    final Collection errors = new ArrayList();
+    final Collection warnings = new ArrayList();
+    
+    public void onStart() {
+        errors.clear();
+        warnings.clear();
+    }
+    
+    public void handle( final CompilationProblem pProblem ) {
+        if (pProblem.isError()) {
+            errors.add(pProblem);
+        } else {
+            warnings.add(pProblem);
+        }
+    }
+    
+    public void onStop() {    
+    }
+    
+    public CompilationProblem[] getErrors() {
+        final CompilationProblem[] result = new CompilationProblem[errors.size()];
+        errors.toArray(result);
+        return result;
+    }
+
+    public CompilationProblem[] getWarnings() {
+        final CompilationProblem[] result = new CompilationProblem[warnings.size()];
+        warnings.toArray(result);
+        return result;
+    }
+}

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/LogCompilationProblemHandler.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/LogCompilationProblemHandler.java?rev=239667&r1=239666&r2=239667&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/LogCompilationProblemHandler.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/problems/LogCompilationProblemHandler.java
Wed Aug 24 07:17:25 2005
@@ -22,28 +22,15 @@
  * @author tcurdt
  *
  */
-public class LogCompilationProblemHandler implements CompilationProblemHandler {
+public final class LogCompilationProblemHandler extends DefaultCompilationProblemHandler
{
 
     private final static Log log = LogFactory.getLog(ConsoleCompilationProblemHandler.class);
 
-    private int errors;
-    private int warnings;
-
     public void handle( final CompilationProblem pProblem ) {
         if (pProblem.isError()) {
-            errors++;
-            log.debug("error(" + errors + "):" + pProblem);
+            log.debug("error:" + pProblem);
         } else {
-            warnings++;
-            log.debug("warning(" + warnings + "):" + pProblem);
+            log.debug("warning:" + pProblem);
         }
-    }
-
-    public int getErrorCount() {
-        return errors;
-    }
-
-    public int getWarningCount() {
-        return warnings;
     }
 }

Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/AbstractCompilerTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/AbstractCompilerTestCase.java?rev=239667&r1=239666&r2=239667&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/AbstractCompilerTestCase.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/compilers/AbstractCompilerTestCase.java
Wed Aug 24 07:17:25 2005
@@ -2,8 +2,7 @@
 
 import java.io.File;
 import org.apache.commons.jci.AbstractTestCase;
-import org.apache.commons.jci.problems.CompilationProblemHandler;
-import org.apache.commons.jci.problems.LogCompilationProblemHandler;
+import org.apache.commons.jci.problems.DefaultCompilationProblemHandler;
 import org.apache.commons.jci.readers.FileResourceReader;
 import org.apache.commons.jci.stores.FileResourceStore;
 
@@ -11,7 +10,7 @@
 public abstract class AbstractCompilerTestCase extends AbstractTestCase {
 
         
-    protected CompilationProblemHandler compileWith( final JavaCompiler pCompiler, final
String pSource ) throws Exception {
+    protected DefaultCompilationProblemHandler compileWith( final JavaCompiler pCompiler,
final String pSource ) throws Exception {
         final File srcDir = new File(directory, "src");
         final File dstDir = new File(directory, "dst");
         
@@ -21,7 +20,7 @@
         final FileResourceReader src = new FileResourceReader(srcDir);
         final FileResourceStore dst = new FileResourceStore(dstDir);
         
-        final CompilationProblemHandler handler = new LogCompilationProblemHandler();
+        final DefaultCompilationProblemHandler handler = new DefaultCompilationProblemHandler();
 
         writeFile("src/jci/Simple.java", pSource);
         

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=239667&r1=239666&r2=239667&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
Wed Aug 24 07:17:25 2005
@@ -3,28 +3,28 @@
 import org.apache.commons.jci.compilers.AbstractCompilerTestCase;
 import org.apache.commons.jci.compilers.JavaCompiler;
 import org.apache.commons.jci.compilers.JavaSources;
-import org.apache.commons.jci.problems.CompilationProblemHandler;
+import org.apache.commons.jci.problems.DefaultCompilationProblemHandler;
 
 
 public final class EclipseJavaCompilerTestCase extends AbstractCompilerTestCase {
     public void testSimpleCompilation() throws Exception {
         final JavaCompiler compiler = new EclipseJavaCompiler();
-        final CompilationProblemHandler handler = compileWith(compiler, JavaSources.simple);
-        assertTrue(handler.getWarningCount() == 0);
-        assertTrue(handler.getErrorCount() == 0);
+        final DefaultCompilationProblemHandler handler = compileWith(compiler, JavaSources.simple);
+        assertTrue(handler.getWarnings().length == 0);
+        assertTrue(handler.getErrors().length == 0);
     }
     
     public void testCompilationError() throws Exception {
         final JavaCompiler compiler = new EclipseJavaCompiler();
-        final CompilationProblemHandler handler = compileWith(compiler, JavaSources.error);
-        assertTrue(handler.getWarningCount() == 0);
-        assertTrue(handler.getErrorCount() == 1);
+        final DefaultCompilationProblemHandler handler = compileWith(compiler, JavaSources.error);
+        assertTrue(handler.getWarnings().length == 0);
+        assertTrue(handler.getErrors().length == 1);
     }
 
     public void testCompilationWarning() throws Exception {
         final JavaCompiler compiler = new EclipseJavaCompiler();
-        final CompilationProblemHandler handler = compileWith(compiler, JavaSources.warning);
-        assertTrue(handler.getWarningCount() == 1);
-        assertTrue(handler.getErrorCount() == 0);
-    }    
+        final DefaultCompilationProblemHandler handler = compileWith(compiler, JavaSources.warning);
+        assertTrue(handler.getWarnings().length == 1);
+        assertTrue(handler.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=239667&r1=239666&r2=239667&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
Wed Aug 24 07:17:25 2005
@@ -3,27 +3,27 @@
 import org.apache.commons.jci.compilers.AbstractCompilerTestCase;
 import org.apache.commons.jci.compilers.GroovySources;
 import org.apache.commons.jci.compilers.JavaCompiler;
-import org.apache.commons.jci.problems.CompilationProblemHandler;
+import org.apache.commons.jci.problems.DefaultCompilationProblemHandler;
 
 
 public final class GroovyJavaCompilerTestCase extends AbstractCompilerTestCase {
     public void testSimpleCompilation() throws Exception {
         final JavaCompiler compiler = new GroovyJavaCompiler();
-        final CompilationProblemHandler handler = compileWith(compiler, GroovySources.simple);
-        assertTrue(handler.getWarningCount() == 0);
-        assertTrue(handler.getErrorCount() == 0);
+        final DefaultCompilationProblemHandler handler = compileWith(compiler, GroovySources.simple);
+        assertTrue(handler.getWarnings().length == 0);
+        assertTrue(handler.getErrors().length == 0);
     }
     
     public void testCompilationError() throws Exception {
         final JavaCompiler compiler = new GroovyJavaCompiler();
-        final CompilationProblemHandler handler = compileWith(compiler, GroovySources.error);
-        assertTrue(handler.getWarningCount() == 0);
-        assertTrue(handler.getErrorCount() == 1);
+        final DefaultCompilationProblemHandler handler = compileWith(compiler, GroovySources.error);
+        assertTrue(handler.getWarnings().length == 0);
+        assertTrue(handler.getErrors().length == 1);
     }
 
     public void testCompilationWarning() throws Exception {
         final JavaCompiler compiler = new GroovyJavaCompiler();
-        final CompilationProblemHandler handler = compileWith(compiler, GroovySources.warning);
-        assertTrue(handler.getWarningCount() == 1);
-        assertTrue(handler.getErrorCount() == 0);
+        final DefaultCompilationProblemHandler handler = compileWith(compiler, GroovySources.warning);
+        assertTrue(handler.getWarnings().length == 1);
+        assertTrue(handler.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=239667&r1=239666&r2=239667&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
Wed Aug 24 07:17:25 2005
@@ -3,28 +3,28 @@
 import org.apache.commons.jci.compilers.AbstractCompilerTestCase;
 import org.apache.commons.jci.compilers.JavaCompiler;
 import org.apache.commons.jci.compilers.JavaSources;
-import org.apache.commons.jci.problems.CompilationProblemHandler;
+import org.apache.commons.jci.problems.DefaultCompilationProblemHandler;
 
 
 public final class JaninoJavaCompilerTestCase extends AbstractCompilerTestCase {
     public void testSimpleCompilation() throws Exception {
         final JavaCompiler compiler = new JaninoJavaCompiler();
-        final CompilationProblemHandler handler = compileWith(compiler, JavaSources.simple);
-        assertTrue(handler.getWarningCount() == 0);
-        assertTrue(handler.getErrorCount() == 0);
+        final DefaultCompilationProblemHandler handler = compileWith(compiler, JavaSources.simple);
+        assertTrue(handler.getWarnings().length == 0);
+        assertTrue(handler.getErrors().length == 0);
     }
     
     public void testCompilationError() throws Exception {
         final JavaCompiler compiler = new JaninoJavaCompiler();
-        final CompilationProblemHandler handler = compileWith(compiler, JavaSources.error);
-        assertTrue(handler.getWarningCount() == 0);
-        assertTrue(handler.getErrorCount() == 1);
+        final DefaultCompilationProblemHandler handler = compileWith(compiler, JavaSources.error);
+        assertTrue(handler.getWarnings().length == 0);
+        assertTrue(handler.getErrors().length == 1);
     }
 
     public void testCompilationWarning() throws Exception {
         final JavaCompiler compiler = new JaninoJavaCompiler();
-        final CompilationProblemHandler handler = compileWith(compiler, JavaSources.warning);
-        //assertTrue(handler.getWarningCount() == 1);
-        assertTrue(handler.getErrorCount() == 0);
+        final DefaultCompilationProblemHandler handler = compileWith(compiler, JavaSources.warning);
+        assertTrue(handler.getWarnings().length == 1);
+        assertTrue(handler.getErrors().length == 0);
     }
 }

Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/problems/CompilationProblemTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/problems/CompilationProblemTestCase.java?rev=239667&r1=239666&r2=239667&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/problems/CompilationProblemTestCase.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/problems/CompilationProblemTestCase.java
Wed Aug 24 07:17:25 2005
@@ -1,5 +1,6 @@
 package org.apache.commons.jci.problems;
 
+import junit.framework.TestCase;
 import org.apache.commons.jci.compilers.eclipse.EclipseCompilationProblem;
 import org.apache.commons.jci.compilers.groovy.GroovyCompilationProblem;
 import org.apache.commons.jci.compilers.janino.JaninoCompilationProblem;
@@ -13,8 +14,6 @@
 import org.eclipse.jdt.internal.compiler.IProblemFactory;
 import org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
 
-import junit.framework.TestCase;
-
 /**
  * TODO: It might be better to actually try to compile some faulty code and
  *       to handle the problems caused by those errors.
@@ -82,16 +81,16 @@
     }
 
     public void testErrorHandling() {
-        final CompilationProblemHandler handler = new ConsoleCompilationProblemHandler();
+        final DefaultCompilationProblemHandler handler = new DefaultCompilationProblemHandler();
         final CompilationProblem error = createJaninoCompilationProblem(true);
         handler.handle(error);
-        assertEquals("wrong number of errors", 1, handler.getErrorCount());
-        assertEquals("wrong number of warnings", 0, handler.getWarningCount());
+        assertEquals("wrong number of errors", 1, handler.getErrors().length);
+        assertEquals("wrong number of warnings", 0, handler.getWarnings().length);
 
         final CompilationProblem warning = createJaninoCompilationProblem(false);
         handler.handle(warning);
-        assertEquals("wrong number of errors", 1, handler.getErrorCount());
-        assertEquals("wrong number of warnings", 1, handler.getWarningCount());
+        assertEquals("wrong number of errors", 1, handler.getErrors().length);
+        assertEquals("wrong number of warnings", 1, handler.getWarnings().length);
     }
 
     private static JaninoCompilationProblem createJaninoCompilationProblem(final boolean
pError) {

Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/utils/ThreadUtilsTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/utils/ThreadUtilsTestCase.java?rev=239667&r1=239666&r2=239667&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/utils/ThreadUtilsTestCase.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/utils/ThreadUtilsTestCase.java
Wed Aug 24 07:17:25 2005
@@ -9,7 +9,7 @@
         final long start = System.currentTimeMillis();
         ThreadUtils.sleep(1000);
         final long stop = System.currentTimeMillis();
-        assertTrue( Math.abs( (stop-start) - 1000) < 20 );
+        assertTrue( Math.abs( (stop-start) - 1000) < 200 );
     }
 
     public void testSleepInterruption() throws InterruptedException {



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message