Writing unit tests requiring the Petals Administration API

compared with
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (2)

View Page History
Such a implementation was created to provide a mock for Petals Administration API: *Petals Administration Mock*.

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 Administration Mock

h2. Working with JBI artifacts

The Petals Administration Mock comes with an internal JBI artifact registry. All methods of the Petals Administration Mock managing JBI artifact works with this artifact registry according to the Petals Administration API definition.

h3. Creating a JBI artifact

A JBI artifact can be created using one of following classes:
|| JBI artifact || Class || Life-cycle supported ||
| Shared library | {{org.ow2.petals.admin.api.artifact.SharedLibrary}} | no |
| Component | {{org.ow2.petals.admin.api.artifact.Component}} | yes |
| Service assembly | {{org.ow2.petals.admin.api.artifact.ServiceAssembly}} | yes |
| Service unit | {{org.ow2.petals.admin.api.artifact.ServiceUnit}} | no |

You can initialize the state of JBI artifacts supporting a life-cycle:
{code}
final Component component = new Component("component-name", ComponentType.BC);
component.setState(State.STARTED);
{code}

h3. Registering a JBI artifact

A JBI artifact can be put into the artifact registry at any moment of the unit test. *Caution, the artifact registry is cleared at the end of the unit test.*
{code}
@Rule
public PetalsAdministrationApi petalsAdminApi = new PetalsAdministrationApi();

@Test
public void test...() {

final Component component = new Component("component-name", ComponentType.BC);
component.setState(State.STARTED);
this.petalsAdminApi.registerArtifact(component);

... Your unit test source code ...

// The artifact registry will be automatically cleared leaving the unit test.
}
{code}

h1. Installation

</project>
{code}

{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}