Unverified Commit f556b332 authored by 张亮's avatar 张亮 Committed by GitHub
Browse files

Merge pull request #1009 from tristaZero/dev

Rewrite DCL IntegrateTestCases
parents 4402cac0 5dfedf4e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -222,6 +222,6 @@ public final class IntegrateTestCasesLoader {
     * @return count of all data set test cases
     */
    public int countAllDataSetTestCases() {
        return dqlIntegrateTestCaseMap.size() + dmlIntegrateTestCaseMap.size() + ddlIntegrateTestCaseMap.size();
        return dqlIntegrateTestCaseMap.size() + dmlIntegrateTestCaseMap.size() + ddlIntegrateTestCaseMap.size() + dclIntegrateTestCaseMap.size();
    }
}
+0 −12
Original line number Diff line number Diff line
@@ -20,8 +20,6 @@ package io.shardingsphere.dbtest.cases.assertion.dcl;
import io.shardingsphere.dbtest.cases.assertion.root.IntegrateTestCaseAssertion;
import lombok.Getter;

import javax.xml.bind.annotation.XmlAttribute;

/**
 * JAXB definition of DCL integrate test case assertion.
 *
@@ -29,14 +27,4 @@ import javax.xml.bind.annotation.XmlAttribute;
 */
@Getter
public final class DCLIntegrateTestCaseAssertion extends IntegrateTestCaseAssertion {
    
    @XmlAttribute(name = "init-sqls")
    private String initSQLs;
    
    @XmlAttribute(name = "clean-sqls")
    private String cleanSQLs;
    
    @XmlAttribute(name = "db-types")
    private String dbTypes;
    
}
+70 −0
Original line number Diff line number Diff line
/*
 * Copyright 2016-2018 shardingsphere.io.
 * <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 io.shardingsphere.dbtest.cases.authority;

import io.shardingsphere.core.constant.DatabaseType;
import io.shardingsphere.dbtest.cases.authority.sql.SQLSet;
import io.shardingsphere.dbtest.cases.authority.sql.SQLType;
import lombok.Getter;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Collection;
import java.util.LinkedList;

/**
 * Authority root xml entry.
 * 
 * @author panjuan
 */
@Getter
//@Setter
@XmlRootElement(name = "authority")
public final class Authority {
    
    @XmlElement(name = "sqlset")
    private Collection<SQLSet> SQLSets = new LinkedList<>();
    
    /**
     * Get init sqls of this data base type.
     *
     * @param databaseType data base type
     * @return init sqls of this data base type
     */
    public Collection<String> getInitSQLs(DatabaseType databaseType) {
        Collection<String> result = new LinkedList<>();
        for (SQLSet each : SQLSets) {
            result.addAll(each.getAllSQLContent(SQLType.Init, databaseType));
        }
        return result;
    }
    
    /**
     * Get clean sqls of this data base type.
     *
     * @param databaseType data base type
     * @return clean sqls of this data base type
     */
    public Collection<String> getCleanSQLs(DatabaseType databaseType) {
        Collection<String> result = new LinkedList<>();
        for (SQLSet each : SQLSets) {
            result.addAll(each.getAllSQLContent(SQLType.Clean, databaseType));
        }
        return result;
    }
}
+37 −0
Original line number Diff line number Diff line
/*
 * Copyright 2016-2018 shardingsphere.io.
 * <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 io.shardingsphere.dbtest.cases.authority.sql;

/**
 * Authority SQL xml entry.
 *
 * @author panjuan
 */
import lombok.Getter;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;

@Getter
@XmlAccessorType(XmlAccessType.FIELD)
public final class SQL {
    
    @XmlAttribute(name = "content")
    private String content;
}
+75 −0
Original line number Diff line number Diff line
/*
 * Copyright 2016-2018 shardingsphere.io.
 * <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 io.shardingsphere.dbtest.cases.authority.sql;

import io.shardingsphere.core.constant.DatabaseType;
import lombok.Getter;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;

/**
 * Authority SQL set xml entry.
 *
 * @author panjuan
 */
@Getter
@XmlAccessorType(XmlAccessType.FIELD)
public final class SQLSet {
    
    @XmlAttribute(name = "db-types")
    private String dbTypes;
    
    @XmlAttribute(name = "sql-type")
    private SQLType sqlType;
    
    @XmlElement(name = "sql")
    private Collection<SQL> SQLs = new LinkedList<>();
    
    private Collection<DatabaseType> getDatabaseTypeList() {
        if (null == dbTypes) {
            return Arrays.asList(DatabaseType.MySQL, DatabaseType.Oracle, DatabaseType.H2, DatabaseType.PostgreSQL, DatabaseType.SQLServer);
        }
        Collection<DatabaseType> result = new LinkedList<>();
        for (String each : dbTypes.split(",")) {
            result.add(DatabaseType.valueOf(each));
        }
        return result;
    }
    
    /**
     * Get all sqls content.
     *
     * @return sqls content
     */
    public Collection<String> getAllSQLContent(final SQLType sqlType, final DatabaseType databaseType ) {
        Collection<String> result = new LinkedList<>();
        if (this.sqlType != sqlType || !getDatabaseTypeList().contains(databaseType)) {
            return result;
        }
        for (SQL each : SQLs) {
            result.add(each.getContent());
        }
        return result;
    }
}
Loading