Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 49347 invoked from network); 14 Aug 2005 15:08:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 14 Aug 2005 15:08:05 -0000 Received: (qmail 89905 invoked by uid 500); 14 Aug 2005 15:08:02 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 89821 invoked by uid 500); 14 Aug 2005 15:08:02 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 89808 invoked by uid 500); 14 Aug 2005 15:08:02 -0000 Received: (qmail 89805 invoked by uid 99); 14 Aug 2005 15:08:01 -0000 X-ASF-Spam-Status: No, hits=-9.8 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Sun, 14 Aug 2005 08:08:01 -0700 Received: (qmail 49301 invoked by uid 65534); 14 Aug 2005 15:08:01 -0000 Message-ID: <20050814150801.49300.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commons-cvs@jakarta.apache.org From: tcurdt@apache.org X-Mailer: svnmailer-1.0.3 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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