本文整理汇总了Java中org.dbunit.operation.DatabaseOperation.CLEAN_INSERT属性的典型用法代码示例。如果您正苦于以下问题:Java DatabaseOperation.CLEAN_INSERT属性的具体用法?Java DatabaseOperation.CLEAN_INSERT怎么用?Java DatabaseOperation.CLEAN_INSERT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.dbunit.operation.DatabaseOperation
的用法示例。
在下文中一共展示了DatabaseOperation.CLEAN_INSERT属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
@Before
public void setUp() throws Exception {
initialDataSet = new FlatXmlDataSetBuilder().build(new File("src/test/resources/test-data.xml"));
connection = new DatabaseConnection(DriverManager.getConnection(CONNECTION_URL, USER_NAME, PASSWORD));
final DatabaseOperation operation = DatabaseOperation.CLEAN_INSERT;
operation.execute(connection, initialDataSet);
connection.getConnection().createStatement().execute(
"insert into XML_TABLE_1(id, version, value_1, value_2, value_3, value_4, value_5) values(10, 'Record 10 version', 'Record 10 Value 1', 'Record 10 Value 2', 'Record 10 Value 3', 'Record 10 Value 4', 'Record 10 Value 5');");
connection.getConnection().commit();
connection.getConnection().createStatement().execute(
"merge into XML_TABLE_3(id, version, value_8, value_9) values(11, 'Record 11 version', 'Record 11 Value 8', 'Record 11 Value 9');");
connection.getConnection().commit();
assertThat(getRecordCountFromTable(connection, "XML_TABLE_1"), equalTo(4));
assertThat(getRecordCountFromTable(connection, "XML_TABLE_2"), equalTo(1));
assertThat(getRecordCountFromTable(connection, "XML_TABLE_3"), equalTo(1));
}
示例2: getDBOperation
/**
* Gets the Database operation
*
* @param operation
* @return
* @throws Exception
*/
private static DatabaseOperation getDBOperation(@NonNull String operation)
throws Exception {
switch (operation) {
case "INSERT":
return DatabaseOperation.INSERT;
case "CLEAN_INSERT":
return DatabaseOperation.CLEAN_INSERT;
case "UPDATE":
return DatabaseOperation.UPDATE;
case "REFRESH":
return DatabaseOperation.REFRESH;
case "DELETE":
return DatabaseOperation.DELETE;
case "DELETE_ALL":
return DatabaseOperation.DELETE_ALL;
case "TRUNCATE_TABLE":
return DatabaseOperation.TRUNCATE_TABLE;
case "NONE":
return DatabaseOperation.NONE;
default:
log.error("Unknown DB operation : " + operation);
throw new Exception("Unknown DB operation : " + operation);
}
}
示例3: getSetUpOperation
protected DatabaseOperation getSetUpOperation() throws Exception {
parseCreateTableScriptFile();
initSpringContext();
return new CompositeOperation(new DatabaseOperation[] { new DatabaseOperation() {
@Override
public void execute(IDatabaseConnection connection, IDataSet dataSet)
throws DatabaseUnitException, SQLException {
DatabaseConfig databaseConfig = connection.getConfig();
IStatementFactory statementFactory = (IStatementFactory) databaseConfig
.getProperty(DatabaseConfig.PROPERTY_STATEMENT_FACTORY);
IBatchStatement statement = statementFactory.createBatchStatement(connection);
try {
int count = 0;
for (SingleCreateTableScriptEntry entry : createdTableList) {
statement.addBatch(entry.getCreateTableScript());
count++;
}
if (count > 0) {
statement.executeBatch();
statement.clearBatch();
}
} finally {
statement.close();
}
}
}, DatabaseOperation.CLEAN_INSERT });
}
示例4: getSetUpOperation
protected DatabaseOperation getSetUpOperation()
throws Exception
{
if (!update) {
if (doCleanInsert())
{
return DatabaseOperation.CLEAN_INSERT;
}
return DatabaseOperation.REFRESH;
}
return DatabaseOperation.UPDATE;
}
示例5: cleanInsertStrategy
@Override
public DatabaseOperation cleanInsertStrategy() {
return DatabaseOperation.CLEAN_INSERT;
}
示例6: getSetUpOperation
@Override
protected DatabaseOperation getSetUpOperation() throws Exception {
return DatabaseOperation.CLEAN_INSERT;
}
示例7: getSetUpOperation
@Override
protected DatabaseOperation getSetUpOperation() throws Exception {
return DatabaseOperation.CLEAN_INSERT;
}