commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcu...@apache.org
Subject svn commit: r232615 - in /jakarta/commons/sandbox/jci/trunk: ./ src/test/org/apache/commons/jci/ src/test/org/apache/commons/jci/monitor/ src/test/org/apache/commons/jci/readers/ src/test/org/apache/commons/jci/stores/
Date Sun, 14 Aug 2005 15:07:59 GMT
Author: tcurdt
Date: Sun Aug 14 08:07:48 2005
New Revision: 232615

URL: http://svn.apache.org/viewcvs?rev=232615&view=rev
Log:
more testcases


Added:
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/readers/
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/readers/FileResourceReaderTestCase.java
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/stores/TransactinonalResourceStoreTestCase.java
Modified:
    jakarta/commons/sandbox/jci/trunk/TODO
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/CompilingClassLoaderTestCase.java
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/ReloadingClassLoaderTestCase.java
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/monitor/FilesystemAlterationMonitorTestCase.java
    jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/stores/FileResourceStoreTestCase.java

Modified: jakarta/commons/sandbox/jci/trunk/TODO
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/TODO?rev=232615&r1=232614&r2=232615&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/TODO (original)
+++ jakarta/commons/sandbox/jci/trunk/TODO Sun Aug 14 08:07:48 2005
@@ -1,8 +1,10 @@
 o integrate just4log into the build system
-o subscribing to compiler events
-o monitor multiple repositories
 o compiler factory
 o compiler implementations
   o groovy
   o embedded java compiler
   o javac 
+  o jikes
+o transformation "pipelines"
+o make suffixes matching (*.java, *.class) configurable
+o documentation

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=232615&r1=232614&r2=232615&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
Sun Aug 14 08:07:48 2005
@@ -152,6 +152,7 @@
     }
 
     protected void tearDown() throws Exception {
+        cl.removeListener(listener);
         cl.stop();
         super.tearDown();
     }

Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/ReloadingClassLoaderTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/ReloadingClassLoaderTestCase.java?rev=232615&r1=232614&r2=232615&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/ReloadingClassLoaderTestCase.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/ReloadingClassLoaderTestCase.java
Sun Aug 14 08:07:48 2005
@@ -16,29 +16,137 @@
 package org.apache.commons.jci;
 
 import java.io.File;
