Commit 24050a12 authored by haocao's avatar haocao
Browse files

Add mssql test cases and test scope dependency.

parent 5b703313
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@
        <mysql-connector-java.version>5.1.30</mysql-connector-java.version>
        <h2.version>1.4.184</h2.version>
        <postgresql.version>9.1-901-1.jdbc4</postgresql.version>
        <mssql.version>6.1.7.jre7-preview</mssql.version>
        <junit.version>4.12</junit.version>
        <system-rules.version>1.16.0</system-rules.version>
        <hamcrest.version>1.3</hamcrest.version>
@@ -184,6 +185,12 @@
                <version>${postgresql.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>com.microsoft.sqlserver</groupId>
                <artifactId>mssql-jdbc</artifactId>
                <version>${mssql.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>org.hamcrest</groupId>
                <artifactId>hamcrest-library</artifactId>
+4 −0
Original line number Diff line number Diff line
@@ -54,6 +54,10 @@
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
        </dependency>
        <dependency>
            <groupId>com.microsoft.sqlserver</groupId>
            <artifactId>mssql-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
+6 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import com.dangdang.ddframe.rdb.integrate.sql.DatabaseTestSQL;
import com.dangdang.ddframe.rdb.integrate.sql.mysql.MySQLTestSQL;
import com.dangdang.ddframe.rdb.integrate.sql.oracle.OracleSQLTestSQL;
import com.dangdang.ddframe.rdb.integrate.sql.postgresql.PostgreSQLTestSQL;
import com.dangdang.ddframe.rdb.integrate.sql.sqlserver.SQLServerSQLTestSQL;
import com.dangdang.ddframe.rdb.sharding.constant.DatabaseType;
import org.apache.commons.dbcp.BasicDataSource;
import org.dbunit.DatabaseUnitException;
@@ -31,6 +32,7 @@ import org.dbunit.dataset.IDataSet;
import org.dbunit.dataset.ITable;
import org.dbunit.dataset.xml.FlatXmlDataSetBuilder;
import org.dbunit.ext.h2.H2Connection;
import org.dbunit.ext.mssql.MsSqlConnection;
import org.dbunit.ext.mysql.MySqlConnection;
import org.dbunit.ext.oracle.OracleConnection;
import org.dbunit.operation.DatabaseOperation;
@@ -104,6 +106,8 @@ public abstract class AbstractDBUnitTest {
                return new PostgreSQLTestSQL();
            case Oracle:
                return new OracleSQLTestSQL();
            case SQLServer:
                return new SQLServerSQLTestSQL();
            default:
                throw new UnsupportedOperationException(dbEnv.getDatabaseType().name());
        }
@@ -180,6 +184,8 @@ public abstract class AbstractDBUnitTest {
                return new DatabaseConnection(connection);
            case Oracle:
                return new OracleConnection(connection, "JDBC");
            case SQLServer:
                return new MsSqlConnection(connection);
            default: 
                throw new UnsupportedOperationException(dbEnv.getDatabaseType().name());
        }
+6 −0
Original line number Diff line number Diff line
@@ -69,6 +69,12 @@ public final class DataBaseEnvironment {
        USERNAME.put(DatabaseType.Oracle, "jdbc");
        PASSWORD.put(DatabaseType.Oracle, "jdbc");
        SCHEMA.put(DatabaseType.Oracle, "JDBC");
        
        DRIVER_CLASS_NAME.put(DatabaseType.SQLServer, com.microsoft.sqlserver.jdbc.SQLServerDriver.class.getName());
        URL.put(DatabaseType.SQLServer, "jdbc:sqlserver://db.mssql:1433;DatabaseName=db_0");
        USERNAME.put(DatabaseType.SQLServer, "sa");
        PASSWORD.put(DatabaseType.SQLServer, "Jdbc1234");
        SCHEMA.put(DatabaseType.SQLServer, null);
    }
    
    public String getDriverClassName() {
+31 −0
Original line number Diff line number Diff line
/*
 * Copyright 1999-2015 dangdang.com.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * </p>
 */

package com.dangdang.ddframe.rdb.integrate.sql.sqlserver;

import com.dangdang.ddframe.rdb.integrate.sql.AbstractDatabaseTestSQL;

public final class SQLServerSQLTestSQL extends AbstractDatabaseTestSQL {
    
    private static final String SELECT_LIMIT_WITH_BINDING_TABLE_SQL = "SELECT i.* FROM t_order o JOIN t_order_item i ON o.user_id = i.user_id AND o.order_id = i.order_id"
            + " WHERE o.user_id IN (%s, %s) AND o.order_id BETWEEN %s AND %s ORDER BY i.item_id DESC OFFSET %s LIMIT %s";
    
    @Override
    public String getSelectLimitWithBindingTableSql() {
        return SELECT_LIMIT_WITH_BINDING_TABLE_SQL;
    }
}
Loading