### Question:
MailManager { public String send(String from, Set<String> addressListTO, Set<String> addressListCC, String subject, String body) throws MailException { StringBuilder errorBuilder = new StringBuilder(); try { MimeMessage myMessage = new MimeMessage(this.getMailSession()); myMessage.setSubject(subject, encoding_); if ((from != null) && !from.equals("")) { myMessage.setFrom(new InternetAddress(from, STRICT_EMAIL_CHECK)); } MimeBodyPart mbp1 = new MimeBodyPart(); mbp1.setText(body, encoding_); Multipart mp = new MimeMultipart(); mp.addBodyPart(mbp1); myMessage.setContent(mp); for (String addr : addressListTO) { try { Address addressAux = new InternetAddress(addr, STRICT_EMAIL_CHECK); myMessage.addRecipient(Message.RecipientType.TO, addressAux); } catch (AddressException addEx) { final String cause = String.format("Invalid email address TO [%s] caused by [%s]", addr, addEx.getLocalizedMessage()); errorBuilder.append(cause); } } if (addressListCC != null) { for (String addr : addressListCC) { try { Address addressAux = new InternetAddress(addr, STRICT_EMAIL_CHECK); myMessage.addRecipient(Message.RecipientType.CC, addressAux); } catch (AddressException addEx) { final String cause = String.format("Invalid email address CC [%s] caused by [%s]", addr, addEx.getLocalizedMessage()); errorBuilder.append(cause); } } } Transport tr = session_.getTransport(MailManager.DEFAULT_TRANSPORT); tr.connect(host_, username_, password_); myMessage.saveChanges(); tr.sendMessage(myMessage, myMessage.getAllRecipients()); tr.close(); } catch (AddressException ae) { throw new MailException(MailManager.BAD_INTERNET_ADDRESS_ERROR, ae); } catch (javax.mail.MessagingException exc) { throw new MailException(MailManager.BAD_INTERNET_ADDRESS_ERROR, exc); } catch (javax.naming.NamingException exc) { throw new MailException(MailManager.BAD_JNDI_ERROR, exc); } return errorBuilder.toString(); } protected  MailManager(String host, String username, String password, String encoding,
        Boolean isAuth, Boolean isTls, Boolean isSsl, Integer sslPort); protected  MailManager(String host, String username, String password, String encoding,
        Boolean isAuth, Boolean isTls); protected  MailManager(String host, String username, String password, String encoding,
        Boolean isAuth); protected  MailManager(String host, String username, String password, String encoding); private  MailManager(String host, String username, String password); static synchronized MailManager instance(); String send(String from, Set<String> addressListTO, Set<String> addressListCC,
        String subject, String body); String send(String mailFrom, String mailTo, String mailCc, String subject, String body); String send(String mailFrom, String mailTo, String subject, String body); String sendFromMailUser(String mailTo, String mailCc, String subject, String body); String sendFromMailUser(String mailTo, String subject, String body);  }### Answer:
@Test public final void testSendArrayOfAddresses() { try { Set<String> to = new HashSet<String>(); Set<String> cc = new HashSet<String>(); to.add(mailTo); cc.add(mailCC); mail.send(mailUser, to, cc, mailSubject, mailBody); } catch (Exception e) { e.printStackTrace(); fail("Exception raised:" + e.toString()); } }
@Test public final void testSendAddresses() { try { mail.send(mailUser, mailTo, mailCC, mailSubject, mailBody); } catch (Exception e) { e.printStackTrace(); fail("Exception raised:" + e.toString()); } }