package com.alibaba.druid.util;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Properties;

import com.alibaba.druid.pool.DruidAbstractDataSource;
import com.alibaba.druid.pool.DruidDataSource;

import junit.framework.TestCase;

/**
 * @author lizongbo
 
 */
public class DruidDataSourceUtilsTest extends TestCase {

    public void testConfigFromProperties() {
        Properties properties = new Properties();
//DruidAbstractDataSource fields
        String druidDefaultAutoCommit = "true";
        properties.put("druid.defaultAutoCommit", druidDefaultAutoCommit);
        String druidDefaultReadOnly = "true";
        properties.put("druid.defaultReadOnly", druidDefaultReadOnly);
        String druidDefaultTransactionIsolation = "20240616";
        properties.put("druid.defaultTransactionIsolation", druidDefaultTransactionIsolation);
        String druidDefaultCatalog = "1@lizongbo";
        properties.put("druid.defaultCatalog", druidDefaultCatalog);
        String druidName = "name@lizongbo";
        properties.put("druid.name", druidName);
        String druidUsername = "3@lizongbo";
        properties.put("druid.username", druidUsername);
        String druidPassword = "4@lizongbo";
        properties.put("druid.password", druidPassword);
        String druidJdbcUrl = "jdbc:mock:xxx";
        properties.put("druid.url", druidJdbcUrl);
        String druidDriverClass = "org.h2.Driver";
        properties.put("druid.driverClassName", druidDriverClass);
        String druidDriverClassLoader = "@lizongbo";
        properties.put("druid.driverClassLoader", druidDriverClassLoader);
        String druidConnectProperties = "@lizongbo";
        properties.put("druid.connectProperties", druidConnectProperties);
        String druidPasswordCallback = "@lizongbo";
        properties.put("druid.passwordCallback", druidPasswordCallback);
        String druidUserCallback = "@lizongbo";
        properties.put("druid.userCallback", druidUserCallback);
        String druidInitialSize = "2";
        properties.put("druid.initialSize", druidInitialSize);
        String druidMaxActive = "8";
        properties.put("druid.maxActive", druidMaxActive);
        String druidMinIdle = "3";
        properties.put("druid.minIdle", druidMinIdle);
        String druidMaxIdle = "100";
        properties.put("druid.maxIdle", druidMaxIdle);
        String druidMaxWait = "3600";
        properties.put("druid.maxWait", druidMaxWait);
        String druidNotFullTimeoutRetryCount = "20";
        properties.put("druid.notFullTimeoutRetryCount", druidNotFullTimeoutRetryCount);
        String druidValidationQuery = "select 1";
        properties.put("druid.validationQuery", druidValidationQuery);
        String druidValidationQueryTimeout = "12";
        properties.put("druid.validationQueryTimeout", druidValidationQueryTimeout);
        String druidTestOnBorrow = "true";
        properties.put("druid.testOnBorrow", druidTestOnBorrow);
        String druidTestOnReturn = "true";
        properties.put("druid.testOnReturn", druidTestOnReturn);
        String druidTestWhileIdle = "true";
        properties.put("druid.testWhileIdle", druidTestWhileIdle);
        String druidPoolPreparedStatements = "true";
        properties.put("druid.poolPreparedStatements", druidPoolPreparedStatements);
        String druidSharePreparedStatements = "true";
        properties.put("druid.sharePreparedStatements", druidSharePreparedStatements);
        String druidMaxPoolPreparedStatementPerConnectionSize = "50";
        properties.put("druid.maxPoolPreparedStatementPerConnectionSize", druidMaxPoolPreparedStatementPerConnectionSize);
        String druidInited = "true";
        properties.put("druid.inited", druidInited);
        String druidInitExceptionThrow = "true";
        properties.put("druid.initExceptionThrow", druidInitExceptionThrow);
        String druidLogWriter = "@lizongbo";
        properties.put("druid.logWriter", druidLogWriter);
        String druidFilters = "wall";
        properties.put("druid.filters", druidFilters);
        String druidClearFiltersEnable = "true";
        properties.put("druid.clearFiltersEnable", druidClearFiltersEnable);
        String druidExceptionSorter = "@lizongbo";
        properties.put("druid.exceptionSorter", druidExceptionSorter);
        String druidDriver = "@lizongbo";
        properties.put("druid.driver", druidDriver);
        String druidConnectTimeout = "20240616";
        properties.put("druid.connectTimeout", druidConnectTimeout);
        String druidSocketTimeout = "20240616";
        properties.put("druid.socketTimeout", druidSocketTimeout);
        String druidConnectTimeoutStr = "@lizongbo";
        properties.put("druid.connectTimeoutStr", druidConnectTimeoutStr);
        String druidSocketTimeoutStr = "@lizongbo";
        properties.put("druid.socketTimeoutStr", druidSocketTimeoutStr);
        String druidQueryTimeout = "20240616";
        properties.put("druid.queryTimeout", druidQueryTimeout);
        String druidTransactionQueryTimeout = "20240616";
        properties.put("druid.transactionQueryTimeout", druidTransactionQueryTimeout);
        String druidCreateTimespan = "20240616";
        properties.put("druid.createTimespan", druidCreateTimespan);
        String druidMaxWaitThreadCount = "20240616";
        properties.put("druid.maxWaitThreadCount", druidMaxWaitThreadCount);
        String druidAccessToUnderlyingConnectionAllowed = "true";
        properties.put("druid.accessToUnderlyingConnectionAllowed", druidAccessToUnderlyingConnectionAllowed);
        String druidTimeBetweenEvictionRunsMillis = "20240616";
        properties.put("druid.timeBetweenEvictionRunsMillis", druidTimeBetweenEvictionRunsMillis);
        String druidNumTestsPerEvictionRun = "20240616";
        properties.put("druid.numTestsPerEvictionRun", druidNumTestsPerEvictionRun);
        String druidMinEvictableIdleTimeMillis = "20240616";
        properties.put("druid.minEvictableIdleTimeMillis", druidMinEvictableIdleTimeMillis);
        String druidMaxEvictableIdleTimeMillis = "20240616";
        properties.put("druid.maxEvictableIdleTimeMillis", druidMaxEvictableIdleTimeMillis);
        String druidKeepAliveBetweenTimeMillis = "20240616";
        properties.put("druid.keepAliveBetweenTimeMillis", druidKeepAliveBetweenTimeMillis);
        String druidPhyTimeoutMillis = "20240616";
        properties.put("druid.phyTimeoutMillis", druidPhyTimeoutMillis);
        String druidPhyMaxUseCount = "20240616";
        properties.put("druid.phyMaxUseCount", druidPhyMaxUseCount);
        String druidRemoveAbandoned = "true";
        properties.put("druid.removeAbandoned", druidRemoveAbandoned);
        String druidRemoveAbandonedTimeoutMillis = "20240616";
        properties.put("druid.removeAbandonedTimeoutMillis", druidRemoveAbandonedTimeoutMillis);
        String druidLogAbandoned = "true";
        properties.put("druid.logAbandoned", druidLogAbandoned);
        String druidMaxOpenPreparedStatements = "20240616";
        properties.put("druid.maxOpenPreparedStatements", druidMaxOpenPreparedStatements);
        String druidConnectionInitSqls = "@lizongbo";
        properties.put("druid.connectionInitSqls", druidConnectionInitSqls);
        String druidDbTypeName = "@lizongbo";
        properties.put("druid.dbTypeName", druidDbTypeName);
        String druidTimeBetweenConnectErrorMillis = "20240616";
        properties.put("druid.timeBetweenConnectErrorMillis", druidTimeBetweenConnectErrorMillis);
        String druidValidConnectionChecker = "@lizongbo";
        properties.put("druid.validConnectionChecker", druidValidConnectionChecker);
        String druidUsePingMethod = "true";
        properties.put("druid.usePingMethod", druidUsePingMethod);
        String druidActiveConnections = "@lizongbo";
        properties.put("druid.activeConnections", druidActiveConnections);
        String druidId = "20240616";
        properties.put("druid.id", druidId);
        String druidConnectionErrorRetryAttempts = "20240616";
        properties.put("druid.connectionErrorRetryAttempts", druidConnectionErrorRetryAttempts);
        String druidBreakAfterAcquireFailure = "true";
        properties.put("druid.breakAfterAcquireFailure", druidBreakAfterAcquireFailure);
        String druidTransactionThresholdMillis = "20240616";
        properties.put("druid.transactionThresholdMillis", druidTransactionThresholdMillis);
        String druidCreatedTime = "@lizongbo";
        properties.put("druid.createdTime", druidCreatedTime);
        String druidInitedTime = "@lizongbo";
        properties.put("druid.initedTime", druidInitedTime);
        String druidErrorCount = "20240616";
        properties.put("druid.errorCount", druidErrorCount);
        String druidDupCloseCount = "20240616";
        properties.put("druid.dupCloseCount", druidDupCloseCount);
        String druidStartTransactionCount = "20240616";
        properties.put("druid.startTransactionCount", druidStartTransactionCount);
        String druidCommitCount = "20240616";
        properties.put("druid.commitCount", druidCommitCount);
        String druidRollbackCount = "20240616";
        properties.put("druid.rollbackCount", druidRollbackCount);
        String druidCachedPreparedStatementHitCount = "20240616";
        properties.put("druid.cachedPreparedStatementHitCount", druidCachedPreparedStatementHitCount);
        String druidPreparedStatementCount = "20240616";
        properties.put("druid.preparedStatementCount", druidPreparedStatementCount);
        String druidClosedPreparedStatementCount = "20240616";
        properties.put("druid.closedPreparedStatementCount", druidClosedPreparedStatementCount);
        String druidCachedPreparedStatementCount = "20240616";
        properties.put("druid.cachedPreparedStatementCount", druidCachedPreparedStatementCount);
        String druidCachedPreparedStatementDeleteCount = "20240616";
        properties.put("druid.cachedPreparedStatementDeleteCount", druidCachedPreparedStatementDeleteCount);
        String druidCachedPreparedStatementMissCount = "20240616";
        properties.put("druid.cachedPreparedStatementMissCount", druidCachedPreparedStatementMissCount);
        String druidFilterChain = "@lizongbo";
        properties.put("druid.filterChain", druidFilterChain);
        String druidTransactionHistogram = "@lizongbo";
        properties.put("druid.transactionHistogram", druidTransactionHistogram);
        String druidDupCloseLogEnable = "true";
        properties.put("druid.dupCloseLogEnable", druidDupCloseLogEnable);
        String druidObjectName = "@lizongbo";
        properties.put("druid.objectName", druidObjectName);
        String druidExecuteCount = "20240616";
        properties.put("druid.executeCount", druidExecuteCount);
        String druidExecuteQueryCount = "20240616";
        properties.put("druid.executeQueryCount", druidExecuteQueryCount);
        String druidExecuteUpdateCount = "20240616";
        properties.put("druid.executeUpdateCount", druidExecuteUpdateCount);
        String druidExecuteBatchCount = "20240616";
        properties.put("druid.executeBatchCount", druidExecuteBatchCount);
        String druidCreateError = "@lizongbo";
        properties.put("druid.createError", druidCreateError);
        String druidLastError = "@lizongbo";
        properties.put("druid.lastError", druidLastError);
        String druidLastErrorTimeMillis = "20240616";
        properties.put("druid.lastErrorTimeMillis", druidLastErrorTimeMillis);
        String druidLastCreateError = "@lizongbo";
        properties.put("druid.lastCreateError", druidLastCreateError);
        String druidLastCreateErrorTimeMillis = "20240616";
        properties.put("druid.lastCreateErrorTimeMillis", druidLastCreateErrorTimeMillis);
        String druidLastCreateStartTimeMillis = "20240616";
        properties.put("druid.lastCreateStartTimeMillis", druidLastCreateStartTimeMillis);
        String druidIsOracle = "true";
        properties.put("druid.isOracle", druidIsOracle);
        String druidIsMySql = "true";
        properties.put("druid.isMySql", druidIsMySql);
        String druidUseOracleImplicitCache = "true";
        properties.put("druid.useOracleImplicitCache", druidUseOracleImplicitCache);
        String druidLock = "@lizongbo";
        properties.put("druid.lock", druidLock);
        String druidNotEmpty = "@lizongbo";
        properties.put("druid.notEmpty", druidNotEmpty);
        String druidEmpty = "@lizongbo";
        properties.put("druid.empty", druidEmpty);
        String druidActiveConnectionLock = "@lizongbo";
        properties.put("druid.activeConnectionLock", druidActiveConnectionLock);
        String druidCreateErrorCount = "20240616";
        properties.put("druid.createErrorCount", druidCreateErrorCount);
        String druidCreatingCount = "20240616";
        properties.put("druid.creatingCount", druidCreatingCount);
        String druidDirectCreateCount = "20240616";
        properties.put("druid.directCreateCount", druidDirectCreateCount);
        String druidCreateCount = "20240616";
        properties.put("druid.createCount", druidCreateCount);
        String druidDestroyCount = "20240616";
        properties.put("druid.destroyCount", druidDestroyCount);
        String druidCreateStartNanos = "20240616";
        properties.put("druid.createStartNanos", druidCreateStartNanos);
        String druidUseUnfairLock = "true";
        properties.put("druid.useUnfairLock", druidUseUnfairLock);
        String druidUseLocalSessionState = "true";
        properties.put("druid.useLocalSessionState", druidUseLocalSessionState);
        String druidKeepConnectionUnderlyingTransactionIsolation = "true";
        properties.put("druid.keepConnectionUnderlyingTransactionIsolation", druidKeepConnectionUnderlyingTransactionIsolation);
        String druidTimeBetweenLogStatsMillis = "20240616";
        properties.put("druid.timeBetweenLogStatsMillis", druidTimeBetweenLogStatsMillis);
        String druidStatLogger = "@lizongbo";
        properties.put("druid.statLogger", druidStatLogger);
        String druidAsyncCloseConnectionEnable = "true";
        properties.put("druid.asyncCloseConnectionEnable", druidAsyncCloseConnectionEnable);
        String druidMaxCreateTaskCount = "20240616";
        properties.put("druid.maxCreateTaskCount", druidMaxCreateTaskCount);
        String druidFailFast = "true";
        properties.put("druid.failFast", druidFailFast);
        String druidFailContinuous = "20240616";
        properties.put("druid.failContinuous", druidFailContinuous);
        String druidFailContinuousTimeMillis = "20240616";
        properties.put("druid.failContinuousTimeMillis", druidFailContinuousTimeMillis);
        String druidDestroyScheduler = "@lizongbo";
        properties.put("druid.destroyScheduler", druidDestroyScheduler);
        String druidCreateScheduler = "@lizongbo";
        properties.put("druid.createScheduler", druidCreateScheduler);
        String druidNetTimeoutExecutor = "@lizongbo";
        properties.put("druid.netTimeoutExecutor", druidNetTimeoutExecutor);
        String druidNetTimeoutError = "true";
        properties.put("druid.netTimeoutError", druidNetTimeoutError);
        String druidInitVariants = "true";
        properties.put("druid.initVariants", druidInitVariants);
        String druidInitGlobalVariants = "true";
        properties.put("druid.initGlobalVariants", druidInitGlobalVariants);
        String druidOnFatalError = "true";
        properties.put("druid.onFatalError", druidOnFatalError);
        String druidOnFatalErrorMaxActive = "20240616";
        properties.put("druid.onFatalErrorMaxActive", druidOnFatalErrorMaxActive);
        String druidFatalErrorCount = "20240616";
        properties.put("druid.fatalErrorCount", druidFatalErrorCount);
        String druidFatalErrorCountLastShrink = "20240616";
        properties.put("druid.fatalErrorCountLastShrink", druidFatalErrorCountLastShrink);
        String druidLastFatalErrorTimeMillis = "20240616";
        properties.put("druid.lastFatalErrorTimeMillis", druidLastFatalErrorTimeMillis);
        String druidLastFatalErrorSql = "@lizongbo";
        properties.put("druid.lastFatalErrorSql", druidLastFatalErrorSql);
        String druidLastFatalError = "@lizongbo";
        properties.put("druid.lastFatalError", druidLastFatalError);
        String druidKeepAliveError = "@lizongbo";
        properties.put("druid.keepAliveError", druidKeepAliveError);
        String druidConnectionIdSeed = "20240616";
        properties.put("druid.connectionIdSeed", druidConnectionIdSeed);
        String druidStatementIdSeed = "20240616";
        properties.put("druid.statementIdSeed", druidStatementIdSeed);
        String druidResultSetIdSeed = "20240616";
        properties.put("druid.resultSetIdSeed", druidResultSetIdSeed);
        String druidTransactionIdSeed = "20240616";
        properties.put("druid.transactionIdSeed", druidTransactionIdSeed);
        String druidMetaDataIdSeed = "20240616";
        properties.put("druid.metaDataIdSeed", druidMetaDataIdSeed);

        //DruidDataSource fields
        String druidRecycleErrorCount = "20240616";
        properties.put("druid.recycleErrorCount", druidRecycleErrorCount);
        String druidDiscardErrorCount = "20240616";
        properties.put("druid.discardErrorCount", druidDiscardErrorCount);
        String druidDiscardErrorLast = "@lizongbo";
        properties.put("druid.discardErrorLast", druidDiscardErrorLast);
        String druidConnectCount = "20240616";
        properties.put("druid.connectCount", druidConnectCount);
        String druidCloseCount = "20240616";
        properties.put("druid.closeCount", druidCloseCount);
        String druidConnectErrorCount = "20240616";
        properties.put("druid.connectErrorCount", druidConnectErrorCount);
        String druidRecycleCount = "20240616";
        properties.put("druid.recycleCount", druidRecycleCount);
        String druidRemoveAbandonedCount = "20240616";
        properties.put("druid.removeAbandonedCount", druidRemoveAbandonedCount);
        String druidNotEmptyWaitCount = "20240616";
        properties.put("druid.notEmptyWaitCount", druidNotEmptyWaitCount);
        String druidNotEmptySignalCount = "20240616";
        properties.put("druid.notEmptySignalCount", druidNotEmptySignalCount);
        String druidNotEmptyWaitNanos = "20240616";
        properties.put("druid.notEmptyWaitNanos", druidNotEmptyWaitNanos);
        String druidKeepAliveCheckCount = "20240616";
        properties.put("druid.keepAliveCheckCount", druidKeepAliveCheckCount);
        String druidActivePeak = "20240616";
        properties.put("druid.activePeak", druidActivePeak);
        String druidActivePeakTime = "20240616";
        properties.put("druid.activePeakTime", druidActivePeakTime);
        String druidPoolingPeak = "20240616";
        properties.put("druid.poolingPeak", druidPoolingPeak);
        String druidPoolingPeakTime = "20240616";
        properties.put("druid.poolingPeakTime", druidPoolingPeakTime);
        String druidKeepAliveCheckErrorCount = "20240616";
        properties.put("druid.keepAliveCheckErrorCount", druidKeepAliveCheckErrorCount);
        String druidKeepAliveCheckErrorLast = "@lizongbo";
        properties.put("druid.keepAliveCheckErrorLast", druidKeepAliveCheckErrorLast);
        String druidConnections = "@lizongbo";
        properties.put("druid.connections", druidConnections);
        String druidPoolingCount = "20240616";
        properties.put("druid.poolingCount", druidPoolingCount);
        String druidActiveCount = "20240616";
        properties.put("druid.activeCount", druidActiveCount);
        String druidCreateDirectCount = "20240616";
        properties.put("druid.createDirectCount", druidCreateDirectCount);
        String druidDiscardCount = "20240616";
        properties.put("druid.discardCount", druidDiscardCount);
        String druidNotEmptyWaitThreadCount = "20240616";
        properties.put("druid.notEmptyWaitThreadCount", druidNotEmptyWaitThreadCount);
        String druidNotEmptyWaitThreadPeak = "20240616";
        properties.put("druid.notEmptyWaitThreadPeak", druidNotEmptyWaitThreadPeak);
        String druidEvictConnections = "@lizongbo";
        properties.put("druid.evictConnections", druidEvictConnections);
        String druidKeepAliveConnections = "@lizongbo";
        properties.put("druid.keepAliveConnections", druidKeepAliveConnections);
        String druidNullConnections = "@lizongbo";
        properties.put("druid.nullConnections", druidNullConnections);
        String druidDestroySchedulerFuture = "@lizongbo";
        properties.put("druid.destroySchedulerFuture", druidDestroySchedulerFuture);
        String druidDestroyTask = "@lizongbo";
        properties.put("druid.destroyTask", druidDestroyTask);
        String druidCreateSchedulerFutures = "@lizongbo";
        properties.put("druid.createSchedulerFutures", druidCreateSchedulerFutures);
        String druidCreateConnectionThread = "@lizongbo";
        properties.put("druid.createConnectionThread", druidCreateConnectionThread);
        String druidDestroyConnectionThread = "@lizongbo";
        properties.put("druid.destroyConnectionThread", druidDestroyConnectionThread);
        String druidLogStatsThread = "@lizongbo";
        properties.put("druid.logStatsThread", druidLogStatsThread);
        String druidCreateTaskCount = "20240616";
        properties.put("druid.createTaskCount", druidCreateTaskCount);
        String druidCreateTaskIdSeed = "20240616";
        properties.put("druid.createTaskIdSeed", druidCreateTaskIdSeed);
        String druidCreateTasks = "@lizongbo";
        properties.put("druid.createTasks", druidCreateTasks);
        String druidEnable = "true";
        properties.put("druid.enable", druidEnable);
        String druidResetStatEnable = "true";
        properties.put("druid.resetStatEnable", druidResetStatEnable);
        String druidResetCount = "20240616";
        properties.put("druid.resetCount", druidResetCount);
        String druidInitStackTrace = "@lizongbo";
        properties.put("druid.initStackTrace", druidInitStackTrace);
        String druidClosing = "true";
        properties.put("druid.closing", druidClosing);
        String druidClosed = "true";
        properties.put("druid.closed", druidClosed);
        String druidCloseTimeMillis = "20240616";
        properties.put("druid.closeTimeMillis", druidCloseTimeMillis);
        String druidDataSourceStat = "@lizongbo";
        properties.put("druid.dataSourceStat", druidDataSourceStat);
        String druidUseGlobalDataSourceStat = "true";
        properties.put("druid.useGlobalDataSourceStat", druidUseGlobalDataSourceStat);
        String druidMbeanRegistered = "true";
        properties.put("druid.mbeanRegistered", druidMbeanRegistered);
        String druidLogDifferentThread = "true";
        properties.put("druid.logDifferentThread", druidLogDifferentThread);
        String druidKeepAlive = "true";
        properties.put("druid.keepAlive", druidKeepAlive);
        String druidAsyncInit = "true";
        properties.put("druid.asyncInit", druidAsyncInit);
        String druidKillWhenSocketReadTimeout = "true";
        properties.put("druid.killWhenSocketReadTimeout", druidKillWhenSocketReadTimeout);
        String druidCheckExecuteTime = "true";
        properties.put("druid.checkExecuteTime", druidCheckExecuteTime);
        String druidLoadSpifilterSkip = "true";
        properties.put("druid.loadSpifilterSkip", druidLoadSpifilterSkip);
        String druidDisableException = "@lizongbo";
        properties.put("druid.disableException", druidDisableException);
        String druidInstanceKey = "@lizongbo";
        properties.put("druid.instanceKey", druidInstanceKey);

        DruidDataSource dataSource = new DruidDataSource();
        dataSource.configFromPropeties(properties);
//DruidAbstractDataSource assertions
        assertEquals(druidDefaultAutoCommit, String.valueOf(dataSource.isDefaultAutoCommit()));
        assertEquals(druidName, String.valueOf(dataSource.getName()));
        assertEquals(druidUsername, String.valueOf(dataSource.getUsername()));
        assertEquals(druidPassword, String.valueOf(dataSource.getPassword()));
        assertEquals(druidJdbcUrl, String.valueOf(dataSource.getUrl()));
        assertEquals(druidDriverClass, String.valueOf(dataSource.getDriverClassName()));
        assertEquals(druidInitialSize, String.valueOf(dataSource.getInitialSize()));
        assertEquals(druidMaxActive, String.valueOf(dataSource.getMaxActive()));
        assertEquals(druidMinIdle, String.valueOf(dataSource.getMinIdle()));
        assertEquals(druidMaxWait, String.valueOf(dataSource.getMaxWait()));
        assertEquals(druidNotFullTimeoutRetryCount, String.valueOf(dataSource.getNotFullTimeoutRetryCount()));
        assertEquals(druidValidationQuery, String.valueOf(dataSource.getValidationQuery()));
        assertEquals(druidValidationQueryTimeout, String.valueOf(dataSource.getValidationQueryTimeout()));
        assertEquals(druidTestOnBorrow, String.valueOf(dataSource.isTestOnBorrow()));
        assertEquals(druidTestOnReturn, String.valueOf(dataSource.isTestOnReturn()));
        assertEquals(druidTestWhileIdle, String.valueOf(dataSource.isTestWhileIdle()));
        assertEquals(druidPoolPreparedStatements, String.valueOf(dataSource.isPoolPreparedStatements()));
        assertEquals(druidMaxPoolPreparedStatementPerConnectionSize, String.valueOf(dataSource.getMaxPoolPreparedStatementPerConnectionSize()));
        assertEquals(druidInitExceptionThrow, String.valueOf(dataSource.isInitExceptionThrow()));
        assertEquals(druidClearFiltersEnable, String.valueOf(dataSource.isClearFiltersEnable()));
        assertEquals(druidConnectTimeout, String.valueOf(dataSource.getConnectTimeout()));
        assertEquals(druidSocketTimeout, String.valueOf(dataSource.getSocketTimeout()));
        assertEquals(druidQueryTimeout, String.valueOf(dataSource.getQueryTimeout()));
        assertEquals(druidTransactionQueryTimeout, String.valueOf(dataSource.getTransactionQueryTimeout()));
        assertEquals(druidMaxWaitThreadCount, String.valueOf(dataSource.getMaxWaitThreadCount()));
        assertEquals(druidAccessToUnderlyingConnectionAllowed, String.valueOf(dataSource.isAccessToUnderlyingConnectionAllowed()));
        assertEquals(druidTimeBetweenEvictionRunsMillis, String.valueOf(dataSource.getTimeBetweenEvictionRunsMillis()));
        assertEquals(druidMinEvictableIdleTimeMillis, String.valueOf(dataSource.getMinEvictableIdleTimeMillis()));
        assertEquals(druidMaxEvictableIdleTimeMillis, String.valueOf(dataSource.getMaxEvictableIdleTimeMillis()));
        assertEquals(druidKeepAliveBetweenTimeMillis, String.valueOf(dataSource.getKeepAliveBetweenTimeMillis()));
        assertEquals(druidPhyTimeoutMillis, String.valueOf(dataSource.getPhyTimeoutMillis()));
        assertEquals(druidPhyMaxUseCount, String.valueOf(dataSource.getPhyMaxUseCount()));
        assertEquals(druidRemoveAbandoned, String.valueOf(dataSource.isRemoveAbandoned()));
        assertEquals(druidRemoveAbandonedTimeoutMillis, String.valueOf(dataSource.getRemoveAbandonedTimeoutMillis()));
        assertEquals(druidLogAbandoned, String.valueOf(dataSource.isLogAbandoned()));
        assertEquals(druidTimeBetweenConnectErrorMillis, String.valueOf(dataSource.getTimeBetweenConnectErrorMillis()));
        assertEquals(druidConnectionErrorRetryAttempts, String.valueOf(dataSource.getConnectionErrorRetryAttempts()));
        assertEquals(druidBreakAfterAcquireFailure, String.valueOf(dataSource.isBreakAfterAcquireFailure()));
        assertEquals(druidUseUnfairLock, String.valueOf(dataSource.isUseUnfairLock()));
        assertEquals(druidUseLocalSessionState, String.valueOf(dataSource.isUseLocalSessionState()));
        assertEquals(druidTimeBetweenLogStatsMillis, String.valueOf(dataSource.getTimeBetweenLogStatsMillis()));
        assertEquals(druidAsyncCloseConnectionEnable, String.valueOf(dataSource.isAsyncCloseConnectionEnable()));
        assertEquals(druidFailFast, String.valueOf(dataSource.isFailFast()));
        assertEquals(druidInitVariants, String.valueOf(dataSource.isInitVariants()));
        assertEquals(druidInitGlobalVariants, String.valueOf(dataSource.isInitGlobalVariants()));

//DruidDataSource assertions
        assertEquals(druidEnable, String.valueOf(dataSource.isEnable()));
        assertEquals(druidResetStatEnable, String.valueOf(dataSource.isResetStatEnable()));
        assertEquals(druidUseGlobalDataSourceStat, String.valueOf(dataSource.isUseGlobalDataSourceStat()));
        assertEquals(druidKeepAlive, String.valueOf(dataSource.isKeepAlive()));
        assertEquals(druidAsyncInit, String.valueOf(dataSource.isAsyncInit()));
        assertEquals(druidKillWhenSocketReadTimeout, String.valueOf(dataSource.isKillWhenSocketReadTimeout()));
        //assertEquals(druidCheckExecuteTime, String.valueOf(dataSource.isCheckExecuteTime()));
        //assertEquals(druidLoadSpifilterSkip, String.valueOf(dataSource.isLoadSpifilterSkip()));
    }

