Running the SPI Testsuite unit tests with maven

View: New views
5 Messages — Rating Filter:   Alert me  

Running the SPI Testsuite unit tests with maven

by Pierre Leman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,


I'm currently trying to run the SPI testsuite on my SPI implementation with
maven but it doesn't seem to work (I don't see them running when I launch a
command like mvn install or mvn test). The interesting parts of my maven
project POM are given below.

Thanks in advance,
Pierre

PS : Special thanks to Angela for the work realised on the SPI Testsuite

Dependencies section :
     <!-- spi2mdweb connector dependencies -->
    <dependency>
        <groupId>javax.jcr</groupId>
        <artifactId>jcr</artifactId>
        <version>1.0</version>
        <scope>provided</scope>
      </dependency>
      <dependency>
        <groupId>org.apache.jackrabbit</groupId>
        <artifactId>jackrabbit-spi</artifactId>
        <version>1.5-SNAPSHOT</version>
      </dependency>
      <dependency>
        <groupId>org.apache.jackrabbit</groupId>
        <artifactId>jackrabbit-spi-commons</artifactId>
        <version>1.5-SNAPSHOT</version>
      </dependency>
      <dependency>
        <groupId>org.apache.jackrabbit</groupId>
        <artifactId>jackrabbit-jcr2spi</artifactId>
        <version>1.5-SNAPSHOT</version>
      </dependency>
      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.0</version>
      </dependency>
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.3.0</version>
      </dependency>
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.3.0</version>
      </dependency>
      <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl104-over-slf4j</artifactId>
        <version>1.3.0</version>
      </dependency>
      <!-- spi2mdweb external tests -->
      <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>jackrabbit-spi</artifactId>
      <version>1.5-SNAPSHOT</version>
      <classifier>tests</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.jackrabbit</groupId>
      <artifactId>jackrabbit-jcr2spi</artifactId>
      <version>1.5-SNAPSHOT</version>
      <classifier>tests</classifier>
      <scope>test</scope>
    </dependency>

Repositories section :
  <repository>
      <id>maven repository 1</id>
      <name>maven repository</name>
      <url>http://repo1.maven.org/maven2/</url>
   </repository>
<!-- Maven Snapshots version needed for Jackrabbit 1.5 -->
    <repository>
          <id>apache.org</id>
          <name>Maven Snapshots</name>
          <url>http://people.apache.org/repo/m2-snapshot-repository</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>

Plugin section :
<plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
            </manifest>
          </archive>
        </configuration>
        <!-- Allow the execution of external test suites -->
         <executions>
         <execution>
           <goals>
             <goal>test-jar</goal>
           </goals>
         </execution>
       </executions>
      </plugin>

Re: Running the SPI Testsuite unit tests with maven

by Angela Schreiber :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi pierre

> I'm currently trying to run the SPI testsuite on my SPI implementation with
> maven but it doesn't seem to work (I don't see them running when I launch a
> command like mvn install or mvn test). The interesting parts of my maven
> project POM are given below.

i'm not a maven expert and initially run into problems
with the classifier-stuff too.

it worked from me both in jackrabbit-spi2jcr and in
the sandbox/spi project by doing the following:

1) providing the following test resources
    > repositoryServiceStubImpl.properties
    > extension of the abstract RepositoryServiceStub
    > a test suite that includes the spi tests
    > additional properties/classes need for creation of
      the stub
    for the complete list i needed see
http://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-spi2jcr/src/test

2) modify the pom.xml by adding an extra
    dependency entry for the tests-jar file thus
    resulting in:

<dependencies>
     [...]
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-spi</artifactId>
       <version>${project.parent.version}</version>
       <classifier></classifier>
     </dependency>
     <dependency>
       <groupId>org.apache.jackrabbit</groupId>
       <artifactId>jackrabbit-spi</artifactId>
       <version>${project.parent.version}</version>
       <classifier>tests</classifier>
       <scope>test</scope>
     </dependency>
     [...]
<dependencies>

i didn't have to touch the maven-surefire-plugin section.

and as far as i know michael duerig did the same when
testing it with his custom SPI implementation. that
seemed to work.

so, can you check if you have all required resources/classes?
if this is the case: what maven version are you using?

hope you get it work!
angela

> PS : Special thanks to Angela for the work realised on the SPI Testsuite

no problem. it's far away from being a complete test-suite. but
at least (if it really works) we have something to start with,
where we can add more tests easily.

Re: Running the SPI Testsuite unit tests with maven

by Pierre Leman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Angela,


Thank you for your answer. I tested what you said today and it worked
perfectly. The tests runs successfully and I see the results in the surefire
reports. So its works great with Maven 2.0.8 and JUnit 4.
I saw that there wasn't so much test for the moment but if I can give a
modest contribution ...
Here is the code of my testGetRootNode() method. I will search if I can't
find other methods sufficiently generic to work in this kind of test cases.

Kind regards,
Pierre

testGetRootNode() {
Node rootNode = service.getRootNode();
assertEquals("The root node must have the JCR path of the root node", "/",
rootNode.getPath());
assertEquals("The root node must have the local name \"\"", "",
rootNode.getName());

try {
      rootNode.getParent();

       fail("The root node cannot have a parent node");
} catch (ItemNotFoundException e) {}
}

Re: Running the SPI Testsuite unit tests with maven

by Angela Schreiber :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

hi pierre

> Thank you for your answer. I tested what you said today and it worked
> perfectly. The tests runs successfully and I see the results in the surefire
> reports.

glad to hear.

> I saw that there wasn't so much test for the moment but if I can give a
> modest contribution ...
> Here is the code of my testGetRootNode() method.
 > Node rootNode = service.getRootNode(); [...]

that's a test against the JCR API, isn't it? these
kind of tests should either go into jackrabbit-jcr-tests
or into the test-section of jackrabbit-jcr2spi.

regarding the spi-tests: probably we will need to add
some more configuration entries, in order to have a
generic suite... in any case: there is more to come.

if you have tests you want to contribute (for any of
the components in jackrabbit), feel free to open
an jira issue.

regards
angela




> I will search if I can't
> find other methods sufficiently generic to work in this kind of test cases.
>
> Kind regards,
> Pierre
>
> testGetRootNode() {

> assertEquals("The root node must have the JCR path of the root node", "/",
> rootNode.getPath());
> assertEquals("The root node must have the local name \"\"", "",
> rootNode.getName());
>
> try {
>       rootNode.getParent();
>
>        fail("The root node cannot have a parent node");
> } catch (ItemNotFoundException e) {}
> }
>


Re: Running the SPI Testsuite unit tests with maven

by Pierre Leman :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Angela,


Concerning the tests you're right I posted the JCR version of my test (I
always make my tests at two levels, one "internal" at SPI level and one
"external" at JCR level). I have well understood that jira is better adapted
than the mailing list for collaboration so I will use it for future code
contribution. So let's go !

Regards,
Pierre
LightInTheBox - Buy quality products at wholesale price