-import junit.framework.TestCase;
+import org.apache.commons.jci.compilers.Programs;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 
-public final class ReloadingClassLoaderTestCase extends TestCase {
+public final class ReloadingClassLoaderTestCase extends AbstractTestCase {
+
+    private final static Log log = LogFactory.getLog(ReloadingClassLoaderTestCase.class);
+    
+    private final Signal reload = new Signal();
 
     private ReloadingClassLoader cl;
-    private File repository;
+    private ReloadingClassLoaderListener listener;
     
     protected void setUp() throws Exception {
+        super.setUp();
+        
+        listener = new ReloadingClassLoaderListener() {
+            public void reload() {
+                synchronized(reload) {
+                    reload.triggered = true;
+                    reload.notify();
+                }
+            }
+        };
+
+        cl = new ReloadingClassLoader(this.getClass().getClassLoader(), directory);
+        cl.addListener(listener);
+        cl.start();
+    }
+
+    private void initialCompile() throws Exception {
+        delay();
+        
+        // writeFile
+        // compile file
+        
+        waitForSignal(reload);
+
+        writeFile("jci/Simple.class",
+                Programs.simple
+        );
+        
+        waitForSignal(reload);
+    }
+    
+    
+    public void testCreate() throws Exception {
+        initialCompile();
+        
+        Object o;
+        
+        o = cl.loadClass("jci.Simple").newInstance();        
+        assertTrue("Simple".equals(o.toString()));        
     }
 
+    public void testChange() throws Exception {        
+        initialCompile();
 
-    public void testCreate() {
+        Object o;
+        
+        o = cl.loadClass("jci.Simple").newInstance();        
+        assertTrue("Simple".equals(o.toString()));
+        
+        writeFile("jci/Simple.java",
+                Programs.SIMPLE
+        );
+
+        waitForSignal(reload);
+    
+        o = cl.loadClass("jci.Simple").newInstance();        
+        assertTrue("SIMPLE".equals(o.toString()));        
     }
 
-    public void testChange() {        
+    public void testDelete() throws Exception {
+        initialCompile();
+
+        Object o;
+        
+        o = cl.loadClass("jci.Simple").newInstance();        
+        assertTrue("Simple".equals(o.toString()));
+        
+        assertTrue(new File(directory, "jci/Simple.java").delete());
+        
+        waitForSignal(reload);
+
+        try {
+            o = cl.loadClass("jci.Simple").newInstance();        
+            fail();
+        } catch(final ClassNotFoundException e) {
+        }
+        
     }
 
-    public void testDelete() {        
+    public void testDeleteDependency() throws Exception {        
+        initialCompile();
+
+        Object o;
+        
+        o = cl.loadClass("jci.Simple").newInstance();        
+        assertTrue("Simple".equals(o.toString()));
+        
+        o = cl.loadClass("jci.Extended").newInstance();        
+        assertTrue("Extended:Simple".equals(o.toString()));
+        
+        assertTrue(new File(directory, "jci/Simple.class").delete());
+        
+        waitForSignal(reload);
+
+        try {
+            o = cl.loadClass("jci.Extended").newInstance();
+            fail();
+        } catch(final NoClassDefFoundError e) {
+            assertTrue("jci/Simple".equals(e.getMessage()));
+        }
+        
     }
 
+    public void testClassNotFound() {
+        try {
+            Object o = cl.loadClass("bla");
+            fail();
+        } catch(final ClassNotFoundException e) {
+            log.info(e.getMessage());
+        }
+    }
     
     protected void tearDown() throws Exception {
+        cl.removeListener(listener);
+        cl.stop();
+        super.tearDown();
     }
-
+    
 }

Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/monitor/FilesystemAlterationMonitorTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/monitor/FilesystemAlterationMonitorTestCase.java?rev=232615&r1=232614&r2=232615&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/monitor/FilesystemAlterationMonitorTestCase.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/monitor/FilesystemAlterationMonitorTestCase.java
Sun Aug 14 08:07:48 2005
@@ -254,4 +254,16 @@
         assertTrue(directory.lastModified() == modified);
     }
     
+    public void testInterval() throws Exception {
+        start();
+        fam.setInterval(1000);
+        stop();
+    }
+    
+    public void testListener() throws Exception {
+        start();
+        fam.removeListener(listener);
+        stop();
+    }
+    
 }

Added: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/readers/FileResourceReaderTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/readers/FileResourceReaderTestCase.java?rev=232615&view=auto
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/readers/FileResourceReaderTestCase.java
(added)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/readers/FileResourceReaderTestCase.java
Sun Aug 14 08:07:48 2005
@@ -0,0 +1,19 @@
+package org.apache.commons.jci.readers;
+
+import org.apache.commons.jci.AbstractTestCase;
+
+
+public final class FileResourceReaderTestCase extends AbstractTestCase {
+    public void testGetContent() throws Exception {
+        final ResourceReader reader = new FileResourceReader(directory);
+        writeFile("test", "test");
+
+        assertTrue(reader.isAvailable("test"));
+        final char[] content = reader.getContent("test");
+        assertTrue(content != null);
+        assertTrue("test".equals(new String(content)));        
+
+        assertTrue(!reader.isAvailable("bla"));
+        assertTrue(reader.getContent("bla") == null);
+    }
+}

Modified: jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/stores/FileResourceStoreTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/stores/FileResourceStoreTestCase.java?rev=232615&r1=232614&r2=232615&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/stores/FileResourceStoreTestCase.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/stores/FileResourceStoreTestCase.java
Sun Aug 14 08:07:48 2005
@@ -23,6 +23,9 @@
         final ResourceStore store = new FileResourceStore(directory);
         super.testStore(store);
     }
+
+    public void testFailedStore() {
+    }
     
     public void testRemove() {
         final ResourceStore store = new FileResourceStore(directory);

Added: 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=232615&view=auto
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/stores/TransactinonalResourceStoreTestCase.java
(added)
+++ jakarta/commons/sandbox/jci/trunk/src/test/org/apache/commons/jci/stores/TransactinonalResourceStoreTestCase.java
Sun Aug 14 08:07:48 2005
@@ -0,0 +1,42 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * 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.
+ */
+package org.apache.commons.jci.stores;
+
+
+
+public final class TransactinonalResourceStoreTestCase extends AbstractStoreTestCase {
+
+    public void testStore() {
+        final TransactionalResourceStore store = new TransactionalResourceStore(new MemoryResourceStore())
{
+            public void onStart() {
+            }
+            public void onStop() {
+            }
+        };
+        super.testStore(store);
+        assertTrue("[key]".equals(store.toString()));
+    }
+    
+    public void testRemove() {
+        final TransactionalResourceStore store = new TransactionalResourceStore(new MemoryResourceStore())
{
+            public void onStart() {
+            }
+            public void onStop() {
+            }
+        };
+        super.testRemove(store);
+    }
+}



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