Example #1
0
 /*
  * Validate a Blob can be read
  */
 @Test(enabled = true)
 public void test07() throws Exception {
   Blob b = new StubBlob();
   Object[] values = {b};
   SQLInputImpl sqli = new SQLInputImpl(values, map);
   Blob b2 = sqli.readBlob();
   assertTrue(Arrays.equals(b.getBytes(1, (int) b.length()), b2.getBytes(1, (int) b2.length())));
 }
  /** @tests {@link javax.sql.rowset.serial.SQLInputImpl#readBlob()} */
  public void testReadBlob() throws SQLException {
    Blob blob = new MockBlob();
    Object[] attributes = new Object[] {blob};
    SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
    assertEquals(blob, impl.readBlob());

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

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