Examples of RereadableInputStream


Examples of org.apache.tika.utils.RereadableInputStream

    private final int NUM_PASSES = 4;

    public void test() throws IOException {

        InputStream is = createTestInputStream();
        RereadableInputStream ris = new RereadableInputStream(is,
                MEMORY_THRESHOLD, true, true);
        try {
            for (int pass = 0; pass < NUM_PASSES; pass++) {
                for (int byteNum = 0; byteNum < TEST_SIZE; byteNum++) {
                    int byteRead = ris.read();
                    assertEquals("Pass = " + pass + ", byte num should be "
                            + byteNum + " but is " + byteRead + ".", byteNum,
                            byteRead);
                }
                ris.rewind();
            }
        } finally {
            // The RereadableInputStream should close the original input
            // stream (if it hasn't already).
            ris.close();
        }
    }
View Full Code Here

Examples of org.apache.tika.utils.RereadableInputStream

        doTestRewind(false);
    }

    private void doTestRewind(boolean readToEndOnRewind) throws IOException {

        RereadableInputStream ris = null;

        try {
            InputStream s1 = createTestInputStream();
            ris = new RereadableInputStream(s1, 5, readToEndOnRewind, true);
            ris.read();
            assertEquals(1, ris.getSize());
            ris.rewind();
            boolean moreBytesWereRead = (ris.getSize() > 1);
            assertEquals(readToEndOnRewind, moreBytesWereRead);
        } finally {
            if (ris != null) {
                ris.close();
            }
        }

    }
View Full Code Here

Examples of org.apache.tika.utils.RereadableInputStream

    }

    private void doACloseBehaviorTest(boolean wantToClose) throws IOException {

        TestInputStream tis = createTestInputStream();
        RereadableInputStream ris =
                new RereadableInputStream(tis, 5, true, wantToClose);
        ris.close();
        assertEquals(wantToClose, tis.isClosed());

        if (! tis.isClosed()) {
            tis.close();
        }
View Full Code Here

Examples of org.apache.tika.utils.RereadableInputStream

    @Test
    public void test() throws IOException {

        InputStream is = createTestInputStream();
        RereadableInputStream ris = new RereadableInputStream(is,
                MEMORY_THRESHOLD, true, true);
        try {
            for (int pass = 0; pass < NUM_PASSES; pass++) {
                for (int byteNum = 0; byteNum < TEST_SIZE; byteNum++) {
                    int byteRead = ris.read();
                    assertEquals("Pass = " + pass + ", byte num should be "
                            + byteNum + " but is " + byteRead + ".", byteNum,
                            byteRead);
                }
                ris.rewind();
            }
        } finally {
            // The RereadableInputStream should close the original input
            // stream (if it hasn't already).
            ris.close();
        }
    }
View Full Code Here

Examples of org.apache.tika.utils.RereadableInputStream

        doTestRewind(false);
    }

    private void doTestRewind(boolean readToEndOnRewind) throws IOException {

        RereadableInputStream ris = null;

        try {
            InputStream s1 = createTestInputStream();
            ris = new RereadableInputStream(s1, 5, readToEndOnRewind, true);
            ris.read();
            assertEquals(1, ris.getSize());
            ris.rewind();
            boolean moreBytesWereRead = (ris.getSize() > 1);
            assertEquals(readToEndOnRewind, moreBytesWereRead);
        } finally {
            if (ris != null) {
                ris.close();
            }
        }

    }
View Full Code Here

Examples of org.apache.tika.utils.RereadableInputStream

    }

    private void doACloseBehaviorTest(boolean wantToClose) throws IOException {

        TestInputStream tis = createTestInputStream();
        RereadableInputStream ris =
                new RereadableInputStream(tis, 5, true, wantToClose);
        ris.close();
        assertEquals(wantToClose, tis.isClosed());

        if (! tis.isClosed()) {
            tis.close();
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.