org.test4j.module.database.config.DbConfigKey Maven / Gradle / Ivy
package org.test4j.module.database.config;
import cn.org.atool.fluent.mybatis.metadata.DbType;
import java.util.HashMap;
import java.util.Map;
import static cn.org.atool.fluent.mybatis.metadata.DbFeatures.DF_H2;
import static cn.org.atool.fluent.mybatis.metadata.DbFeatures.DF_MYSQL;
/**
* test4j 数据库配置常量
*
* @author darui.wudr
*/
public interface DbConfigKey {
String DB_DATASOURCE_DEFAULT = "dataSource";
String DB_DATASOURCE_DEFAULT_NAME = "db.default";
String DB_DATASOURCE_LIST = "db.dataSources";
String CONNECT_ONLY_TEST_DB = "database.only.test";
String DRIVER = "driver";
String URL = "url";
String USERNAME = "username";
String PASSWORD = "password";
String SCHEMA = "schema";
String MysqlDriver = "com.mysql.jdbc.Driver";
/**
* 数据库默认配置值
*/
Map> DB_DEFAULT = new HashMap>() {
{
this.put(DbType.H2, new HashMap() {
{
this.put(DRIVER, DF_H2.getDriver());
this.put(URL, "jdbc:h2:mem:test;DATABASE_TO_UPPER=false;MODE=MySQL;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=false;INIT=CREATE SCHEMA IF NOT EXISTS test\\;SET SCHEMA test");
this.put(USERNAME, "sa");
this.put(PASSWORD, "sa");
this.put(SCHEMA, "");
}
});
this.put(DbType.MYSQL, new HashMap() {
{
this.put(DRIVER, DF_MYSQL.getDriver());
this.put(URL, "jdbc:mysql://localhost:3306/ut?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true");
this.put(USERNAME, "root");
this.put(PASSWORD, "password");
this.put(SCHEMA, "ut");
}
});
this.put(DbType.MARIADB, new HashMap() {
{
this.put(DRIVER, MysqlDriver);
this.put(URL, "");
this.put(USERNAME, "sa");
this.put(PASSWORD, "sa");
this.put(SCHEMA, "test");
}
});
}
};
}