use of io.shardingjdbc.core.constant.ShardingProperties in project sharding-jdbc by shardingjdbc.
the class SpringBootShardingTest method assertWithShardingDataSource.
@Test
public void assertWithShardingDataSource() throws NoSuchFieldException, IllegalAccessException {
assertTrue(dataSource instanceof ShardingDataSource);
Field field = ShardingDataSource.class.getDeclaredField("shardingContext");
field.setAccessible(true);
ShardingContext shardingContext = (ShardingContext) field.get(dataSource);
for (DataSource each : shardingContext.getDataSourceMap().values()) {
assertThat(((BasicDataSource) each).getMaxTotal(), is(16));
}
assertTrue(shardingContext.isShowSQL());
Map<String, Object> configMap = new ConcurrentHashMap<>();
configMap.put("key1", "value1");
assertThat(ConfigMapContext.getInstance().getShardingConfig(), is(configMap));
Field propertiesField = ShardingDataSource.class.getDeclaredField("shardingProperties");
propertiesField.setAccessible(true);
ShardingProperties shardingProperties = (ShardingProperties) propertiesField.get(dataSource);
assertTrue((Boolean) shardingProperties.getValue(ShardingPropertiesConstant.SQL_SHOW));
assertThat((Integer) shardingProperties.getValue(ShardingPropertiesConstant.EXECUTOR_SIZE), is(100));
}
Aggregations