Hi,
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
requested.
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 {
session.logout();
}
}
/**
* 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.
BR,
Jukka Zitting
--
Yukatan - http://yukatan.fi/ - [EMAIL PROTECTED]
Software craftsmanship, JCR consulting, and Java development