You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by malsi <is...@epfl.ch> on 2007/11/29 09:51:48 UTC

JUnit and jackrabbit


Hi,

I am implementing classes that access and store nodes in a repository. I
would like to test my code using JUnit in order to see if my code is doing
well in terms of performance and behavior (see if nodes are realy deleted or
not, really read or not, if the right node is read, etc..)
My questions are the following:

Is JUnit the best way to test my code?
Is there any documentation anywhere for using JUnit for testing an
implementation that uses Jackrabbit ?


cheers.
-- 
View this message in context: http://www.nabble.com/JUnit-and-jackrabbit-tf4895763.html#a14021368
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Re: JUnit and jackrabbit

Posted by Marcel Reutegger <ma...@gmx.net>.
malsi wrote:
> I am implementing classes that access and store nodes in a repository. I
> would like to test my code using JUnit in order to see if my code is doing
> well in terms of performance and behavior (see if nodes are realy deleted or
> not, really read or not, if the right node is read, etc..)
> My questions are the following:
> 
> Is JUnit the best way to test my code?
> Is there any documentation anywhere for using JUnit for testing an
> implementation that uses Jackrabbit ?

jackrabbit already contains unit and integration tests written as JUnits, which 
means you can do a checkout of the jackrabbit-core module and write new test 
classes along the already existing ones.

alternatively and this might probably be easier, you can start from scratch and 
use TransientRepository. This is a convenience class to quickly get a running 
jackrabbit instance.

public class Test extends TestCase {

     private TransientRepository repository;

     public void testLogin() throws RepositoryException {
         Session s = repository.login(new SimpleCredentials("user", 
"pass".toCharArray()));
         try {
             s.getUserID();
         } finally {
             s.logout();
         }
     }

     protected void setUp() throws Exception {
         super.setUp();
         repository = new TransientRepository();
     }

     protected void tearDown() throws Exception {
         repository.shutdown();
         super.tearDown();
     }
}

regards
  marcel