Exemplo n.º 1
0
 /*
  * Validate that readObject returns the correct value
  */
 @Test()
 public void test05() throws Exception {
   Object[] values = {hero};
   SQLInputImpl sqli = new SQLInputImpl(values, map);
   Object o = sqli.readObject();
   assertTrue(hero.equals(o));
 }
Exemplo n.º 2
0
  /*
   * Validate that readObject returns the correct value when a Struct is
   * next on the stream
   */
  @Test()
  public void test11() throws Exception {
    Object[] attributes = new Object[] {"Bruce", "Wayne", 1939, "Batman"};
    map.put(sqlType, Class.forName("util.SuperHero"));
    Struct struct = new StubStruct(sqlType, attributes);
    Object[] values = {struct};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Object o = sqli.readObject();

    assertTrue(hero.equals(o));
  }
 /** @tests {@link javax.sql.rowset.serial.SQLInputImpl#readObject()} */
 public void testReadObject() throws SQLException {
   Object[] structAttributes = {"hello", Boolean.TRUE, "abc", Integer.valueOf(99)};
   Struct struct = new MockStruct(structAttributes, "harmonytests.MockSQLData");
   Struct struct2 = new MockStruct(structAttributes, "not stored name");
   HashMap<String, Class<?>> types = new HashMap<String, Class<?>>();
   types.put("harmonytests.MockSQLData", MockSQLData.class);
   Object[] attributes = new Object[] {struct, struct2, null, "xyz"};
   SQLInputImpl impl = new SQLInputImpl(attributes, types);
   Object obj = impl.readObject();
   assertTrue(obj instanceof MockSQLData);
   MockSQLData sqlData = (MockSQLData) obj;
   assertEquals(structAttributes[0], sqlData.firstAttribute);
   assertEquals(structAttributes[1], sqlData.secondAttribute);
   assertEquals(structAttributes[2], sqlData.thirdAttribute);
   assertEquals(structAttributes[3], sqlData.fourthAttribute);
   Object obj2 = impl.readObject();
   assertEquals(struct2, obj2);
   Object obj3 = impl.readObject();
   assertNull(obj3);
   Object obj4 = impl.readObject();
   assertEquals(attributes[3], obj4);
 }