未验证 提交 a67c09f9 编写于 作者: L Liang Zhang 提交者: GitHub

Merge pull request #2856 from FujiwaraTakumi/dev

add unit test cases about mariadb;
......@@ -21,6 +21,7 @@ import com.microsoft.sqlserver.jdbc.SQLServerXADataSource;
import org.apache.shardingsphere.core.database.DatabaseTypes;
import org.h2.jdbcx.JdbcDataSource;
import org.junit.Test;
import org.mariadb.jdbc.MariaDbDataSource;
import org.postgresql.xa.PGXADataSource;
import javax.sql.XADataSource;
......@@ -35,7 +36,13 @@ public final class XADataSourceFactoryTest {
XADataSource xaDataSource = XADataSourceFactory.build(DatabaseTypes.getActualDatabaseType("H2"));
assertThat(xaDataSource, instanceOf(JdbcDataSource.class));
}
@Test
public void assertCreateMariaDBXADataSource() {
XADataSource xaDataSource = XADataSourceFactory.build(DatabaseTypes.getActualDatabaseType("MariaDB"));
assertThat(xaDataSource, instanceOf(MariaDbDataSource.class));
}
@Test
public void assertCreatePGXADataSource() {
XADataSource xaDataSource = XADataSourceFactory.build(DatabaseTypes.getActualDatabaseType("PostgreSQL"));
......
......@@ -18,11 +18,7 @@
package org.apache.shardingsphere.transaction.xa.jta.datasource.properties;
import org.apache.shardingsphere.core.database.DatabaseTypes;
import org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.H2XADataSourceDefinition;
import org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.MySQLXADataSourceDefinition;
import org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.OracleXADataSourceDefinition;
import org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.PostgreSQLXADataSourceDefinition;
import org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.SQLServerXADataSourceDefinition;
import org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect.*;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.instanceOf;
......@@ -39,6 +35,11 @@ public final class XADataSourceDefinitionFactoryTest {
public void assertCreateXAPropertiesForMySQL() {
assertThat(XADataSourceDefinitionFactory.getXADataSourceDefinition(DatabaseTypes.getActualDatabaseType("MySQL")), instanceOf(MySQLXADataSourceDefinition.class));
}
@Test
public void assertCreateXAPropertiesForMariaDB() {
assertThat(XADataSourceDefinitionFactory.getXADataSourceDefinition(DatabaseTypes.getActualDatabaseType("MariaDB")), instanceOf(MariaDBXADataSourceDefinition.class));
}
@Test
public void assertCreateXAPropertiesForPostgreSQL() {
......
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
package org.apache.shardingsphere.transaction.xa.jta.datasource.properties.dialect;
import org.apache.shardingsphere.core.config.DatabaseAccessConfiguration;
import org.hamcrest.CoreMatchers;
import org.junit.Test;
import java.util.Arrays;
import java.util.Collection;
import java.util.Properties;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
public final class MariaDBXADataSourceDefinitionTest {
@Test
public void assertGetXADriverClassName() {
assertThat(new MariaDBXADataSourceDefinition().getXADriverClassName(),
CoreMatchers.<Collection<String>>is(Arrays.asList(org.mariadb.jdbc.MariaDbDataSource.class.getName())));
}
@Test
public void assertGetXAProperties() {
Properties actual = new MariaDBXADataSourceDefinition().getXAProperties(new DatabaseAccessConfiguration("jdbc:mysql://127.0.0.1:3306/demo", "root", "root"));
assertThat(actual.getProperty("user"), is("root"));
assertThat(actual.getProperty("password"), is("root"));
assertThat(actual.getProperty("url"), is("jdbc:mysql://127.0.0.1:3306/demo"));
assertThat(actual.getProperty("ServerName"), is("127.0.0.1"));
assertThat(actual.getProperty("port"), is("3306"));
assertThat(actual.getProperty("DatabaseName"), is("demo"));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册