Package org.apache.jackrabbit.core.data.db

Examples of org.apache.jackrabbit.core.data.db.TempFileInputStream


public class TempFileInputStreamTest extends JUnitTest {

    public void testReadPastEOF() throws IOException {
        File temp = File.createTempFile("test", null);
        TempFileInputStream.writeToFileAndClose(new ByteArrayInputStream(new byte[1]), temp);
        TempFileInputStream in = new TempFileInputStream(temp);
        assertEquals(0, in.read());
        assertEquals(-1, in.read());
        assertEquals(-1, in.read());
        assertEquals(-1, in.read());
        in.close();
    }
View Full Code Here


    }

    public void testMarkReset() throws IOException {
        File temp = File.createTempFile("test", null);
        TempFileInputStream.writeToFileAndClose(new ByteArrayInputStream(new byte[10]), temp);
        InputStream in = new BufferedInputStream(new TempFileInputStream(temp));
        in.mark(100);
        for (int i = 0; i < 10; i++) {
            assertEquals(0, in.read());
        }
        assertEquals(-1, in.read());
View Full Code Here

public class TempFileInputStreamTest extends JUnitTest {

    public void testReadPastEOF() throws IOException {
        File temp = File.createTempFile("test", null);
        TempFileInputStream.writeToFileAndClose(new ByteArrayInputStream(new byte[1]), temp);
        TempFileInputStream in = new TempFileInputStream(temp, false);
        assertEquals(0, in.read());
        assertEquals(-1, in.read());
        assertEquals(-1, in.read());
        assertEquals(-1, in.read());
        in.close();
    }
View Full Code Here

    }

    public void testMarkReset() throws IOException {
        File temp = File.createTempFile("test", null);
        TempFileInputStream.writeToFileAndClose(new ByteArrayInputStream(new byte[10]), temp);
        InputStream in = new BufferedInputStream(new TempFileInputStream(temp, false));
        in.mark(100);
        for (int i = 0; i < 10; i++) {
            assertEquals(0, in.read());
        }
        assertEquals(-1, in.read());
View Full Code Here

     * @return returns true if it was able to reset the Stream
     */
    public boolean resetStream() {
      if (stream instanceof TempFileInputStream) {
        try {
          TempFileInputStream tempFileInputStream = (TempFileInputStream) stream;
          // Close it if it is not already closed ...
          tempFileInputStream.close();
          stream = new TempFileInputStream(tempFileInputStream.getFile(), true);
          return true;
        } catch (Exception e) {
          log.warn("Failed to create a new TempFileInputStream", e);
        }
      }
View Full Code Here

public class TempFileInputStreamTest extends JUnitTest {

    public void testReadPastEOF() throws IOException {
        File temp = File.createTempFile("test", null);
        TempFileInputStream.writeToFileAndClose(new ByteArrayInputStream(new byte[1]), temp);
        TempFileInputStream in = new TempFileInputStream(temp);
        assertEquals(0, in.read());
        assertEquals(-1, in.read());
        assertEquals(-1, in.read());
        assertEquals(-1, in.read());
        in.close();
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.data.db.TempFileInputStream

Copyright © 2018 www.massapicom. 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.