I like the test. Scripting a complex test might be a pain, especially to test distributed caching. Hmmn.
> -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, February 13, 2002 7:58 PM > To: [EMAIL PROTECTED] > Subject: cvs commit: jakarta-turbine-stratum/src/test-conf cache.ccf > log4j.properties logger.properties > > jtaylor 02/02/13 16:57:41 > > Modified: . build-test.xml build.xml default.properties > src/java/org/apache/stratum/jcs/engine/group > GroupCache.java > Added: src/aspect/org/apache/stratum/jcs TraceJCS.aj > src/test/org/apache/stratum/jcs TestJCS.java > src/test-conf cache.ccf log4j.properties logger.properties > Log: > Added a simple unit test for the JCS class. This includes simple cache > and log > configuration files. > > Added optional tracing aspects which are disabled by default. Everything > should > still build and run fine without them. Everything also builds with them, > but > there are still some problems to be worked out. > > build.xml still needs some cleanup. Also, the test structure could be a > little > better, a number of classes which are not Junit tests are getting > included in > the run. > > Revision Changes Path > 1.5 +36 -2 jakarta-turbine-stratum/build-test.xml > > Index: build-test.xml > =================================================================== > RCS file: /home/cvs/jakarta-turbine-stratum/build-test.xml,v > retrieving revision 1.4 > retrieving revision 1.5 > diff -u -r1.4 -r1.5 > --- build-test.xml 5 Feb 2002 20:38:20 -0000 1.4 > +++ build-test.xml 14 Feb 2002 00:57:41 -0000 1.5 > @@ -14,9 +14,28 @@ > <pathelement location="${dom4j.jar}"/> > <pathelement location="${junit.jar}"/> > <pathelement location="${commons-beanutils.jar}"/> > - <pathelement location="${commons-util.jar}"/> > <pathelement location="${commons-collections.jar}"/> > + <pathelement location="${commons-util.jar}"/> > + <pathelement location="${commons-logging.jar}"/> > + <pathelement location="${jgl.jar}"/> > + <pathelement location="${jetty.jar}"/> > + <pathelement location="${log4j.jar}"/> > + <pathelement location="${microstar.xml.jar}"/> > + <pathelement location="${j2ee.jar}"/> > <pathelement location="${servlet.jar}"/> > + <pathelement location="${javamail.jar}"/> > + <pathelement location="${tomcat.jar}"/> > + <pathelement location="${jasper.jar}"/> > + <pathelement location="${hsqldb.jar}"/> > + <pathelement location="${jisp.jar}"/> > + <pathelement location="${javaclass.jar}"/> > + <pathelement location="${jaf.jar}"/> > + <pathelement location="${jaxp.jar}"/> > + <pathelement location="${crimson.jar}"/> > + <pathelement location="${xmlrpc.jar}"/> > + <pathelement location="${build.dest}"/> > + <pathelement location="${aspectjrt.jar}"/> > + > <pathelement location="${build.dest}"/> > </path> > > @@ -26,7 +45,7 @@ > > <target > name="test" > - depends="compile" > + depends="compile,prepare" > description="runs (junit) unit tests"> > > <echo> > @@ -68,6 +87,21 @@ > <pathelement path="${build.dest}"/> > </classpath> > </javac> > + </target> > + > + <target > + name="prepare"> > + > + <!-- Make directory for log output from tests (distinct from > reports) --> > + > + <mkdir dir="${build.dir}/test/logs/jcs"/> > + > + <!-- Copy test config files to the test build dir --> > + > + <copy todir="${build.dest}"> > + <fileset dir="${src.dir}/test-conf"/> > + </copy> > + > </target> > > </project> > > > > 1.18 +55 -6 jakarta-turbine-stratum/build.xml > > Index: build.xml > =================================================================== > RCS file: /home/cvs/jakarta-turbine-stratum/build.xml,v > retrieving revision 1.17 > retrieving revision 1.18 > diff -u -r1.17 -r1.18 > --- build.xml 13 Feb 2002 19:13:59 -0000 1.17 > +++ build.xml 14 Feb 2002 00:57:41 -0000 1.18 > @@ -35,6 +35,11 @@ > <pathelement location="${xmlrpc.jar}"/> > <pathelement location="${build.dest}"/> > > + <!-- AspectJ Jars for non-invasive use of aspects > + this is needed only for acompile target --> > + <pathelement location="${aspectjrt.jar}"/> > + <pathelement location="${aspectjtools.jar}"/> > + > <!-- This is required to bootstrap the build --> > <pathelement location="tdk.jar"/> > </path> > @@ -124,8 +129,13 @@ > depends="init"> > > <mkdir dir="${build.dir}"/> > + <mkdir dir="${build.src}"/> > <mkdir dir="${build.dest}"/> > - > + > + <copy todir="${build.src}" overwrite="yes"> > + <fileset dir="${src.dir}/java/"/> > + </copy> > + > </target> > > <!-- > ================================================================== --> > @@ -134,10 +144,15 @@ > > <target > name="compile" > + depends="javac.compile, aspectj.compile"/> > + > + <target > + name="javac.compile" > + unless="build.includes.aspects" > depends="prepare" > description="==> compiles the source code"> > > - <javac srcdir="${src.dir}/java" > + <javac srcdir="${build.src}" > destdir="${build.dest}" > debug="${debug}" > deprecation="${deprecation}" > @@ -145,8 +160,11 @@ > <classpath refid="classpath"/> > </javac> > > + </target> > > - > + <target > + name="rmi.compile" > + depends="compile"> > > <rmic > base="${build.dest}" > @@ -168,7 +186,38 @@ > base="${build.dest}" > > classname="org.apache.stratum.jcs.auxiliary.remote.RemoteCacheClientTest "/ > > > > + </target> > + > + <!-- > =================================================================== --> > + <!-- A S P E C T C O M P I L E > --> > + <!-- > =================================================================== --> > + > + <target > + name="aspectj.compile" > + if="build.includes.aspects" > + depends="prepare" > + description="==> compiles the source code with aspects"> > + > + <!-- Move aspects into the build cycle --> > + <copy todir="${build.src}" filtering="yes"> > + <fileset dir="${src.dir}/aspect"> > + <include name="**/Trace*.aj" > if="build.includes.tracing.aspects"/> > + </fileset> > + </copy> > + > + <taskdef > + name="ajc" > + classname="org.aspectj.tools.ant.taskdefs.Ajc"/> > > + <ajc srcdir="${build.src}" > + destdir="${build.dest}" > + debug="${debug}" > + deprecation="${deprecation}" > + optimize="${optimize}"> > + <classpath refid="classpath"/> > + <include name="**/*.java"/> > + <include name="**/*.aj"/> > + </ajc> > > </target> > > @@ -191,7 +240,7 @@ > > > <!-- > ================================================================== --> > - <!-- FILTER Scripts and Config Files > --> > + <!-- FILTER Scripts and Config Files > --> > <!-- > ================================================================== --> > > <target > @@ -216,7 +265,7 @@ > > > <!-- > ================================================================== --> > - <!-- Dev Standard Build > --> > + <!-- Dev Standard Build > --> > <!-- > ================================================================== --> > > <target > @@ -261,7 +310,7 @@ > name="clean" > description="==> cleans up the build directory"> > > - <delete dir="${build.dir}/classes/"/> > + <delete dir="${build.dir}"/> > <delete dir="${test.reportsDirectory}"/> > </target> > > > > > 1.15 +15 -0 jakarta-turbine-stratum/default.properties > > Index: default.properties > =================================================================== > RCS file: /home/cvs/jakarta-turbine-stratum/default.properties,v > retrieving revision 1.14 > retrieving revision 1.15 > diff -u -r1.14 -r1.15 > --- default.properties 13 Feb 2002 19:13:59 -0000 1.14 > +++ default.properties 14 Feb 2002 00:57:41 -0000 1.15 > @@ -13,6 +13,7 @@ > final.name = ${project}-${version} > > build.dir = ./bin > +build.src = ${build.dir}/src > build.dest = ${build.dir}/classes > src.dir = ./src > test.dir = ${src.dir}/test > @@ -28,6 +29,15 @@ > optimize = off > deprecation = off > > +# This property determines if the aspectj compiler will be used to > compile. If > +# false, that standard javac task is used > +# build.includes.aspects = true > + > +# Should optional tracing aspects (using AspectJ) be included in the > build? > +# Great for debuging, bad idea for production use! Does nothing without > the > +# above property also being set. > +# build.includes.tracing.aspects = true > + > test.reportsDirectory = test-reports > > commons-beanutils.jar = ${lib.repo}/commons-beanutils.jar > @@ -54,6 +64,11 @@ > crimson.jar = ${lib.repo}/crimson.jar > xmlrpc.jar = ${lib.repo}/xmlrpc.jar > log4j.jar = ${lib.repo}/log4j-1.1.3.jar > + > +# For aspects to be used (entirely optional) > +# Set aspectj.home in your build.properties and all should be good. > +aspectjrt.jar = ${aspectj.home}/lib/aspectjrt.jar > +aspectjtools.jar = ${aspectj.home}/lib/aspectjtools.jar > > # For import scrubber > #importscrubber.jar = ${lib.repo}/importscrubber.jar > > > > 1.1 jakarta-turbine- > stratum/src/aspect/org/apache/stratum/jcs/TraceJCS.aj > > Index: TraceJCS.aj > =================================================================== > package org.apache.stratum.jcs; > > import java.io.PrintStream; > import org.apache.log4j.Category; > > /** > * This class provides support for printing trace messages into a > * log4j category. > * > * The messages are appended with the string representation of the > objects > * whose constructors and methods are being traced. > * > * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> > * @author <a href="mailto:[EMAIL PROTECTED]">James Taylor</a> > * @version $Id: TraceJCS.aj,v 1.1 2002/02/14 00:57:41 jtaylor Exp $ > */ > public aspect TraceJCS > { > /* > * Functional part > */ > > /** > * There are 3 trace levels (values of TRACELEVEL): > * > * 0 - No messages are printed > * 1 - Trace messages are printed, but there is no indentation > * according to the call stack > * 2 - Trace messages are printed, and they are indented > * according to the call stack > */ > public static int TRACELEVEL = 2; > > /** > * Tracks the call depth for indented traces made according > * to the structure of the stack. > */ > protected static int callDepth = 0; > > /** > * Log4j category used for tracing. > */ > private static Category log = Category.getInstance( TraceJCS.class > ); > > /** > * Tracing method used in before advice. > */ > protected static void traceEntry(String str, Object o) > { > if (TRACELEVEL == 0) > { > return; > } > > if (TRACELEVEL == 2) > { > callDepth++; > } > printEntering(str + ": " + o.toString()); > } > > /** > * Tracing method used in after advice. > */ > protected static void traceExit(String str, Object o) > { > if (TRACELEVEL == 0) > { > return; > } > > printExiting(str + ": " + o.toString()); > > if (TRACELEVEL == 2) > { > callDepth--; > } > } > > private static void printEntering(String str) > { > log.debug(indent() + "--> " + str); > } > > private static void printExiting(String str) > { > log.debug(indent() + "<-- " + str); > } > > private static String indent() > { > StringBuffer sb = new StringBuffer(); > > for (int i = 0; i < callDepth; i++) > { > sb.append(" "); > } > > return sb.toString(); > } > > /* > * Crosscut part > */ > > /** > * JCS Application classes > */ > pointcut myClass(Object obj): this(obj) && > (within(org.apache.stratum.jcs..*)); > > /** > * The constructors in those classes. > */ > pointcut myConstructor(Object obj): myClass(obj) && > execution(new(..)); > > /** > * The methods of those classes. > */ > pointcut myMethod(Object obj): myClass(obj) && > execution(* *(..)) && !execution(String toString()); > > /** > * Before advice that will execute before a constructor > * is invoked. > */ > before(Object obj): myConstructor(obj) > { > traceEntry("" + thisJoinPointStaticPart.getSignature(), obj); > } > > /** > * After advice that will execute after a constructor > * a constructor has been invoked. > */ > after(Object obj): myConstructor(obj) > { > traceExit("" + thisJoinPointStaticPart.getSignature(), obj); > } > > /** > * Before advice that will execute before a method > * is invoked. > */ > before(Object obj): myMethod(obj) > { > traceEntry("" + thisJoinPointStaticPart.getSignature(), obj); > } > > /** > * After advice that will execute after a method > * has been invoked. > */ > after(Object obj): myMethod(obj) > { > traceExit("" + thisJoinPointStaticPart.getSignature(), obj); > } > } > > > > 1.10 +14 -35 jakarta-turbine- > stratum/src/java/org/apache/stratum/jcs/engine/group/GroupCache.java > > Index: GroupCache.java > =================================================================== > RCS file: /home/cvs/jakarta-turbine- > stratum/src/java/org/apache/stratum/jcs/engine/group/GroupCache.java,v > retrieving revision 1.9 > retrieving revision 1.10 > diff -u -r1.9 -r1.10 > --- GroupCache.java 13 Feb 2002 19:13:59 -0000 1.9 > +++ GroupCache.java 14 Feb 2002 00:57:41 -0000 1.10 > @@ -83,18 +83,17 @@ > import org.apache.commons.logging.LogSource; > > /** > - * Group cache is basically a composite cache with the additional > capability of > - * providing automatic and safe attribute name list update for each > - * GroupAttrName cache item. > + * Group cache is basically a composite cache with the additional > capability of > + * providing automatic and safe attribute name list update for each > + * GroupAttrName cache item. > * > - * TODO: WORKING ON THIS NOW -- reduce the number of methods or > describe > - * them better. The complexity of this points to group design > problems. I need > - * to fix the locking and the maintenance of the remote list. The list > can be > - * infered fromt he contents of the cache. Iterating through the > hashtable > - * could be problematic but easier. > + * TODO: WORKING ON THIS NOW -- reduce the number of methods or > describe > + * them better. The complexity of this points to group design problems. > I need > + * to fix the locking and the maintenance of the remote list. The list > can be > + * infered fromt he contents of the cache. Iterating through the > hashtable > + * could be problematic but easier. > * > - *@author asmuts > - *@created January 15, 2002 > + * @author asmuts > */ > public class GroupCache extends Cache implements ICompositeCache > { > @@ -106,11 +105,6 @@ > private ReadWriteLockManager locker = > GroupRWLockManager.getInstance(); > > /** > - * Rarely used class identity. Mainly for debugging. > - */ > - private String source_id = > "org.apache.stratum.jcs.engine.group.GroupCache"; > - > - /** > * Declare a group_id cache here, so ids and elements don't compete > * for first with the list. > * The systemGroupIdCache will have different remote behavior. > @@ -118,31 +112,16 @@ > * the list will not move back and forth. > * The list can be maintained locally but the elements themselves > * need not be. > - * > */ > ICompositeCache systemGroupIdCache; > > - > - /////////////////////////////////////////////////// > - /** > - * Gets the sourceId attribute of the GroupCache object > - * > - *@return The sourceId value > - */ > - public Serializable getSourceId() > - { > - return this.source_id; > - } > - > - > - /////////////////////////////////////////////////////////////// > /** > - * Constructor for the GroupCache object > + * Constructor for the GroupCache object > * > - *@param cacheName The name of the region > - *@param auxCaches The auxiliary caches to be used by this region > - *@param cattr The cache attribute > - *@param attr The default element attributes > + * @param cacheName The name of the region > + * @param auxCaches The auxiliary caches to be used by this > region > + * @param cattr The cache attribute > + * @param attr The default element attributes > */ > public GroupCache( String cacheName, ICache[] auxCaches, > ICompositeCacheAttributes cattr, Attributes attr ) > { > > > > 1.1 jakarta-turbine- > stratum/src/test/org/apache/stratum/jcs/TestJCS.java > > Index: TestJCS.java > =================================================================== > package org.apache.stratum.jcs; > > /* ==================================================================== > * The Apache Software License, Version 1.1 > * > * Copyright (c) 2001-2002 The Apache Software Foundation. All rights > * reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions > * are met: > * > * 1. Redistributions of source code must retain the above copyright > * notice, this list of conditions and the following disclaimer. > * > * 2. Redistributions in binary form must reproduce the above copyright > * notice, this list of conditions and the following disclaimer in > * the documentation and/or other materials provided with the > * distribution. > * > * 3. The end-user documentation included with the redistribution, > * if any, must include the following acknowledgment: > * "This product includes software developed by the > * Apache Software Foundation (http://www.apache.org/)." > * Alternately, this acknowledgment may appear in the software > itself, > * if and wherever such third-party acknowledgments normally appear. > * > * 4. The names "Apache" and "Apache Software Foundation" and > * "Apache Turbine" must not be used to endorse or promote products > * derived from this software without prior written permission. For > * written permission, please contact [EMAIL PROTECTED] > * > * 5. Products derived from this software may not be called "Apache", > * "Apache Turbine", nor may "Apache" appear in their name, without > * prior written permission of the Apache Software Foundation. > * > * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED > * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE > * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR > * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, > * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT > * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF > * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND > * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, > * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT > * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > * SUCH DAMAGE. > * ==================================================================== > * > * This software consists of voluntary contributions made by many > * individuals on behalf of the Apache Software Foundation. For more > * information on the Apache Software Foundation, please see > * <http://www.apache.org/>. > */ > > import junit.framework.Test; > import junit.framework.TestCase; > import junit.framework.TestSuite; > > import org.apache.stratum.jcs.JCS; > > import java.util.LinkedList; > import java.util.HashMap; > import java.util.Random; > > /** > * Simple test for the JCS class. > * > * @author <a href="mailto:[EMAIL PROTECTED]">James Taylor</a> > * @version $Id: TestJCS.java,v 1.1 2002/02/14 00:57:41 jtaylor Exp $ > */ > public class TestJCS extends TestCase > { > Random random = new Random(); > > public TestJCS( String testName ) > { > super( testName ); > } > > public static Test suite() > { > return new TestSuite( TestJCS.class ); > } > > public static void main( String args[] ) > { > String[] testCaseName = { TestJCS.class.getName() }; > junit.textui.TestRunner.main( testCaseName ); > } > > public void testJCS() throws Exception > { > JCS jcs = JCS.getInstance( "testCache1" ); > > LinkedList list = buildList(); > > jcs.put( "some:key", list ); > > assertEquals( list, jcs.get( "some:key" ) ); > } > > private LinkedList buildList() > { > LinkedList list = new LinkedList(); > > for ( int i = 0; i < 100; i++ ) > { > list.add( buildMap() ); > } > > return list; > } > > private HashMap buildMap() > { > HashMap map = new HashMap(); > > byte[] keyBytes = new byte[32]; > byte[] valBytes = new byte[128]; > > for ( int i = 0; i < 10; i++ ) > { > random.nextBytes( keyBytes ); > random.nextBytes( valBytes ); > > map.put( new String( keyBytes ), new String( valBytes ) ); > } > > return map; > } > > } > > > > 1.1 jakarta-turbine-stratum/src/test-conf/cache.ccf > > Index: cache.ccf > =================================================================== > # JCS Config for unit testing, just a simple memory only cache > > jcs.default= > > jcs.default.cacheattributes=org.apache.stratum.jcs.engine.CompositeCache At > tributes > jcs.default.cacheattributes.MaxObjects=1000 > > jcs.default.cacheattributes.MemoryCacheName=org.apache.stratum.jcs.engin e. > memory.lru.LRUMemoryCache > > jcs.system.groupIdCache= > > jcs.system.groupIdCache.cacheattributes=org.apache.stratum.jcs.engine.Co mp > ositeCacheAttributes > jcs.system.groupIdCache.cacheattributes.MaxObjects=10000 > > jcs.system.groupIdCache.cacheattributes.MemoryCacheName=org.apache.strat um > .jcs.engine.memory.lru.LRUMemoryCache > > jcs.region.testCache1= > > jcs.region.testCache1.cacheattributes=org.apache.stratum.jcs.engine.Comp os > iteCacheAttributes > jcs.region.testCache1.cacheattributes.MaxObjects=1000 > > jcs.region.testCache1.cacheattributes.MemoryCacheName=org.apache.stratum .j > cs.engine.memory.lru.LRUMemoryCache > > > > > 1.1 jakarta-turbine-stratum/src/test- > conf/log4j.properties > > Index: log4j.properties > =================================================================== > # For unit testing, all output goes to bin/test/logs/jcs.log > > log4j.category.org.apache.stratum.jcs = DEBUG, jcs > log4j.appender.jcs = org.apache.log4j.FileAppender > log4j.appender.jcs.file = bin/test/logs/jcs.log > log4j.appender.jcs.layout = org.apache.log4j.PatternLayout > log4j.appender.jcs.layout.conversionPattern = %d [%t] %-5p %c - %m%n > log4j.appender.jcs.append = false > > > > 1.1 jakarta-turbine-stratum/src/test- > conf/logger.properties > > Index: logger.properties > =================================================================== > # The LoggerManager creates loggers for entries in this file. > # This initializes certain logs at the set debugging levels( 0 - 4 ) > # A management tool will force reinitialization and a reread of this > file at > # runtime. However the primary way to alter runtime loggin levels will > be to > # modify the level of the logger object through the tool. > # An entry must have a .level entry to be initialized > # .systemout is N by default, Y will turn it on > # .maxfilesize -- number of bytes before archiving log > # .numtocheck -- number of entries before checking to see if it is too > big > # The logroot value is used by default. This can be overridden with > # a specific entry > > logroot=bin/test/jcs/logs > > # the sleepinterval value is how often the writing thread wakes up in > ms. > # Recommend set to 1000 for development servers (so it would write with > 1 sec. delay > # and 10000 for production servers (so it would write every 10 seconds.) > > #Min is 5 secs ie 5000 > sleepInterval=1000 > > # The string buffer size before messages are flushed to disk. > # Minimum is zero, which flushes every log message to disk asap. > buffer_capacity=0 > > access_cacheaccess.level=2 > access_cacheaccess.systemout=y > access_cacheaccess.maxfilesize=100000 > access_cacheaccess.numtocheck=300 > > control_cache.level=2 > control_cache.systemout=y > control_cache.maxfilesize=100000 > control_cache.numtocheck=300 > > engine_groupcache.level=2 > engine_groupcache.systemout=y > engine_groupcache.maxfilesize=100000 > engine_groupcache.numtocheck=300 > > control_cachemanager.level=2 > control_cachemanager.systemout=y > control_cachemanager.maxfilesize=100000 > control_cachemanager.numtocheck=300 > > memory_lateralcacheunicaster.level=0 > memory_lateralcacheunicaster.systemout=n > memory_lateralcacheunicaster.maxfilesize=100000 > memory_lateralcacheunicaster.numtocheck=300 > > remote_remotecachemanager.level=2 > remote_remotecachemanager.systemout=y > remote_remotecachemanager.maxfilesize=100000 > remote_remotecachemanager.numtocheck=300 > > group_remotegroupcacheserver.level=2 > group_remotegroupcacheserver.systemout=y > group_remotegroupcacheserver.maxfilesize=100000 > group_remotegroupcacheserver.numtocheck=300 > > > > > -- > To unsubscribe, e-mail: <mailto:turbine-dev- > [EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:turbine-dev- > [EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
