use of mondrian.spi.impl.MicrosoftSqlServerDialect in project mondrian by pentaho.
the class DialectTest method testDialectVsDatabaseProduct.
public void testDialectVsDatabaseProduct() throws SQLException {
final Dialect dialect = getDialect();
final Dialect.DatabaseProduct databaseProduct = dialect.getDatabaseProduct();
final DatabaseMetaData databaseMetaData = getConnection().getMetaData();
switch(databaseProduct) {
case MARIADB:
// Dialect has identified that it is MariaDB.
assertTrue(dialect instanceof MySqlDialect);
assertFalse(dialect instanceof InfobrightDialect);
assertTrue(dialect instanceof MariaDBDialect);
assertFalse(MySqlDialect.isInfobright(databaseMetaData));
assertEquals("MariaDB", databaseMetaData.getDatabaseProductName());
break;
case MYSQL:
// Dialect has identified that it is MySQL.
assertTrue(dialect instanceof MySqlDialect);
assertFalse(dialect instanceof InfobrightDialect);
assertFalse(MySqlDialect.isInfobright(databaseMetaData));
assertEquals("MySQL", databaseMetaData.getDatabaseProductName());
break;
case HIVE:
// Dialect has identified that it is Hive.
assertTrue(dialect instanceof HiveDialect);
break;
case INFOBRIGHT:
// Dialect has identified that it is MySQL.
assertTrue(dialect instanceof MySqlDialect);
assertTrue(dialect instanceof InfobrightDialect);
assertTrue(MySqlDialect.isInfobright(databaseMetaData));
assertEquals("MySQL", databaseMetaData.getDatabaseProductName());
break;
case POSTGRESQL:
// Dialect has identified that it is PostgreSQL.
assertTrue(dialect instanceof PostgreSqlDialect);
assertFalse(dialect instanceof NetezzaDialect);
assertTrue(databaseMetaData.getDatabaseProductName().indexOf("PostgreSQL") >= 0);
break;
case MSSQL:
// Dialect has identified that it is MSSQL.
assertTrue(dialect instanceof MicrosoftSqlServerDialect);
assertTrue(databaseMetaData.getDatabaseProductName().contains("Microsoft"));
break;
case NETEZZA:
// Dialect has identified that it is Netezza and a sub class of
// PostgreSql.
assertTrue(dialect instanceof PostgreSqlDialect);
assertTrue(dialect instanceof NetezzaDialect);
assertTrue(databaseMetaData.getDatabaseProductName().indexOf("Netezza") >= 0);
break;
case NUODB:
// Dialect has identified that it is NUODB.
assertTrue(dialect instanceof NuoDbDialect);
assertTrue(databaseMetaData.getDatabaseProductName().contains("NuoDB"));
break;
case GOOGLEBIGQUERY:
assertTrue(dialect instanceof GoogleBigQueryDialect);
assertTrue(databaseMetaData.getDatabaseProductName().contains("Google BigQuery"));
break;
default:
// Neither MySQL nor Infobright.
assertFalse(dialect instanceof MySqlDialect);
assertFalse(dialect instanceof InfobrightDialect);
assertNotSame("MySQL", databaseMetaData.getDatabaseProductName());
break;
}
}
Aggregations