### Question:
MailHandler extends Handler { @Override public void publish(final LogRecord record) { if (tryMutex()) { try { if (isLoggable(record)) { if (record != null) { record.getSourceMethodName(); publish0(record); } else { reportNullError(ErrorManager.WRITE_FAILURE); } } } catch (final LinkageError JDK8152515) { reportLinkageError(JDK8152515, ErrorManager.WRITE_FAILURE); } finally { releaseMutex(); } } else { reportUnPublishedError(record); } } MailHandler();  MailHandler(final int capacity);  MailHandler(final Properties props); @Override boolean isLoggable(final LogRecord record); @Override void publish(final LogRecord record); void postConstruct(); void preDestroy(); void push(); @Override void flush(); @Override void close(); @Override void setLevel(final Level newLevel); @Override Level getLevel(); @Override ErrorManager getErrorManager(); @Override void setErrorManager(final ErrorManager em); @Override Filter getFilter(); @Override void setFilter(final Filter newFilter); @Override synchronized String getEncoding(); @Override void setEncoding(String encoding); @Override synchronized Formatter getFormatter(); @Override synchronized void setFormatter(Formatter newFormatter); final synchronized Level getPushLevel(); final synchronized void setPushLevel(final Level level); final synchronized Filter getPushFilter(); final synchronized void setPushFilter(final Filter filter); final synchronized Comparator<? super LogRecord> getComparator(); final synchronized void setComparator(Comparator<? super LogRecord> c); final synchronized int getCapacity(); final synchronized Authenticator getAuthenticator(); final void setAuthenticator(final Authenticator auth); final void setAuthenticator(final char... password); final void setMailProperties(Properties props); final Properties getMailProperties(); final Filter[] getAttachmentFilters(); final void setAttachmentFilters(Filter... filters); final Formatter[] getAttachmentFormatters(); final void setAttachmentFormatters(Formatter... formatters); final Formatter[] getAttachmentNames(); final void setAttachmentNames(final String... names); final void setAttachmentNames(Formatter... formatters); final synchronized Formatter getSubject(); final void setSubject(final String subject); final void setSubject(final Formatter format);  }### Answer:
@Test public void testPublish() { MailHandler instance = createHandlerWithRecords(); InternalErrorManager em = internalErrorManagerFrom(instance); assertEquals(em.exceptions.isEmpty(), true); instance.close(); assertEquals(true, em.exceptions.get(0) instanceof MessagingException); assertEquals(1, em.exceptions.size()); instance = createHandlerWithRecords(); instance.setErrorManager(new FlushErrorManager(instance)); final Level[] lvls = getAllLevels(); String SOURCE_CLASS = MailHandlerTest.class.getName(); String SOURCE_METHOD = "testPublish"; for (Level lvl : lvls) { LogRecord r = new LogRecord(lvl, ""); r.setSourceClassName(SOURCE_CLASS); r.setSourceMethodName(SOURCE_METHOD); instance.publish(r); } instance.close(); }