View Source

{section}
{column}

h1. 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|https://github.com/junit-team/junit/wiki/Rules], and so the Petals environment is cleaned between each unit test.

{column}
{column:width=35%}
{panel:title=Table of contents}{toc:outline=true}{panel}
{panel:title=Contributors}{contributors:order=name|mode=list|showAnonymous=true|showCount=true|showLastTime=true}{panel}
{column}
{section}

h1. 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}}:
{code}
@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 ...

}
{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()}}.

h1. Installation

The Petals Registry Overlay JUnit extension is available as a Maven artifact to add to the POM of your project:
{code}
<project>
...
<dependencies>
...
<dependency>
<groupId>org.ow2.petals</groupId>
<artifactId>petals-registryoverlay-junit</artifactId>
<version>...</version>
<scope>test</scope>
</dependency>
...
</dependencies>
...
</project>
{code}