MailTransportUtils { public static String getSubject(URI uri) { Matcher matcher = SUBJECT_PATTERN.matcher(uri.getSchemeSpecificPart()); if (matcher.find()) { return matcher.group(1); } return null; } private  MailTransportUtils(); static InternetAddress getTo(URI uri); static String getSubject(URI uri); static void closeService(Service service); static void closeFolder(Folder folder); static void closeFolder(Folder folder, boolean expunge); static String toPasswordProtectedString(URLName name); static URI toUri(InternetAddress to, String subject);  }
@Test public void testGetSubject() throws Exception { URI uri = new URI("mailto:infobot@example.com?subject=current-issue"); String subject = MailTransportUtils.getSubject(uri); Assert.assertEquals("Invalid destination", "current-issue", subject); uri = new URI("mailto:infobot@example.com"); subject = MailTransportUtils.getSubject(uri); Assert.assertNull("Invalid destination", subject); }