Package javax.sql.rowset.serial

Examples of javax.sql.rowset.serial.SerialClob


        }

    }

    public void testPositionLClobJ() throws Exception {
        SerialClob serialClob = new SerialClob("helloo".toCharArray());
        SerialClob searchClob = new SerialClob("llo".toCharArray());
        long pos = serialClob.position(searchClob, 1);
        assertEquals(3, pos);

        pos = serialClob.position(searchClob, 3);
        assertEquals(3, pos);

        searchClob = new SerialClob("o".toCharArray());
        pos = serialClob.position(searchClob, 6);
        assertEquals(6, pos);

        searchClob = new SerialClob("ooooooo".toCharArray());
        pos = serialClob.position(searchClob, 1);
        assertEquals(-1, pos);

        searchClob = new SerialClob("llo".toCharArray());
        pos = serialClob.position(searchClob, 4);
        assertEquals(-1, pos);

        pos = serialClob.position(searchClob, 0);
        assertEquals(-1, pos);
View Full Code Here


        pos = serialClob.position(searchClob, 10);
        assertEquals(-1, pos);
    }

    public void testPositionLStringJ() throws Exception {
        SerialClob serialClob = new SerialClob("helloo".toCharArray());

        long pos = serialClob.position("llo", 1);
        assertEquals(3, pos);

        pos = serialClob.position("llo", 3);
        assertEquals(3, pos);

        pos = serialClob.position("o", 6);
        assertEquals(6, pos);

        pos = serialClob.position("ooooooo", 1);
        assertEquals(-1, pos);

        pos = serialClob.position("llo", 4);
        assertEquals(-1, pos);

        pos = serialClob.position("llo", 0);
        assertEquals(-1, pos);

        pos = serialClob.position("llo", -1);
        assertEquals(-1, pos);

        pos = serialClob.position("llo", 10);
        assertEquals(-1, pos);
    }
View Full Code Here

    public void testSetAsciiStream() throws Exception {
        MockSerialClob mockClob = new MockSerialClob();
        mockClob.characterStreamReader = new CharArrayReader(mockClob.buf);
        mockClob.asciiInputStream = new ByteArrayInputStream(new byte[] { 1 });
        SerialClob serialClob = new SerialClob(mockClob);
        OutputStream os = null;
        try {
            os = serialClob.setAsciiStream(1);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }
        mockClob.asciiOutputStream = new ByteArrayOutputStream();
        os = serialClob.setAsciiStream(1);
        assertNotNull(os);
        assertTrue(mockClob.isSetAsciiStreamInvoked);
        assertEquals(mockClob.asciiOutputStream, os);

        try {
            serialClob = new SerialClob("helloo".toCharArray());
            // Harmony-3491, non bug difference from RI
            serialClob.setAsciiStream(1);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }
    }
View Full Code Here

    public void testSetCharacterStream() throws Exception {
        MockSerialClob mockClob = new MockSerialClob();
        mockClob.characterStreamReader = new CharArrayReader(mockClob.buf);
        mockClob.asciiInputStream = new ByteArrayInputStream(new byte[] { 1 });
        mockClob.characterStreamWriter = new CharArrayWriter();
        SerialClob serialClob = new SerialClob(mockClob);
        Writer writer = serialClob.setCharacterStream(1);
        assertTrue(mockClob.isSetCharacterStreamInvoked);
        assertEquals(mockClob.characterStreamWriter, writer);

        try {
            serialClob = new SerialClob("helloo".toCharArray());
            // Harmony-3491, non bug difference from RI
            serialClob.setCharacterStream(1);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }
    }
View Full Code Here

    }

    public void testSetStringJLString() throws Exception {
        String s = "hello";
        char[] buf = s.toCharArray();
        SerialClob serialClob = new SerialClob(buf);

        int count = serialClob.setString(1, "olleh");
        String sub = serialClob.getSubString(1, 5);
        assertEquals("olleh", sub);
        assertEquals(5, count);

        count = serialClob.setString(2, "mm");
        sub = serialClob.getSubString(1, 5);
        assertEquals("ommeh", sub);
        assertEquals(2, count);

        try {
            serialClob.setString(-1, "hello");
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        try {
            serialClob.setString(6, "hello");
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        // Harmony-3335, non bug difference from RI
        try {
            serialClob.setString(2, "hello");
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }
    }
View Full Code Here

            // expected
        }
    }

    public void testSetStringJLStringII() throws Exception {
        SerialClob serialClob = new SerialClob("hello".toCharArray());
        int count = serialClob.setString(1, "olleh", 0, 5);
        String sub = serialClob.getSubString(1, 5);
        assertEquals("olleh", sub);
        assertEquals(5, count);

        count = serialClob.setString(2, "mmnn", 1, 2);
        sub = serialClob.getSubString(1, 5);
        // RI's bug
        assertEquals(2, count);
        assertEquals("omneh", sub);

        try {
            serialClob.setString(-1, "hello", 0, 5);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        try {
            serialClob.setString(6, "hello", 0, 5);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        try {
            serialClob.setString(1, "hello", 0, 6);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        // Harmony-3335, non bug difference from RI
        try {
            serialClob.setString(2, "hello", 0, 5);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        try {
            // Harmony-3335
            serialClob.setString(1, "hello", -1, 5);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }
    }
View Full Code Here

            // expected
        }
    }

    public void testTruncate() throws Exception {
        SerialClob serialClob = new SerialClob("hello".toCharArray());
        serialClob.truncate(3);
        assertEquals(3, serialClob.length());
        String s = serialClob.getSubString(1, 3);
        assertEquals("hel", s);
        serialClob.truncate(0);
        assertEquals(0, serialClob.length());

        serialClob = new SerialClob("hello".toCharArray());
        try {
            serialClob.truncate(10);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        try {
            serialClob.truncate(-1);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }
    }
View Full Code Here

        SQLArray() throws SQLException {

            char[] chars = { 'a', 'b', 'c', 'd' };
            array = new Object[1];

            array[0] = (Object) new SerialClob(chars);
        }
View Full Code Here

     */
    public Object convert( String value, TypeLiteral<?> toType )
    {
        try
        {
            return new SerialClob( value.toCharArray() );
        }
        catch ( SQLException e )
        {
            throw new IllegalArgumentException( "String value '" + value + "' is not a valid SerialClob", e );
        }
View Full Code Here

                        }
                    }

                    break;
                case 13:
                    entity.dangerousSetNoCheckButFast(curField, new SerialClob(rs.getClob(ind)));
                    break;
                case 14:
                case 15:
                    entity.dangerousSetNoCheckButFast(curField, rs.getObject(ind));
                    break;
View Full Code Here

TOP

Related Classes of javax.sql.rowset.serial.SerialClob

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.