Ejemplo n.º 1
0
 /*
  * Validate that wasNull indicates if a null was read in
  */
 @Test()
 public void test04() throws Exception {
   Object[] values = {"Hello", null, 1};
   SQLInputImpl sqli = new SQLInputImpl(values, map);
   String s = sqli.readString();
   assertFalse(sqli.wasNull());
   s = sqli.readString();
   assertTrue(sqli.wasNull());
   int i = sqli.readInt();
   assertFalse(sqli.wasNull());
 }
 /** @tests {@link javax.sql.rowset.serial.SQLInputImpl#wasNull()} */
 public void testWasNull() throws SQLException {
   Object[] attributes = new Object[] {null, "hello"};
   SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
   assertFalse(impl.wasNull());
   assertEquals(null, impl.readString());
   assertTrue(impl.wasNull());
   assertEquals("hello", impl.readString());
   assertFalse(impl.wasNull());
   try {
     impl.readString();
     fail("should throw SQLException");
   } catch (SQLException e) {
     // expected
   }
   assertFalse(impl.wasNull());
   assertFalse(impl.wasNull());
 }