Search in sources :

Example 6 with IconSet

use of org.xwiki.icon.IconSet in project xwiki-platform by xwiki.

the class DefaultIconRendererTest method renderHTML.

@Test
public void renderHTML() throws Exception {
    IconSet iconSet = new IconSet("default");
    iconSet.setRenderHTML("<img src=\"$icon.png\" />");
    iconSet.addIcon("test", new Icon("blabla"));
    when(velocityRenderer.render("#set($icon = \"blabla\")\n<img src=\"$icon.png\" />")).thenReturn("<img src=\"blabla.png\" />");
    // Test
    String result = mocker.getComponentUnderTest().renderHTML("test", iconSet);
    // Verify
    assertEquals("<img src=\"blabla.png\" />", result);
}
Also used : Icon(org.xwiki.icon.Icon) IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Example 7 with IconSet

use of org.xwiki.icon.IconSet in project xwiki-platform by xwiki.

the class DefaultIconRendererTest method renderHTMLWithJSX.

@Test
public void renderHTMLWithJSX() throws Exception {
    IconSet iconSet = new IconSet("default");
    iconSet.setJsx("jsx");
    iconSet.addIcon("test", new Icon("blabla"));
    // Test
    mocker.getComponentUnderTest().renderHTML("test", iconSet);
    // Verify
    verify(jsExtension).use("jsx");
    verify(linkExtension, never()).use(any());
    verify(skinExtension, never()).use(any());
}
Also used : Icon(org.xwiki.icon.Icon) IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Example 8 with IconSet

use of org.xwiki.icon.IconSet in project xwiki-platform by xwiki.

the class DefaultIconSetCacheTest method putByNameAndWiki.

@Test
public void putByNameAndWiki() throws Exception {
    IconSet iconSet = new IconSet("key");
    mocker.getComponentUnderTest().put("key", "wikiId", iconSet);
    verify(cache).set("NAMED:6wikiId_key", iconSet);
}
Also used : IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Example 9 with IconSet

use of org.xwiki.icon.IconSet 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);
}
Also used : CacheManager(org.xwiki.cache.CacheManager) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) CacheFactory(org.xwiki.cache.CacheFactory) CacheConfiguration(org.xwiki.cache.config.CacheConfiguration) Cache(org.xwiki.cache.Cache) IconSet(org.xwiki.icon.IconSet) Before(org.junit.Before)

Example 10 with IconSet

use of org.xwiki.icon.IconSet in project xwiki-platform by xwiki.

the class DefaultIconSetCacheTest method getByDocRef.

@Test
public void getByDocRef() throws Exception {
    IconSet iconSet = new IconSet("key");
    DocumentReference docRef = new DocumentReference("a", "b", "c");
    when(entityReferenceSerializer.serialize(docRef)).thenReturn("a:b.c");
    when(cache.get("DOC:a:b.c")).thenReturn(iconSet);
    IconSet result = mocker.getComponentUnderTest().get(docRef);
    assertTrue(iconSet == result);
}
Also used : DocumentReference(org.xwiki.model.reference.DocumentReference) IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Aggregations

IconSet (org.xwiki.icon.IconSet)38 Test (org.junit.Test)33 Icon (org.xwiki.icon.Icon)14 DocumentReference (org.xwiki.model.reference.DocumentReference)9 InputStreamReader (java.io.InputStreamReader)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 IconException (org.xwiki.icon.IconException)4 InputStream (java.io.InputStream)2 Reader (java.io.Reader)2 HashMap (java.util.HashMap)2 Query (org.xwiki.query.Query)2 XWiki (com.xpn.xwiki.XWiki)1 XWikiContext (com.xpn.xwiki.XWikiContext)1 IOException (java.io.IOException)1 StringWriter (java.io.StringWriter)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 Before (org.junit.Before)1 DocumentModelBridge (org.xwiki.bridge.DocumentModelBridge)1