@Test public void testIsMissingContent() throws Exception { Properties props = createInitProperties(""); MailHandler target = new MailHandler(props); Session session = Session.getInstance(props); MimeMessage msg = new MimeMessage(session); Address[] from = InternetAddress.parse("me@localhost", false); msg.addFrom(from); msg.setRecipients(Message.RecipientType.TO, from); msg.saveChanges(); try { msg.writeTo(new ByteArrayOutputStream(384)); fail("Verify type 'remote' may hide remote exceptions."); } catch (RuntimeException re) { throw re; } catch (Exception expect) { assertNotNull(expect.getMessage()); assertTrue(expect.getMessage().length() != 0); assertTrue(target.isMissingContent(msg, expect)); } }
final boolean isMissingContent(Message msg, Throwable t) { for (Throwable cause = t.getCause(); cause != null;) { t = cause; cause = cause.getCause(); } try { msg.writeTo(new ByteArrayOutputStream(MIN_HEADER_SIZE)); } catch (final RuntimeException RE) { throw RE; } catch (final Exception noContent) { final String txt = noContent.getMessage(); if (!isEmpty(txt) && noContent.getClass() == t.getClass()) { return txt.equals(t.getMessage()); } } return false; }
MailHandler extends Handler { final boolean isMissingContent(Message msg, Throwable t) { for (Throwable cause = t.getCause(); cause != null;) { t = cause; cause = cause.getCause(); } try { msg.writeTo(new ByteArrayOutputStream(MIN_HEADER_SIZE)); } catch (final RuntimeException RE) { throw RE; } catch (final Exception noContent) { final String txt = noContent.getMessage(); if (!isEmpty(txt) && noContent.getClass() == t.getClass()) { return txt.equals(t.getMessage()); } } return false; } }
MailHandler extends Handler { final boolean isMissingContent(Message msg, Throwable t) { for (Throwable cause = t.getCause(); cause != null;) { t = cause; cause = cause.getCause(); } try { msg.writeTo(new ByteArrayOutputStream(MIN_HEADER_SIZE)); } catch (final RuntimeException RE) { throw RE; } catch (final Exception noContent) { final String txt = noContent.getMessage(); if (!isEmpty(txt) && noContent.getClass() == t.getClass()) { return txt.equals(t.getMessage()); } } return false; } MailHandler();  MailHandler(final int capacity);  MailHandler(final Properties props); }
MailHandler extends Handler { final boolean isMissingContent(Message msg, Throwable t) { for (Throwable cause = t.getCause(); cause != null;) { t = cause; cause = cause.getCause(); } try { msg.writeTo(new ByteArrayOutputStream(MIN_HEADER_SIZE)); } catch (final RuntimeException RE) { throw RE; } catch (final Exception noContent) { final String txt = noContent.getMessage(); if (!isEmpty(txt) && noContent.getClass() == t.getClass()) { return txt.equals(t.getMessage()); } } return false; } 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); }
MailHandler extends Handler { final boolean isMissingContent(Message msg, Throwable t) { for (Throwable cause = t.getCause(); cause != null;) { t = cause; cause = cause.getCause(); } try { msg.writeTo(new ByteArrayOutputStream(MIN_HEADER_SIZE)); } catch (final RuntimeException RE) { throw RE; } catch (final Exception noContent) { final String txt = noContent.getMessage(); if (!isEmpty(txt) && noContent.getClass() == t.getClass()) { return txt.equals(t.getMessage()); } } return false; } 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);  }