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

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


        int lobSize = 1000000;

        // Insert a single BLOB in the table.
        PreparedStatement insert =
                prepareStatement("insert into d5752 values (1,?)");
        insert.setBinaryStream(1, new LoopingAlphabetStream(lobSize), lobSize);
        insert.execute();
        closeStatement(insert);

        Blob[] blobs = new Blob[15];
View Full Code Here


    public void testReadBlobCloseToMaxDssLength() throws Exception {
        final int length = 32766; // max DSS length is 32767

        // Create test data with the requested length
        DataInputStream stream1 =
                new DataInputStream(new LoopingAlphabetStream(length));
        byte[] bytes = new byte[length];
        stream1.readFully(bytes);

        // See if the test data can be sent to the server and back with
        // no errors.
        PreparedStatement ps = prepareStatement("values cast(? as blob)");
        ps.setBytes(1, bytes);
        ResultSet rs = ps.executeQuery();
        assertTrue("empty result set", rs.next());
        InputStream stream2 = rs.getBinaryStream(1);
        assertEquals(new LoopingAlphabetStream(length), stream2);
        assertFalse("too many rows", rs.next());
        rs.close();
    }
View Full Code Here

        case PH_CREATE: // create with old version
        s.execute("create table table1LOBtest (id int, status smallint, bl blob(2G))");
        PreparedStatement ps = prepareStatement(
        "insert into table1LOBtest values (?, 0, ?)");
        ps.setInt(1, 1);
            ps.setBinaryStream(2, new LoopingAlphabetStream(lobsize), lobsize);
            ps.executeUpdate();
           
        s.execute("create table table2LOBtest (id int, updates int default 0)");
        ps = prepareStatement(
            "insert into table2LOBtest (id) values (?)");
View Full Code Here

     * @throws IOException if reading from the source fails
     */
    private BlockedByteArray createBlockedByteArray(long length)
            throws IOException {
        BlockedByteArray data = new BlockedByteArray();
        InputStream src = new LoopingAlphabetStream(length);
        byte[] buf = new byte[4*1024];
        long pos = 0;
        while (pos < length) {
            int readFromSrc = src.read(buf);
            pos += data.writeBytes(pos, buf, 0, readFromSrc);
        }
        return data;
    }
View Full Code Here

    /**
     * Verifies that reading after EOF doesn't change the position.
     */
    public void testPositionAfterEOFRead()
            throws IOException, StandardException {
        InputStream in = new LoopingAlphabetStream(10);
        PositionedStoreStream pss = new PositionedStoreStream(in);
        assertEquals(0, pss.getPosition());
        for (int i=0; i < 10; i++) {
            pss.read();
            assertEquals(i +1, pss.getPosition());
View Full Code Here

    /**
     * Verifies that reading after EOF doesn't change the position.
     */
    public void testPositionAfterEOFReadArray()
            throws IOException, StandardException {
        InputStream in = new LoopingAlphabetStream(10);
        PositionedStoreStream pss = new PositionedStoreStream(in);
        assertEquals(0, pss.getPosition());
        byte[] two = new byte[2];
        for (int i=0; i < 10; i += 2) {
            assertEquals(2, pss.read(two, 0, 2));
View Full Code Here

     * Reads the whole stream repeatedly in one go, and resets it after each
     * read.
     */
    public void testReadEverythingInOneGo()
            throws IOException, StandardException {
        InputStream in = new LoopingAlphabetStream(127);
        PositionedStoreStream pss = new PositionedStoreStream(in);
        byte[] b = new byte[256];
        for (int i=0; i < 3; i++) {
            Arrays.fill(b, (byte)-1);
            assertEquals(127, pss.read(b, 0, 256));
View Full Code Here

    }

    public void testRepositionForwards()
            throws IOException, StandardException {
        final long length = 20L;
        InputStream in = new LoopingAlphabetStream(length);
        PositionedStoreStream pss = new PositionedStoreStream(in);
        assertEquals(0, pss.getPosition());
        //  Position forwards one by one.
        for (int i=0; i < length; i++) {
            InputStream inComp = new LoopingAlphabetStream(length);
            pss.reposition(i);
            inComp.skip(i);
            assertEquals(inComp.read(), pss.read());
        }
        // Position forwards two by two.
        for (int i=1; i < length; i += 2) {
            InputStream inComp = new LoopingAlphabetStream(length);
            pss.reposition(i);
            inComp.skip(i);
            assertEquals(inComp.read(), pss.read());
        }
    }
View Full Code Here

    }
   
    public void testRepositionBackwards()
            throws IOException, StandardException {
        final long length = 20L;
        InputStream in = new LoopingAlphabetStream(length);
        PositionedStoreStream pss = new PositionedStoreStream(in);
        assertEquals(0, pss.getPosition());
        // Position backwards one by one.
        for (int i=(int)length; i >= 0; i--) {
            InputStream inComp = new LoopingAlphabetStream(length);
            pss.reposition(i);
            inComp.skip(i);
            assertEquals(inComp.read(), pss.read());
        }
        // Position backwards two by two.
        for (int i=(int)length -1; i >= 0; i -= 2) {
            InputStream inComp = new LoopingAlphabetStream(length);
            pss.reposition(i);
            inComp.skip(i);
            assertEquals(inComp.read(), pss.read());
        }
    }
View Full Code Here

     * Executes a simple read sequence against the lower case modern latin
     * alphabet, which involves some repositioning.
     */
    public void testSimpleReadSequence()
            throws IOException, StandardException {
        InputStream in = new LoopingAlphabetStream(26);
        PositionedStoreStream pss = new PositionedStoreStream(in);
        assertEquals('a', pss.read());
        pss.reposition(9);
        assertEquals('j', pss.read());
        pss.reposition(10);
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.