Search in sources :

Example 1 with YamlShardingConfiguration

use of io.shardingjdbc.core.yaml.sharding.YamlShardingConfiguration in project sharding-jdbc by shardingjdbc.

the class SQLRewriteEngineTest method setUp.

@Before
public void setUp() throws IOException {
    URL url = SQLRewriteEngineTest.class.getClassLoader().getResource("yaml/rewrite-rule.yaml");
    Preconditions.checkNotNull(url, "Cannot found rewrite rule yaml configuration.");
    YamlShardingConfiguration yamlShardingConfig = YamlShardingConfiguration.unmarshal(new File(url.getFile()));
    shardingRule = yamlShardingConfig.getShardingRule(yamlShardingConfig.getDataSources().keySet());
    selectStatement = new SelectStatement();
    tableTokens = new HashMap<>(1, 1);
    tableTokens.put("table_x", "table_1");
}
Also used : SelectStatement(io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement) YamlShardingConfiguration(io.shardingjdbc.core.yaml.sharding.YamlShardingConfiguration) File(java.io.File) URL(java.net.URL) Before(org.junit.Before)

Example 2 with YamlShardingConfiguration

use of io.shardingjdbc.core.yaml.sharding.YamlShardingConfiguration in project sharding-jdbc by shardingjdbc.

the class AbstractBaseIntegrateSQLParsingTest method buildShardingRule.

private static ShardingRule buildShardingRule() throws IOException {
    URL url = AbstractBaseIntegrateSQLParsingTest.class.getClassLoader().getResource("yaml/parser-rule.yaml");
    Preconditions.checkNotNull(url, "Cannot found parser rule yaml configuration.");
    YamlShardingConfiguration yamlShardingConfig = YamlShardingConfiguration.unmarshal(new File(url.getFile()));
    return yamlShardingConfig.getShardingRule(yamlShardingConfig.getDataSources().keySet());
}
Also used : YamlShardingConfiguration(io.shardingjdbc.core.yaml.sharding.YamlShardingConfiguration) File(java.io.File) URL(java.net.URL)

Aggregations

YamlShardingConfiguration (io.shardingjdbc.core.yaml.sharding.YamlShardingConfiguration)2 File (java.io.File)2 URL (java.net.URL)2 SelectStatement (io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement)1 Before (org.junit.Before)1