Package org.apache.derbyTesting.functionTests.util.streams

Examples of org.apache.derbyTesting.functionTests.util.streams.LoopingAlphabetStream


     * If the bug is present, the repositioning will cause an EOF-exception to
     * be thrown in {@code skipFully}.
     */
    public void testDerby3735()
            throws IOException, StandardException {
        InputStream in = new LoopingAlphabetStream(2);
        PositionedStoreStream pss = new PositionedStoreStream(in);
        byte[] b = new byte[2];
        for (int i=0; i < 10; i++) {
            // After the first iteration, the position will be decreased and
            // eventually become negative.
View Full Code Here


     * @throws StandardException will never happen
     */
    public void testDerby3781()
            throws IOException, StandardException {
        final long size = 10;
        InputStream in = new LoopingAlphabetStream(size);
        PositionedStoreStream pss = new PositionedStoreStream(in);
        assertEquals("Invalid initial position", 0L, pss.getPosition());
        pss.reposition(size -1); // Goto end.
        assertEquals(size -1, pss.getPosition());
        assertEquals('j', pss.read());
View Full Code Here

        // Insert a Blob
        PreparedStatement ps = prepareStatement(
            "insert into BLOBCLOB(ID, BLOBDATA) values(?,?)");
        int id = BlobClobTestSetup.getID();
        ps.setInt(1, id);
        ps.setBinaryStream(2, new LoopingAlphabetStream(length), length);
        ps.execute();
        ps.close();

        // Get last byte from the source stream.
        InputStream cmpIs = new LoopingAlphabetStream(length);
        cmpIs.skip(length -1);
        int srcLastByte = cmpIs.read();
        assertTrue(cmpIs.read() == -1);

        // Read everything first.
        int bytesToRead = 5000;
        ps = prepareStatement("select BLOBDATA from BLOBCLOB where ID=?");
        ps.setInt(1, id);
View Full Code Here

        PreparedStatement ps =
                prepareStatement("insert into BLOBCLOB(ID, BLOBDATA) values(?,?)");
        int id =BlobClobTestSetup.getID();
        ps.setInt(1, id);
        ps.setBinaryStream(2,
                           new LoopingAlphabetStream(lobLength), lobLength);
        ps.execute();
        ps.close();
        commit();

        // Fetch the Blob object from the database
View Full Code Here

     */
    public static void transferAlphabetData(OutputStream writer, long length)
            throws IOException {
        byte[] buffer = new byte[8*1024];
        int bytesRead = 0;
        LoopingAlphabetStream contents = new LoopingAlphabetStream(length);
        while ((bytesRead = contents.read(buffer)) > 0) {
            writer.write(buffer, 0, bytesRead);
        }
    }
View Full Code Here

            }
            return b;
        }

        public void resetStream() throws IOException, StandardException {
            this.stream = new LoopingAlphabetStream(length, ALPHABET);
            this.encodedLengthRemaining = 2;
            this.eofMarkerRemaining = 3;
        }
View Full Code Here

            this.encodedLengthRemaining = 2;
            this.eofMarkerRemaining = 3;
        }

        public void initStream() throws StandardException {
            this.stream = new LoopingAlphabetStream(length, ALPHABET);
            this.encodedLengthRemaining = 2;
            this.eofMarkerRemaining = 3;
        }
View Full Code Here

     * If this assumption is broken, several of the other tests will fail.
     */
    public void testEqualityOfModifedUTF8AndASCII()
            throws IOException {
        final int length = 12706;
        InputStream ascii = new LoopingAlphabetStream(length);
        InputStream modUTF8 = new ReaderToUTF8Stream(
                                    new LoopingAlphabetReader(length),
                                    length, 0, TYPENAME,
                                    new CharStreamHeaderGenerator());
        modUTF8.skip(HEADER_LENGTH); // Skip encoded length added by ReaderToUTF8Stream.
View Full Code Here

        assertEquals(ascii, modUTF8);
    }

    public void testSkipUntilEOFOnZeroLengthStream()
            throws IOException {
        assertEquals(0, UTF8Util.skipUntilEOF(new LoopingAlphabetStream(0)));
    }
View Full Code Here

        assertEquals(0, UTF8Util.skipUntilEOF(new LoopingAlphabetStream(0)));
    }
   
    public void testSkipUntilEOFOnShortStreamASCII()
            throws IOException {
        assertEquals(5, UTF8Util.skipUntilEOF(new LoopingAlphabetStream(5)));
    }
View Full Code Here

TOP

Related Classes of org.apache.derbyTesting.functionTests.util.streams.LoopingAlphabetStream

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.