Search in sources :

Example 11 with RootNodeMockFactory

use of com.adobe.acs.commons.httpcache.store.jcr.impl.visitor.mock.RootNodeMockFactory in project acs-aem-commons by Adobe-Consulting-Services.

the class EntryNodeMapVisitorTest method test5entries.

@Test
public void test5entries() throws Exception {
    final RootNodeMockFactory.Settings settings = new RootNodeMockFactory.Settings();
    settings.setEntryNodeCount(5);
    final Node rootNode = new RootNodeMockFactory(settings).build();
    final EntryNodeMapVisitor visitor = getMockedNodeMapVisitor();
    visitor.visit(rootNode);
    final Map<CacheKey, CacheContent> cache = visitor.getCache();
    assertEquals(5, cache.size());
}
Also used : RootNodeMockFactory(com.adobe.acs.commons.httpcache.store.jcr.impl.visitor.mock.RootNodeMockFactory) Node(javax.jcr.Node) CacheContent(com.adobe.acs.commons.httpcache.engine.CacheContent) CacheKey(com.adobe.acs.commons.httpcache.keys.CacheKey) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 12 with RootNodeMockFactory

use of com.adobe.acs.commons.httpcache.store.jcr.impl.visitor.mock.RootNodeMockFactory in project acs-aem-commons by Adobe-Consulting-Services.

the class EntryNodeMapVisitorTest method test10entries.

@Test
public void test10entries() throws Exception {
    final RootNodeMockFactory.Settings settings = new RootNodeMockFactory.Settings();
    settings.setEntryNodeCount(10);
    final Node rootNode = new RootNodeMockFactory(settings).build();
    final EntryNodeMapVisitor visitor = getMockedNodeMapVisitor();
    visitor.visit(rootNode);
    final Map<CacheKey, CacheContent> cache = visitor.getCache();
    assertEquals(10, cache.size());
}
Also used : RootNodeMockFactory(com.adobe.acs.commons.httpcache.store.jcr.impl.visitor.mock.RootNodeMockFactory) Node(javax.jcr.Node) CacheContent(com.adobe.acs.commons.httpcache.engine.CacheContent) CacheKey(com.adobe.acs.commons.httpcache.keys.CacheKey) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 13 with RootNodeMockFactory

use of com.adobe.acs.commons.httpcache.store.jcr.impl.visitor.mock.RootNodeMockFactory in project acs-aem-commons by Adobe-Consulting-Services.

the class InvalidateAllNodesVisitorTest method test.

@Test
public void test() throws Exception {
    final RootNodeMockFactory.Settings settings = new RootNodeMockFactory.Settings();
    settings.setEntryNodeCount(10);
    settings.setExpiredEntryNodeCount(20);
    final Node rootNode = new RootNodeMockFactory(settings).build();
    final InvalidateAllNodesVisitor visitor = getMockedExpiredNodesVisitor(8);
    visitor.visit(rootNode);
    visitor.close();
    // validate 40 evictions. 10 entries, 20 expired entries, 10 bucket nodes should be removed.
    assertEquals(40, visitor.getEvictionCount());
    // validate 5 saves. 40 divided by 8 equals 5.
    Mockito.verify(rootNode.getSession(), Mockito.times(5)).save();
}
Also used : RootNodeMockFactory(com.adobe.acs.commons.httpcache.store.jcr.impl.visitor.mock.RootNodeMockFactory) Node(javax.jcr.Node) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 14 with RootNodeMockFactory

use of com.adobe.acs.commons.httpcache.store.jcr.impl.visitor.mock.RootNodeMockFactory in project acs-aem-commons by Adobe-Consulting-Services.

the class InvalidateAllNodesVisitorTest method testWithEmptyBuckets.

@Test
public void testWithEmptyBuckets() throws Exception {
    final RootNodeMockFactory.Settings settings = new RootNodeMockFactory.Settings();
    settings.setEntryNodeCount(10);
    settings.setExpiredEntryNodeCount(20);
    settings.setEmptyBucketNodeChainCount(2);
    final Node rootNode = new RootNodeMockFactory(settings).build();
    final InvalidateAllNodesVisitor visitor = getMockedExpiredNodesVisitor(4);
    visitor.visit(rootNode);
    visitor.close();
    // validate 60 evictions. 10 entries, 20 expired entries, 30 bucket nodes should be removed.
    assertEquals(60, visitor.getEvictionCount());
    Mockito.verify(rootNode.getSession(), Mockito.times(12)).save();
}
Also used : RootNodeMockFactory(com.adobe.acs.commons.httpcache.store.jcr.impl.visitor.mock.RootNodeMockFactory) Node(javax.jcr.Node) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 15 with RootNodeMockFactory

use of com.adobe.acs.commons.httpcache.store.jcr.impl.visitor.mock.RootNodeMockFactory in project acs-aem-commons by Adobe-Consulting-Services.

the class TotalCacheSizeVisitorTest method test.

@Test
public void test() throws Exception {
    final RootNodeMockFactory.Settings settings = new RootNodeMockFactory.Settings();
    settings.setEntryNodeCount(10);
    settings.setExpiredEntryNodeCount(20);
    settings.setEnableCacheEntryBinaryContent(true);
    final Node rootNode = new RootNodeMockFactory(settings).build();
    final TotalCacheSizeVisitor visitor = getMockedExpiredNodesVisitor();
    visitor.visit(rootNode);
    assertEquals(TEST_FILE_SIZE * 30, visitor.getBytes());
}
Also used : RootNodeMockFactory(com.adobe.acs.commons.httpcache.store.jcr.impl.visitor.mock.RootNodeMockFactory) Node(javax.jcr.Node) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

RootNodeMockFactory (com.adobe.acs.commons.httpcache.store.jcr.impl.visitor.mock.RootNodeMockFactory)15 Node (javax.jcr.Node)15 Test (org.junit.Test)15 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)15 CacheContent (com.adobe.acs.commons.httpcache.engine.CacheContent)4 CacheKey (com.adobe.acs.commons.httpcache.keys.CacheKey)4