@@ -0,0 +1,2393 @@
+package io.mycat.route;%0A%0Aimport java.sql.SQLNonTransientException;%0Aimport java.util.Map;%0A%0Aimport org.junit.Test;%0A%0Aimport io.mycat.SimpleCachePool;%0Aimport io.mycat.cache.LayerCachePool;%0Aimport io.mycat.config.loader.SchemaLoader;%0Aimport io.mycat.config.loader.xml.XMLSchemaLoader;%0Aimport io.mycat.config.model.SchemaConfig;%0Aimport io.mycat.config.model.SystemConfig;%0Aimport io.mycat.route.RouteResultset;%0Aimport io.mycat.route.RouteStrategy;%0Aimport io.mycat.route.factory.RouteStrategyFactory;%0Aimport junit.framework.Assert;%0A%0Apublic class DruidMysqlHavingTest%0A%7B%0A%09protected Map%3CString, SchemaConfig%3E schemaMap;%0A%09protected LayerCachePool cachePool = new SimpleCachePool();%0A    protected RouteStrategy routeStrategy = RouteStrategyFactory.getRouteStrategy(%22druidparser%22);%0A%0A%09public DruidMysqlHavingTest() %7B%0A%09%09String schemaFile = %22/route/schema.xml%22;%0A%09%09String ruleFile = %22/route/rule.xml%22;%0A%09%09SchemaLoader schemaLoader = new XMLSchemaLoader(schemaFile, ruleFile);%0A%09%09schemaMap = schemaLoader.getSchemas();%0A%09%7D%0A%0A%09@Test%0A%09public void testHaving() throws SQLNonTransientException %7B%0A%09%09String sql = %22select avg(offer_id) avgofferid, member_id from offer_detail group by member_id having avgofferid %3E 100%22;%0A%09%09SchemaConfig schema = schemaMap.get(%22cndb%22);%0A        RouteResultset rrs = routeStrategy.route(new SystemConfig(), schema, -1, sql, null,%0A                null, cachePool);%0A        Assert.assertEquals(3, rrs.getSqlMerge().getHavingColsName().length);%0A%0A%09%09sql = %22select avg(offer_id) avgofferid, member_id from offer_detail group by member_id having avg(offer_id) %3E 100%22;%0A        rrs = routeStrategy.route(new SystemConfig(), schema, -1, sql, null,%0A                null, cachePool);%0A        Assert.assertEquals(3, rrs.getSqlMerge().getHavingColsName().length);%0A%0A        sql = %22select count(offer_id) countofferid, member_id from offer_detail group by member_id having countofferid %3E 100%22;%0A        rrs = routeStrategy.route(new SystemConfig(), schema, -1, sql, null,%0A                null, cachePool);%0A        Assert.assertEquals(3, rrs.getSqlMerge().getHavingColsName().length);%0A%0A        sql = %22select count(offer_id) countofferid, member_id from offer_detail group by member_id having count(offer_id) %3E 100%22;%0A        rrs = routeStrategy.route(new SystemConfig(), schema, -1, sql, null,%0A                null, cachePool);%0A        Assert.assertEquals(3, rrs.getSqlMerge().getHavingColsName().length);%0A%0A%09%7D%0A%7D%0A

test having clauses, like: "select avg(offer_id) avgofferid, member_id from offer_detail group by member_id having avgofferid > 100" "select avg(offer_id) avgofferid, member_id from offer_detail group by member_id having avg(offer_id) > 100" "select count(offer_id) countofferid, member_id from offer_detail group by member_id having countofferid > 100" "select count(offer_id) countofferid, member_id from offer_detail group by member_id having count(offer_id) > 100"