Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Configure Arquillian integration tests to use Infinispan.
Browse files Browse the repository at this point in the history
Configuration is kept to in-memory at all times, since persistence should not be needed for integration tests.
  • Loading branch information
Carlos A. Munoz committed Sep 9, 2014
1 parent 11fdd52 commit ccf9a0f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 7 deletions.
Expand Up @@ -60,7 +60,6 @@ public class VersionStateCacheImpl implements VersionStateCache {
private CacheWrapper<VersionLocaleKey, WordStatistic> versionStatisticCache;
private CacheLoader<VersionLocaleKey, WordStatistic> versionStatisticLoader;

@In
private CacheContainer cacheContainer;

@In
Expand Down Expand Up @@ -127,6 +126,11 @@ public void clearVersionStatsCache(Long versionId) {
}
}

@In
public void setCacheContainer(CacheContainer cacheContainer) {
this.cacheContainer = cacheContainer;
}

private static class VersionStatisticLoader extends
CacheLoader<VersionLocaleKey, WordStatistic> {

Expand Down
Expand Up @@ -10,6 +10,7 @@
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.zanata.cache.InfinispanTestCacheContainer;
import org.zanata.common.LocaleId;
import org.zanata.service.VersionLocaleKey;
import org.zanata.ui.model.statistic.WordStatistic;
Expand All @@ -26,14 +27,15 @@ public class VersionStateCacheImplTest {

@Mock
private CacheLoader<VersionLocaleKey, WordStatistic> versionStatisticLoader;
private final InfinispanTestCacheContainer cacheContainer =
new InfinispanTestCacheContainer();

@BeforeMethod
public void beforeMethod() {
MockitoAnnotations.initMocks(this);
cache = new VersionStateCacheImpl(versionStatisticLoader);

cache.create();
cache.destroy();
cacheContainer.start();
cache.setCacheContainer(cacheContainer);
cache.create();
}

Expand Down
7 changes: 4 additions & 3 deletions zanata-war/src/test/resources/arquillian/persistence.xml
Expand Up @@ -83,9 +83,10 @@

<!-- Search engine -->
<property name="hibernate.search.default.directory_provider"
value="org.hibernate.search.store.impl.FSDirectoryProvider" />
<property name="hibernate.search.default.indexBase"
value="zanatasearchindex" />
value="infinispan" />
<!-- to use an existing cache manager (Good for external configuration) -->
<property name="hibernate.search.infinispan.cachemanager_jndiname"
value="java:jboss/infinispan/container/hibernate-search"/>
<property name="hibernate.search.lucene_version" value="LUCENE_36" />
<property name="hibernate.search.worker.batch_size" value="50" />

Expand Down
21 changes: 21 additions & 0 deletions zanata-war/src/test/resources/arquillian/standalone.xml
Expand Up @@ -191,6 +191,27 @@
<eviction strategy="NONE" />
</local-cache>
</cache-container>
<!--
Hibernate search infinispan settings
- Default In-memory settings
-->
<cache-container name="hibernate-search" default-cache="indexes" jndi-name="java:jboss/infinispan/container/hibernate-search" start="EAGER" module="org.jboss.as.clustering.web.infinispan">
<local-cache name="LuceneIndexesMetadata" start="EAGER" batching="false"/>
<local-cache name="LuceneIndexesData" start="EAGER" batching="false"/>
<local-cache name="LuceneIndexesLocking" start="EAGER" batching="false"/>
</cache-container>
<!--
Zanata multi-purpose caches.
-->
<cache-container name="zanata" default-cache="default" jndi-name="java:jboss/infinispan/container/zanata"
start="EAGER"
module="org.jboss.as.clustering.web.infinispan">
<local-cache name="default">
<transaction mode="NON_XA"/>
<eviction strategy="LRU" max-entries="10000"/>
<expiration max-idle="100000"/>
</local-cache>
</cache-container>
</subsystem>
<subsystem xmlns="urn:jboss:domain:jaxrs:1.0" />
<subsystem xmlns="urn:jboss:domain:jca:1.1">
Expand Down

0 comments on commit ccf9a0f

Please sign in to comment.