Search in sources :

Example 31 with IconSet

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

the class DefaultIconRendererTest method renderWithException.

@Test
public void renderWithException() throws Exception {
    IconSet iconSet = new IconSet("default");
    iconSet.setRenderWiki("image:$icon.png");
    iconSet.addIcon("test", new Icon("blabla"));
    IconException exception = new IconException("exception", null);
    when(velocityRenderer.render(any())).thenThrow(exception);
    // Test
    IconException caughtException = null;
    try {
        mocker.getComponentUnderTest().render("test", iconSet);
    } catch (IconException e) {
        caughtException = e;
    }
    // Verify
    assertNotNull(caughtException);
    assertEquals(exception, caughtException);
}
Also used : Icon(org.xwiki.icon.Icon) IconSet(org.xwiki.icon.IconSet) IconException(org.xwiki.icon.IconException) Test(org.junit.Test)

Example 32 with IconSet

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

the class DefaultIconRendererTest method renderWithJSX.

@Test
public void renderWithJSX() throws Exception {
    IconSet iconSet = new IconSet("default");
    iconSet.setJsx("jsx");
    iconSet.addIcon("test", new Icon("blabla"));
    // Test
    mocker.getComponentUnderTest().render("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 33 with IconSet

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

the class DefaultIconRendererTest method renderNonExistentIcon.

@Test
public void renderNonExistentIcon() throws Exception {
    IconSet iconSet = new IconSet("default");
    // Test
    String result = mocker.getComponentUnderTest().render("non-existent-icon", iconSet);
    // Verify
    assertEquals("", result);
}
Also used : IconSet(org.xwiki.icon.IconSet) Test(org.junit.Test)

Example 34 with IconSet

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

the class DefaultIconSetCacheTest method putByName.

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

Example 35 with IconSet

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

the class DefaultIconSetCacheTest method getByName.

@Test
public void getByName() throws Exception {
    IconSet iconSet = new IconSet("key");
    when(cache.get("NAMED:key")).thenReturn(iconSet);
    IconSet result = mocker.getComponentUnderTest().get("key");
    assertTrue(iconSet == result);
}
Also used : 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