Search in sources :

Example 1 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 AllEntryNodesCountVisitorTest method test.

@Test
public void test() throws IOException, RepositoryException {
    final AllEntryNodesCountVisitor visitor = new AllEntryNodesCountVisitor(11);
    final RootNodeMockFactory.Settings settings = new RootNodeMockFactory.Settings();
    settings.setEntryNodeCount(10);
    final Node rootNode = new RootNodeMockFactory(settings).build();
    visitor.visit(rootNode);
    assertEquals(10, visitor.getTotalEntryNodeCount());
}
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 2 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 testNoEntries.

@Test
public void testNoEntries() throws Exception {
    final RootNodeMockFactory.Settings settings = new RootNodeMockFactory.Settings();
    settings.setEntryNodeCount(0);
    final Node rootNode = new RootNodeMockFactory(settings).build();
    final EntryNodeMapVisitor visitor = getMockedNodeMapVisitor();
    visitor.visit(rootNode);
    final Map<CacheKey, CacheContent> cache = visitor.getCache();
    assertTrue(cache.isEmpty());
}
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 3 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 test5BucketDepth.

@Test
public void test5BucketDepth() throws Exception {
    final RootNodeMockFactory.Settings settings = new RootNodeMockFactory.Settings();
    settings.setEntryNodeCount(10);
    settings.setBucketDepth(5);
    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 4 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 EntryNodeByStringKeyVisitorTest method testNotPresent.

@Test
public void testNotPresent() throws Exception {
    final RootNodeMockFactory.Settings settings = new RootNodeMockFactory.Settings();
    settings.setEntryNodeCount(10);
    final Node rootNode = new RootNodeMockFactory(settings).build();
    final EntryNodeByStringKeyVisitor visitor = getMockedEntryNodeByStringKeyVisitor("[resourcePath: /content/some/path]", false);
    visitor.visit(rootNode);
    assertNull(visitor.getCacheContentIfPresent());
}
Also used : RootNodeMockFactory(com.adobe.acs.commons.httpcache.store.jcr.impl.visitor.mock.RootNodeMockFactory) Node(javax.jcr.Node) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 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 ExpiredNodesVisitorTest method testEmptyBucketNodes.

@Test
public void testEmptyBucketNodes() throws Exception {
    final RootNodeMockFactory.Settings settings = new RootNodeMockFactory.Settings();
    settings.setEntryNodeCount(10);
    settings.setExpiredEntryNodeCount(20);
    settings.setEmptyBucketNodeChainCount(1);
    final Node rootNode = new RootNodeMockFactory(settings).build();
    final ExpiredNodesVisitor visitor = getMockedExpiredNodesVisitor(8);
    visitor.visit(rootNode);
    visitor.close();
    assertEquals(30, visitor.getEvictionCount());
    Mockito.verify(rootNode.getSession(), Mockito.times(4)).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)

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