Search in sources :

Example 6 with FSSkinReference

use of org.xwiki.lesscss.internal.skin.FSSkinReference in project xwiki-platform by xwiki.

the class DefaultLESSResourcesCacheTest method clearFromLESSResource.

@Test
public void clearFromLESSResource() 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(file2), eq(new FSSkinReference("skin1")), eq(new NamedColorThemeReference("colorTheme1")), eq(true))).thenReturn("k3");
    when(cacheKeyFactory.getCacheKey(eq(file1), 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("file2"), new FSSkinReference("skin1"), new NamedColorThemeReference("colorTheme1"), "css");
    mocker.getComponentUnderTest().set(createLESSSkinFileResourceReference("file1"), new FSSkinReference("skin2"), new NamedColorThemeReference("colorTheme1"), "css3");
    // Test
    mocker.getComponentUnderTest().clearFromLESSResource(createLESSSkinFileResourceReference("file1"));
    // Verify
    verify(cache, times(1)).remove("k1");
    verify(cache).remove("k4");
    verify(cache, never()).remove("k3");
}
Also used : NamedColorThemeReference(org.xwiki.lesscss.internal.colortheme.NamedColorThemeReference) FSSkinReference(org.xwiki.lesscss.internal.skin.FSSkinReference) LESSSkinFileResourceReference(org.xwiki.lesscss.internal.resources.LESSSkinFileResourceReference) Test(org.junit.Test)

Example 7 with FSSkinReference

use of org.xwiki.lesscss.internal.skin.FSSkinReference in project xwiki-platform by xwiki.

the class DefaultLESSResourcesCacheTest method get.

@Test
public void get() throws Exception {
    // Mock
    when(cache.get("12_lessResource_4_skin_10_colorTheme")).thenReturn("Expected output");
    // Test
    String result = mocker.getComponentUnderTest().get(new LESSSkinFileResourceReference("lessResource", null, null), new FSSkinReference("skin"), new NamedColorThemeReference("colorTheme"));
    // Verify
    assertEquals("Expected output", result);
}
Also used : NamedColorThemeReference(org.xwiki.lesscss.internal.colortheme.NamedColorThemeReference) FSSkinReference(org.xwiki.lesscss.internal.skin.FSSkinReference) LESSSkinFileResourceReference(org.xwiki.lesscss.internal.resources.LESSSkinFileResourceReference) Test(org.junit.Test)

Example 8 with FSSkinReference

use of org.xwiki.lesscss.internal.skin.FSSkinReference in project xwiki-platform by xwiki.

the class DefaultLESSColorThemeConverterTest method setUp.

@Before
public void setUp() throws Exception {
    cache = mocker.getInstance(ColorThemeCache.class);
    currentColorThemeGetter = mocker.getInstance(CurrentColorThemeGetter.class);
    skinReferenceFactory = mocker.getInstance(SkinReferenceFactory.class);
    colorThemeReferenceFactory = mocker.getInstance(ColorThemeReferenceFactory.class);
    lessResourceReferenceFactory = mocker.getInstance(LESSResourceReferenceFactory.class);
    xcontextProvider = mocker.registerMockComponent(XWikiContext.TYPE_PROVIDER);
    xcontext = mock(XWikiContext.class);
    when(xcontextProvider.get()).thenReturn(xcontext);
    xwiki = mock(XWiki.class);
    when(xcontext.getWiki()).thenReturn(xwiki);
    when(xwiki.getSkin(xcontext)).thenReturn("skin");
    when(currentColorThemeGetter.getCurrentColorTheme(true, "default")).thenReturn("colorTheme");
    when(skinReferenceFactory.createReference("skin")).thenReturn(new FSSkinReference("skin"));
    when(colorThemeReferenceFactory.createReference("colorTheme")).thenReturn(new NamedColorThemeReference("colorTheme"));
    when(cache.getMutex(eq(new LESSSkinFileResourceReference("file", null, null)), eq(new FSSkinReference("skin")), eq(new NamedColorThemeReference("colorTheme")))).thenReturn("mutex");
}
Also used : CurrentColorThemeGetter(org.xwiki.lesscss.internal.colortheme.CurrentColorThemeGetter) LESSResourceReferenceFactory(org.xwiki.lesscss.resources.LESSResourceReferenceFactory) ColorThemeReferenceFactory(org.xwiki.lesscss.internal.colortheme.ColorThemeReferenceFactory) NamedColorThemeReference(org.xwiki.lesscss.internal.colortheme.NamedColorThemeReference) XWikiContext(com.xpn.xwiki.XWikiContext) XWiki(com.xpn.xwiki.XWiki) FSSkinReference(org.xwiki.lesscss.internal.skin.FSSkinReference) ColorThemeCache(org.xwiki.lesscss.internal.cache.ColorThemeCache) SkinReferenceFactory(org.xwiki.lesscss.internal.skin.SkinReferenceFactory) LESSSkinFileResourceReference(org.xwiki.lesscss.internal.resources.LESSSkinFileResourceReference) Before(org.junit.Before)

Aggregations

NamedColorThemeReference (org.xwiki.lesscss.internal.colortheme.NamedColorThemeReference)8 LESSSkinFileResourceReference (org.xwiki.lesscss.internal.resources.LESSSkinFileResourceReference)8 FSSkinReference (org.xwiki.lesscss.internal.skin.FSSkinReference)8 Test (org.junit.Test)6 Before (org.junit.Before)2 XWiki (com.xpn.xwiki.XWiki)1 XWikiContext (com.xpn.xwiki.XWikiContext)1 Cache (org.xwiki.cache.Cache)1 CacheFactory (org.xwiki.cache.CacheFactory)1 CacheManager (org.xwiki.cache.CacheManager)1 CacheConfiguration (org.xwiki.cache.config.CacheConfiguration)1 ColorThemeCache (org.xwiki.lesscss.internal.cache.ColorThemeCache)1 ColorTheme (org.xwiki.lesscss.internal.colortheme.ColorTheme)1 ColorThemeReferenceFactory (org.xwiki.lesscss.internal.colortheme.ColorThemeReferenceFactory)1 CurrentColorThemeGetter (org.xwiki.lesscss.internal.colortheme.CurrentColorThemeGetter)1 SkinReferenceFactory (org.xwiki.lesscss.internal.skin.SkinReferenceFactory)1 LESSResourceReferenceFactory (org.xwiki.lesscss.resources.LESSResourceReferenceFactory)1