IntroductionTo unitary test a client of the Petals Registry Client API (as Petals Registry CLI), it is needed to use a dedicated implementation not requiring a Petals Registry Overlay. Such an implementation was created to provide a mock for Petals Registry Client API: Petals Registry Client Mock. It is available as JUnit Rule, and so the Petals environment is cleaned between each unit test. |
Table of contents Contributors
No contributors found for: authors on selected page(s)
|
Using the Petals Registry Client Mock
Working with topologies
Each Petals Registry Client Mock instance comes with an internal registry registry. All methods of the Petals Registry Client Mock managing topologies works with this topology registry according to the Petals Registry Client API definition.
Registering a topology
A topology can be put into the topology registry at any moment of the unit test. Caution, the topology registry is cleared at the end of the unit test.
@Rule public PetalsRegistryClientApi petalsRegistryClientApi = new PetalsRegistryClientApi(); @Test public void test...() { this.petalsRegistryClientApi.registerTopology("a-topology-id", new Topology()); ... Your unit test source code ... // The topology registry will be automatically cleared leaving the unit test }
Installation
The Petals Registry Client Mock implementation is available as a Maven artifact to add to the POM of your project:
<project> ... <dependencies> ... <dependency> <groupId>org.ow2.petals</groupId> <artifactId>petals-registry-client-mock</artifactId> <version>...</version> <scope>test</scope> </dependency> ... </dependencies> ... </project>