Writing unit tests requiring a Petals Registry Overlay

Introduction

To unitary test interactions with a real Petals Registry Overlay (as the fractal component 'Petals Registry Client'), it is needed to be able to simply instantiate embedded Petals Registry Overlay members.

Such an implementation was created to provide this embedded Petals Registry Overlay members: Petals Registry Overlay JUnit extension.

It is available as JUnit Rule, and so the Petals environment is cleaned between each unit test.

Contributors
No contributors found for: authors on selected page(s)

Using the Petals Registry Overlay JUnit extension

The JUnit rule to instantiate an embedded Petals Registry Overlay member is: org.ow2.petals.registry_overlay.junit.PetalsRegistryOverlayNode:

    @Rule
    public PetalsRegistryOverlayNode petalsRegistryNode = new PetalsRegistryOverlayNode();

    @Test
    public void test...() {

        ... Your unit test source code ...

        assertEquals(..., this.petalsRegistryNode.getHost());
        assertEquals(..., this.petalsRegistryNode.getPort());
        assertEquals(..., this.petalsRegistryNode.getGroupName());
        assertEquals(..., this.petalsRegistryNode.getPassword());

        ... Your unit test source code ...

    }

The following methods can be used to retrieve all connection information required to established a connection to the current Petals Registry Ovelray member:

  • getHost(),
  • getPort(),
  • getGroupName(),
  • getPassword().

Installation

The Petals Registry Overlay JUnit extension is available as a Maven artifact to add to the POM of your project:

<project>
    ...
    <dependencies>
        ...
        <dependency>
            <groupId>org.ow2.petals</groupId>
            <artifactId>petals-registryoverlay-junit</artifactId>
            <version>...</version>
            <scope>test</scope>
        </dependency>
        ...
    </dependencies>
    ...
</project>
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.