Search in sources :

Example 1 with IPentahoSystemSessionFactory

use of org.apache.jackrabbit.core.IPentahoSystemSessionFactory in project pentaho-platform by pentaho.

the class RepositoryCleanerTest method gc.

@Test
public void gc() throws Exception {
    GarbageCollector collector = mock(GarbageCollector.class);
    RepositoryImpl repository = mock(RepositoryImpl.class);
    when(repository.createDataStoreGarbageCollector()).thenReturn(collector);
    MicroPlatform mp = new MicroPlatform(getSolutionPath());
    mp.defineInstance(Repository.class, repository);
    mp.defineInstance("jcrRepository", repository);
    mp.start();
    RepositoryCleaner cleaner = new RepositoryCleaner();
    Session systemSession = mock(Session.class);
    IPentahoSystemSessionFactory sessionFactory = mock(IPentahoSystemSessionFactory.class);
    when(sessionFactory.create(repository)).thenReturn(systemSession);
    cleaner.setSystemSessionFactory(sessionFactory);
    try {
        cleaner.gc();
    } finally {
        mp.stop();
    }
    verify(collector, times(1)).mark();
    verify(collector, times(1)).sweep();
    verify(collector, times(1)).close();
}
Also used : IPentahoSystemSessionFactory(org.apache.jackrabbit.core.IPentahoSystemSessionFactory) RepositoryImpl(org.apache.jackrabbit.core.RepositoryImpl) MicroPlatform(org.pentaho.test.platform.engine.core.MicroPlatform) GarbageCollector(org.apache.jackrabbit.core.gc.GarbageCollector) Session(javax.jcr.Session) Test(org.junit.Test)

Aggregations

Session (javax.jcr.Session)1 IPentahoSystemSessionFactory (org.apache.jackrabbit.core.IPentahoSystemSessionFactory)1 RepositoryImpl (org.apache.jackrabbit.core.RepositoryImpl)1 GarbageCollector (org.apache.jackrabbit.core.gc.GarbageCollector)1 Test (org.junit.Test)1 MicroPlatform (org.pentaho.test.platform.engine.core.MicroPlatform)1