use of org.xwiki.cache.CacheManager in project xwiki-platform by xwiki.
the class SendMailConfigClassDocumentConfigurationSourceTest method getPropertyWhenNoSendMailConfigClassXObject.
@Test
public void getPropertyWhenNoSendMailConfigClassXObject() throws Exception {
Cache<Object> cache = mock(Cache.class);
CacheManager cacheManager = this.mocker.getInstance(CacheManager.class);
when(cacheManager.createNewCache(any(CacheConfiguration.class))).thenReturn(cache);
WikiDescriptorManager wikiDescriptorManager = this.mocker.getInstance(WikiDescriptorManager.class);
when(wikiDescriptorManager.getCurrentWikiId()).thenReturn("wiki");
LocalDocumentReference classReference = new LocalDocumentReference("Mail", "SendMailConfigClass");
XWikiDocument document = mock(XWikiDocument.class);
when(document.getXObject(classReference)).thenReturn(null);
DocumentReference documentReference = new DocumentReference("wiki", "Mail", "MailConfig");
XWiki xwiki = mock(XWiki.class);
when(xwiki.getDocument(eq(documentReference), any(XWikiContext.class))).thenReturn(document);
XWikiContext xcontext = mock(XWikiContext.class);
when(xcontext.getWiki()).thenReturn(xwiki);
Provider<XWikiContext> xcontextProvider = this.mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER);
when(xcontextProvider.get()).thenReturn(xcontext);
assertEquals("defaultValue", this.mocker.getComponentUnderTest().getProperty("key", "defaultValue"));
}
use of org.xwiki.cache.CacheManager in project xwiki-platform by xwiki.
the class SendMailConfigClassDocumentConfigurationSourceTest method getPropertyWhenSendMailConfigClassXObjectExists.
@Test
public void getPropertyWhenSendMailConfigClassXObjectExists() throws Exception {
ConverterManager converterManager = this.mocker.getInstance(ConverterManager.class);
when(converterManager.convert(String.class, "value")).thenReturn("value");
Cache<Object> cache = mock(Cache.class);
CacheManager cacheManager = this.mocker.getInstance(CacheManager.class);
when(cacheManager.createNewCache(any(CacheConfiguration.class))).thenReturn(cache);
WikiDescriptorManager wikiDescriptorManager = this.mocker.getInstance(WikiDescriptorManager.class);
when(wikiDescriptorManager.getCurrentWikiId()).thenReturn("wiki");
LocalDocumentReference classReference = new LocalDocumentReference("Mail", "SendMailConfigClass");
BaseProperty property = mock(BaseProperty.class);
when(property.toText()).thenReturn("value");
BaseObject object = mock(BaseObject.class);
when(object.getField("key")).thenReturn(property);
XWikiDocument document = mock(XWikiDocument.class);
when(document.getXObject(classReference)).thenReturn(object);
DocumentReference documentReference = new DocumentReference("wiki", "Mail", "MailConfig");
XWiki xwiki = mock(XWiki.class);
when(xwiki.getDocument(eq(documentReference), any(XWikiContext.class))).thenReturn(document);
XWikiContext xcontext = mock(XWikiContext.class);
when(xcontext.getWiki()).thenReturn(xwiki);
Provider<XWikiContext> xcontextProvider = this.mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER);
when(xcontextProvider.get()).thenReturn(xcontext);
assertEquals("value", this.mocker.getComponentUnderTest().getProperty("key", "defaultValue"));
}
use of org.xwiki.cache.CacheManager in project xwiki-platform by xwiki.
the class DefaultLESSResourcesCacheTest method setUp.
@Before
public void setUp() throws Exception {
cacheManager = mocker.getInstance(CacheManager.class);
cache = mock(Cache.class);
CacheFactory cacheFactory = mock(CacheFactory.class);
when(cacheManager.getCacheFactory()).thenReturn(cacheFactory);
CacheConfiguration configuration = new CacheConfiguration("lesscss.skinfiles.cache");
when(cacheFactory.<String>newCache(eq(configuration))).thenReturn(cache);
cacheKeyFactory = mocker.getInstance(CacheKeyFactory.class);
LESSSkinFileResourceReference lessSkinFileResourceReference = new LESSSkinFileResourceReference("lessResource", null, null);
when(cacheKeyFactory.getCacheKey(eq(lessSkinFileResourceReference), eq(new FSSkinReference("skin")), eq(new NamedColorThemeReference("colorTheme")), eq(true))).thenReturn("12_lessResource_4_skin_10_colorTheme");
}
use of org.xwiki.cache.CacheManager in project xwiki-platform by xwiki.
the class DefaultOfficeResourceViewerTest method configure.
/**
* Test fixture.
*
* @throws Exception in case of an exception raised during the fixture preparation
*/
@Before
public void configure() throws Exception {
final CacheManager cacheManager = mocker.getInstance(CacheManager.class);
attachmentCache = mock(Cache.class, "attachment");
externalCache = mock(Cache.class, "external");
when(cacheManager.<OfficeDocumentView>createNewCache(notNull(CacheConfiguration.class))).thenReturn(attachmentCache, externalCache);
EntityReferenceSerializer<String> entityReferenceSerializer = mocker.getInstance(EntityReferenceSerializer.TYPE_STRING);
when(entityReferenceSerializer.serialize(ATTACHMENT_REFERENCE)).thenReturn(STRING_ATTACHMENT_REFERENCE);
when(entityReferenceSerializer.serialize(ATTACHMENT_REFERENCE.getDocumentReference())).thenReturn(STRING_DOCUMENT_REFERENCE);
AttachmentReferenceResolver<String> attachmentReferenceResolver = mocker.getInstance(AttachmentReferenceResolver.TYPE_STRING, "current");
when(attachmentReferenceResolver.resolve(STRING_ATTACHMENT_REFERENCE)).thenReturn(ATTACHMENT_REFERENCE);
this.resourceReferenceSerializer = mocker.getInstance(ResourceReferenceTypeSerializer.class);
when(this.resourceReferenceSerializer.serialize(ATTACHMENT_RESOURCE_REFERENCE)).thenReturn(STRING_ATTACHMENT_RESOURCE_REFERENCE);
ConverterManager converterManager = mocker.getInstance(ConverterManager.class);
when(converterManager.convert(boolean.class, null)).thenReturn(false);
when(converterManager.convert(DocumentReference.class, ATTACHMENT_REFERENCE.getDocumentReference())).thenReturn(ATTACHMENT_REFERENCE.getDocumentReference());
documentAccessBridge = mocker.getInstance(DocumentAccessBridge.class);
officeDocumentBuilder = mocker.getInstance(XDOMOfficeDocumentBuilder.class);
OfficeServer officeServer = mocker.getInstance(OfficeServer.class);
OfficeConverter officeConverter = mock(OfficeConverter.class);
when(officeServer.getConverter()).thenReturn(officeConverter);
when(officeConverter.getFormatRegistry()).thenReturn(new DefaultDocumentFormatRegistry());
}
use of org.xwiki.cache.CacheManager in project xwiki-platform by xwiki.
the class DefaultIconSetCacheTest method setUp.
@Before
public void setUp() throws Exception {
cacheManager = mocker.getInstance(CacheManager.class);
entityReferenceSerializer = mocker.getInstance(new DefaultParameterizedType(null, EntityReferenceSerializer.class, String.class));
cache = mock(Cache.class);
CacheFactory cacheFactory = mock(CacheFactory.class);
when(cacheManager.getCacheFactory()).thenReturn(cacheFactory);
CacheConfiguration configuration = new CacheConfiguration("iconset");
when(cacheFactory.<IconSet>newCache(eq(configuration))).thenReturn(cache);
}
Aggregations