@Test public void getFileContent() throws Exception { URL myURL = new URL("http: Whitebox.invokeMethod(mailService, "getFileContent", myURL); }
private byte[] getFileContent(URL attachmentUrl) throws IOException { HttpURLConnection connection = (HttpURLConnection) attachmentUrl.openConnection(); InputStream inputStream = connection.getInputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.copy(inputStream, baos); inputStream.close(); baos.close(); return baos.toByteArray(); }
MailService { private byte[] getFileContent(URL attachmentUrl) throws IOException { HttpURLConnection connection = (HttpURLConnection) attachmentUrl.openConnection(); InputStream inputStream = connection.getInputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.copy(inputStream, baos); inputStream.close(); baos.close(); return baos.toByteArray(); } }
MailService { private byte[] getFileContent(URL attachmentUrl) throws IOException { HttpURLConnection connection = (HttpURLConnection) attachmentUrl.openConnection(); InputStream inputStream = connection.getInputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.copy(inputStream, baos); inputStream.close(); baos.close(); return baos.toByteArray(); } @Autowired  MailService(JavaMailSender mailSender, MailContentBuilderService mailContentBuilderService); }
MailService { private byte[] getFileContent(URL attachmentUrl) throws IOException { HttpURLConnection connection = (HttpURLConnection) attachmentUrl.openConnection(); InputStream inputStream = connection.getInputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.copy(inputStream, baos); inputStream.close(); baos.close(); return baos.toByteArray(); } @Autowired  MailService(JavaMailSender mailSender, MailContentBuilderService mailContentBuilderService); void prepareAndSendMail(String cc,String from, List<String> to, String subject, String mailMessageUrlOrBody, Map<String, Object> placeholderValues, final String attachmentUrl, final Boolean isPlainMessage); void prepareTemplateAndSendMail(String from, List<String> to, String subject, String mailMessageUrlOrBody, Map<String, Object> placeholderValues, final String attachmentUrl, final Boolean isPlainMessage); void prepareTemplateAndSendMail(String from, List<String> to, String subject, String mailContent , final String attachmentUrl); @SuppressWarnings("deprecation") String processTemplate(String templateUrl, Map<String, Object> model); }
MailService { private byte[] getFileContent(URL attachmentUrl) throws IOException { HttpURLConnection connection = (HttpURLConnection) attachmentUrl.openConnection(); InputStream inputStream = connection.getInputStream(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); IOUtils.copy(inputStream, baos); inputStream.close(); baos.close(); return baos.toByteArray(); } @Autowired  MailService(JavaMailSender mailSender, MailContentBuilderService mailContentBuilderService); void prepareAndSendMail(String cc,String from, List<String> to, String subject, String mailMessageUrlOrBody, Map<String, Object> placeholderValues, final String attachmentUrl, final Boolean isPlainMessage); void prepareTemplateAndSendMail(String from, List<String> to, String subject, String mailMessageUrlOrBody, Map<String, Object> placeholderValues, final String attachmentUrl, final Boolean isPlainMessage); void prepareTemplateAndSendMail(String from, List<String> to, String subject, String mailContent , final String attachmentUrl); @SuppressWarnings("deprecation") String processTemplate(String templateUrl, Map<String, Object> model);  }