commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcu...@apache.org
Subject svn commit: r384799 - in /jakarta/commons/sandbox/jci/trunk/src: java/org/apache/commons/jci/compilers/ java/org/apache/commons/jci/monitor/ java/org/apache/commons/jci/utils/ test/org/apache/commons/jci/ test/org/apache/commons/jci/utils/
Date Fri, 10 Mar 2006 14:19:31 GMT
Author: tcurdt
Date: Fri Mar 10 06:19:29 2006
New Revision: 384799

URL: http://svn.apache.org/viewcvs?rev=384799&view=rev
Log:
extending the testcase to show the behavior Patrick Lightbody was reporting,
fixed http://issues.apache.org/bugzilla/show_bug.cgi?id=37137


Added:
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/MyBar.java   (with props)
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/MyFoo.java   (with props)
Removed:
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/utils/
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/utils/
Modified:
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/JavaCompiler.java
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/monitor/FilesystemAlterationMonitor.java
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/AbstractTestCase.java
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/CompilingClassLoaderTestCase.java

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/JavaCompiler.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/JavaCompiler.java?rev=384799&r1=384798&r2=384799&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/JavaCompiler.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/compilers/JavaCompiler.java
Fri Mar 10 06:19:29 2006
@@ -29,15 +29,14 @@
     void setCompilationProblemHandler( final CompilationProblemHandler pHandler );
     
     CompilationResult compile(
-                              final String[] pClazzNames,
-                              final ResourceReader pReader,
-                              final ResourceStore pStore
-                              );    
+            final String[] pClazzNames,
+            final ResourceReader pReader,
+            final ResourceStore pStore );
+
 
     CompilationResult compile(
             final String[] pClazzNames,
             final ResourceReader pReader,
             final ResourceStore pStore,
-            final ClassLoader classLoader
-            );
+            final ClassLoader classLoader );
 }

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/monitor/FilesystemAlterationMonitor.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/monitor/FilesystemAlterationMonitor.java?rev=384799&r1=384798&r2=384799&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/monitor/FilesystemAlterationMonitor.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/monitor/FilesystemAlterationMonitor.java
Fri Mar 10 06:19:29 2006
@@ -17,7 +17,6 @@
 import java.util.Map;
 import java.util.Set;
 import org.apache.commons.collections.MultiHashMap;
-import org.apache.commons.jci.utils.ThreadUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -419,7 +418,10 @@
                     onStop(directory);
                 }
             }
-            ThreadUtils.sleep(delay);
+            try {
+                Thread.sleep(delay);
+            } catch (final InterruptedException e) {
+            }
         }
         log.info("fam exiting");
     }

Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/AbstractTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/AbstractTestCase.java?rev=384799&r1=384798&r2=384799&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/AbstractTestCase.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/AbstractTestCase.java
Fri Mar 10 06:19:29 2006
@@ -21,7 +21,6 @@
 import java.io.IOException;
 import junit.framework.TestCase;
 import org.apache.commons.io.FileUtils;
-import org.apache.commons.jci.utils.ThreadUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -101,7 +100,10 @@
     }
     
     protected void delay() {
-        ThreadUtils.sleep(1500);
+        try {
+            Thread.sleep(1500);
+        } catch (final InterruptedException e) {
+        }
     }
     
     protected File createTempDirectory() throws IOException {

Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/CompilingClassLoaderTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/CompilingClassLoaderTestCase.java?rev=384799&r1=384798&r2=384799&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/CompilingClassLoaderTestCase.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/CompilingClassLoaderTestCase.java
Fri Mar 10 06:19:29 2006
@@ -1,6 +1,8 @@
 package org.apache.commons.jci;
 
 import java.io.File;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.jci.compilers.AbstractCompilerTestCase;
 import org.apache.commons.jci.compilers.JavaSources;
@@ -18,6 +20,17 @@
     private CompilingListener listener;
     private FilesystemAlterationMonitor fam;
     
+    private final static class BeanUtils {
+        
+        public static void setProperty( Object object, String property, Object value) throws
SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException,
InvocationTargetException {
+            final Class clazz = object.getClass();
+            
+            final Method setter = clazz.getMethod("set" + property, new Class[]{ value.getClass()});
+            setter.invoke(object, new Object[]{ value });   
+        }
+    }
+    
+    
     protected void setUp() throws Exception {
         super.setUp();
         
@@ -133,6 +146,109 @@
         }
         
     }
