Search in sources :

Example 6 with CacheFactory

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

the class DefaultIconSetCacheTest method initializeWhenError.

@Test
public void initializeWhenError() throws Exception {
    DefaultIconSetCache cache = mocker.getComponentUnderTest();
    CacheFactory cacheFactory = mock(CacheFactory.class);
    when(cacheManager.getCacheFactory()).thenReturn(cacheFactory);
    Exception exception = new CacheException("ERROR");
    when(cacheFactory.newCache(any(CacheConfiguration.class))).thenThrow(exception);
    Exception exceptionCaught = null;
    try {
        cache.initialize();
    } catch (InitializationException e) {
        exceptionCaught = e;
    }
    assertNotNull(exceptionCaught);
    assertEquals("Failed to initialize the IconSet Cache.", exceptionCaught.getMessage());
    assertEquals(exception, exceptionCaught.getCause());
}
Also used : CacheException(org.xwiki.cache.CacheException) CacheFactory(org.xwiki.cache.CacheFactory) InitializationException(org.xwiki.component.phase.InitializationException) InitializationException(org.xwiki.component.phase.InitializationException) CacheException(org.xwiki.cache.CacheException) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration) Test(org.junit.Test)

Aggregations

CacheFactory (org.xwiki.cache.CacheFactory)6 CacheConfiguration (org.xwiki.cache.config.CacheConfiguration)6 CacheException (org.xwiki.cache.CacheException)4 InitializationException (org.xwiki.component.phase.InitializationException)4 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)3 Before (org.junit.Before)2 Cache (org.xwiki.cache.Cache)2 CacheManager (org.xwiki.cache.CacheManager)2 Test (org.junit.Test)1 DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)1 IconSet (org.xwiki.icon.IconSet)1 NamedColorThemeReference (org.xwiki.lesscss.internal.colortheme.NamedColorThemeReference)1 LESSSkinFileResourceReference (org.xwiki.lesscss.internal.resources.LESSSkinFileResourceReference)1 FSSkinReference (org.xwiki.lesscss.internal.skin.FSSkinReference)1