Skip to content
Browse files

MODE-1842 - Added an integration test which uses a JDBC cache loader …

…together with eviction
  • Loading branch information...
1 parent bc95b22 commit 11a8119999204f894eeaa5f25a4eada6dc2075b2 @hchiorean hchiorean committed
View
19 ...ests/src/main/resources/kit/jboss-eap61/standalone/configuration/standalone-modeshape.xml
@@ -247,6 +247,19 @@
</string-keyed-table>
</string-keyed-jdbc-store>
</local-cache>
+ <local-cache name="jdbcRepositoryWithEviction">
+ <transaction mode="NON_XA" locking="PESSIMISTIC"/>
+ <eviction strategy="LRU" max-entries="100"/>
+ <string-keyed-jdbc-store datasource="java:jboss/datasources/ModeshapeJDBCStoreDS" shared="false" preload="false" passivation="false" purge="false">
+ <write-behind flush-lock-timeout="1" modification-queue-size="1024" shutdown-timeout="25000" thread-pool-size="1"/>
+ <property name="databaseType">H2</property>
+ <string-keyed-table prefix="JDG_MC_SK">
+ <id-column name="id" type="VARCHAR(200)"/>
+ <data-column name="datum" type="BYTEA"/>
+ <timestamp-column name="version" type="BIGINT"/>
+ </string-keyed-table>
+ </string-keyed-jdbc-store>
+ </local-cache>
</cache-container>
<cache-container name="binary-cache-container" default-cache="binary-fs" module="org.modeshape">
<local-cache name="binary-fs">
@@ -406,6 +419,12 @@
<initial-content>initial-content-default.xml</initial-content>
</workspaces>
</repository>
+ <repository name="jdbcRepositoryWithEviction">
+ <workspaces allow-workspace-creation="true" default-workspace="default">
+ <workspace name="default"/>
+ <initial-content>initial-content-default.xml</initial-content>
+ </workspaces>
+ </repository>
<repository name="infinispanRepository">
<workspaces cache-container="ws-cache-container">
<workspace name="default"/>
View
45 ...ion-tests/src/test/java/org/modeshape/test/integration/JDBCRepositoryIntegrationTest.java
@@ -27,6 +27,7 @@
import java.io.File;
import javax.annotation.Resource;
import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
import javax.jcr.Session;
import javax.jcr.query.Query;
import org.jboss.arquillian.container.test.api.Deployment;
@@ -35,6 +36,7 @@
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.modeshape.common.FixFor;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -47,7 +49,10 @@
public class JDBCRepositoryIntegrationTest {
@Resource( mappedName = "/jcr/jdbcRepository" )
- private Repository repository;
+ private Repository repositoryWithoutEviction;
+
+ @Resource( mappedName = "/jcr/jdbcRepositoryWithEviction" )
+ private Repository repositoryWithEviction;
@Deployment
public static WebArchive createDeployment() {
@@ -58,21 +63,35 @@ public static WebArchive createDeployment() {
}
@Test
- public void shouldPersistDataInJDBC() throws Exception {
+ public void shouldPersistDataInJDBCWithoutEviction() throws Exception {
+ assertDataPersisted(repositoryWithoutEviction);
+ }
+
+ @Test
+ @FixFor( "MODE-1842" )
+ public void shouldPersistDataInJDBCWithEviction() throws Exception {
+ assertDataPersisted(repositoryWithEviction);
+ }
+
+ private void assertDataPersisted( Repository repository ) throws RepositoryException {
assertNotNull(repository);
Session session = repository.login();
- //check predefined content was imported
- assertNotNull(session.getNode("/files"));
- assertNotNull(session.getNode("/cars"));
+ try {
+ //check predefined content was imported
+ assertNotNull(session.getNode("/files"));
+ assertNotNull(session.getNode("/cars"));
- //add a node and check it can be queried
- session.getRootNode().addNode("testNode");
- session.save();
+ //add a node and check it can be queried
+ session.getRootNode().addNode("testNode");
+ session.save();
- Query query = session.getWorkspace()
- .getQueryManager()
- .createQuery("select [jcr:path] FROM [nt:base] WHERE [jcr:name] LIKE '%testNode%'",
- Query.JCR_SQL2);
- assertEquals(1, query.execute().getNodes().getSize());
+ Query query = session.getWorkspace()
+ .getQueryManager()
+ .createQuery("select [jcr:path] FROM [nt:base] WHERE [jcr:name] LIKE '%testNode%'",
+ Query.JCR_SQL2);
+ assertEquals(1, query.execute().getNodes().getSize());
+ } finally {
+ session.logout();
+ }
}
}

0 comments on commit 11a8119

Please sign in to comment.
Something went wrong with that request. Please try again.