use of org.testng.annotations.BeforeGroups in project latke by b3log.
the class JdbcRepositoryTestCase method createTestTable.
/**
* createTestTable.
*/
@BeforeGroups(groups = { "jdbc" })
public void createTestTable() {
final StringBuffer createTableSql = new StringBuffer();
createTableSql.append(" IF NOT EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'[dbo].[basetable]')" + " AND OBJECTPROPERTY(id, N'IsUserTable') = 1) CREATE TABLE [dbo].[basetable]");
createTableSql.append(" ( ");
createTableSql.append(" oId VARCHAR(200) NOT NULL, ");
createTableSql.append(" col1 INT, ");
createTableSql.append(" col2 VARCHAR(200), ");
createTableSql.append(" col3 DECIMAL(10,2), ");
createTableSql.append(" col4 CHAR(1), ");
createTableSql.append(" PRIMARY KEY (oId) ");
createTableSql.append(" ) ");
createTableSql.append("; ");
try {
final Connection connection = Connections.getConnection();
JdbcUtil.executeSql(createTableSql.toString(), connection);
connection.commit();
connection.close();
Latkes.initRuntimeEnv();
} catch (final Exception e) {
e.printStackTrace();
ifRun = false;
System.out.println("skip JdbcRepositoryTestCase test");
} catch (final ExceptionInInitializerError e) {
ifRun = false;
System.out.println("skip JdbcRepositoryTestCase test");
}
final List<RepositoryDefinition> repositoryDefinitions = new ArrayList<>();
final RepositoryDefinition repositoryDefinition = new RepositoryDefinition();
repositoryDefinitions.add(repositoryDefinition);
JdbcRepositories.setRepositoryDefinitions(repositoryDefinitions);
final List<FieldDefinition> dList = new ArrayList<>();
FieldDefinition definition = new FieldDefinition();
definition.setName("oId");
definition.setIsKey(true);
definition.setType("String");
dList.add(definition);
definition = new FieldDefinition();
definition.setName("col1");
definition.setType("int");
dList.add(definition);
definition = new FieldDefinition();
definition.setName("col2");
definition.setType("String");
dList.add(definition);
definition = new FieldDefinition();
definition.setName("col3");
definition.setType("double");
dList.add(definition);
definition = new FieldDefinition();
definition.setName("col4");
definition.setType("boolean");
dList.add(definition);
repositoryDefinition.setName("basetable");
repositoryDefinition.setKeys(dList);
}
Aggregations