find "${CFB_ROOT}/prod" -name "*.java" | xargs javac -g -Xlint:deprecation
find "${CFB_ROOT}/test" -name "*.java" | xargs javac -g -classpath ${CFB_ROOT}/prod:${CLASSPATH} -Xlint:deprecation
+if [ -d "${CFB_ROOT}/bin" ]; then
+ rm -rf "${CFB_ROOT}/bin"
+fi
+mkdir -p "${CFB_ROOT}/bin"
+cd "${CFB_ROOT}/prod"
+find . -name '*.class' | xargs tar zcf "${CFB_ROOT}/tmp_classes.tar.gz"
+cd "${CFB_ROOT}/bin"
+tar zxf "${CFB_ROOT}/tmp_classes.tar.gz"
+if [ -e "${CFB_ROOT}/tmp_classes.tar.gz" ]; then
+ rm "${CFB_ROOT}/tmp_classes.tar.gz"
+fi
+cd "${CFB_ROOT}"
+
#####################
echo Cleaning old coverage files...
for x in "${INSTR_DIR}" report
echo Generating HTML Report...
java -jar "${CFB_ROOT}/jcov/jcov.jar" RepGen -sourcepath "${CFB_ROOT}/prod" -log.level FINE result.xml
+
+#####################
+echo Cleaning up
+find "${CFB_ROOT}/prod" -type f -name '*.class' -exec rm {} \;
+find "${CFB_ROOT}/test" -type f -name '*.class' -exec rm {} \;
--- /dev/null
+package net.jaekl.qd.util;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.charset.Charset;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class InputStreamWrapperTest {
+ static final String[] DATA = {
+ "",
+ "<?xml encoding=\"utf-8\"?><Root/>\n",
+ "古池\n蛙飛び込む\n水の音\n",
+
+ "arma virumque cano, Troiae qui primus ab oris\n" +
+ "Italiam fato profugus Laviniaque venit\n" +
+ "litora, multum ille et terris iactatus et alto\n" +
+ "vi superum, saevae memorem Iunonis ob iram,\n" +
+ "multa quoque et bello passus, dum conderet urbem\n" +
+ "inferretque deos Latio; genus unde\n" +
+ "Albanique patres atque altae moenia Romae.\n" +
+ "Musa, mihi causas memora, quo numine laeso\n" +
+ "quidve dolens regina deum tot volvere\n" +
+ "insignem pietate virum, tot adire labores\n" +
+ "impulerit. tantaene animis caelestibus irae?\n" +
+ "urbs antiqua fuit (Tyrii tenuere coloni)\n" +
+ "Karthago, Italiam contra Tiberinaque longe\n" +
+ "ostia, dives opum studiisque asperrima belli,\n" +
+ "quam Iuno fertur terris magis omnibus unam\n" +
+ "posthabita coluisse Samo. hic illius arma,\n" +
+ "hic currus fuit; hoc regnum dea gentibus esse,\n" +
+ "si qua fata sinant, iam tum tenditque fovetque.\n" +
+ "progeniem sed enim Troiano a sanguine duci\n" +
+ "audierat Tyrias olim quae verteret arces;\n" +
+ "hinc populum late regem belloque superbum\n" +
+ "venturum excidio Libyae; sic volvere Parcas.\n" +
+ "id metuens veterisque memor Saturnia belli,\n" +
+ "prima quod ad Troiam pro caris gesserat Argis_\n" +
+ "necdum etiam causae irarum saevique dolores\n" +
+ "exciderant animo; manet alta mente repostum\n" +
+ "iudicium Paridis spretaeque iniuria formae\n" +
+ "et genus invisum et rapti Ganymedis honores:\n" +
+ "his accensa super iactatos aequore toto\n" +
+ "Troas, reliquias Danaum atque immitis Achilli,\n" +
+ "arcebat longe Latio, multosque per annos\n" +
+ "errabant acti fatis maria omnia circum.\n"
+ };
+
+ @Test
+ public void testRead() throws IOException {
+ Charset utf8 = Charset.forName("UTF-8");
+ StringBuilder sb = new StringBuilder();
+ ByteArrayInputStream bais = null;
+ BufferedReader br = null;
+ String line;
+ for (String datum : DATA) {
+ sb.setLength(0); // reset the builder
+ int end = datum.length();
+ if (end > InputStreamWrapper.HEAD_MAX) {
+ end = InputStreamWrapper.HEAD_MAX;
+ }
+ String expected = datum.substring(0, end);
+
+ try {
+ bais = new ByteArrayInputStream(datum.getBytes(utf8));
+ InputStreamWrapper isw = new InputStreamWrapper(bais);
+ br = new BufferedReader(new InputStreamReader(isw));
+ line = br.readLine();
+ while (null != line) {
+ sb.append(line).append("\n");
+ line = br.readLine();
+ }
+ String actualRead = sb.toString();
+ String actualHead = new String(isw.getHeadBytes(), utf8);
+
+ Assert.assertEquals(datum, actualRead);
+ Assert.assertEquals(expected, actualHead);
+ }
+ finally {
+ if (null != br) {
+ br.close();
+ }
+ }
+ }
+ }
+}