Commit e11e0fa9 authored by haocao's avatar haocao
Browse files

Refactor sharding test cases 4th.

parent 6f37511f
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -82,8 +82,10 @@ public class PostgreSQLSelectParser extends AbstractSelectParser {
                break;
            }
        }
        if (offset.isPresent() || rowCount.isPresent()) {
            setLimit(offset, rowCount);
        }
    }
    
    private Optional<LimitValue> buildRowCount() {
        int parameterIndex = getParametersIndex();
+16 −14
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ public abstract class AbstractDBUnitTest {
    }
    
    private static void createSchema() {
        if (H2 == CURRENT_DB_TYPE) {
            try {
                Connection conn;
                for (int i = 0; i < 10; i++) {
@@ -87,6 +88,7 @@ public abstract class AbstractDBUnitTest {
                ex.printStackTrace();
            }
        }
    }
    
    @Before
    public final void importDataSet() throws Exception {
@@ -102,8 +104,8 @@ public abstract class AbstractDBUnitTest {
    
    protected abstract List<String> getDataSetFiles();
    
    protected final String currentDbType() {
        return H2 == CURRENT_DB_TYPE ? "mysql" : CURRENT_DB_TYPE.name().toLowerCase();
    protected final DatabaseType currentDbType() {
        return H2 == CURRENT_DB_TYPE ? DatabaseType.MySQL : CURRENT_DB_TYPE;
    }
    
    protected final boolean isAliasSupport() {
+1 −1
Original line number Diff line number Diff line
@@ -59,7 +59,7 @@ public class ShardingDatabaseOnlyForPreparedStatementWithSelectTest extends Abst
    @Test
    public void assertSelectLimitWithBindingTable() throws SQLException, DatabaseUnitException {
        String expectedDataSetFile = "integrate/dataset/db/expect/select/SelectLimitWithBindingTable.xml";
        if (PostgreSQL.name().equalsIgnoreCase(currentDbType())) {
        if (PostgreSQL == currentDbType()) {
            assertDataSet(expectedDataSetFile, getShardingDataSource().getConnection(),
                    "t_order_item", replacePreparedStatement(getDatabaseTestSQL().getSelectLimitWithBindingTableSql()), 10, 19, 1000, 1909, 1.5, 2.4);
        } else {
+2 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

package com.dangdang.ddframe.rdb.integrate.single;

import com.dangdang.ddframe.rdb.sharding.constant.DatabaseType;
import org.dbunit.DatabaseUnitException;
import org.junit.Test;

@@ -26,7 +27,7 @@ public final class SingleResultSetWithPreparedStatementTest extends AbstractSing
    
    @Test
    public void assertSelectWithRowCountAndOffset() throws SQLException, DatabaseUnitException {
        if ("mysql".equals(currentDbType())) {
        if (DatabaseType.MySQL == currentDbType()) {
            String sql = "SELECT o.* FROM t_order o WHERE o.user_id = ? ORDER BY o.order_id limit ?, ?";
            String expectedDataSetFile = "integrate/dataset/single/expect/SelectWithLimit.xml";
            assertDataSet(expectedDataSetFile, getShardingDataSource().getConnection(), "t_order", sql, 10, 2, 4);
+2 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@

package com.dangdang.ddframe.rdb.integrate.single;

import com.dangdang.ddframe.rdb.sharding.constant.DatabaseType;
import org.dbunit.DatabaseUnitException;
import org.junit.Test;

@@ -26,7 +27,7 @@ public final class SingleResultSetWithStatementTest extends AbstractSingleResult
    
    @Test
    public void assertSelectWithRowCountAndOffset() throws SQLException, DatabaseUnitException {
        if ("mysql".equals(currentDbType())) {
        if (DatabaseType.MySQL == currentDbType()) {
            String sql = "SELECT o.* FROM t_order o WHERE o.user_id = %s ORDER BY o.order_id limit %s, %s";
            String expectedDataSetFile = "integrate/dataset/single/expect/SelectWithLimit.xml";
            assertDataSet(expectedDataSetFile, getShardingDataSource().getConnection(), "t_order", String.format(sql, 10, 2, 4));
Loading