We like tests. We use JUnit and Mockito (and, sometimes, reluctantly, PowerMockito.) HTTP Integration tests use grizzly.
Writing tests
Each module has unit tests in the src/test/java/org/fcrepo/
directory and integration tests in the src/test/java/org/fcrepo/integration/
directory.
The unit tests often use mock objects to create surrogates for the Modeshape and webapp machinery that much of the Fedora code interacts with. Some good examples of mock object usage are in the fcrepo-http-api
module (e.g., FedoraNodesTest.java) and in the fcrepo-jms-indexer-core
module (e.g. IndexerGroupTest.java). By convention, unit test classes are named as: <FunctionalClass>Test.java
Integration tests use embedded Modeshape, servlet engine, etc. to run real requests against the code. The web-based tests typically use HttpClient to make requests. Non-web tests, use injection to have the repository and service objects made accessible to the tests (the embedded repository and injection are configured in the src/test/resources
directory). Some good examples are in the fcrepo-http-api
module (e.g. FedoraNodesIT.java) and fcrepo-kernel
module (e.g., FedoraResourceImplIT.java). By convention, integration test classes are named as: <FunctionalClass>IT.java
Remember to follow the Code Style Guide when writing your test classes. This is especially true if writing a test class is your first foray into contributing to Fedora.
Running the tests
$ mvn test verify
See the fcrepo4 README file for more detailed instructions concerning Maven settings, etc., to build from source.