Search in sources :

Example 11 with JdbcSchema

use of com.google.gwtorm.jdbc.JdbcSchema in project gerrit by GerritCodeReview.

the class SchemaCreatorTest method getCauses_CreateSchema.

@Test
public void getCauses_CreateSchema() throws OrmException, SQLException, IOException {
    // Initially the schema should be empty.
    String[] types = { "TABLE", "VIEW" };
    try (JdbcSchema d = (JdbcSchema) db.open();
        ResultSet rs = d.getConnection().getMetaData().getTables(null, null, null, types)) {
        assertThat(rs.next()).isFalse();
    }
    // Create the schema using the current schema version.
    //
    db.create();
    db.assertSchemaVersion();
    // By default sitePath is set to the current working directory.
    //
    File sitePath = new File(".").getAbsoluteFile();
    if (sitePath.getName().equals(".")) {
        sitePath = sitePath.getParentFile();
    }
    assertThat(db.getSystemConfig().sitePath).isEqualTo(sitePath.getCanonicalPath());
}
Also used : JdbcSchema(com.google.gwtorm.jdbc.JdbcSchema) ResultSet(java.sql.ResultSet) File(java.io.File) Test(org.junit.Test)

Aggregations

JdbcSchema (com.google.gwtorm.jdbc.JdbcSchema)11 SqlDialect (com.google.gwtorm.schema.sql.SqlDialect)5 StatementExecutor (com.google.gwtorm.server.StatementExecutor)5 OrmException (com.google.gwtorm.server.OrmException)4 CurrentSchemaVersion (com.google.gerrit.reviewdb.client.CurrentSchemaVersion)3 JdbcExecutor (com.google.gwtorm.jdbc.JdbcExecutor)3 Connection (java.sql.Connection)3 Statement (java.sql.Statement)3 ResultSet (java.sql.ResultSet)2 SQLException (java.sql.SQLException)2 HashMap (java.util.HashMap)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 GeneralPreferencesInfo (com.google.gerrit.extensions.client.GeneralPreferencesInfo)1 Account (com.google.gerrit.reviewdb.client.Account)1 VersionedAccountPreferences (com.google.gerrit.server.account.VersionedAccountPreferences)1 MetaDataUpdate (com.google.gerrit.server.git.MetaDataUpdate)1 DialectPostgreSQL (com.google.gwtorm.schema.sql.DialectPostgreSQL)1 File (java.io.File)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1