Search in sources :

Example 11 with CacheManager

use of org.xwiki.cache.CacheManager in project xwiki-platform by xwiki.

the class XWikiCacheStoreTest method before.

@Before
public void before() throws Exception {
    this.oldcore.getMocker().registerMockComponent(RemoteObservationManagerContext.class);
    this.oldcore.getMocker().registerMockComponent(ObservationManager.class);
    CacheManager cacheManager = this.oldcore.getMocker().registerMockComponent(CacheManager.class);
    cache = mock(Cache.class);
    when(cacheManager.<XWikiDocument>createNewCache(isCacheConfiguration("xwiki.store.pagecache"))).thenReturn(cache);
    existCache = mock(Cache.class);
    when(cacheManager.<Boolean>createNewCache(isCacheConfiguration("xwiki.store.pageexistcache"))).thenReturn(existCache);
}
Also used : XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) CacheManager(org.xwiki.cache.CacheManager) Cache(org.xwiki.cache.Cache) Before(org.junit.Before)

Example 12 with CacheManager

use of org.xwiki.cache.CacheManager in project xwiki-platform by xwiki.

the class AbstractTestDocumentConfigurationSource method before.

@Before
public void before() throws Exception {
    this.mockCache = mock(Cache.class);
    this.mockConverter = this.componentManager.getInstance(ConverterManager.class);
    when(this.mockConverter.convert(any(Type.class), anyObject())).then(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            return invocation.getArguments()[1];
        }
    });
    CacheManager cacheManager = this.componentManager.getInstance(CacheManager.class);
    when(cacheManager.createNewCache(any(CacheConfiguration.class))).thenReturn(this.mockCache);
    WikiDescriptorManager wikiManager = this.componentManager.getInstance(WikiDescriptorManager.class);
    when(wikiManager.getCurrentWikiId()).thenReturn(CURRENT_WIKI);
    DocumentReferenceResolver<EntityReference> mockCurrentEntityResolver = this.componentManager.registerMockComponent(DocumentReferenceResolver.TYPE_REFERENCE, "current");
    when(mockCurrentEntityResolver.resolve(eq(getClassReference()), any(DocumentReference.class))).thenReturn(new DocumentReference(getClassReference(), new WikiReference(CURRENT_WIKI)));
}
Also used : WikiDescriptorManager(org.xwiki.wiki.descriptor.WikiDescriptorManager) Type(java.lang.reflect.Type) ConverterManager(org.xwiki.properties.ConverterManager) InvocationOnMock(org.mockito.invocation.InvocationOnMock) EntityReference(org.xwiki.model.reference.EntityReference) CacheManager(org.xwiki.cache.CacheManager) BaseObject(com.xpn.xwiki.objects.BaseObject) ArgumentMatchers.anyObject(org.mockito.ArgumentMatchers.anyObject) WikiReference(org.xwiki.model.reference.WikiReference) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration) LocalDocumentReference(org.xwiki.model.reference.LocalDocumentReference) DocumentReference(org.xwiki.model.reference.DocumentReference) Cache(org.xwiki.cache.Cache) Before(org.junit.Before)

Aggregations

CacheManager (org.xwiki.cache.CacheManager)12 CacheConfiguration (org.xwiki.cache.config.CacheConfiguration)10 Before (org.junit.Before)6 Cache (org.xwiki.cache.Cache)6 DocumentReference (org.xwiki.model.reference.DocumentReference)4 XWikiContext (com.xpn.xwiki.XWikiContext)3 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)3 BaseObject (com.xpn.xwiki.objects.BaseObject)3 Test (org.junit.Test)3 LocalDocumentReference (org.xwiki.model.reference.LocalDocumentReference)3 ConverterManager (org.xwiki.properties.ConverterManager)3 WikiDescriptorManager (org.xwiki.wiki.descriptor.WikiDescriptorManager)3 XWiki (com.xpn.xwiki.XWiki)2 CacheFactory (org.xwiki.cache.CacheFactory)2 WikiReference (org.xwiki.model.reference.WikiReference)2 XWikiBridge (org.xwiki.security.internal.XWikiBridge)2 BeforeComponent (org.xwiki.test.annotation.BeforeComponent)2 XWikiException (com.xpn.xwiki.XWikiException)1 XWikiAttachment (com.xpn.xwiki.doc.XWikiAttachment)1 XWikiAttachmentContent (com.xpn.xwiki.doc.XWikiAttachmentContent)1