Search in sources :

Example 21 with BeforeGroups

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);
}
Also used : Connection(java.sql.Connection) ArrayList(java.util.ArrayList) BeforeGroups(org.testng.annotations.BeforeGroups)

Aggregations

BeforeGroups (org.testng.annotations.BeforeGroups)21 SSHCommandResult (com.redhat.qe.tools.SSHCommandResult)11 BugzillaAPIException (com.redhat.qe.auto.bugzilla.BugzillaAPIException)7 SkipException (org.testng.SkipException)7 Series (com.axibase.tsd.api.model.series.Series)4 File (java.io.File)4 ArrayList (java.util.ArrayList)4 Sample (com.axibase.tsd.api.model.series.Sample)2 Date (java.util.Date)2 JSONObject (org.json.JSONObject)2 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 Connection (java.sql.Connection)1 HashMap (java.util.HashMap)1 JSONArray (org.json.JSONArray)1 AfterGroups (org.testng.annotations.AfterGroups)1