use of org.eclipse.scout.rt.server.jdbc.SqlBind in project scout.rt by eclipse.
the class AbstractSqlStyleTest method verifySetNullCalledOnPS.
/**
* Verifies that {@link PreparedStatement#setNull(int, int)} is called when invoking
* {@link AbstractSqlStyle#writeBind(PreparedStatement, int, SqlBind)}
*
* @param nullType
* {@link Types} null type for preparedStatement
* @throws SQLException
*/
private void verifySetNullCalledOnPS(int nullType) throws SQLException {
PreparedStatement ps = Mockito.mock(PreparedStatement.class);
SqlBind bind = new SqlBind(nullType, null);
sql.writeBind(ps, 1, bind);
Mockito.verify(ps).setNull(1, nullType);
}
use of org.eclipse.scout.rt.server.jdbc.SqlBind in project scout.rt by eclipse.
the class AbstractSqlStyleTest method testWriteBindForNullClob.
/**
* Test for {@link AbstractSqlStyle#writeBind} for null values with nulltype {@link Clob}
*
* @throws SQLException
*/
@Test
public void testWriteBindForNullClob() throws SQLException {
PreparedStatement ps = Mockito.mock(PreparedStatement.class);
SqlBind bind = new SqlBind(Types.CLOB, null);
sql.writeBind(ps, 1, bind);
Mockito.verify(ps).setClob(1, (Clob) null);
}
use of org.eclipse.scout.rt.server.jdbc.SqlBind in project scout.rt by eclipse.
the class AbstractSqlStyleTest method testWriteBindNoScale.
/**
* Test for {@link AbstractSqlStyle#writeBind} for {@link BigDecimal}
*
* @throws SQLException
*/
@Test
public void testWriteBindNoScale() throws SQLException {
BigDecimal bd = new BigDecimal("9");
SqlBind bind = new SqlBind(Types.NUMERIC, bd);
PreparedStatement ps = Mockito.mock(PreparedStatement.class);
sql.writeBind(ps, 1, bind);
Mockito.verify(ps).setObject(1, bd, Types.NUMERIC, 0);
}
use of org.eclipse.scout.rt.server.jdbc.SqlBind in project scout.rt by eclipse.
the class AbstractSqlStyleTest method testWriteBindForLongVarBinary.
/**
* Test for {@link AbstractSqlStyle#writeBind} for null values with nulltype {@link Types.LONGVARBINARY}
*
* @throws SQLException
*/
@Test
public void testWriteBindForLongVarBinary() throws SQLException {
PreparedStatement ps = Mockito.mock(PreparedStatement.class);
SqlBind bind = new SqlBind(Types.LONGVARBINARY, null);
sql.writeBind(ps, 1, bind);
Mockito.verify(ps).setBytes(1, (byte[]) null);
}
use of org.eclipse.scout.rt.server.jdbc.SqlBind in project scout.rt by eclipse.
the class AbstractSqlStyleTest method testWriteBind.
/**
* Test for {@link AbstractSqlStyle#writeBind} for {@link BigDecimal}
*
* @throws SQLException
*/
@Test
public void testWriteBind() throws SQLException {
BigDecimal bd = new BigDecimal("9.123");
SqlBind bind = new SqlBind(Types.DECIMAL, bd);
PreparedStatement ps = Mockito.mock(PreparedStatement.class);
sql.writeBind(ps, 1, bind);
Mockito.verify(ps).setObject(1, bd, Types.DECIMAL, 3);
}
Aggregations