MailHandler extends Handler { public void flush() { push(false, ErrorManager.FLUSH_FAILURE); } MailHandler();  MailHandler(final int capacity);  MailHandler(final Properties props); @Override boolean isLoggable(final LogRecord record); void publish(final LogRecord record); void push(); void flush(); void close(); @Override synchronized void setLevel(final Level newLevel); 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);  }
@Test public void testFlush() { MailHandler instance = new MailHandler(createInitProperties("")); InternalErrorManager em = new InternalErrorManager(); instance.setErrorManager(em); instance.flush(); assertEquals(true, em.exceptions.isEmpty()); instance.close(); instance = createHandlerWithRecords(); em = internalErrorManagerFrom(instance); instance.flush(); assertEquals(1, em.exceptions.size()); assertEquals(true, em.exceptions.get(0) instanceof MessagingException); instance.close(); instance = createHandlerWithRecords(); instance.setErrorManager(new FlushErrorManager(instance)); instance.flush(); instance.close(); instance = new MailHandler(1); instance.setMailProperties(createInitProperties("")); instance.setLevel(Level.ALL); instance.setErrorManager(new FlushErrorManager(instance)); instance.setPushFilter((Filter) null); instance.setPushLevel(Level.SEVERE); LogRecord record = new LogRecord(Level.INFO, ""); instance.publish(record); instance.push(); instance.close(); }