Hippo Unit Tester

Hippo Unit Tester is framework aimed at simplifying unit testing of Hippo CMS

License

License

GroupId

GroupId

nl.openweb.hippo
ArtifactId

ArtifactId

hippo-unit-tester
Last Version

Last Version

2.2.1
Release Date

Release Date

Type

Type

jar
Description

Description

Hippo Unit Tester
Hippo Unit Tester is framework aimed at simplifying unit testing of Hippo CMS
Project URL

Project URL

https://github.com/openweb-nl/hippo-unit-tester
Project Organization

Project Organization

Open Web IT
Source Code Management

Source Code Management

https://github.com/openweb-nl/hippo-unit-tester

Download hippo-unit-tester

How to add to project

<!-- https://jarcasting.com/artifacts/nl.openweb.hippo/hippo-unit-tester/ -->
<dependency>
    <groupId>nl.openweb.hippo</groupId>
    <artifactId>hippo-unit-tester</artifactId>
    <version>2.2.1</version>
</dependency>
// https://jarcasting.com/artifacts/nl.openweb.hippo/hippo-unit-tester/
implementation 'nl.openweb.hippo:hippo-unit-tester:2.2.1'
// https://jarcasting.com/artifacts/nl.openweb.hippo/hippo-unit-tester/
implementation ("nl.openweb.hippo:hippo-unit-tester:2.2.1")
'nl.openweb.hippo:hippo-unit-tester:jar:2.2.1'
<dependency org="nl.openweb.hippo" name="hippo-unit-tester" rev="2.2.1">
  <artifact name="hippo-unit-tester" type="jar" />
</dependency>
@Grapes(
@Grab(group='nl.openweb.hippo', module='hippo-unit-tester', version='2.2.1')
)
libraryDependencies += "nl.openweb.hippo" % "hippo-unit-tester" % "2.2.1"
[nl.openweb.hippo/hippo-unit-tester "2.2.1"]

Dependencies

compile (4)

Group / Artifact Type Version
nl.openweb.jcr : jcr-mocking-tool jar 1.3.3
nl.openweb.jcr : in-memory-jcr jar hippo-1.3.3
org.onehippo.cms7.hst » hst-mock jar
org.onehippo.cms7.hst » hst-content-beans jar

provided (3)

Group / Artifact Type Version
org.onehippo.cms7.hst.dependencies » hst-spring-dependencies pom
org.onehippo.cms7.hst.dependencies » hst-client-dependencies pom
org.onehippo.cms7.hst.dependencies » hst-server-dependencies pom

test (3)

Group / Artifact Type Version
org.onehippo.cms7 » hippo-essentials-components-hst jar
junit : junit jar 4.13.1
org.mockito : mockito-core jar 2.10.0

Project Modules

There are no modules declared in this project.

Hippo Unit Tester

Hippo Unit Tester is a framework that tries to take advantage of JCR mocking solutions and Hippo Mock objects to setup a mock Hippo API. It tries to be as realistic as possible while still be highly manipulatable. In order to enable developers to focus on designing their unit tests scenarios instead of focusing on technical details mocking process.

Installation

  1. Add dependency to pom.xml
<dependencyManagement>
  <dependencies>
    <dependency>
        <groupId>nl.openweb.hippo</groupId>
        <artifactId>hippo-unit-tester</artifactId>
        <version>2.2.0</version>
        <scope>test</scope>
    </dependency>
    ...
  </dependencies>
</dependencyManagement>
  1. Add dependency to site pom.xml.
<dependency>
    <groupId>nl.openweb.hippo</groupId>
    <artifactId>hippo-unit-tester</artifactId>
</dependency>

Usage

Within the package there are classes to extend from:

  • BaseHippoTest
  • SimpleHippoTest

Importer

The importer works with JSON or XML. It will import the file at given location.

XML

<sv:node sv:name="news1">
    <sv:property sv:name="jcr:primaryType" sv:type="Name">
        <sv:value>hippo:handle</sv:value>
    </sv:property>
    <sv:property sv:name="jcr:mixinTypes" sv:type="Name" sv:multiple="true">
        <sv:value>mix:referenceable</sv:value>
    </sv:property>
    <sv:property sv:name="jcr:uuid" sv:type="String">
        <sv:value>3119bd98-9361-4b78-a81b-ad8228bc8bfb</sv:value>
    </sv:property>
    <sv:node sv:name="news1">
        <sv:property sv:name="jcr:primaryType" sv:type="Name">
            <sv:value>ns:NewsPage</sv:value>
        </sv:property>
        ...
    </sv:node>
</sv:node>

JSON

 

Debug

/**
* prints out the whole JCR structure
*/
printNodeStructure();

/**
* prints out the JCR structure from given path
*/
printNodeStructure("/path");

Explain

/**
* When you want to create you own namespace
*/
registerNodeType("ns:custom");
/**
* eForms needs a Local to be set
*/
request.setLocale(new Locale("nl_NL"));
/**
 * From the given file create a node containing the content of imported file
 * Location should contain the path the node should be created not where you want to import the file
**/
importer.createNodesFromXml(getResourceAsStream("/nl/openweb/hippo/demo/news.xml"), "/content/documents/mychannel/news", "hippostd:folder");

Demo

One of the best ways to learn about how to use this library is by looking at an example

nl.openweb.hippo

Open Web

Software development and open source is in our DNA. Development, contracting, maintenance and management. Discover what Open Web professionals can do for you.

Versions

Version
2.2.1
2.2.0
2.1.2
2.1.1
2.1.0