use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalDirectClientTestStub method batchUpdateTestWithoutRollback.
// The SQL server does not support auto commit for batch update
@Test
public void batchUpdateTestWithoutRollback() throws SQLException {
if (diff.category == DatabaseCategory.SqlServer)
return;
String[] sqls = new String[] { "DELETE FROM " + TABLE_NAME + " WHERE ID = 1", "DELETE FROM " + TABLE_NAME + " WHERE _ID = 2", "DELETE FROM " + TABLE_NAME + " WHERE ID = 3" };
DalHints hints = new DalHints();
hints.set(DalHintEnum.forceAutoCommit);
try {
client.batchUpdate(sqls, hints);
Assert.fail();
} catch (Exception e) {
}
List<ClientTestModel> models = this.queryModelsByIds();
Assert.assertEquals(3 - 1, models.size());
}
use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalQueryDaoTestStub method testQueryFirstNullableSuccess.
/**
* Test query for first success
* @throws SQLException
*/
@Test
public void testQueryFirstNullableSuccess() throws SQLException {
String sql = "SELECT * FROM " + TABLE_NAME + " WHERE id = 1";
StatementParameters param = new StatementParameters();
DalHints hints = new DalHints();
ClientTestModel model = client.queryFirstNullable(sql, param, hints, mapper);
Assert.assertEquals(1, model.getId().intValue());
}
use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalQueryDaoTestStub method testQueryFromSuccess.
/**
* Test query for From success
* @throws SQLException
*/
@Test
public void testQueryFromSuccess() throws SQLException {
String sql = "SELECT * FROM " + TABLE_NAME;
StatementParameters param = new StatementParameters();
DalHints hints = new DalHints();
List<ClientTestModel> models = client.queryFrom(sql, param, hints, mapper, 0, 10);
Assert.assertEquals(10, models.size());
Assert.assertEquals(1, models.get(0).getId().intValue());
List<ClientTestModel> models_2 = client.queryFrom(sql, param, hints, mapper, 100, 10);
Assert.assertEquals(10, models_2.size());
Assert.assertEquals(101, models_2.get(0).getId().intValue());
}
use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalQueryDaoTestStub method testQueryTopFailed.
/**
* Test query for Top failed
* @throws SQLException
*/
@Test
public void testQueryTopFailed() throws SQLException {
String sql = "SELECT * FROM " + TABLE_NAME + " WHERE iid = -1";
StatementParameters param = new StatementParameters();
DalHints hints = new DalHints();
try {
List<ClientTestModel> models = client.queryTop(sql, param, hints, mapper, 1000);
Assert.fail();
} catch (Exception e) {
}
}
use of test.com.ctrip.platform.dal.dao.unitbase.ClientTestModel in project dal by ctripcorp.
the class DalQueryDaoTestStub method testQueryWithCallback.
/**
* Test the query function with callback
* @throws SQLException
*/
@Test
public void testQueryWithCallback() throws SQLException {
String sql = "SELECT * FROM " + TABLE_NAME + " WHERE id = 1";
final ClientTestModel model = new ClientTestModel();
DalRowCallback callback = new DalRowCallback() {
@Override
public void process(ResultSet rs) throws SQLException {
model.setId(rs.getInt(1));
model.setQuantity(rs.getInt(2));
model.setType(rs.getShort(3));
model.setAddress(rs.getString(4));
model.setLastChanged(rs.getTimestamp(5));
}
};
StatementParameters param = new StatementParameters();
DalHints hints = new DalHints();
client.query(sql, param, hints, callback);
Assert.assertEquals(1, model.getId().intValue());
}
Aggregations