# JUnit with RepositoryTestCase

**URL:** <https://community.bloomreach.com/t/junit-with-repositorytestcase/92>\
**Category:** Experience Manager (PaaS/OnPrem)\
**Created:** [July 9, 2018, 4:20pm UTC](https://community.bloomreach.com/t/junit-with-repositorytestcase/92 "2018-07-09T16:20:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leo\_Aharon](https://avatars.discourse-cdn.com/v4/letter/l/d07c76/32.png) [@Leo\_Aharon](https://community.bloomreach.com/u/Leo_Aharon)\
**Post date:** [July 9, 2018, 4:20pm UTC](https://community.bloomreach.com/t/junit-with-repositorytestcase/92/1 "2018-07-09T16:20:58Z")

</div>

Hi,

could please explain where can I find some documentation about org.onehippo.repository.testutils.RepositoryTestCase?

I would like to Test HippoCMS Classes, my own Validators, Services and Repository.  
Unfortunately I get following Error

javax.jcr.RepositoryException: unchecked exception: java.lang.IllegalStateException: Node ‘/hippo:configuration/hippo:translations/hippo:cms/validators/de’ defined at ‘Hippo-CMS/Hippo-CMS/Hippo-CMS-repository-data-application [config: configuration/translations/cms.yaml]’ is missing the required jcr:primaryType property.

cms.yaml . seems to be OK (is working in the produtction mode now) :

------cms.yaml------  
definitions:  
config:  
/hippo:configuration/hippo:translations/hippo:cms/validators/en:  
seo-fields#title-too-long: Title limited to 70 characters  
seo-fields#description-too-long: Description limited to 160 characters  
seo-fields#keywords-too-long: The keywords limited to 5 terms  
seo-fields#canonical-not-absolute: The canonical URL has to be absolute  
link-compound#link-and-downloadlink-set: Link and download link cannot be set  
at the same time  
link-compound#internal-link-absolute: Internal links should not be absolute  
/hippo:configuration/hippo:translations/hippo:cms/validators/de:  
seo-fields#description-too-long: Description ist beschränkt auf 160 Zeichen  
seo-fields#canonical-not-absolute: Canonical URL muss absolut sein  
seo-fields#keywords-too-long: Keywords ist beschränkt auf 5 Begriffe  
seo-fields#title-too-long: Title ist beschränkt auf 70 Zeichen  
link-compound#internal-link-absolute: Interne Links sollten nicht absolut sein  
link-compound#link-and-downloadlink-set: Link und Donwload Link können nicht  
zu gleichen Zeit gesetzt sein

* * *

```
<dependency>
  <groupId>org.onehippo.cms7.hst</groupId>
  <artifactId>hst-test</artifactId>
  <version>5.3.0</version>
  <scope>test</scope>
</dependency>
```

---

<div class="post-metadata">

**Author:** ![Leo\_Aharon](https://avatars.discourse-cdn.com/v4/letter/l/d07c76/32.png) [@Leo\_Aharon](https://community.bloomreach.com/u/Leo_Aharon)\
**Post date:** [July 9, 2018, 4:37pm UTC](https://community.bloomreach.com/t/junit-with-repositorytestcase/92/2 "2018-07-09T16:37:41Z")

</div>

Now I edited cms.yaml …  
definitions:  
config:  
/hippo:configuration/hippo:translations/hippo:cms/validators/en:  
`_ **jcr:primaryType: hipposys:resourcebundle** _`  
seo-fields#title-too-long: Title limited to 70 characters

New Error :

javax.jcr.RepositoryException: unchecked exception: java.lang.NoClassDefFoundError: com/onehippo/cms7/services/hst/WorkspaceHasher

```
at org.hippoecm.repository.HippoRepositoryFactory.getHippoRepository(HippoRepositoryFactory.java:161)
at org.onehippo.repository.testutils.RepositoryTestCase.setUpClass(RepositoryTestCase.java:115)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

```

Caused by: java.lang.NoClassDefFoundError: com/onehippo/cms7/services/hst/WorkspaceHasher  
at java.lang.Class.forName0(Native Method)  
at java.lang.Class.forName(Class.java:264)  
at org.onehippo.cm.engine.ConfigurationServiceImpl.loadMigrators(ConfigurationServiceImpl.java:733)

hippo-enterprise-services-1.3.0.jar is loaded

---

<div class="post-metadata">

**Author:** ![jasper.floor](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/jasper.floor/32/28_2.png) [@jasper.floor](https://community.bloomreach.com/u/jasper.floor)\
**Post date:** [July 10, 2018, 8:32am UTC](https://community.bloomreach.com/t/junit-with-repositorytestcase/92/3 "2018-07-10T08:32:55Z")

</div>

I think you don’t have all your dependencies defined correctly. You may need some extra dependencies for the test classes. Best to compare with other modules that use the RepositoryTestCase.

Unfortunately there is not really documentation on the RepositoryTestCase.

---

<div class="post-metadata">

**Author:** ![Leo\_Aharon](https://avatars.discourse-cdn.com/v4/letter/l/d07c76/32.png) [@Leo\_Aharon](https://community.bloomreach.com/u/Leo_Aharon)\
**Post date:** [July 11, 2018, 2:20pm UTC](https://community.bloomreach.com/t/junit-with-repositorytestcase/92/4 "2018-07-11T14:20:17Z")

</div>

10x. Could you give me some Ideas how can I run JUnits, testing Hippo Plugins, Services, , or other stuff?

Example issue : I want to Test org.hippoecm.frontend.plugins.console.menu.save.SaveDialog.  
I found out how can I listen for Events, but I have a big problem to call onOk from SaveDialog.

I tried following :

HippoServiceRegistry.registerService(eventBus = new GuavaHippoEventBus(), HippoEventBus.class);  
HippoServiceRegistry.registerService(listenerEvents = new ListenerHippoEvent(), HippoEventBus.class);  
HippoEvent event = new HippoEvent(“console”);  
event.category(“console”).user(“max”).action(“test”);  
event.message(“hello world”);  
eventBus.post(event);  
waitForEvent(listenerEvents);  
…  
private void waitForEvent(final ListenerHippoEvent listener) throws Exception {  
int n = 50;  
System.out.println(" Start waiting for HippoEvent …");  
while (n-- \> 0) {  
Thread.sleep(100);  
if (listener.seenEvents.size() == 1) {  
Thread.sleep(100);  
return;  
}  
}  
throw new Exception(“HippoEvent not received within 5 seconds”);  
}

```
public static class ListenerHippoEvent {
	List<HippoEvent> seenEvents = new LinkedList<HippoEvent>();
	@Subscribe
	public void handleEvent(HippoEvent event) {
		System.out.println(" received HippoEvent message: " + event.message());
		seenEvents.add(event);
	}
}

```

So I just can send and receive Events by myself… But I want Events from SaveDialog

Could somebody help?

---

<div class="post-metadata">

**Author:** ![jasper.floor](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.bloomreach.com/jasper.floor/32/28_2.png) [@jasper.floor](https://community.bloomreach.com/u/jasper.floor)\
**Post date:** [July 19, 2018, 12:35pm UTC](https://community.bloomreach.com/t/junit-with-repositorytestcase/92/5 "2018-07-19T12:35:49Z")

</div>

I think this gets into testing Wicket. You aren’t waiting for a repository event but for a UI event. I’m not sure how that would be done in a unit test.
