/** * @tests {@link javax.sql.rowset.serial.SQLOutputImpl#writeObject(java.sql.SQLData)} */ public void test_writeObjectLjava_sql_SQLData() throws SQLException { MockSQLData sqlData = new MockSQLData(); sqlData.firstAttribute = "one"; sqlData.secondAttribute = Boolean.FALSE; sqlData.thirdAttribute = "three"; sqlData.fourthAttribute = Integer.valueOf(4); impl.writeObject(sqlData); assertTrue(attr.get(0) instanceof SerialStruct); SerialStruct struct = (SerialStruct) attr.get(0); Object[] attributes = struct.getAttributes(); assertEquals(sqlData.firstAttribute, attributes[0]); assertEquals(sqlData.secondAttribute, attributes[1]); assertEquals(sqlData.thirdAttribute, attributes[2]); assertEquals(sqlData.fourthAttribute, attributes[3]); assertEquals("harmonytests.MockSQLData", struct.getSQLTypeName()); }
@Test(enabled = true) public void test08() throws Exception { Object[] attributes = new Object[]{"Bruce", "Wayne", 1939, "Batman"}; Struct s = new StubStruct(sqlType, attributes); outImpl.writeStruct(s); SerialStruct ss = (SerialStruct) results.get(0); assertTrue(Arrays.equals(attributes, (Object[]) ss.getAttributes())); assertTrue(sqlType.equals(ss.getSQLTypeName())); }
@Test(enabled = true) public void test10() throws Exception { Object[] attributes = new Object[]{"Bruce", "Wayne", 1939, "Batman"}; outImpl.writeObject(hero); SerialStruct ss = (SerialStruct) results.get(0); assertTrue(Arrays.equals(attributes, (Object[]) ss.getAttributes())); assertTrue(sqlType.equals(ss.getSQLTypeName())); }
/** * Validate that a SerialStruct that is serialized & deserialized is equal * to itself */ @Test public void test08() throws Exception { SerialStruct ss = new SerialStruct(struct, map); SerialStruct ss1 = serializeDeserializeObject(ss);; assertTrue(ss.equals(ss1)); }
protected Object convertObject(Object object) throws SQLException { if (object instanceof Struct) { switch (structRetrieval) { case OBJECT: return object; case ARRAY: return new ArrayImpl(((Struct)object).getAttributes()); case COPY: return new SerialStruct((Struct)object, Collections.<String, Class<?>> emptyMap()); } } return object; }
/** * @tests {@link javax.sql.rowset.serial.SQLOutputImpl#writeStruct(java.sql.Struct)} */ public void test_writeStructLjava_sql_Struct() throws SQLException { Struct struct = new MockStruct(new Object[] {}, "mockStruct1"); impl.writeStruct(struct); assertEquals(1, attr.size()); assertTrue(attr.get(0) instanceof SerialStruct); SerialStruct ss = (SerialStruct) attr.get(0); assertEquals(0, ss.getAttributes().length); assertEquals("mockStruct1", ss.getSQLTypeName()); }
public void testSerialStructStructMapOfStringClassOfQ() throws SerialException { Man sdata = new Man(1, new Name("Tony", "Wu")); SerialStruct ss = new SerialStruct(sdata, emptyMap); try { new SerialStruct((SerialStruct) null, emptyMap); fail("should throw NullPointerException."); } catch (NullPointerException e) { // expected. } new SerialStruct(ss, null); SerialStruct ss2 = new SerialStruct(ss, emptyMap); assertNotNull(ss2); }
@Test public void test01() throws Exception { SerialStruct ss = new SerialStruct(struct, map); assertEquals(ss.getSQLTypeName(), sqlType); }
@Test public void test02() throws Exception { SerialStruct ss = new SerialStruct(hero, map); assertEquals(ss.getSQLTypeName(), sqlType); }
@Test public void test03() throws Exception { SerialStruct ss = new SerialStruct(struct, map); assertTrue(Arrays.equals(attributes, ss.getAttributes())); }
@Test public void test04() throws Exception { SerialStruct ss = new SerialStruct(hero, map); assertTrue(Arrays.equals(attributes, ss.getAttributes())); }
@Test public void test05() throws Exception { SerialStruct ss = new SerialStruct(struct, map); assertTrue(Arrays.equals(attributes, ss.getAttributes(map))); }
@Test public void test06() throws Exception { SerialStruct ss = new SerialStruct(hero, map); assertTrue(Arrays.equals(attributes, ss.getAttributes(map))); }
@Test public void test07() throws Exception { SerialStruct ss = new SerialStruct(struct, map); SerialStruct ss1 = (SerialStruct) ss.clone(); assertTrue(ss.equals(ss1)); }