Skip to content

Testing against different Storage Backends

Florian Gutmann edited this page Jan 14, 2014 · 2 revisions

We have set up a test infrastructure that allows to run tests automatically against different storage backends. The implementation is also designed to allow tests that require multiple HierarchicalNodeStores with different backends. This allows to create tests that push/pull between storage backends.

Writing a test

To easiest way to write a test that is capable of running against different storage backends is to extend AbstractHierarchicalNodeStoreTest. This base class provides a method getNodeStore() that will return a fresh initialized NodeStore for every test. The store is also cleaned properly after every test.

If you have more complicated use cases (eg. need multiple storages) you can utilize the TestStorageBackends.getConfiguredProviders() to get all configured TestStorageProviders. Don't forget to destroy created backends with TestStorageProvider.destroyStorageBackend afterwards.

Selecting against which storage backends to test

The system property com.dc2f.dstore.test.storageProviders takes a comma separated list of fully qualified class names of TestStorageProviders. If the property is not set tests will only run against HashMapStorageBackend.

TestStorageProviders

A TestStorageProvider is capable of creating and destroying backend storages for test purposes. To implement a new StorageBackend and run all tests against it you only need to implement a TestStorageProvider that initializes a HierarchicalNodeStore with your backend.