Thursday, May 13, 2010

How to setup and test a custom JCR implementation with JCR TCK

JCR TCK stands for Java Content Repository Technology Compatible Kit.

This will guide to test your JCR implementation with JCR2 (JSR 283) TCK.

This example shows how to test WSO2 Governance Registry JCR implementation with JCR TCK.

It is really easy if we can setup a java project (suppose an IDEA project) for testing purposes.

1.Create a new IntellijIDEA project

2.Add the following jars as dependencies to the above created IDEA project.

- jcr-2.0-b114.jar - Download
- jcr-tck-2.0.0.jar - Download
- junit.jar - Download
- org.osgi.core-4.1.0.jar - Download
- jars of your JCR implementation(ex: /.../carbon/components/registry/org.wso2.carbon.registry.jcr/target)
- any other required jars for your impl (for instance in WSO2 greg implementation ,it is better to do an ant inside /..../carbon/products/greg/ modules/distribution/target/wso2greg-3.5.0-SNAPSHOT/bin and add all jars inside /repository/lib and /lib )

3.Then set the following parameters in your test project

- Main Class : junit.swingui.TestRunner
- VM parameters : -Djavax.jcr.tck.properties=/home/subash/aaa/aaa.properties -Dcarbon.home=/home/subash/carbon/core/distribution/target/ wso2carbon-3.0.0-SNAPSHOT.
(Here note that aaa.properties file contains the name (as a value for the key javax.jcr.tck.repository_stub_impl) of your class which extends RepositoryStub ,which is used to return your RepositoryImpl to start the test ,also we have to set the carbon home to the above path ,carbon core)

- Programme parameters : org.apache.jackrabbit.test.api.NodeTest :This is the test class which you are going to test (actually you can change the test class you want , by simply changing this param)
- Working Directory : Set the working dir to your repository product home dir (for instance in this case: /..../carbon/products/greg/modules/distribution/target/wso2greg-3.5.0-SNAPSHOT)

4.Thats it.But remember ,you have to create your own class RepositoryStubImpl (any name which is the value for the key javax.jcr.tck.repository_stub_impl)
and implement getRepository() method such that you return your JCR RepositoryImpl instance.

No comments:

Post a Comment