Package javax.sql.rowset.serial

Examples of javax.sql.rowset.serial.SQLInputImpl


    /**
     * @tests {@link javax.sql.rowset.serial.SQLInputImpl#readByte()}
     */
    public void testReadByte() throws SQLException {
        Object[] attributes = new Object[] { Byte.valueOf("3") };
        SQLInputImpl impl = new SQLInputImpl(attributes,
                new HashMap<String, Class<?>>());
        assertEquals((byte) 3, impl.readByte());

        try {
            impl.readByte();
            fail("should throw SQLException");
        } catch (SQLException e) {
            // expected
        }

        attributes = new Object[] { null };
        impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
        assertEquals((byte) 0, impl.readByte());
    }
View Full Code Here


     * @tests {@link javax.sql.rowset.serial.SQLInputImpl#readBytes()}
     */
    public void testReadBytes() throws SQLException {
        byte[] bytes = new byte[] { 1, 2, 3 };
        Object[] attributes = new Object[] { bytes };
        SQLInputImpl impl = new SQLInputImpl(attributes,
                new HashMap<String, Class<?>>());
        assertEquals(bytes, impl.readBytes());

        try {
            impl.readBytes();
            fail("should throw SQLException");
        } catch (SQLException e) {
            // expected
        }

        attributes = new Object[] { null };
        impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
        assertNull(impl.readBytes());
    }
View Full Code Here

     * @tests {@link javax.sql.rowset.serial.SQLInputImpl#readCharacterStream()}
     */
    public void testReadCharacterStream() throws SQLException {
        Reader stream = new StringReader("abc");
        Object[] attributes = new Object[] { stream };
        SQLInputImpl impl = new SQLInputImpl(attributes,
                new HashMap<String, Class<?>>());
        assertEquals(stream, impl.readCharacterStream());

        try {
            impl.readCharacterStream();
            fail("should throw SQLException");
        } catch (SQLException e) {
            // expected
        }

        attributes = new Object[] { null };
        impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
        assertNull(impl.readCharacterStream());
    }
View Full Code Here

     * @tests {@link javax.sql.rowset.serial.SQLInputImpl#readClob()}
     */
    public void testReadClob() throws SQLException {
        Clob clob = new MockClob();
        Object[] attributes = new Object[] { clob };
        SQLInputImpl impl = new SQLInputImpl(attributes,
                new HashMap<String, Class<?>>());
        assertEquals(clob, impl.readClob());

        try {
            impl.readClob();
            fail("should throw SQLException");
        } catch (SQLException e) {
            // expected
        }

        attributes = new Object[] { null };
        impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
        assertNull(impl.readClob());
    }
View Full Code Here

     * @tests {@link javax.sql.rowset.serial.SQLInputImpl#readDate()}
     */
    public void testReadDate() throws SQLException {
        Date date = new Date(12);
        Object[] attributes = new Object[] { date };
        SQLInputImpl impl = new SQLInputImpl(attributes,
                new HashMap<String, Class<?>>());
        assertEquals(date, impl.readDate());

        try {
            impl.readDate();
            fail("should throw SQLException");
        } catch (SQLException e) {
            // expected
        }

        attributes = new Object[] { null };
        impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
        assertNull(impl.readDate());
    }
View Full Code Here

    /**
     * @tests {@link javax.sql.rowset.serial.SQLInputImpl#readDouble()}
     */
    public void testReadDouble() throws SQLException {
        Object[] attributes = new Object[] { Double.valueOf("3") };
        SQLInputImpl impl = new SQLInputImpl(attributes,
                new HashMap<String, Class<?>>());
        assertEquals((double) 3, impl.readDouble());

        try {
            impl.readDouble();
            fail("should throw SQLException");
        } catch (SQLException e) {
            // expected
        }

        attributes = new Object[] { null };
        impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
        assertEquals(0, impl.readDouble(), 0);
    }
View Full Code Here

    /**
     * @tests {@link javax.sql.rowset.serial.SQLInputImpl#readFloat()}
     */
    public void testReadFloat() throws SQLException {
        Object[] attributes = new Object[] { Float.valueOf("3.5") };
        SQLInputImpl impl = new SQLInputImpl(attributes,
                new HashMap<String, Class<?>>());
        assertEquals((float) 3.5, impl.readFloat());

        try {
            impl.readFloat();
            fail("should throw SQLException");
        } catch (SQLException e) {
            // expected
        }

        attributes = new Object[] { null };
        impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
        assertEquals(0f, impl.readFloat(), 0);
    }
View Full Code Here

    /**
     * @tests {@link javax.sql.rowset.serial.SQLInputImpl#readInt()}
     */
    public void testReadInt() throws SQLException {
        Object[] attributes = new Object[] { Integer.valueOf("3") };
        SQLInputImpl impl = new SQLInputImpl(attributes,
                new HashMap<String, Class<?>>());
        assertEquals(3, impl.readInt());

        try {
            impl.readInt();
            fail("should throw SQLException");
        } catch (SQLException e) {
            // expected
        }

        attributes = new Object[] { null };
        impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
        assertEquals(0, impl.readInt());
    }
View Full Code Here

    /**
     * @tests {@link javax.sql.rowset.serial.SQLInputImpl#readLong()}
     */
    public void testReadLong() throws SQLException {
        Object[] attributes = new Object[] { Long.valueOf("3") };
        SQLInputImpl impl = new SQLInputImpl(attributes,
                new HashMap<String, Class<?>>());
        assertEquals((long) 3, impl.readLong());

        try {
            impl.readLong();
            fail("should throw SQLException");
        } catch (SQLException e) {
            // expected
        }

        attributes = new Object[] { null };
        impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
        assertEquals(0, impl.readLong());
    }
View Full Code Here

                "harmonytests.MockSQLData");
        Struct struct2 = new MockStruct(structAttributes, "not stored name");
        HashMap<String, Class<?>> types = new HashMap<String, Class<?>>();
        types.put("harmonytests.MockSQLData", MockSQLData.class);
        Object[] attributes = new Object[] { struct, struct2, null, "xyz" };
        SQLInputImpl impl = new SQLInputImpl(attributes, types);
        Object obj = impl.readObject();
        assertTrue(obj instanceof MockSQLData);
        MockSQLData sqlData = (MockSQLData) obj;
        assertEquals(structAttributes[0], sqlData.firstAttribute);
        assertEquals(structAttributes[1], sqlData.secondAttribute);
        assertEquals(structAttributes[2], sqlData.thirdAttribute);
        assertEquals(structAttributes[3], sqlData.fourthAttribute);
        Object obj2 = impl.readObject();
        assertEquals(struct2, obj2);
        Object obj3 = impl.readObject();
        assertNull(obj3);
        Object obj4 = impl.readObject();
        assertEquals(attributes[3], obj4);
    }
View Full Code Here

TOP

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

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.