    public void testGenTestCode() {
        for (Field field : DruidAbstractDataSource.class.getDeclaredFields()) {
            if (Modifier.isStatic(field.getModifiers())) {
                continue;
            }
            String name = field.getName();
            String varName = "druid" + Character.toUpperCase(name.charAt(0)) + name.substring(1);
            Class t = field.getType();
            if (Long.class.equals(t) || long.class.equals(t) || Integer.class.equals(t) || int.class.equals(t)) {
                System.out.println("String " + varName + " =\"20240616\";");
            } else if (Boolean.class.equals(t) || boolean.class.equals(t)) {
                System.out.println("String " + varName + "=\"true\";");
            } else {
                System.out.println("String " + varName + "=\"@lizongbo\";");
            }
            System.out.println("properties.put(\"druid." + name + "\", " + varName + ");");
        }

        for (Field field : DruidAbstractDataSource.class.getDeclaredFields()) {
            if (Modifier.isStatic(field.getModifiers())) {
                continue;
            }
            String name = field.getName();
            String uname = Character.toUpperCase(name.charAt(0)) + name.substring(1);
            String varName = "druid" + uname;
            Class t = field.getType();
            if (Boolean.class.equals(t) || boolean.class.equals(t)) {
                System.out.println("assertEquals(" + varName + ", String.valueOf(dataSource.is" + uname + "()));");
            } else {
                System.out.println("assertEquals(" + varName + ", String.valueOf(dataSource.get" + uname + "()));");
            }
        }

        Properties properties = new Properties();
        String druidName = "ds@lizongbo";
        properties.put("druid.name", druidName);
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.configFromPropeties(properties);

    }
}