This README contains information that is intended to be helpful for developers who are unfamiliar with the metacat codebase. If you find any of this advice to be incorrect, please update this document!
LeanTestUtils
is intended to be a fast and lightweight provider of common setup and runtime functionality that is needed in multiple tests, but without incorporating JUnit3-specific functionality (e.g. no "extends TestCase"), and importantly, WITHOUT REQUIRING A RUNNING INSTANCE OF METACAT to allow testing.- This class should therefore be most useful for fast-running Unit tests, or integration tests that do not rely on querying metacat, solr, postgres, etc, but instead use mocks.
- Many of the older tests extend
MCTestCase
, which, in turn, extends JUnit v3'sjunit.framework.TestCase
. - Any new tests should strive not to extend
MCTestCase
, (thus avoiding being stuck on JUnit 3). IfMCTestCase
utility methods are needed in newer tests, these should be refactored to allow public access. MCTestCase
is configured by default to load its properties from the "runtime" copies of the properties files, by calling:LeanTestUtils.initializePropertyService(LeanTestUtils.PropertiesMode.LIVE_TEST)
This file contains configurable, test-specific properties that must be customized to your dev environment. Hints:
metacat.contextDir=
/your/context/dir/typically/tomcat/webapps/metacatexpected.internalURL=http\://localhost\:8080
- the hostname and port should match whatever settings exist inmetacat.properties
for the keysserver.internalName
andserver.internalPort
, respectively. This should already be true for a clean checkout.- The following will be used to override the properties with the same keys in
metacat.properties
:application.backupDir=
/your/backup/props/dir/typically/var/metacat/.metacatapplication.context=
metacat_or_whateverapplication.deployDir=
/your/deploy/dir/typically/tomcat/webappstest.printdebug=true
(preferred, so you can see output)guid.doi.enabled=true
(needed for DOI tests to pass)guid.doi.password=apitest
(needed for DOI tests to pass)
The LeanTestUtils.initializePropertyService()
method can be used to make properties available
for tests, initializing PropertyService
in one of two modes:
PropertiesMode.UNIT_TEST
mode (preferred): default properties fromlib/metacat.properties
overlaid with configurable test-specific properties fromtest/test.properties
PropertiesMode.LIVE_TEST
mode (deprecated *): default properties from<metacat.contextDir>/WEB-INF/metacat.properties
overlaid with configurable properties fromtest/test.properties
(wheremetacat.contextDir
is defined in thetest/test.properties
file). * NOTE thatPropertiesMode.LIVE_TEST
mode is provided to support legacy tests, and should not be used for new tests, if testing in live mode can be avoided through the use of mocks.
NOTE there may currently be tests in the wrong location. Feel free to move them!
This directory should contain unit and integration tests that do NOT require metacat to be running, use the test directory.
This directory should contain only tests that require a running metacat instance (e.g. to test networking and replication functionality)
Do not add any more tests here! All new tests (and any old ones you want to move :-) should be located in one of the previous places.