use of org.xwiki.icon.IconException in project xwiki-platform by xwiki.
the class DefaultIconSetLoaderTest method loadIconSetWithException.
@Test
public void loadIconSetWithException() throws Exception {
Reader content = mock(Reader.class);
IOException exception = new IOException("test");
when(content.read(any(char[].class))).thenThrow(exception);
// Test
Exception caughException = null;
try {
mocker.getComponentUnderTest().loadIconSet(content, "FontAwesome");
} catch (IconException e) {
caughException = e;
}
assertNotNull(caughException);
assert (caughException instanceof IconException);
assertEquals(exception, caughException.getCause());
assertEquals("Failed to load the IconSet [FontAwesome].", caughException.getMessage());
}
use of org.xwiki.icon.IconException in project xwiki-platform by xwiki.
the class DefaultIconSetManagerTest method getDefaultIconWithException.
@Test
public void getDefaultIconWithException() throws Exception {
// Mocks
Exception exception = new MalformedURLException();
when(xwiki.getResourceAsStream(any())).thenThrow(exception);
// Test
Exception exceptionCaught = null;
try {
mocker.getComponentUnderTest().getDefaultIconSet();
} catch (IconException e) {
exceptionCaught = e;
}
// Verify
assertNotNull(exceptionCaught);
assertEquals(exception, exceptionCaught.getCause());
assertEquals("Failed to get the current default icon set.", exceptionCaught.getMessage());
}
use of org.xwiki.icon.IconException in project xwiki-platform by xwiki.
the class DefaultIconSetManagerTest method getIconSetNamesWhenException.
@Test
public void getIconSetNamesWhenException() throws Exception {
// Mocks
QueryException exception = new QueryException("exception in the query", null, null);
when(queryManager.createQuery(any(), eq(Query.XWQL))).thenThrow(exception);
// Test
IconException caughtException = null;
try {
mocker.getComponentUnderTest().getIconSetNames();
} catch (IconException e) {
caughtException = e;
}
// Verify
assertNotNull(caughtException);
assertEquals("Failed to get the name of all icon sets.", caughtException.getMessage());
assertEquals(exception, caughtException.getCause());
}
use of org.xwiki.icon.IconException in project xwiki-platform by xwiki.
the class VelocityRendererTest method renderWhenEvaluateReturnsFalse.
@Test
public void renderWhenEvaluateReturnsFalse() throws Exception {
// Mocks
VelocityEngine engine = mock(VelocityEngine.class);
when(velocityManager.getVelocityEngine()).thenReturn(engine);
when(engine.evaluate(any(VelocityContext.class), any(Writer.class), any(), eq("myCode"))).thenReturn(false);
// Test
IconException caughtException = null;
try {
mocker.getComponentUnderTest().render("myCode");
} catch (IconException e) {
caughtException = e;
}
// Verify
assertNotNull(caughtException);
assertEquals("Failed to render the icon. See the Velocity runtime log.", caughtException.getMessage());
verify(engine).startedUsingMacroNamespace("IconVelocityRenderer_" + Thread.currentThread().getId());
verify(engine).stoppedUsingMacroNamespace("IconVelocityRenderer_" + Thread.currentThread().getId());
}
Aggregations