Search in sources :

Example 6 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 testPresent.

@Test
public void testPresent() 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]", true);
    visitor.visit(rootNode);
    assertNotNull(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 7 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 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 ExpiredNodesVisitor visitor = getMockedExpiredNodesVisitor(8);
    visitor.visit(rootNode);
    visitor.close();
    assertEquals(20, visitor.getEvictionCount());
    Mockito.verify(rootNode.getSession(), Mockito.times(3)).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 8 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 InvalidateByCacheConfigVisitorTest method test.

@Test
public void test() throws Exception {
    final InvalidateByCacheConfigVisitor visitor = getInvalidateByCacheConfigVisitor(5, true);
    final RootNodeMockFactory.Settings settings = new RootNodeMockFactory.Settings();
    settings.setEntryNodeCount(10);
    final Node rootNode = new RootNodeMockFactory(settings).build();
    visitor.visit(rootNode);
    visitor.close();
    Mockito.verify(rootNode.getSession(), Mockito.times(2)).save();
}
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 9 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 testEmpty.

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

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

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