Search in sources :

Example 1 with CachingFDS

use of org.apache.jackrabbit.core.data.CachingFDS in project jackrabbit-oak by apache.

the class DataStoreServiceTest method configCachingFDS.

/**
     *
     * Test @CachingFDS is returned when cacheSize > 0
     */
@Test
public void configCachingFDS() throws Exception {
    System.setProperty(JR2_CACHING_PROP, "true");
    try {
        String nasPath = folder.getRoot().getAbsolutePath() + "/NASPath";
        String cachePath = folder.getRoot().getAbsolutePath() + "/cachePath";
        long cacheSize = 100L;
        Map<String, Object> config = new HashMap<String, Object>();
        config.put("repository.home", folder.getRoot().getAbsolutePath());
        config.put(FileDataStoreService.CACHE_SIZE, cacheSize);
        config.put(FileDataStoreService.PATH, nasPath);
        config.put(FileDataStoreService.CACHE_PATH, cachePath);
        FileDataStoreService fdsSvc = new FileDataStoreService();
        DataStore ds = fdsSvc.createDataStore(context.componentContext(), config);
        PropertiesUtil.populate(ds, config, false);
        ds.init(folder.getRoot().getAbsolutePath());
        assertTrue("not instance of CachingFDS", ds instanceof CachingFDS);
        CachingFDS cds = (CachingFDS) ds;
        assertEquals("cachesize not equal", cacheSize, cds.getCacheSize());
        assertEquals("cachepath not equal", cachePath, cds.getPath());
        Backend backend = cds.getBackend();
        Properties props = (Properties) getField(backend);
        assertEquals("path not equal", nasPath, props.getProperty(FSBackend.FS_BACKEND_PATH));
    } finally {
        System.clearProperty(JR2_CACHING_PROP);
    }
}
Also used : SharedBackend(org.apache.jackrabbit.oak.spi.blob.SharedBackend) Backend(org.apache.jackrabbit.core.data.Backend) FSBackend(org.apache.jackrabbit.core.data.FSBackend) HashMap(java.util.HashMap) DataStore(org.apache.jackrabbit.core.data.DataStore) FileDataStore(org.apache.jackrabbit.core.data.FileDataStore) CachingFDS(org.apache.jackrabbit.core.data.CachingFDS) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 Properties (java.util.Properties)1 Backend (org.apache.jackrabbit.core.data.Backend)1 CachingFDS (org.apache.jackrabbit.core.data.CachingFDS)1 DataStore (org.apache.jackrabbit.core.data.DataStore)1 FSBackend (org.apache.jackrabbit.core.data.FSBackend)1 FileDataStore (org.apache.jackrabbit.core.data.FileDataStore)1 SharedBackend (org.apache.jackrabbit.oak.spi.blob.SharedBackend)1 Test (org.junit.Test)1