### Question:
DefaultExceptionFormatter implements ExceptionFormatter { public void setCustomExceptionFormatter(ExceptionFormatter customFormatter) { if (customFormatter == null) { throw new IllegalArgumentException("customFormatter cannot be null"); } if (this.customFormatter == null) { this.customFormatter = customFormatter; } else { s_log.error( "setCustomExceptionFormatter: An existing customFormatter ( "+ this.customFormatter.getClass().getName()+" )has already " + "been set - ignoring "+customFormatter.getClass().getName()); } }  String format(Throwable th); String defaultFormatSQLException(Throwable cause); boolean formatsException(Throwable t); void setCustomExceptionFormatter(ExceptionFormatter customFormatter);  }### Answer:
@Test (expected = IllegalArgumentException.class) public final void testSetNullCustomExceptionFormatter() { formatterUnderTest.setCustomExceptionFormatter(null); }
@Test public final void testSetCustomExceptionFormatter() throws Exception { ExceptionFormatter formatter1 = createMock(ExceptionFormatter.class); SQLException ex = new SQLException("table does not exist"); SQLExecutionException ee = new SQLExecutionException(ex, ""); expect(formatter1.formatsException(isA(SQLException.class))).andReturn(true).anyTimes(); expect(formatter1.format(ex)).andReturn("foo").anyTimes(); replay(formatter1); formatterUnderTest.setCustomExceptionFormatter(formatter1); String formattedEx = formatterUnderTest.format(ee); verify(formatter1); Assert.assertEquals("foo", formattedEx); }