use of org.xwiki.lesscss.internal.colortheme.NamedColorThemeReference in project xwiki-platform by xwiki.
the class DefaultLESSResourcesCacheTest method clearFromSkin.
@Test
public void clearFromSkin() throws Exception {
// Mocks
LESSSkinFileResourceReference file1 = createLESSSkinFileResourceReference("file1");
LESSSkinFileResourceReference file2 = createLESSSkinFileResourceReference("file2");
when(cacheKeyFactory.getCacheKey(eq(file1), eq(new FSSkinReference("skin1")), eq(new NamedColorThemeReference("colorTheme")), eq(true))).thenReturn("k1");
when(cacheKeyFactory.getCacheKey(eq(file1), eq(new FSSkinReference("skin2")), eq(new NamedColorThemeReference("colorTheme")), eq(true))).thenReturn("k3");
when(cacheKeyFactory.getCacheKey(eq(file2), eq(new FSSkinReference("skin1")), eq(new NamedColorThemeReference("colorTheme")), eq(true))).thenReturn("k4");
// Add the first one twice
mocker.getComponentUnderTest().set(createLESSSkinFileResourceReference("file1"), new FSSkinReference("skin1"), new NamedColorThemeReference("colorTheme"), "css1");
mocker.getComponentUnderTest().set(createLESSSkinFileResourceReference("file1"), new FSSkinReference("skin1"), new NamedColorThemeReference("colorTheme"), "css1");
// Others
mocker.getComponentUnderTest().set(createLESSSkinFileResourceReference("file1"), new FSSkinReference("skin2"), new NamedColorThemeReference("colorTheme"), "css2");
mocker.getComponentUnderTest().set(createLESSSkinFileResourceReference("file2"), new FSSkinReference("skin1"), new NamedColorThemeReference("colorTheme"), "css3");
// Test
mocker.getComponentUnderTest().clearFromSkin(new FSSkinReference("skin1"));
// Verify
verify(cache, times(1)).remove("k1");
verify(cache).remove("k4");
verify(cache, never()).remove("k3");
}
use of org.xwiki.lesscss.internal.colortheme.NamedColorThemeReference 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.lesscss.internal.colortheme.NamedColorThemeReference in project xwiki-platform by xwiki.
the class DefaultLESSResourcesCacheTest method set.
@Test
public void set() throws Exception {
// Test
mocker.getComponentUnderTest().set(new LESSSkinFileResourceReference("lessResource", null, null), new FSSkinReference("skin"), new NamedColorThemeReference("colorTheme"), "css");
// Verify
verify(cache).set(eq("12_lessResource_4_skin_10_colorTheme"), eq("css"));
}
use of org.xwiki.lesscss.internal.colortheme.NamedColorThemeReference in project xwiki-platform by xwiki.
the class DefaultLESSResourcesCacheTest method clearFromColorTheme.
@Test
public void clearFromColorTheme() throws Exception {
// Mocks
LESSSkinFileResourceReference file1 = createLESSSkinFileResourceReference("file1");
LESSSkinFileResourceReference file2 = createLESSSkinFileResourceReference("file2");
when(cacheKeyFactory.getCacheKey(eq(file1), eq(new FSSkinReference("skin1")), eq(new NamedColorThemeReference("colorTheme1")), eq(true))).thenReturn("k1");
when(cacheKeyFactory.getCacheKey(eq(file1), eq(new FSSkinReference("skin1")), eq(new NamedColorThemeReference("colorTheme2")), eq(true))).thenReturn("k3");
when(cacheKeyFactory.getCacheKey(eq(file2), eq(new FSSkinReference("skin2")), eq(new NamedColorThemeReference("colorTheme1")), eq(true))).thenReturn("k4");
// Add the first one twice
mocker.getComponentUnderTest().set(createLESSSkinFileResourceReference("file1"), new FSSkinReference("skin1"), new NamedColorThemeReference("colorTheme1"), "css1");
mocker.getComponentUnderTest().set(createLESSSkinFileResourceReference("file1"), new FSSkinReference("skin1"), new NamedColorThemeReference("colorTheme1"), "css1");
// Others
mocker.getComponentUnderTest().set(createLESSSkinFileResourceReference("file1"), new FSSkinReference("skin1"), new NamedColorThemeReference("colorTheme2"), "css2");
mocker.getComponentUnderTest().set(createLESSSkinFileResourceReference("file2"), new FSSkinReference("skin2"), new NamedColorThemeReference("colorTheme1"), "css3");
// Test
mocker.getComponentUnderTest().clearFromColorTheme(new NamedColorThemeReference("colorTheme1"));
// Verify
verify(cache, times(1)).remove("k1");
verify(cache).remove("k4");
verify(cache, never()).remove("k3");
}
use of org.xwiki.lesscss.internal.colortheme.NamedColorThemeReference in project xwiki-platform by xwiki.
the class DefaultLESSColorThemeConverterTest method getColorThemeFromSkinFileWhenInCache.
@Test
public void getColorThemeFromSkinFileWhenInCache() throws Exception {
// Mocks
ColorTheme cachedColorTheme = new ColorTheme();
cachedColorTheme.put("key", "value1");
LESSSkinFileResourceReference lessSkinFileResourceReference = new LESSSkinFileResourceReference("file", null, null);
when(lessResourceReferenceFactory.createReferenceForSkinFile("file")).thenReturn(lessSkinFileResourceReference);
when(cache.get(eq(lessSkinFileResourceReference), eq(new FSSkinReference("skin")), eq(new NamedColorThemeReference("colorTheme")))).thenReturn(cachedColorTheme);
// Test
ColorTheme result = mocker.getComponentUnderTest().getColorThemeFromSkinFile("file", "skin", false);
// Verify
assertEquals(cachedColorTheme, result);
// Verify that the returned value is not the instance stored in the cache (that the end-user would wrongly be
// able to modify)
assertTrue(result != cachedColorTheme);
// Be extra-sure :)
result.put("key", "value2");
assertNotEquals("value2", cachedColorTheme.get("key"));
}
Aggregations