mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 18:02:15 -05:00
Reformat
This commit is contained in:
parent
c96a11212e
commit
fe8e779b32
@ -1,16 +1,19 @@
|
|||||||
package com.fsck.k9.mail;
|
package com.fsck.k9.mail;
|
||||||
|
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
|
||||||
public class AddressTest {
|
public class AddressTest {
|
||||||
/**
|
/**
|
||||||
* test the possibility to parse "From:" fields with no email.
|
* test the possibility to parse "From:" fields with no email.
|
||||||
* for example: From: News for Vector Limited - Google Finance
|
* for example: From: News for Vector Limited - Google Finance
|
||||||
* http://code.google.com/p/k9mail/issues/detail?id=3814
|
* http://code.google.com/p/k9mail/issues/detail?id=3814
|
||||||
*/
|
*/
|
||||||
@Test public void testParseWithMissingEmail() {
|
@Test
|
||||||
|
public void testParseWithMissingEmail() {
|
||||||
Address[] addresses = Address.parse("NAME ONLY");
|
Address[] addresses = Address.parse("NAME ONLY");
|
||||||
assertEquals(1, addresses.length);
|
assertEquals(1, addresses.length);
|
||||||
assertEquals(null, addresses[0].getAddress());
|
assertEquals(null, addresses[0].getAddress());
|
||||||
@ -20,16 +23,19 @@ public class AddressTest {
|
|||||||
/**
|
/**
|
||||||
* test name + valid email
|
* test name + valid email
|
||||||
*/
|
*/
|
||||||
@Test public void testPraseWithValidEmail() {
|
@Test
|
||||||
|
public void testPraseWithValidEmail() {
|
||||||
Address[] addresses = Address.parse("Max Mustermann <maxmuster@mann.com>");
|
Address[] addresses = Address.parse("Max Mustermann <maxmuster@mann.com>");
|
||||||
assertEquals(1, addresses.length);
|
assertEquals(1, addresses.length);
|
||||||
assertEquals("maxmuster@mann.com", addresses[0].getAddress());
|
assertEquals("maxmuster@mann.com", addresses[0].getAddress());
|
||||||
assertEquals("Max Mustermann", addresses[0].getPersonal());
|
assertEquals("Max Mustermann", addresses[0].getPersonal());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test with multi email addresses
|
* test with multi email addresses
|
||||||
*/
|
*/
|
||||||
@Test public void testPraseWithValidEmailMulti() {
|
@Test
|
||||||
|
public void testPraseWithValidEmailMulti() {
|
||||||
Address[] addresses = Address.parse("lorem@ipsum.us,mark@twain.com");
|
Address[] addresses = Address.parse("lorem@ipsum.us,mark@twain.com");
|
||||||
assertEquals(2, addresses.length);
|
assertEquals(2, addresses.length);
|
||||||
assertEquals("lorem@ipsum.us", addresses[0].getAddress());
|
assertEquals("lorem@ipsum.us", addresses[0].getAddress());
|
||||||
|
@ -5,9 +5,10 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class Address_quoteAtoms
|
|
||||||
{
|
public class Address_quoteAtoms {
|
||||||
@Test public void testNoQuote() {
|
@Test
|
||||||
|
public void testNoQuote() {
|
||||||
// Alpha
|
// Alpha
|
||||||
noQuote("a");
|
noQuote("a");
|
||||||
noQuote("aa");
|
noQuote("aa");
|
||||||
|
@ -8,6 +8,7 @@ import java.io.ByteArrayOutputStream;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
|
||||||
public class EOLConvertingOutputStreamTest {
|
public class EOLConvertingOutputStreamTest {
|
||||||
private EOLConvertingOutputStream subject;
|
private EOLConvertingOutputStream subject;
|
||||||
private ByteArrayOutputStream out;
|
private ByteArrayOutputStream out;
|
||||||
@ -18,37 +19,43 @@ public class EOLConvertingOutputStreamTest {
|
|||||||
subject = new EOLConvertingOutputStream(out);
|
subject = new EOLConvertingOutputStream(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testFilterWithoutCRorLF() throws Exception {
|
@Test
|
||||||
|
public void testFilterWithoutCRorLF() throws Exception {
|
||||||
subject.write("Unchanged".getBytes());
|
subject.write("Unchanged".getBytes());
|
||||||
subject.flush();
|
subject.flush();
|
||||||
assertEquals("Unchanged", out.toString());
|
assertEquals("Unchanged", out.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testFilterWithCRLF() throws Exception {
|
@Test
|
||||||
|
public void testFilterWithCRLF() throws Exception {
|
||||||
subject.write("Filter\r\nNext Line".getBytes());
|
subject.write("Filter\r\nNext Line".getBytes());
|
||||||
subject.flush();
|
subject.flush();
|
||||||
assertEquals("Filter\r\nNext Line", out.toString());
|
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.write("\n\n\n".getBytes());
|
||||||
subject.flush();
|
subject.flush();
|
||||||
assertEquals("\r\n\r\n\r\n", out.toString());
|
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.write("Filter\rNext Line".getBytes());
|
||||||
subject.flush();
|
subject.flush();
|
||||||
assertEquals("Filter\r\nNext Line", out.toString());
|
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.write("Filter\nNext Line".getBytes());
|
||||||
subject.flush();
|
subject.flush();
|
||||||
assertEquals("Filter\r\nNext Line", out.toString());
|
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.write("Flush\r".getBytes());
|
||||||
subject.flush();
|
subject.flush();
|
||||||
assertEquals("Flush\r\n", out.toString());
|
assertEquals("Flush\r\n", out.toString());
|
||||||
@ -56,14 +63,16 @@ public class EOLConvertingOutputStreamTest {
|
|||||||
assertEquals("Flush\r\n\r\n\r\n", out.toString());
|
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.write("Flush\r".getBytes());
|
||||||
subject.flush();
|
subject.flush();
|
||||||
subject.write("Next line".getBytes());
|
subject.write("Next line".getBytes());
|
||||||
assertEquals("Flush\r\nNext line", out.toString());
|
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.write("Flush\n".getBytes());
|
||||||
subject.flush();
|
subject.flush();
|
||||||
subject.write("\n".getBytes());
|
subject.write("\n".getBytes());
|
||||||
|
@ -5,9 +5,11 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
|
||||||
public class CharsetSupportTest {
|
public class CharsetSupportTest {
|
||||||
|
|
||||||
@Test public void testFixupCharset() throws Exception {
|
@Test
|
||||||
|
public void testFixupCharset() throws Exception {
|
||||||
String charsetOnMail;
|
String charsetOnMail;
|
||||||
String expect;
|
String expect;
|
||||||
|
|
||||||
|
@ -5,9 +5,11 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
|
||||||
public class DecoderUtilTest {
|
public class DecoderUtilTest {
|
||||||
|
|
||||||
@Test public void testDecodeEncodedWords() {
|
@Test
|
||||||
|
public void testDecodeEncodedWords() {
|
||||||
String body, expect;
|
String body, expect;
|
||||||
MimeMessage message;
|
MimeMessage message;
|
||||||
|
|
||||||
@ -47,7 +49,8 @@ public class DecoderUtilTest {
|
|||||||
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
body = "=??q??=";
|
body = "=??q??=";
|
||||||
expect = "=??q??=";;
|
expect = "=??q??=";
|
||||||
|
;
|
||||||
message = null;
|
message = null;
|
||||||
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
assertEquals(expect, DecoderUtil.decodeEncodedWords(body, message));
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.fsck.k9.mail.internet;
|
package com.fsck.k9.mail.internet;
|
||||||
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
@ -27,7 +28,8 @@ public class MimeMessageParseTest {
|
|||||||
BinaryTempFileBody.setTempDirectory(new File(System.getProperty("java.io.tmpdir")));
|
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(
|
MimeMessage msg = parseWithoutRecurse(toStream(
|
||||||
"From: <adam@example.org>\r\n" +
|
"From: <adam@example.org>\r\n" +
|
||||||
"To: <eva@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()));
|
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(
|
MimeMessage msg = parseWithRecurse(toStream(
|
||||||
"From: <adam@example.org>\r\n" +
|
"From: <adam@example.org>\r\n" +
|
||||||
"To: <eva@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()));
|
assertEquals("gefährliche Umlaute", streamToString(msg.getBody().getInputStream()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test public void testSinglePartBase64NoRecurse() throws Exception {
|
@Test
|
||||||
|
public void testSinglePartBase64NoRecurse() throws Exception {
|
||||||
MimeMessage msg = parseWithoutRecurse(toStream(
|
MimeMessage msg = parseWithoutRecurse(toStream(
|
||||||
"From: <adam@example.org>\r\n" +
|
"From: <adam@example.org>\r\n" +
|
||||||
"To: <eva@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()));
|
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(
|
MimeMessage msg = parseWithoutRecurse(toStream(
|
||||||
"From: <x@example.org>\r\n" +
|
"From: <x@example.org>\r\n" +
|
||||||
"To: <y@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(
|
MimeMessage msg = parseWithRecurse(toStream(
|
||||||
"From: <x@example.org>\r\n" +
|
"From: <x@example.org>\r\n" +
|
||||||
"To: <y@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(
|
MimeMessage msg = parseWithRecurse(toStream(
|
||||||
"From: <x@example.org>\r\n" +
|
"From: <x@example.org>\r\n" +
|
||||||
"To: <y@example.org>\r\n" +
|
"To: <y@example.org>\r\n" +
|
||||||
|
@ -5,8 +5,10 @@ import org.junit.Test;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
|
||||||
public class MimeUtilityTest {
|
public class MimeUtilityTest {
|
||||||
@Test public void testGetHeaderParameter() {
|
@Test
|
||||||
|
public void testGetHeaderParameter() {
|
||||||
String result;
|
String result;
|
||||||
|
|
||||||
/* Test edge cases */
|
/* Test edge cases */
|
||||||
|
Loading…
Reference in New Issue
Block a user