@@ -0,0 +1,2932 @@
+/*%0A * Copyright 1999-2015 dangdang.com.%0A * %3Cp%3E%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A * %3C/p%3E%0A */%0A%0Apackage io.shardingjdbc.core.routing.router;%0A%0A%0Aimport io.shardingjdbc.core.api.HintManager;%0Aimport io.shardingjdbc.core.api.config.ShardingRuleConfiguration;%0Aimport io.shardingjdbc.core.api.config.TableRuleConfiguration;%0Aimport io.shardingjdbc.core.api.config.strategy.HintShardingStrategyConfiguration;%0Aimport io.shardingjdbc.core.fixture.OrderDatabaseHintShardingAlgorithm;%0Aimport io.shardingjdbc.core.hint.HintManagerHolder;%0Aimport io.shardingjdbc.core.parsing.parser.sql.dql.DQLStatement;%0Aimport io.shardingjdbc.core.parsing.parser.sql.dql.select.SelectStatement;%0Aimport io.shardingjdbc.core.rule.ShardingRule;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Collections;%0A%0Aimport static org.hamcrest.CoreMatchers.instanceOf;%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.junit.Assert.assertThat;%0A%0Apublic final class DatabaseHintSQLRouterTest %7B%0A%0A    private DatabaseHintSQLRouter databaseHintSQLRouter;%0A%0A    private ShardingRule shardingRule;%0A%0A    private boolean showSQL;%0A%0A    @Before%0A    public void setRouteRuleContext() %7B%0A        ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();%0A        TableRuleConfiguration tableRuleConfig = new TableRuleConfiguration();%0A        tableRuleConfig.setLogicTable(%22LOGIC_TABLE%22);%0A        tableRuleConfig.setActualDataNodes(%22ds$%7B0..1%7D.table_$%7B0..2%7D%22);%0A        shardingRuleConfig.getTableRuleConfigs().add(tableRuleConfig);%0A        shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new HintShardingStrategyConfiguration(new OrderDatabaseHintShardingAlgorithm()));%0A        shardingRule = new ShardingRule(shardingRuleConfig, Arrays.asList(%22ds0%22, %22ds1%22));%0A        showSQL=true;%0A        databaseHintSQLRouter = new DatabaseHintSQLRouter(shardingRule, showSQL);%0A    %7D%0A%0A    @Test%0A    public void assertParse() %7B%0A        assertThat(databaseHintSQLRouter.parse(%22select t from table t%22, false), instanceOf(SelectStatement.class));%0A    %7D%0A%0A    @Test%0A    public void assertRoute() %7B%0A        HintManager hintManager = HintManager.getInstance();%0A        hintManager.addDatabaseShardingValue(HintManagerHolder.DB_TABLE_NAME, HintManagerHolder.DB_COLUMN_NAME, 1);%0A        assertNotNull(databaseHintSQLRouter.route(%22select t from table t%22, Collections.emptyList(), new DQLStatement()));%0A    %7D%0A%7D

add test case