### Question:
ResultSetColumnReader { public Long getLong(int columnIdx) throws SQLException { Object obj = _rs.getObject(columnIdx); Long results = LONG_ZERO; _wasNull = true; if (obj != null) { final int columnType = _rsmd.getColumnType(columnIdx); if (columnType != Types.NULL) { _wasNull = false; switch (columnType) { case Types.SMALLINT: case Types.TINYINT: case Types.INTEGER: case Types.BIGINT : if (obj instanceof Number) { results = ((Number)obj).longValue(); } else { results = new Long(obj.toString()); } break; case Types.BIT: if ("true".equalsIgnoreCase(obj.toString())) { results = Long.valueOf(1); } else { results = Long.valueOf(0); } break; default: results = new Long(obj.toString()); break; } } } return results; } ResultSetColumnReader(ResultSet rs); boolean next(); Boolean getBoolean(int columnIdx); Date getDate(int columnIdx); Double getDouble(int columnIdx); Long getLong(int columnIdx); Object getObject(int columnIdx); String getString(int columnIdx); Time getTime(int columnIdx); Timestamp getTimeStamp(int columnIdx); boolean wasNull();  }### Answer:
@Test public final void testGetLong() throws SQLException { int index = 1; expect(mockResultSetMetaData.getColumnType(index++)).andReturn(Types.SMALLINT); expect(mockResultSetMetaData.getColumnType(index++)).andReturn(Types.TINYINT); expect(mockResultSetMetaData.getColumnType(index++)).andReturn(Types.INTEGER); expect(mockResultSetMetaData.getColumnType(index++)).andReturn(Types.BIGINT); expect(mockResultSetMetaData.getColumnType(index++)).andReturn(Types.REAL); expect(mockResultSetMetaData.getColumnType(index++)).andReturn(Types.VARCHAR); expect(mockResultSetMetaData.getColumnType(index++)).andReturn(Types.BIT); expect(mockResultSetMetaData.getColumnType(index++)).andReturn(Types.BIT); index = 1; expect(mockResultSet.getMetaData()).andReturn(mockResultSetMetaData).anyTimes(); expect(mockResultSet.getObject(index++)).andReturn(Long.valueOf(123)).anyTimes(); expect(mockResultSet.getObject(index++)).andReturn(Integer.valueOf(345)).anyTimes(); expect(mockResultSet.getObject(index++)).andReturn("123").anyTimes(); expect(mockResultSet.getObject(index++)).andReturn(Short.valueOf((short)127)).anyTimes(); expect(mockResultSet.getObject(index++)).andReturn("567").anyTimes(); expect(mockResultSet.getObject(index++)).andReturn("789").anyTimes(); expect(mockResultSet.getObject(index++)).andReturn("true").anyTimes(); expect(mockResultSet.getObject(index++)).andReturn("false").anyTimes(); index = 1; replayAll(); readerUnderTest = new ResultSetColumnReader(mockResultSet); Long value = readerUnderTest.getLong(index++); assertEquals(new Long(123), value); value = readerUnderTest.getLong(index++); assertEquals(new Long(345), value); value = readerUnderTest.getLong(index++); assertEquals(new Long(123), value); value = readerUnderTest.getLong(index++); assertEquals(new Long(127), value); value = readerUnderTest.getLong(index++); assertEquals(new Long(567), value); value = readerUnderTest.getLong(index++); assertEquals(new Long(789), value); value = readerUnderTest.getLong(index++); assertEquals(new Long(1), value); value = readerUnderTest.getLong(index++); assertEquals(new Long(0), value); verifyAll(); }