1
0
mirror of https://github.com/moparisthebest/k-9 synced 2024-11-23 18:02:15 -05:00
This commit is contained in:
Jan Berkel 2014-12-23 10:13:57 +01:00
parent c96a11212e
commit fe8e779b32
7 changed files with 155 additions and 125 deletions

View File

@ -1,16 +1,19 @@
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() {
@Test
public void testParseWithMissingEmail() {
Address[] addresses = Address.parse("NAME ONLY");
assertEquals(1, addresses.length);
assertEquals(null, addresses[0].getAddress());
@ -20,16 +23,19 @@ public class AddressTest {
/**
* test name + valid email
*/
@Test public void testPraseWithValidEmail() {
@Test
public void testPraseWithValidEmail() {
Address[] addresses = Address.parse("Max Mustermann <maxmuster@mann.com>");
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() {
@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());

View File

@ -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");

View File

@ -8,6 +8,7 @@ import java.io.ByteArrayOutputStream;
import static org.junit.Assert.assertEquals;
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());

View File

@ -5,9 +5,11 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class CharsetSupportTest {
@Test public void testFixupCharset() throws Exception {
@Test
public void testFixupCharset() throws Exception {
String charsetOnMail;
String expect;

View File

@ -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));

View File

@ -1,5 +1,6 @@
package com.fsck.k9.mail.internet;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
@ -27,7 +28,8 @@ public class MimeMessageParseTest {
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: <adam@example.org>\r\n" +
"To: <eva@example.org>\r\n" +
@ -45,7 +47,8 @@ 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: <adam@example.org>\r\n" +
"To: <eva@example.org>\r\n" +
@ -63,7 +66,8 @@ 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: <adam@example.org>\r\n" +
"To: <eva@example.org>\r\n" +
@ -81,7 +85,8 @@ 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: <x@example.org>\r\n" +
"To: <y@example.org>\r\n" +
@ -118,7 +123,8 @@ public class MimeMessageParseTest {
"");
}
@Test public void testMultipartSingleLayerRecurse() throws Exception {
@Test
public void testMultipartSingleLayerRecurse() throws Exception {
MimeMessage msg = parseWithRecurse(toStream(
"From: <x@example.org>\r\n" +
"To: <y@example.org>\r\n" +
@ -155,7 +161,8 @@ public class MimeMessageParseTest {
"");
}
@Test public void testMultipartTwoLayersRecurse() throws Exception {
@Test
public void testMultipartTwoLayersRecurse() throws Exception {
MimeMessage msg = parseWithRecurse(toStream(
"From: <x@example.org>\r\n" +
"To: <y@example.org>\r\n" +

View File

@ -5,8 +5,10 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class MimeUtilityTest {
@Test public void testGetHeaderParameter() {
@Test
public void testGetHeaderParameter() {
String result;
/* Test edge cases */