jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting" <jukka.zitt...@gmail.com>
Subject Re: Simple unit test template
Date Wed, 22 Mar 2006 23:55:32 GMT

Another shot at this same issue. I'd like to add a
org.apache.jackrabbit.core.TestRepository helper class that could be
used to solve the standalone vs. integrated test case problem without
exposing any details to the
test case writer. The TestRepository class would contain a static
repository instance with configuration that gives a session with full
read-write access from the default Repository.login() method. Unless
this instance is explicitly set by the main test suite then it a
default test repository is automatically created when it is first

Such a helper class could simplify the unit test template to:

    import javax.jcr.*;
    import junit.framework.Test;
    import junit.framework.TestCase;
    import junit.framework.TestSuite;
    import org.apache.jackrabbit.core.TestRepository;

     * Template test case for Jackrabbit. Use this template to write test cases
     * to accompany Jackrabbit bug reports.
    public class ExampleTest extends TestCase {

        public void testSomething() throws Exception {
            Session session = TestRepository.getInstance().login();
            try {
                // TODO: Add test code here.
            } finally {

          * Returns a test suite that contains all the tests in this class.
          * @return test suite
         public static Test suite() {
             return new TestSuite(ExampleTest.class);


I'll file an issue with a simple implementation of the TestRepository
class. Unless anyone objects I'd like to include also this class in
1.0-rc3 so that we can instruct people to use such a unit test
template with any Jackrabbit 1.x version.


Jukka Zitting

Yukatan - http://yukatan.fi/ - info@yukatan.fi
Software craftsmanship, JCR consulting, and Java development
View raw message