branch develop updated (ddf2863 -> b2a42dd)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository faxtomail. See http://git.codelutin.com/faxtomail.git from ddf2863 à la réception des emails, remplacement des images dont l'url est incorrecte par l'image par défaut (configurable) (fixes #7855) new b2a42dd ajout de tests + correction de modif des images invalides (refs #7855) The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit b2a42dd9db05e3cb73f0e6214fb1726a62ffb5d2 Author: Kevin Morin <morin@codelutin.com> Date: Fri Jan 22 14:57:58 2016 +0100 ajout de tests + correction de modif des images invalides (refs #7855) Summary of changes: .../faxtomail/services/FaxToMailServiceUtils.java | 6 ++-- .../services/service/EmailServiceTest.java | 39 ++++++++++++++++------ .../src/test/resources/emails/test6863.eml | 8 +++++ .../src/test/resources/emails/test7716.eml | 31 +++++++++++++++++ .../src/test/resources/emails/test7740.eml | 24 +++++++++++++ .../src/test/resources/emails/test7855.eml | 24 +++++++++++++ 6 files changed, 118 insertions(+), 14 deletions(-) create mode 100644 faxtomail-service/src/test/resources/emails/test6863.eml create mode 100644 faxtomail-service/src/test/resources/emails/test7716.eml create mode 100644 faxtomail-service/src/test/resources/emails/test7740.eml create mode 100644 faxtomail-service/src/test/resources/emails/test7855.eml -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository faxtomail. See http://git.codelutin.com/faxtomail.git commit b2a42dd9db05e3cb73f0e6214fb1726a62ffb5d2 Author: Kevin Morin <morin@codelutin.com> Date: Fri Jan 22 14:57:58 2016 +0100 ajout de tests + correction de modif des images invalides (refs #7855) --- .../faxtomail/services/FaxToMailServiceUtils.java | 6 ++-- .../services/service/EmailServiceTest.java | 39 ++++++++++++++++------ .../src/test/resources/emails/test6863.eml | 8 +++++ .../src/test/resources/emails/test7716.eml | 31 +++++++++++++++++ .../src/test/resources/emails/test7740.eml | 24 +++++++++++++ .../src/test/resources/emails/test7855.eml | 24 +++++++++++++ 6 files changed, 118 insertions(+), 14 deletions(-) diff --git a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceUtils.java b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceUtils.java index 2ec2616..0e5103b 100644 --- a/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceUtils.java +++ b/faxtomail-service/src/main/java/com/franciaflex/faxtomail/services/FaxToMailServiceUtils.java @@ -134,12 +134,10 @@ public class FaxToMailServiceUtils { for (String imgSrcUrl : imgSrcUrls) { - String correctImgUrl; + String correctImgUrl = URIUtil.encodeQuery(imgSrcUrl); try { // test if the url is correct (cf #7855) - new URL(imgSrcUrl); - - correctImgUrl = URIUtil.encodeQuery(imgSrcUrl); + new URL(correctImgUrl); } catch (MalformedURLException e) { //if incorrect, replace it with the default image diff --git a/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/EmailServiceTest.java b/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/EmailServiceTest.java index 782007c..4da29f5 100644 --- a/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/EmailServiceTest.java +++ b/faxtomail-service/src/test/java/com/franciaflex/faxtomail/services/service/EmailServiceTest.java @@ -296,11 +296,31 @@ public class EmailServiceTest extends AbstractFaxToMailServiceTest { } @Test - public void testConvertHTMLToPdf() { + public void test6863() { + testConvertHTMLToPdf("test6863"); + } + + @Test + public void test7716() { + testConvertHTMLToPdf("test7716"); + } + + @Test + public void test7740() { + testConvertHTMLToPdf("test7740"); + } + + @Test + public void test7855() { + testConvertHTMLToPdf("test7855"); + } + + protected void testConvertHTMLToPdf(String emailId) { + + File tempDirectory = FileUtils.getTempDirectory(); try { -// File email = new File("src/test/resources/test.txt"); - File email = new File("/home/kmorin/Téléchargements/test2.eml"); + File email = new File("src/test/resources/emails/" + emailId + ".eml"); String emailContent = FileUtils.readFileToString(email); Properties properties = new Properties(); @@ -317,15 +337,15 @@ public class EmailServiceTest extends AbstractFaxToMailServiceTest { List<String> htmlContent = service.decomposeMultipartEmail(attachments, message); - Attachment attachment = service.convertHTMLToPdf(attachments, htmlContent, "test"); - Files.copy(attachment.getOriginalFile().getFile(), new File("/tmp/test.pdf")); + Attachment attachment = service.convertHTMLToPdf(attachments, htmlContent, emailId); + Files.copy(attachment.getOriginalFile().getFile(), new File(tempDirectory, emailId + ".pdf")); } else if (message.isMimeType("text/*")) { // convertit le contenu texte en PDF String content = IOUtils.toString(message.getInputStream(), charset); if (StringUtils.isNotBlank(content)) { - Attachment attachment = service.convertTextToPdf(content, "test"); - Files.copy(attachment.getOriginalFile().getFile(), new File("/tmp/test.pdf")); + Attachment attachment = service.convertTextToPdf(content, emailId); + Files.copy(attachment.getOriginalFile().getFile(), new File(tempDirectory, emailId + ".pdf")); } } else { String fileName = message.getFileName(); @@ -350,12 +370,11 @@ public class EmailServiceTest extends AbstractFaxToMailServiceTest { // save attachment attachments.add(attachment); - Files.copy(attachment.getOriginalFile().getFile(), new File("/tmp/test.pdf")); + Files.copy(attachment.getOriginalFile().getFile(), new File(tempDirectory, emailId + ".pdf")); } - } catch (Exception e) { - e.printStackTrace(); + Assert.fail(e.getMessage()); } } diff --git a/faxtomail-service/src/test/resources/emails/test6863.eml b/faxtomail-service/src/test/resources/emails/test6863.eml new file mode 100644 index 0000000..e4056e2 --- /dev/null +++ b/faxtomail-service/src/test/resources/emails/test6863.eml @@ -0,0 +1,8 @@ +MIME-Version: 1.0 +Subject: test 6863 +Message-ID: <325364397.0.1447683760764.JavaMail> +Content-Type: application/pdf; name="test6863.pdf" +Content-Transfer-Encoding: base64 +Content-Disposition: attachment; filename="test6863.pdf" + +JVBERi0xLjQKJeLjz9MKMiAwIG9iago8PC9MZW5ndGggMTAwL0ZpbHRlci9GbGF0ZURlY29kZT4+c3RyZWFtCnicK+RyCuEyUDAzNtQzVQhJ4XIN4QrkKuQy0DMwNjdVKOcyUvACSmdxGRoo+HJFxxoopHAZmymYWpoCledymRga6BmZQrk5MK6xmZ6BCZALVIjEhCnK4ArnygNbEsgFADqZGOwKZW5kc3RyZWFtCmVuZG9iagoxIDAgb2JqCjw8L1BhcmVudCAzIDAgUi9Db250ZW50cyAyIDAgUi9UeXBlL1BhZ2UvUmVzb3VyY2VzPDw+Pi9NZWRpYUJveFswIDAgNDQ2LjI1IDYzMS41XT4+CmVuZG9iago0IDAgb2JqCjw8L1R5cGUvWE9iamVjdC9Db2xvclNwYWNlL0RldmljZUdyYXkvU3VidHlwZS9JbWFnZS9CaXRzUGVyQ29tcG9uZW50IDgvV2lkdGggMTAw [...] diff --git a/faxtomail-service/src/test/resources/emails/test7716.eml b/faxtomail-service/src/test/resources/emails/test7716.eml new file mode 100644 index 0000000..4d261db --- /dev/null +++ b/faxtomail-service/src/test/resources/emails/test7716.eml @@ -0,0 +1,31 @@ +Return-Path: <contact@cimino-espace-maconnerie.fr> +MIME-Version: 1.0 +Content-Type: multipart/alternative; + boundary="Apple-Mail=_51C20C20-2115-4295-927F-5379E6212669" +Subject: Test 7714 +X-Mailer: Apple Mail (2.1878.6) + +--Apple-Mail=_51C20C20-2115-4295-927F-5379E6212669 +Content-Type: multipart/mixed; + boundary="Apple-Mail=_CDF68BA5-30D4-4CD7-8FB1-06459A2104DF" + +--Apple-Mail=_CDF68BA5-30D4-4CD7-8FB1-06459A2104DF +Content-Transfer-Encoding: quoted-printable +Content-Type: text/html; charset="windows-1252" + +<html><head> +<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DWindows-1= +252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: space;= + -webkit-line-break: after-white-space;">Bonjour, </body></html>= + +--Apple-Mail=_CDF68BA5-30D4-4CD7-8FB1-06459A2104DF +Content-Transfer-Encoding: 7bit +Content-Type: text/html; charset="us-ascii" + +<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div apple-content-edited="true"><span>test</span> +</div> +<br></body></html> +--Apple-Mail=_CDF68BA5-30D4-4CD7-8FB1-06459A2104DF-- + +--Apple-Mail=_51C20C20-2115-4295-927F-5379E6212669-- + diff --git a/faxtomail-service/src/test/resources/emails/test7740.eml b/faxtomail-service/src/test/resources/emails/test7740.eml new file mode 100644 index 0000000..84bdafa --- /dev/null +++ b/faxtomail-service/src/test/resources/emails/test7740.eml @@ -0,0 +1,24 @@ +Subject: test 7855 +Accept-Language: fr-FR, en-US +Content-Language: fr-FR +Content-Type: multipart/alternative; + boundary="_000_7C51F096CFBF6444A4527AC13C0365C2AB4520E2S8EXCP01" +MIME-Version: 1.0 + +--_000_7C51F096CFBF6444A4527AC13C0365C2AB4520E2S8EXCP01 +Content-Type: text/html; charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr= +osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" = +xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:= +//www.w3.org/TR/REC-html40"> +<body lang=3D"FR" link=3D"blue" vlink=3D"purple"> +<div class=3D"WordSection1"> +<img border=3D"0" width=3D"172" height=3D"51" id=3D"= +_x0000_i1026" src=3D"http://localhost/test image avec espace.jpg"> +</div> +</body> +</html> + +--_000_7C51F096CFBF6444A4527AC13C0365C2AB4520E2S8EXCP01-- diff --git a/faxtomail-service/src/test/resources/emails/test7855.eml b/faxtomail-service/src/test/resources/emails/test7855.eml new file mode 100644 index 0000000..75d3eeb --- /dev/null +++ b/faxtomail-service/src/test/resources/emails/test7855.eml @@ -0,0 +1,24 @@ +Subject: test 7855 +Accept-Language: fr-FR, en-US +Content-Language: fr-FR +Content-Type: multipart/alternative; + boundary="_000_7C51F096CFBF6444A4527AC13C0365C2AB4520E2S8EXCP01" +MIME-Version: 1.0 + +--_000_7C51F096CFBF6444A4527AC13C0365C2AB4520E2S8EXCP01 +Content-Type: text/html; charset="iso-8859-1" +Content-Transfer-Encoding: quoted-printable + +<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr= +osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" = +xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:= +//www.w3.org/TR/REC-html40"> +<body lang=3D"FR" link=3D"blue" vlink=3D"purple"> +<div class=3D"WordSection1"> +<img border=3D"0" width=3D"172" height=3D"51" id=3D"= +_x0000_i1025" src=3D"outbind://96/Seher_fichiers/image001.jpg"> +</div> +</body> +</html> + +--_000_7C51F096CFBF6444A4527AC13C0365C2AB4520E2S8EXCP01-- -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm