1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 03:02:22 -05:00

POP: test new double dot implementation

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1629 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2011-02-22 20:44:26 +00:00
parent f9433cfaa0
commit 799d60911e

View File

@ -40,6 +40,14 @@ public class TestDoubleDotInputStream extends TestCase {
return new String(baos.toByteArray());
}
protected String doubleDotWrite(String value) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DoubleDotOutputStream doubleDotOutputStream = new DoubleDotOutputStream(baos);
doubleDotOutputStream.write(value.getBytes());
doubleDotOutputStream.close();
return new String(baos.toByteArray());
}
public void testSimple() throws IOException {
String value = "simple test";
assertEquals(value, doubleDotRead(value + END_OF_STREAM));
@ -59,9 +67,41 @@ public class TestDoubleDotInputStream extends TestCase {
String value = "simple test\r\n..\r\nsecond line";
assertEquals(value.replaceAll("\\.\\.", "."), doubleDotRead(value+END_OF_STREAM));
}
public void testDoubleDotEnd() throws IOException {
String value = "simple test\r\n..";
assertEquals(value.replaceAll("\\.\\.", "."), doubleDotRead(value+END_OF_STREAM));
assertEquals("..", doubleDotRead(".."+END_OF_STREAM));
}
public void testWriteCRLF() throws IOException {
String value = "simple test\r\n.\r\nsecond line";
assertEquals(value.replaceAll("\\.", "..")+END_OF_STREAM, doubleDotWrite(value));
}
public void testEndsWithCRLF() throws IOException {
String value = "simple test\r\n";
assertEquals("simple test"+END_OF_STREAM, doubleDotWrite(value));
}
public void testEndsWithLF() throws IOException {
String value = "simple test\n";
assertEquals("simple test\n"+END_OF_STREAM, doubleDotWrite(value));
}
public void testWriteOSXCR() throws IOException {
String value = "simple test\r.\rsecond line";
assertEquals(value.replaceAll("\\.", "..")+END_OF_STREAM, doubleDotWrite(value));
}
public void testWriteUnixLF() throws IOException {
String value = "simple test\n.\nsecond line";
assertEquals(value.replaceAll("\\.", "..")+END_OF_STREAM, doubleDotWrite(value));
}
public void testAnotherTest() throws IOException {
String value = "foo\r\n..bar";
assertEquals(value, doubleDotRead(value));
}
}