Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

What's the difference: Unit verses Integration Test?

Triplesec modules all have unit tests and these test out individual functions in isolation. These unit tests do not test the functionality by starting up an instance of the server and testing everything end to end. These kinds of resource intensive tests which start instances of Triplesec are really integration tests.

Running Integration Tests

To run the integration tests just issue the following command at the top level or within a module:

No Format
mvn -Dintegration test
Note
titleIntegration Tests Take a While

Integration tests start up an instance of Triplesec and run several iterations of tests by building and destroying a new instance every time. So prepare to have your machine brought to a crawl and perhaps take a coffee break.

Writing Integration Tests

You can write your own integration tests for Triplesec embedding applications or just to test Triplesec functionality. This is really easy to do using the Triplesec Integration Testing framework. Here's how to setup a JUnit test which starts the Triplesec server in the background:

Code Block
package mytests;

import org.safehaus.triplesec.integration.TriplesecIntegration;

public class MyTestCase extends TriplesecIntegration
{
    public MyTestCase() throws Exception
    {
        super();
    }
}

Now you can write test cases to test Triplesec. The TriplesecIntegration test will use for setup files in your src/test/resources directory to setup Triplesec. These files are the log4j.properties, server.xml, and server.ldif (any ldif files will work). They are used to configure tsec and get it setup with some test data. Also note you're need the following configuration for your m2 surefire plugin configuration:

No Format
<plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <systemProperties>
            <property>
              <name>org.safehaus.triplesec.unit.resourcesDirectory</name>
              <value>${basedir}/src/test/resources</value>
            </property>
          </systemProperties>
        </configuration>
      </plugin>

This tells the TriplesecIntegration test where it can get these file resources to run the server. Note that the unit test will find available ports and set protected member's in the TriplesecIntegration instance. These properties are the server port for LDAP and the Kerberos server port etc. To really get a good idea of how to use this take a look at existing projects that use this framework in the Triplesec code base. Here's a good example to look at:

Tests Guardian LDAP API on Live Triplesec Server