JDK-6467662 : api/javax_sql/rowset/impl/FilteredRowSet/index.html#FilteredRowSet[notifyCursorMovedTest3] fails b98
  • Type: Bug
  • Component: core-libs
  • Sub-Component: javax.sql
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2006-09-06
  • Updated: 2012-03-22
  • Resolved: 2008-01-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u1 b01Fixed 7Fixed
Description
JCK            : JCK6.0 b30
J2SE           : FAIL - mustang b98
Platform[s]    : FAIL - windows
switch/Mode    : FAIL - default

Test api/javax_sql/rowset/impl/FilteredRowSet/index.html#FilteredRowSet[notifyCursorMovedTest3] fails because method relative(1) doesn't notify listener on cursor move (but next() still does). According to specification these methods should do the same ("Note: Calling the method relative(1)  is identical to calling the method next() and calling the method relative(-1) is identical to calling the method previous().").


steps to reproduce: run the following code:

import java.io.PrintWriter;
import java.sql.*;
import javax.sql.*;
import javax.sql.rowset.*;
import java.math.BigDecimal;


public class RowsetTest{
    private static final int UNDEFINED = -1;
    private static final int CONSTRUCTOR = 0;
    private static final int FACTORY = 1;

    protected int mechanism = UNDEFINED;

public static void main (String[] args){

        try {
	   RowSet rs = getRowSetImpl();
	   System.out.println("Initialized...");

           SimpleListener listener = new SimpleListener();
           rs.addRowSetListener(listener);

	   System.out.println("first()");
           rs.first();
	   System.out.println("relative(1)");
           rs.relative(1);
	   System.out.println("first()");
	   rs.first();
	   System.out.println("next()");
           rs.next();

        } catch (Exception e) {
	    e.printStackTrace();
 	    return;
        }
        System.out.println("OK");


}


    protected static RowSet getRowSetImpl() throws Exception {
        try {
            RowSet rs = newInstance();
            initRowSet(rs);
            return rs;
        } catch (SQLException e) {
            e.printStackTrace();
	    throw new RuntimeException(e);
        }
    }

