You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@creadur.apache.org by rd...@apache.org on 2013/12/08 21:00:43 UTC
svn commit: r1549180 -
/creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/annotation/LicenceAppenderTest.java
Author: rdonkin
Date: Sun Dec 8 20:00:43 2013
New Revision: 1549180
URL: http://svn.apache.org/r1549180
Log:
Add test: testBOMInputStreamReadByte
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/annotation/LicenceAppenderTest.java
Modified: creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/annotation/LicenceAppenderTest.java
URL: http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/annotation/LicenceAppenderTest.java?rev=1549180&r1=1549179&r2=1549180&view=diff
==============================================================================
--- creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/annotation/LicenceAppenderTest.java (original)
+++ creadur/rat/branches/gsoc/apache-rat-core/src/test/java/org/apache/rat/annotation/LicenceAppenderTest.java Sun Dec 8 20:00:43 2013
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertFal
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
@@ -1004,4 +1005,31 @@ public class LicenceAppenderTest {
Assert.assertEquals(65, bomInputStream.read());
bomInputStream.close();
}
+
+ /**
+ * Test bom input stream read byte.
+ *
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ */
+ @Test
+ public void testBOMInputStreamReadByte() throws IOException {
+ String document = qualify("tmp.apt");
+ FileCreator creator = new FileCreator() {
+ public void createFile(final Writer writer) throws IOException {
+ writer.write("A Simple APT file");
+ writer.write(" This file contains nothing\n");
+ writer.write(" of any importance\n");
+ }
+ };
+ createTestFile(document, creator);
+ InputStream fis = new FileInputStream(new File(document));
+ BOMInputStream bomInputStream = new BOMInputStream(fis);
+ FileOutputStream fos = new FileOutputStream(document);
+ byte[] buf = new byte[1000];
+ fos.write(buf);
+ fos.close();
+ Assert.assertEquals(1000, bomInputStream.read(buf));
+ bomInputStream.close();
+ }
}