Example #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#readString()} */
  public void testReadString() throws SQLException {
    Object[] attributes = new Object[] {"hello"};
    SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
    assertEquals("hello", impl.readString());

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

    attributes = new Object[] {null};
    impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
    assertNull(impl.readString());
  }