    protected static void initRowSet(RowSet rs) throws SQLException {
        CachedRowSet crs = (CachedRowSet) rs;
        RowSetMetaDataImpl rsmdi = new RowSetMetaDataImpl();
        crs.setType(RowSet.TYPE_SCROLL_INSENSITIVE);

        rsmdi.setColumnCount(18);
        

        rsmdi.setColumnName(1, "_bit_");
        rsmdi.setColumnName(2, "_object_");
        rsmdi.setColumnName(3, "_char_");
        rsmdi.setColumnName(4, "_date_");
        rsmdi.setColumnName(5, "_decimal_");
        rsmdi.setColumnName(6, "_double_");
        rsmdi.setColumnName(7, "_float_");
        rsmdi.setColumnName(8, "_integer_");
        rsmdi.setColumnName(9, "_numeric_");
        rsmdi.setColumnName(10, "_real_");
        rsmdi.setColumnName(11, "_ref_");
        rsmdi.setColumnName(12, "_smallint_");
        rsmdi.setColumnName(13, "_time_");
        rsmdi.setColumnName(14, "_timestamp_");
        rsmdi.setColumnName(15, "_timyint_");
        rsmdi.setColumnName(16, "_varchar_");
        rsmdi.setColumnName(17, "_bin_");        
        rsmdi.setColumnName(18, "_bigint_");


        rsmdi.setNullable(1, ResultSetMetaData.columnNoNulls);
        rsmdi.setNullable(2, ResultSetMetaData.columnNullable);        
        rsmdi.setNullable(3, ResultSetMetaData.columnNullable);
        rsmdi.setNullable(11, ResultSetMetaData.columnNullable);

        
        rsmdi.setColumnType(1, Types.BIT);
        rsmdi.setColumnType(2, Types.JAVA_OBJECT);
        rsmdi.setColumnType(3, Types.CHAR);
        rsmdi.setColumnType(4, Types.DATE);
        rsmdi.setColumnType(5, Types.DECIMAL);
        rsmdi.setColumnType(6, Types.DOUBLE);
        rsmdi.setColumnType(7, Types.FLOAT);
        rsmdi.setColumnType(8, Types.INTEGER);
        rsmdi.setColumnType(9, Types.NUMERIC);
        rsmdi.setColumnType(10, Types.REAL);
        rsmdi.setColumnType(11, Types.REF);
        rsmdi.setColumnType(12, Types.SMALLINT);
        rsmdi.setColumnType(13, Types.TIME);
        rsmdi.setColumnType(14, Types.TIMESTAMP);
        rsmdi.setColumnType(15, Types.TINYINT);
        rsmdi.setColumnType(16, Types.VARCHAR);
        rsmdi.setColumnType(17, Types.BINARY);  
        rsmdi.setColumnType(18, Types.BIGINT);          
        crs.setMetaData(rsmdi);

        // ========== add a few rows
        final byte[] buf = {0x01, 0x02};
        
        crs.moveToInsertRow();

        crs.updateBoolean(1, false);
//        crs.updateBoolean(2, true);
        crs.updateString(3, "Char value");
        crs.updateDate(4, new Date(432423434L));
        crs.updateBigDecimal(5, new BigDecimal(0));
        crs.updateDouble(6, 3.14);
        crs.updateDouble(7, 3.1415);
        crs.updateInt(8, 13);        
        crs.updateBigDecimal(9, new BigDecimal(0));
        crs.updateFloat(10, 0.0f);
        crs.updateNull(11);
        crs.updateShort(12, (short )0 );        
        crs.updateTime(13, new Time(34324));
        crs.updateTimestamp(14, new Timestamp(34322));
        crs.updateByte(15, (byte)1);
        crs.updateString(16, "varchar value");
        crs.updateBytes(17, buf);   
        crs.updateLong(18, Long.MAX_VALUE - 1);              
        crs.insertRow();

        crs.moveToInsertRow();

        crs.updateBoolean(1, false);
  //      crs.updateBoolean(2, true);
        crs.updateString(3, "Char value 1");
        crs.updateDate(4, new Date(436576L));
        crs.updateBigDecimal(5, new BigDecimal(10));
        crs.updateDouble(6, 3.14);
        crs.updateDouble(7, 3.1415);
        crs.updateInt(8, 13);
        crs.updateBigDecimal(9, new BigDecimal(15));
        crs.updateFloat(10, 10.0f);
        crs.updateNull(11);
        crs.updateShort(12, (short )13 );                
        crs.updateTime(13, new Time(777));
        crs.updateTimestamp(14, new Timestamp(45654));
        crs.updateByte(15, (byte)17);
        crs.updateString(16, "varchar value 1");
        crs.updateBytes(17, buf);
        crs.updateLong(18, Long.MAX_VALUE);        
        crs.insertRow();

        crs.moveToCurrentRow();
        crs.beforeFirst();


    }

    protected static RowSet newInstance() throws Exception {
            return (RowSet)(Class.forName("com.sun.rowset.FilteredRowSetImpl").newInstance());
    }


    public static void registerListenerTest(RowSet rs) throws Exception {
        
        SimpleListener listener = new SimpleListener();
        //rs.addRowSetListener(listener);
        rs.execute();
    }

public static class SimpleListener implements RowSetListener {

    boolean rowSetChanged;
    boolean rowChanged;
    boolean cursorMoved;

    public boolean wasRowSetChanged() {
        return rowSetChanged;
    }

    public boolean wasRowChanged() {
        return rowChanged;
    }

    public boolean wasCursorMoved() {
	System.out.println("wasCursorMoved");
        return cursorMoved;
    }

    public void reset() {
        rowSetChanged = false;
        rowChanged = false;
        cursorMoved = false;
    }

    public void rowSetChanged(RowSetEvent event) {
        rowSetChanged = true;
    }

    public void rowChanged(RowSetEvent event) {
        rowChanged = true;
    }

    public void cursorMoved(RowSetEvent event) {
	System.out.println("cursorMoved");
        cursorMoved = true;
    }
}

}

Comments
EVALUATION Fix has been made waiting verification from the TCK team
14-11-2006

EVALUATION the relative() and absolute() methods in FilteredRowSetImpl need to call notifyCursorMoved() before returning to the caller.
13-11-2006

EVALUATION needs waiver request
11-09-2006