From fe8e779b32eaa80321cc0c2a4b58a9a77aaf885d Mon Sep 17 00:00:00 2001 From: Jan Berkel Date: Tue, 23 Dec 2014 10:13:57 +0100 Subject: [PATCH] Reformat --- .../java/com/fsck/k9/mail/AddressTest.java | 18 +- .../com/fsck/k9/mail/Address_quoteAtoms.java | 7 +- .../filter/EOLConvertingOutputStreamTest.java | 27 ++- .../k9/mail/internet/CharsetSupportTest.java | 8 +- .../k9/mail/internet/DecoderUtilTest.java | 7 +- .../mail/internet/MimeMessageParseTest.java | 205 +++++++++--------- .../k9/mail/internet/MimeUtilityTest.java | 8 +- 7 files changed, 155 insertions(+), 125 deletions(-) diff --git a/tests-on-jvm/src/test/java/com/fsck/k9/mail/AddressTest.java b/tests-on-jvm/src/test/java/com/fsck/k9/mail/AddressTest.java index 1be326490..7b9c2b891 100644 --- a/tests-on-jvm/src/test/java/com/fsck/k9/mail/AddressTest.java +++ b/tests-on-jvm/src/test/java/com/fsck/k9/mail/AddressTest.java @@ -1,17 +1,20 @@ package com.fsck.k9.mail; + import org.junit.Test; import static org.junit.Assert.assertEquals; + public class AddressTest { /** * test the possibility to parse "From:" fields with no email. * for example: From: News for Vector Limited - Google Finance * http://code.google.com/p/k9mail/issues/detail?id=3814 */ - @Test public void testParseWithMissingEmail() { - Address[] addresses = Address.parse("NAME ONLY"); + @Test + public void testParseWithMissingEmail() { + Address[] addresses = Address.parse("NAME ONLY"); assertEquals(1, addresses.length); assertEquals(null, addresses[0].getAddress()); assertEquals("NAME ONLY", addresses[0].getPersonal()); @@ -20,17 +23,20 @@ public class AddressTest { /** * test name + valid email */ - @Test public void testPraseWithValidEmail() { - Address[] addresses = Address.parse("Max Mustermann "); + @Test + public void testPraseWithValidEmail() { + Address[] addresses = Address.parse("Max Mustermann "); assertEquals(1, addresses.length); assertEquals("maxmuster@mann.com", addresses[0].getAddress()); assertEquals("Max Mustermann", addresses[0].getPersonal()); } + /** * test with multi email addresses */ - @Test public void testPraseWithValidEmailMulti() { - Address[] addresses = Address.parse("lorem@ipsum.us,mark@twain.com"); + @Test + public void testPraseWithValidEmailMulti() { + Address[] addresses = Address.parse("lorem@ipsum.us,mark@twain.com"); assertEquals(2, addresses.length); assertEquals("lorem@ipsum.us", addresses[0].getAddress()); assertEquals(null, addresses[0].getPersonal()); diff --git a/tests-on-jvm/src/test/java/com/fsck/k9/mail/Address_quoteAtoms.java b/tests-on-jvm/src/test/java/com/fsck/k9/mail/Address_quoteAtoms.java index 498b4756d..6de516565 100644 --- a/tests-on-jvm/src/test/java/com/fsck/k9/mail/Address_quoteAtoms.java +++ b/tests-on-jvm/src/test/java/com/fsck/k9/mail/Address_quoteAtoms.java @@ -5,9 +5,10 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -public class Address_quoteAtoms -{ - @Test public void testNoQuote() { + +public class Address_quoteAtoms { + @Test + public void testNoQuote() { // Alpha noQuote("a"); noQuote("aa"); diff --git a/tests-on-jvm/src/test/java/com/fsck/k9/mail/filter/EOLConvertingOutputStreamTest.java b/tests-on-jvm/src/test/java/com/fsck/k9/mail/filter/EOLConvertingOutputStreamTest.java index c9bc3c41d..0dcff9c12 100644 --- a/tests-on-jvm/src/test/java/com/fsck/k9/mail/filter/EOLConvertingOutputStreamTest.java +++ b/tests-on-jvm/src/test/java/com/fsck/k9/mail/filter/EOLConvertingOutputStreamTest.java @@ -8,7 +8,8 @@ import java.io.ByteArrayOutputStream; import static org.junit.Assert.assertEquals; -public class EOLConvertingOutputStreamTest { + +public class EOLConvertingOutputStreamTest { private EOLConvertingOutputStream subject; private ByteArrayOutputStream out; @@ -18,37 +19,43 @@ public class EOLConvertingOutputStreamTest { subject = new EOLConvertingOutputStream(out); } - @Test public void testFilterWithoutCRorLF() throws Exception { + @Test + public void testFilterWithoutCRorLF() throws Exception { subject.write("Unchanged".getBytes()); subject.flush(); assertEquals("Unchanged", out.toString()); } - @Test public void testFilterWithCRLF() throws Exception { + @Test + public void testFilterWithCRLF() throws Exception { subject.write("Filter\r\nNext Line".getBytes()); subject.flush(); assertEquals("Filter\r\nNext Line", out.toString()); } - @Test public void testFilterWithJustCR() throws Exception { + @Test + public void testFilterWithJustCR() throws Exception { subject.write("\n\n\n".getBytes()); subject.flush(); assertEquals("\r\n\r\n\r\n", out.toString()); } - @Test public void testFilterWithCR() throws Exception { + @Test + public void testFilterWithCR() throws Exception { subject.write("Filter\rNext Line".getBytes()); subject.flush(); assertEquals("Filter\r\nNext Line", out.toString()); } - @Test public void testFilterWithLF() throws Exception { + @Test + public void testFilterWithLF() throws Exception { subject.write("Filter\nNext Line".getBytes()); subject.flush(); assertEquals("Filter\r\nNext Line", out.toString()); } - @Test public void testFlushWithCR() throws Exception { + @Test + public void testFlushWithCR() throws Exception { subject.write("Flush\r".getBytes()); subject.flush(); assertEquals("Flush\r\n", out.toString()); @@ -56,14 +63,16 @@ public class EOLConvertingOutputStreamTest { assertEquals("Flush\r\n\r\n\r\n", out.toString()); } - @Test public void testFlushWithCRNotFollowedByLF() throws Exception { + @Test + public void testFlushWithCRNotFollowedByLF() throws Exception { subject.write("Flush\r".getBytes()); subject.flush(); subject.write("Next line".getBytes()); assertEquals("Flush\r\nNext line", out.toString()); } - @Test public void testFlushWithLF() throws Exception { + @Test + public void testFlushWithLF() throws Exception { subject.write("Flush\n".getBytes()); subject.flush(); subject.write("\n".getBytes()); diff --git a/tests-on-jvm/src/test/java/com/fsck/k9/mail/internet/CharsetSupportTest.java b/tests-on-jvm/src/test/java/com/fsck/k9/mail/internet/CharsetSupportTest.java index 316138d03..d1918be58 100644 --- a/tests-on-jvm/src/test/java/com/fsck/k9/mail/internet/CharsetSupportTest.java +++ b/tests-on-jvm/src/test/java/com/fsck/k9/mail/internet/CharsetSupportTest.java @@ -5,9 +5,11 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -public class CharsetSupportTest { - @Test public void testFixupCharset() throws Exception { +public class CharsetSupportTest { + + @Test + public void testFixupCharset() throws Exception { String charsetOnMail; String expect; @@ -21,7 +23,7 @@ public class CharsetSupportTest { MimeMessage message; - message= new MimeMessage(); + message = new MimeMessage(); message.setHeader("From", "aaa@docomo.ne.jp"); charsetOnMail = "shift_jis"; expect = "x-docomo-shift_jis-2007"; diff --git a/tests-on-jvm/src/test/java/com/fsck/k9/mail/internet/DecoderUtilTest.java b/tests-on-jvm/src/test/java/com/fsck/k9/mail/internet/DecoderUtilTest.java index 21660992b..0f58ddf70 100644 --- a/tests-on-jvm/src/test/java/com/fsck/k9/mail/internet/DecoderUtilTest.java +++ b/tests-on-jvm/src/test/java/com/fsck/k9/mail/internet/DecoderUtilTest.java @@ -5,9 +5,11 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; + public class DecoderUtilTest { - @Test public void testDecodeEncodedWords() { + @Test + public void testDecodeEncodedWords() { String body, expect; MimeMessage message; @@ -47,7 +49,8 @@ public class DecoderUtilTest { assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message)); body = "=??q??="; - expect = "=??q??=";; + expect = "=??q??="; + ; message = null; assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message)); diff --git a/tests-on-jvm/src/test/java/com/fsck/k9/mail/internet/MimeMessageParseTest.java b/tests-on-jvm/src/test/java/com/fsck/k9/mail/internet/MimeMessageParseTest.java index 028912f25..209d31384 100644 --- a/tests-on-jvm/src/test/java/com/fsck/k9/mail/internet/MimeMessageParseTest.java +++ b/tests-on-jvm/src/test/java/com/fsck/k9/mail/internet/MimeMessageParseTest.java @@ -1,5 +1,6 @@ package com.fsck.k9.mail.internet; + import java.io.ByteArrayInputStream; import java.io.File; import java.io.InputStream; @@ -21,22 +22,23 @@ import com.fsck.k9.mail.Multipart; import static org.junit.Assert.assertEquals; -public class MimeMessageParseTest { +public class MimeMessageParseTest { @Before public void setup() { BinaryTempFileBody.setTempDirectory(new File(System.getProperty("java.io.tmpdir"))); } - @Test public void testSinglePart7BitNoRecurse() throws Exception { + @Test + public void testSinglePart7BitNoRecurse() throws Exception { MimeMessage msg = parseWithoutRecurse(toStream( "From: \r\n" + - "To: \r\n" + - "Subject: Testmail\r\n" + - "MIME-Version: 1.0\r\n" + - "Content-type: text/plain\r\n" + - "Content-Transfer-Encoding: 7bit\r\n" + - "\r\n" + - "this is some test text.")); + "To: \r\n" + + "Subject: Testmail\r\n" + + "MIME-Version: 1.0\r\n" + + "Content-type: text/plain\r\n" + + "Content-Transfer-Encoding: 7bit\r\n" + + "\r\n" + + "this is some test text.")); checkAddresses(msg.getFrom(), "adam@example.org"); checkAddresses(msg.getRecipients(RecipientType.TO), "eva@example.org"); @@ -45,16 +47,17 @@ public class MimeMessageParseTest { assertEquals("this is some test text.", streamToString(msg.getBody().getInputStream())); } - @Test public void testSinglePart8BitRecurse() throws Exception { + @Test + public void testSinglePart8BitRecurse() throws Exception { MimeMessage msg = parseWithRecurse(toStream( "From: \r\n" + - "To: \r\n" + - "Subject: Testmail\r\n" + - "MIME-Version: 1.0\r\n" + - "Content-type: text/plain; encoding=ISO-8859-1\r\n" + - "Content-Transfer-Encoding: 8bit\r\n" + - "\r\n" + - "gefährliche Umlaute")); + "To: \r\n" + + "Subject: Testmail\r\n" + + "MIME-Version: 1.0\r\n" + + "Content-type: text/plain; encoding=ISO-8859-1\r\n" + + "Content-Transfer-Encoding: 8bit\r\n" + + "\r\n" + + "gefährliche Umlaute")); checkAddresses(msg.getFrom(), "adam@example.org"); checkAddresses(msg.getRecipients(RecipientType.TO), "eva@example.org"); @@ -63,16 +66,17 @@ public class MimeMessageParseTest { assertEquals("gefährliche Umlaute", streamToString(msg.getBody().getInputStream())); } - @Test public void testSinglePartBase64NoRecurse() throws Exception { + @Test + public void testSinglePartBase64NoRecurse() throws Exception { MimeMessage msg = parseWithoutRecurse(toStream( "From: \r\n" + - "To: \r\n" + - "Subject: Testmail\r\n" + - "MIME-Version: 1.0\r\n" + - "Content-type: text/plain\r\n" + - "Content-Transfer-Encoding: base64\r\n" + - "\r\n" + - "dGhpcyBpcyBzb21lIG1vcmUgdGVzdCB0ZXh0Lg==\r\n")); + "To: \r\n" + + "Subject: Testmail\r\n" + + "MIME-Version: 1.0\r\n" + + "Content-type: text/plain\r\n" + + "Content-Transfer-Encoding: base64\r\n" + + "\r\n" + + "dGhpcyBpcyBzb21lIG1vcmUgdGVzdCB0ZXh0Lg==\r\n")); checkAddresses(msg.getFrom(), "adam@example.org"); checkAddresses(msg.getRecipients(RecipientType.TO), "eva@example.org"); @@ -81,26 +85,27 @@ public class MimeMessageParseTest { assertEquals("this is some more test text.", streamToString(msg.getBody().getInputStream())); } - @Test public void testMultipartSingleLayerNoRecurse() throws Exception { + @Test + public void testMultipartSingleLayerNoRecurse() throws Exception { MimeMessage msg = parseWithoutRecurse(toStream( "From: \r\n" + - "To: \r\n" + - "Subject: Testmail 2\r\n" + - "MIME-Version: 1.0\n" + - "Content-Type: multipart/mixed; boundary=frontier\n" + - "\n" + - "This is a message with multiple parts in MIME format.\n" + - "--frontier\n" + - "Content-Type: text/plain\n" + - "\n" + - "This is the body of the message.\n" + - "--frontier\n" + - "Content-Type: application/octet-stream\n" + - "Content-Transfer-Encoding: base64\n" + - "\n" + - "PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUg\n" + - "Ym9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg=\n" + - "--frontier--")); + "To: \r\n" + + "Subject: Testmail 2\r\n" + + "MIME-Version: 1.0\n" + + "Content-Type: multipart/mixed; boundary=frontier\n" + + "\n" + + "This is a message with multiple parts in MIME format.\n" + + "--frontier\n" + + "Content-Type: text/plain\n" + + "\n" + + "This is the body of the message.\n" + + "--frontier\n" + + "Content-Type: application/octet-stream\n" + + "Content-Transfer-Encoding: base64\n" + + "\n" + + "PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUg\n" + + "Ym9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg=\n" + + "--frontier--")); checkAddresses(msg.getFrom(), "x@example.org"); checkAddresses(msg.getRecipients(RecipientType.TO), "y@example.org"); @@ -109,35 +114,36 @@ public class MimeMessageParseTest { checkLeafParts(msg, "This is the body of the message.", "\n" + - " \n" + - " \n" + - " \n" + - "

This is the body of the message.

\n" + - " \n" + - "\n" + - ""); + " \n" + + " \n" + + " \n" + + "

This is the body of the message.

\n" + + " \n" + + "\n" + + ""); } - @Test public void testMultipartSingleLayerRecurse() throws Exception { + @Test + public void testMultipartSingleLayerRecurse() throws Exception { MimeMessage msg = parseWithRecurse(toStream( "From: \r\n" + - "To: \r\n" + - "Subject: Testmail 2\r\n" + - "MIME-Version: 1.0\n" + - "Content-Type: multipart/mixed; boundary=frontier\n" + - "\n" + - "This is a message with multiple parts in MIME format.\n" + - "--frontier\n" + - "Content-Type: text/plain\n" + - "\n" + - "This is the body of the message.\n" + - "--frontier\n" + - "Content-Type: application/octet-stream\n" + - "Content-Transfer-Encoding: base64\n" + - "\n" + - "PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUg\n" + - "Ym9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg=\n" + - "--frontier--")); + "To: \r\n" + + "Subject: Testmail 2\r\n" + + "MIME-Version: 1.0\n" + + "Content-Type: multipart/mixed; boundary=frontier\n" + + "\n" + + "This is a message with multiple parts in MIME format.\n" + + "--frontier\n" + + "Content-Type: text/plain\n" + + "\n" + + "This is the body of the message.\n" + + "--frontier\n" + + "Content-Type: application/octet-stream\n" + + "Content-Transfer-Encoding: base64\n" + + "\n" + + "PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUg\n" + + "Ym9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg=\n" + + "--frontier--")); checkAddresses(msg.getFrom(), "x@example.org"); checkAddresses(msg.getRecipients(RecipientType.TO), "y@example.org"); @@ -146,41 +152,42 @@ public class MimeMessageParseTest { checkLeafParts(msg, "This is the body of the message.", "\n" + - " \n" + - " \n" + - " \n" + - "

This is the body of the message.

\n" + - " \n" + - "\n" + - ""); + " \n" + + " \n" + + " \n" + + "

This is the body of the message.

\n" + + " \n" + + "\n" + + ""); } - @Test public void testMultipartTwoLayersRecurse() throws Exception { + @Test + public void testMultipartTwoLayersRecurse() throws Exception { MimeMessage msg = parseWithRecurse(toStream( "From: \r\n" + - "To: \r\n" + - "Subject: Testmail 2\r\n" + - "MIME-Version: 1.0\n" + - "Content-Type: multipart/mixed; boundary=1\n" + - "\n" + - "This is a message with multiple parts in MIME format.\n" + - "--1\n" + - "Content-Type: text/plain\n" + - "\n" + - "some text in the first part\n" + - "--1\n" + - "Content-Type: multipart/alternative; boundary=2\n" + - "\n" + - "--2\n" + - "Content-Type: text/plain\n" + - "\n" + - "alternative 1\n" + - "--2\n" + - "Content-Type: text/plain\n" + - "\n" + - "alternative 2\n" + - "--2--\n" + - "--1--")); + "To: \r\n" + + "Subject: Testmail 2\r\n" + + "MIME-Version: 1.0\n" + + "Content-Type: multipart/mixed; boundary=1\n" + + "\n" + + "This is a message with multiple parts in MIME format.\n" + + "--1\n" + + "Content-Type: text/plain\n" + + "\n" + + "some text in the first part\n" + + "--1\n" + + "Content-Type: multipart/alternative; boundary=2\n" + + "\n" + + "--2\n" + + "Content-Type: text/plain\n" + + "\n" + + "alternative 1\n" + + "--2\n" + + "Content-Type: text/plain\n" + + "\n" + + "alternative 2\n" + + "--2--\n" + + "--1--")); checkAddresses(msg.getFrom(), "x@example.org"); checkAddresses(msg.getRecipients(RecipientType.TO), "y@example.org"); diff --git a/tests-on-jvm/src/test/java/com/fsck/k9/mail/internet/MimeUtilityTest.java b/tests-on-jvm/src/test/java/com/fsck/k9/mail/internet/MimeUtilityTest.java index a94a2d449..d5ea1384d 100644 --- a/tests-on-jvm/src/test/java/com/fsck/k9/mail/internet/MimeUtilityTest.java +++ b/tests-on-jvm/src/test/java/com/fsck/k9/mail/internet/MimeUtilityTest.java @@ -5,8 +5,10 @@ import org.junit.Test; import static org.junit.Assert.assertEquals; -public class MimeUtilityTest { - @Test public void testGetHeaderParameter() { + +public class MimeUtilityTest { + @Test + public void testGetHeaderParameter() { String result; /* Test edge cases */ @@ -32,7 +34,7 @@ public class MimeUtilityTest { result = MimeUtility.getHeaderParameter("name=\"value\"", "name"); assertEquals("value", result); - result = MimeUtility.getHeaderParameter("name = \"value\"" , "name"); + result = MimeUtility.getHeaderParameter("name = \"value\"", "name"); assertEquals("value", result); result = MimeUtility.getHeaderParameter("name=\"\"", "name");