+
+
+    public void testReference1() throws Exception {        
+        delay();        
+        writeFile("jci/Foo.java",
+                "package jci;\n" + 
+                "\n" + 
+                "public class Foo {\n" + 
+                "    public String toString() {\n" + 
+                "        return \"foo1\";\n" + 
+                "    }\n" + 
+                "}"
+                );        
+        writeFile("jci/Bar.java",
+                "package jci;\n" + 
+                "\n" + 
+                "public class Bar {\n" + 
+                "    \n" + 
+                "    private Foo foo;\n" + 
+                "    \n" + 
+                "    public void setFoo( Foo foo) {\n" + 
+                "        this.foo = foo;\n" + 
+                "    }\n" + 
+                "    \n" + 
+                "    public String toString() {\n" + 
+                "        return \"bar1\";\n" + 
+                "    }\n" + 
+                "}"
+                );        
+        listener.waitForNotification();
+        
+        final Object foo1 = classloader.loadClass("jci.Foo").newInstance();        
+        assertTrue("foo1".equals(foo1.toString()));
+
+        final Object bar1 = classloader.loadClass("jci.Bar").newInstance();        
+        assertTrue("bar1".equals(bar1.toString()));
+        
+        BeanUtils.setProperty(bar1, "Foo", foo1);
+        
+        delay();
+        writeFile("jci/Foo.java",
+                "package jci;\n" + 
+                "\n" + 
+                "public class Foo {\n" + 
+                "    public String toString() {\n" + 
+                "        return \"foo2\";\n" + 
+                "    }\n" + 
+                "}"
+                );        
+        listener.waitForNotification();
+
+        final Object foo2 = classloader.loadClass("jci.Foo").newInstance();        
+        assertTrue("foo2".equals(foo2.toString()));
+
+        final Object bar2 = classloader.loadClass("jci.Bar").newInstance();        
+        // has not change -> still bar1
+        assertTrue("bar1".equals(bar2.toString()));
+    
+        BeanUtils.setProperty(bar2, "Foo", foo2);
+        BeanUtils.setProperty(bar1, "Foo", foo2);
+
+    }
+
+    public void testReference2() throws Exception {        
+        delay();        
+        writeFile("jci/Foo.java",
+                "package jci;\n" + 
+                "\n" + 
+                "public class Foo implements org.apache.commons.jci.MyFoo {\n" + 
+                "    public String toString() {\n" + 
+                "        return \"foo1\";\n" + 
+                "    }\n" + 
+                "}"
+                );        
+        listener.waitForNotification();
+        
+        final MyFoo foo1 = (MyFoo) classloader.loadClass("jci.Foo").newInstance();      
 
+        assertTrue("foo1".equals(foo1.toString()));
+
+
+        final MyBar bar1 = new MyBar();
+        bar1.setFoo(foo1);
+        
+        delay();
+        writeFile("jci/Foo.java",
+                "package jci;\n" + 
+                "\n" + 
+                "public class Foo implements org.apache.commons.jci.MyFoo {\n" + 
+                "    public String toString() {\n" + 
+                "        return \"foo2\";\n" + 
+                "    }\n" + 
+                "}"
+                );        
+        listener.waitForNotification();
+
+        final MyFoo foo2 = (MyFoo) classloader.loadClass("jci.Foo").newInstance();      
 
+        assertTrue("foo2".equals(foo2.toString()));
+
+        bar1.setFoo(foo2);
+    }
+
+
+
 
     protected void tearDown() throws Exception {
         fam.removeListener(listener);

Added: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/MyBar.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/MyBar.java?rev=384799&view=auto
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/MyBar.java (added)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/MyBar.java Fri Mar 10
06:19:29 2006
@@ -0,0 +1,11 @@
+package org.apache.commons.jci;
+
+
+public class MyBar {
+
+    private MyFoo foo;
+    
+    public void setFoo( MyFoo foo) {
+        this.foo = foo;
+    }
+}

Propchange: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/MyBar.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/MyBar.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/MyFoo.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/MyFoo.java?rev=384799&view=auto
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/MyFoo.java (added)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/MyFoo.java Fri Mar 10
06:19:29 2006
@@ -0,0 +1,5 @@
+package org.apache.commons.jci;
+
+
+public interface MyFoo {
+}

Propchange: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/MyFoo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/MyFoo.java
------------------------------------------------------------------------------
    svn:keywords = Id



---------------------------------------------------------------------
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