@DataProvider(name = "testAdvancedParameters") private Object[][] testAdvancedParameters() throws SQLException { byte[] bytes = new byte[10]; Ref aRef = new SerialRef(new StubRef("INTEGER", query)); Array aArray = new SerialArray(new StubArray("INTEGER", new Object[1])); Blob aBlob = new SerialBlob(new StubBlob()); Clob aClob = new SerialClob(new StubClob()); Reader rdr = new StringReader(query); InputStream is = new StringBufferInputStream(query);; brs = new StubBaseRowSet(); brs.setBytes(1, bytes); brs.setAsciiStream(2, is, query.length()); brs.setRef(3, aRef); brs.setArray(4, aArray); brs.setBlob(5, aBlob); brs.setClob(6, aClob); brs.setBinaryStream(7, is, query.length()); brs.setUnicodeStream(8, is, query.length()); brs.setCharacterStream(9, rdr, query.length()); return new Object[][]{ {1, bytes}, {2, is}, {3, aRef}, {4, aArray}, {5, aBlob}, {6, aClob}, {7, is}, {8, is}, {9, rdr} }; }
@Test(enabled = true) public void test04() throws Exception { Object[] coffees = new Object[]{"Espresso", "Colombian", "French Roast", "Cappuccino"}; Array a = new StubArray("VARCHAR", coffees); outImpl.writeArray(a); SerialArray sa = (SerialArray) results.get(0); assertTrue(Arrays.equals(coffees, (Object[]) sa.getArray())); assertTrue(a.getBaseTypeName().equals(sa.getBaseTypeName())); }
public void setArray(int parameterIndex, Array x) throws SQLException { if (x instanceof ArrayImpl) { setObject(parameterIndex, x); } else { setObject(parameterIndex, new SerialArray(x)); } }
public void setArray(int parameterIndex, Array array) throws SQLException { if (parameterIndex < 1) { throw new SQLException(); } if (params == null) { throw new SQLException(); } params.put(Integer.valueOf(parameterIndex - 1), new SerialArray(array)); }
public void testSetArray() throws SQLException { BaseRowSetImpl brs = new BaseRowSetImpl(); brs.initParams(); Array a = new MockArray(); brs.setArray(1, a); Object[] params = brs.getParams(); assertNotNull(params); assertEquals(1, params.length); assertTrue("Should have stored a SerialArray", params[0] instanceof SerialArray); }
/** * @tests {@link javax.sql.rowset.serial.SQLOutputImpl#writeArray(Array)} */ public void test_writeArrayLjava_sql_Array() throws SQLException { Array array = new MockArray(); impl.writeArray(array); assertEquals(1, attr.size()); assertTrue(attr.get(0) instanceof SerialArray); impl.writeArray(null); assertNull(attr.get(1)); }
@Override protected void setUp() throws Exception { super.setUp(); testElements = new Object[4]; testElements[0] = "test1"; testElements[1] = "test2"; testElements[2] = new SQLException(); testElements[3] = new HashMap(); sa = new SerialArray(mock); map = new HashMap<String, Class<?>>(); map.put("String", MockStringSQLData.class); map.put("Object", null); badmap = new HashMap<String, Class<?>>(); badmap.put("Something", HashMap.class); }
@Test public void test01() throws Exception { SerialArray sa = new SerialArray(a); }
@Test(expectedExceptions = SQLException.class) public void test02() throws Exception { SerialArray sa = new SerialArray(a, null); }
@Test(expectedExceptions = SerialException.class) public void test03() throws Exception { SerialArray sa = new SerialArray(a); sa.getResultSet(); }
@Test(expectedExceptions = SerialException.class) public void test04() throws Exception { SerialArray sa = new SerialArray(a); sa.getResultSet(null); }
@Test(expectedExceptions = SerialException.class) public void test05() throws Exception { SerialArray sa = new SerialArray(a); sa.getResultSet(1, 1); }
@Test(expectedExceptions = SerialException.class) public void test06() throws Exception { SerialArray sa = new SerialArray(a); sa.getResultSet(1, 1, null); }
@Test(expectedExceptions = SerialException.class) public void test07() throws Exception { SerialArray sa = new SerialArray(a); sa.free(); sa.getArray(); }
@Test(expectedExceptions = SerialException.class) public void test08() throws Exception { SerialArray sa = new SerialArray(a); sa.free(); sa.getArray(map); }
@Test(expectedExceptions = SerialException.class) public void test09() throws Exception { SerialArray sa = new SerialArray(a); sa.free(); sa.getArray(1, 1, map); }
@Test(expectedExceptions = SerialException.class) public void test10() throws Exception { SerialArray sa = new SerialArray(a); sa.free(); sa.getArray(1, 1); }
@Test(expectedExceptions = SerialException.class) public void test11() throws Exception { SerialArray sa = new SerialArray(a); sa.free(); sa.getBaseType(); }
@Test(expectedExceptions = SerialException.class) public void test12() throws Exception { SerialArray sa = new SerialArray(a); sa.free(); sa.getBaseTypeName(); }
@Test public void test13() throws Exception { SerialArray sa = new SerialArray(a); Object[] o = (Object[]) sa.getArray(); assertTrue(Arrays.equals(o, coffees)); }
@Test public void test14() throws Exception { SerialArray sa = new SerialArray(a); Object[] o = (Object[]) sa.getArray(map); assertTrue(Arrays.equals(o, coffees)); }
@Test public void test15() throws Exception { SerialArray sa = new SerialArray(a); Object[] o = (Object[]) sa.getArray(1, 2); assertTrue(Arrays.equals(o, Arrays.copyOfRange(coffees, 1, 3))); }
@Test public void test16() throws Exception { SerialArray sa = new SerialArray(a); Object[] o = (Object[]) sa.getArray(1, 2, map); assertTrue(Arrays.equals(o, Arrays.copyOfRange(coffees, 1, 3))); }
@Test public void test17() throws Exception { SerialArray sa = new SerialArray(a); SerialArray sa1 = (SerialArray) sa.clone(); assertTrue(sa.equals(sa1)); }
@Test public void test18() throws Exception { SerialArray sa = new SerialArray(a); SerialArray sa1 = serializeDeserializeObject(sa);; assertTrue(sa.equals(sa1)); }