public class ExceptionTest {
/** Test CedarException. */
@Test public void testCedarException() {
Throwable cause = new Exception("cause");
LocalizableMessage message = new LocalizableMessage("whatever");
try {
throw new CedarException();
} catch (CedarException e) {
assertEquals(null, e.getMessage());
assertMessageValues(e.getLocalizableMessage(), (String) null);
assertNull(e.getCause());
assertFalse(e.hasContext());
assertNull(e.getContext());
}
try {
throw new CedarException((String) null);
} catch (CedarException e) {
assertEquals(null, e.getMessage());
assertMessageValues(e.getLocalizableMessage(), (String) null);
assertNull(e.getCause());
assertFalse(e.hasContext());
assertNull(e.getContext());
}
try {
throw new CedarException((LocalizableMessage) null);
} catch (CedarException e) {
assertNull(message.getText(), e.getMessage());
assertNull(e.getLocalizableMessage());
assertNull(e.getCause());
assertFalse(e.hasContext());
assertNull(e.getContext());
}
try {
throw new CedarException("error");
} catch (CedarException e) {
assertEquals("error", e.getMessage());
assertMessageValues(e.getLocalizableMessage(), "error");
assertNull(e.getCause());
assertFalse(e.hasContext());
assertNull(e.getContext());
}
try {
throw new CedarException(message);
} catch (CedarException e) {
assertEquals(message.getText(), e.getMessage());
assertMessageValues(e.getLocalizableMessage(), message);
assertNull(e.getCause());
assertFalse(e.hasContext());
assertNull(e.getContext());
}
try {
throw new CedarException("error", cause);
} catch (CedarException e) {
assertEquals("error", e.getMessage());
assertMessageValues(e.getLocalizableMessage(), "error");
assertSame(cause, e.getCause());
assertFalse(e.hasContext());
assertNull(e.getContext());
}
try {
throw new CedarException(message, cause);
} catch (CedarException e) {
assertEquals(message.getText(), e.getMessage());
assertMessageValues(e.getLocalizableMessage(), message);
assertSame(cause, e.getCause());
assertFalse(e.hasContext());
assertNull(e.getContext());
}