Skip to content
Permalink
Browse files

code clear

  • Loading branch information
beijing-penguin committed Nov 19, 2019
1 parent c48844e commit 1728ecb017355b6e0bac07fca42087ebea1047d1
Showing with 66 additions and 195 deletions.
  1. +0 −4 ...g-core/sharding-core-api/src/main/java/org/apache/shardingsphere/spi/database/DataSourceInfo.java
  2. +2 −6 ...java/org/apache/shardingsphere/core/metadata/datasource/ShardingSphereDataSourceMetaDataTest.java
  3. +8 −19 ...est/java/org/apache/shardingsphere/core/metadata/datasource/dialect/H2DataSourceMetaDataTest.java
  4. +8 −17 .../java/org/apache/shardingsphere/core/metadata/datasource/dialect/MySQLDataSourceMetaDataTest.java
  5. +8 −17 ...java/org/apache/shardingsphere/core/metadata/datasource/dialect/OracleDataSourceMetaDataTest.java
  6. +8 −16 .../org/apache/shardingsphere/core/metadata/datasource/dialect/PostgreSQLDataSourceMetaDataTest.java
  7. +3 −13 .../java/org/apache/shardingsphere/core/metadata/datasource/dialect/SQL92DataSourceMetaDataTest.java
  8. +10 −19 ...a/org/apache/shardingsphere/core/metadata/datasource/dialect/SQLServerDataSourceMetaDataTest.java
  9. +1 −3 ...sharding-core-common/src/test/java/org/apache/shardingsphere/spi/database/H2DatabaseTypeTest.java
  10. +1 −10 ...rding-core-common/src/test/java/org/apache/shardingsphere/spi/database/MySQLDatabaseTypeTest.java
  11. +2 −10 ...ding-core-common/src/test/java/org/apache/shardingsphere/spi/database/OracleDatabaseTypeTest.java
  12. +1 −9 ...-core-common/src/test/java/org/apache/shardingsphere/spi/database/PostgreSQLDatabaseTypeTest.java
  13. +1 −11 ...rding-core-common/src/test/java/org/apache/shardingsphere/spi/database/SQL92DatabaseTypeTest.java
  14. +5 −20 ...g-core-common/src/test/java/org/apache/shardingsphere/spi/database/SQLServerDatabaseTypeTest.java
  15. +3 −11 ...-route/src/test/java/org/apache/shardingsphere/core/route/type/standard/AbstractSQLRouteTest.java
  16. +1 −2 ...oxy-backend/src/main/java/org/apache/shardingsphere/shardingproxy/backend/schema/LogicSchema.java
  17. +1 −2 ...hardingsphere/transaction/xa/jta/datasource/properties/dialect/MariaDBXADataSourceDefinition.java
  18. +1 −2 ...shardingsphere/transaction/xa/jta/datasource/properties/dialect/OracleXADataSourceDefinition.java
  19. +1 −2 ...dingsphere/transaction/xa/jta/datasource/properties/dialect/PostgreSQLXADataSourceDefinition.java
  20. +1 −2 ...rdingsphere/transaction/xa/jta/datasource/properties/dialect/SQLServerXADataSourceDefinition.java
@@ -19,8 +19,6 @@

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;


/**
@@ -29,8 +27,6 @@
* @author duanchao
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class DataSourceInfo {

@@ -35,13 +35,9 @@
@Before
public void setUp() {
final Map<String, DataSourceInfo> dataSourceInfoMap = new HashMap<String, DataSourceInfo>();
DataSourceInfo info0 = new DataSourceInfo();
info0.setUrl("jdbc:mysql://127.0.0.1:3306/db_0");
info0.setUsername("test");
DataSourceInfo info0 = new DataSourceInfo("jdbc:mysql://127.0.0.1:3306/db_0", "test");

DataSourceInfo info1 = new DataSourceInfo();
info1.setUrl("jdbc:mysql://127.0.0.1:3306/db_1");
info1.setUsername("test");
DataSourceInfo info1 = new DataSourceInfo("jdbc:mysql://127.0.0.1:3306/db_1", "test");

dataSourceInfoMap.put("ds_0", info0);
dataSourceInfoMap.put("ds_1", info1);
@@ -17,29 +17,19 @@

package org.apache.shardingsphere.core.metadata.datasource.dialect;

import org.apache.shardingsphere.core.metadata.datasource.exception.UnrecognizedDatabaseURLException;
import org.apache.shardingsphere.spi.database.DataSourceInfo;
import org.junit.Before;
import org.junit.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

import org.apache.shardingsphere.core.metadata.datasource.exception.UnrecognizedDatabaseURLException;
import org.apache.shardingsphere.spi.database.DataSourceInfo;
import org.junit.Test;

public final class H2DataSourceMetaDataTest {

private DataSourceInfo dataSourceInfo;

@Before
public void setUp() {
dataSourceInfo = new DataSourceInfo();
dataSourceInfo.setUrl("jdbc:h2:mem:ds_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL");
dataSourceInfo.setUsername("test");
}

@Test
public void assertDataSourceInfoParam() {
H2DataSourceMetaData actual = new H2DataSourceMetaData(dataSourceInfo);
H2DataSourceMetaData actual = new H2DataSourceMetaData(new DataSourceInfo("jdbc:h2:mem:ds_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL", "test"));
assertThat(actual.getHostName(), is(""));
assertThat(actual.getPort(), is(-1));
assertThat(actual.getCatalog(), is("ds_0"));
@@ -48,24 +38,23 @@ public void assertDataSourceInfoParam() {

@Test
public void assertGetPropertiesWithMem() {
H2DataSourceMetaData actual = new H2DataSourceMetaData(dataSourceInfo);
H2DataSourceMetaData actual = new H2DataSourceMetaData(new DataSourceInfo("jdbc:h2:mem:ds_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL", "test"));
assertThat(actual.getHostName(), is(""));
assertThat(actual.getPort(), is(-1));
assertEquals(actual.getSchemaName(), null);
}

@Test
public void assertGetPropertiesWithSymbol() {
dataSourceInfo.setUrl("jdbc:h2:~:ds-0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL");
H2DataSourceMetaData actual = new H2DataSourceMetaData(dataSourceInfo);
H2DataSourceMetaData actual = new H2DataSourceMetaData(new DataSourceInfo("jdbc:h2:~:ds-0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MySQL", "test"));
assertThat(actual.getHostName(), is(""));
assertThat(actual.getPort(), is(-1));
assertEquals(actual.getSchemaName(), null);
}

@Test(expected = UnrecognizedDatabaseURLException.class)
public void assertGetPropertiesFailure() {
dataSourceInfo.setUrl("jdbc:h2:file:/data/sample");
DataSourceInfo dataSourceInfo = new DataSourceInfo("jdbc:h2:file:/data/sample", "test");
new H2DataSourceMetaData(dataSourceInfo);
}
}
@@ -17,28 +17,19 @@

package org.apache.shardingsphere.core.metadata.datasource.dialect;

import org.apache.shardingsphere.core.metadata.datasource.exception.UnrecognizedDatabaseURLException;
import org.apache.shardingsphere.spi.database.DataSourceInfo;
import org.junit.Before;
import org.junit.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

import org.apache.shardingsphere.core.metadata.datasource.exception.UnrecognizedDatabaseURLException;
import org.apache.shardingsphere.spi.database.DataSourceInfo;
import org.junit.Test;

public final class MySQLDataSourceMetaDataTest {

private DataSourceInfo dataSourceInfo;

@Before
public void setUp() {
dataSourceInfo = new DataSourceInfo();
dataSourceInfo.setUsername("test");
}

@Test
public void assertDataSourceInfoParam() {
dataSourceInfo.setUrl("jdbc:mysql://127.0.0.1:9999/ds_0?serverTimezone=UTC&useSSL=false");
DataSourceInfo dataSourceInfo = new DataSourceInfo("jdbc:mysql://127.0.0.1:9999/ds_0?serverTimezone=UTC&useSSL=false", "test");
MySQLDataSourceMetaData actual = new MySQLDataSourceMetaData(dataSourceInfo);
assertThat(actual.getHostName(), is("127.0.0.1"));
assertThat(actual.getPort(), is(9999));
@@ -48,7 +39,7 @@ public void assertDataSourceInfoParam() {

@Test
public void assertGetPropertiesWithPort() {
dataSourceInfo.setUrl("jdbc:mysql://127.0.0.1:9999/ds_0?serverTimezone=UTC&useSSL=false");
DataSourceInfo dataSourceInfo = new DataSourceInfo("jdbc:mysql://127.0.0.1:9999/ds_0?serverTimezone=UTC&useSSL=false", "test");
MySQLDataSourceMetaData actual = new MySQLDataSourceMetaData(dataSourceInfo);
assertThat(actual.getHostName(), is("127.0.0.1"));
assertThat(actual.getPort(), is(9999));
@@ -58,7 +49,7 @@ public void assertGetPropertiesWithPort() {

@Test
public void assertGetPropertiesWithDefaultPort() {
dataSourceInfo.setUrl("jdbc:mysql:loadbalance://127.0.0.1/ds_0?serverTimezone=UTC&useSSL=false");
DataSourceInfo dataSourceInfo = new DataSourceInfo("jdbc:mysql:loadbalance://127.0.0.1/ds_0?serverTimezone=UTC&useSSL=false", "test");
MySQLDataSourceMetaData actual = new MySQLDataSourceMetaData(dataSourceInfo);
assertThat(actual.getHostName(), is("127.0.0.1"));
assertThat(actual.getPort(), is(3306));
@@ -67,7 +58,7 @@ public void assertGetPropertiesWithDefaultPort() {

@Test(expected = UnrecognizedDatabaseURLException.class)
public void assertGetPropertiesFailure() {
dataSourceInfo.setUrl("jdbc:mysql:xxxxxxxx");
DataSourceInfo dataSourceInfo = new DataSourceInfo("jdbc:mysql:xxxxxxxx", "test");
new MySQLDataSourceMetaData(dataSourceInfo);
}
}
@@ -17,28 +17,19 @@

package org.apache.shardingsphere.core.metadata.datasource.dialect;

import org.apache.shardingsphere.core.metadata.datasource.exception.UnrecognizedDatabaseURLException;
import org.apache.shardingsphere.spi.database.DataSourceInfo;
import org.junit.Before;
import org.junit.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

import org.apache.shardingsphere.core.metadata.datasource.exception.UnrecognizedDatabaseURLException;
import org.apache.shardingsphere.spi.database.DataSourceInfo;
import org.junit.Test;

public final class OracleDataSourceMetaDataTest {

private DataSourceInfo dataSourceInfo;

@Before
public void setUp() {
dataSourceInfo = new DataSourceInfo();
dataSourceInfo.setUsername("test");
}

@Test
public void assertDataSourceInfoParam() {
dataSourceInfo.setUrl("jdbc:oracle:thin:@//127.0.0.1:9999/ds_0");
DataSourceInfo dataSourceInfo = new DataSourceInfo("jdbc:oracle:thin:@//127.0.0.1:9999/ds_0", "test");
OracleDataSourceMetaData actual = new OracleDataSourceMetaData(dataSourceInfo);
assertThat(actual.getHostName(), is("127.0.0.1"));
assertThat(actual.getPort(), is(9999));
@@ -48,15 +39,15 @@ public void assertDataSourceInfoParam() {

@Test
public void assertGetPropertiesWithPort() {
dataSourceInfo.setUrl("jdbc:oracle:thin:@//127.0.0.1:9999/ds_0");
DataSourceInfo dataSourceInfo = new DataSourceInfo("jdbc:oracle:thin:@//127.0.0.1:9999/ds_0", "test");
OracleDataSourceMetaData actual = new OracleDataSourceMetaData(dataSourceInfo);
assertThat(actual.getHostName(), is("127.0.0.1"));
assertThat(actual.getPort(), is(9999));
}

@Test
public void assertGetPropertiesWithDefaultPort() {
dataSourceInfo.setUrl("jdbc:oracle:oci:@127.0.0.1/ds_0");
DataSourceInfo dataSourceInfo = new DataSourceInfo("jdbc:oracle:oci:@127.0.0.1/ds_0", "test");
OracleDataSourceMetaData actual = new OracleDataSourceMetaData(dataSourceInfo);
assertThat(actual.getHostName(), is("127.0.0.1"));
assertThat(actual.getPort(), is(1521));
@@ -65,7 +56,7 @@ public void assertGetPropertiesWithDefaultPort() {

@Test(expected = UnrecognizedDatabaseURLException.class)
public void assertGetPropertiesFailure() {
dataSourceInfo.setUrl("jdbc:oracle:xxxxxxxx");
DataSourceInfo dataSourceInfo = new DataSourceInfo("jdbc:oracle:xxxxxxxx", "test");
new OracleDataSourceMetaData(dataSourceInfo);
}
}
@@ -17,27 +17,19 @@

package org.apache.shardingsphere.core.metadata.datasource.dialect;

import org.apache.shardingsphere.core.metadata.datasource.exception.UnrecognizedDatabaseURLException;
import org.apache.shardingsphere.spi.database.DataSourceInfo;
import org.junit.Before;
import org.junit.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;

import org.apache.shardingsphere.core.metadata.datasource.exception.UnrecognizedDatabaseURLException;
import org.apache.shardingsphere.spi.database.DataSourceInfo;
import org.junit.Test;

public final class PostgreSQLDataSourceMetaDataTest {
private DataSourceInfo dataSourceInfo;

@Before
public void setUp() {
dataSourceInfo = new DataSourceInfo();
dataSourceInfo.setUsername("test");
}

@Test
public void assertDataSourceInfoParam() {
dataSourceInfo.setUrl("jdbc:postgresql://127.0.0.1:9999/ds_0");
DataSourceInfo dataSourceInfo = new DataSourceInfo("jdbc:postgresql://127.0.0.1:9999/ds_0", "test");
PostgreSQLDataSourceMetaData actual = new PostgreSQLDataSourceMetaData(dataSourceInfo);
assertThat(actual.getHostName(), is("127.0.0.1"));
assertThat(actual.getPort(), is(9999));
@@ -47,7 +39,7 @@ public void assertDataSourceInfoParam() {

@Test
public void assertGetPropertiesWithPort() {
dataSourceInfo.setUrl("jdbc:postgresql://127.0.0.1:9999/ds_0");
DataSourceInfo dataSourceInfo = new DataSourceInfo("jdbc:postgresql://127.0.0.1:9999/ds_0", "test");
PostgreSQLDataSourceMetaData actual = new PostgreSQLDataSourceMetaData(dataSourceInfo);
assertThat(actual.getHostName(), is("127.0.0.1"));
assertThat(actual.getPort(), is(9999));
@@ -56,7 +48,7 @@ public void assertGetPropertiesWithPort() {

@Test
public void assertGetPropertiesWithDefaultPort() {
dataSourceInfo.setUrl("jdbc:postgresql://127.0.0.1/ds_0");
DataSourceInfo dataSourceInfo = new DataSourceInfo("jdbc:postgresql://127.0.0.1/ds_0", "test");
PostgreSQLDataSourceMetaData actual = new PostgreSQLDataSourceMetaData(dataSourceInfo);
assertThat(actual.getHostName(), is("127.0.0.1"));
assertThat(actual.getPort(), is(5432));
@@ -66,7 +58,7 @@ public void assertGetPropertiesWithDefaultPort() {

@Test(expected = UnrecognizedDatabaseURLException.class)
public void assertGetPropertiesFailure() {
dataSourceInfo.setUrl("jdbc:postgresql:xxxxxxxx");
DataSourceInfo dataSourceInfo = new DataSourceInfo("jdbc:postgresql:xxxxxxxx", "test");
new PostgreSQLDataSourceMetaData(dataSourceInfo);
}
}
@@ -23,23 +23,13 @@

import org.apache.shardingsphere.core.metadata.datasource.exception.UnrecognizedDatabaseURLException;
import org.apache.shardingsphere.spi.database.DataSourceInfo;
import org.junit.Before;
import org.junit.Test;

public final class SQL92DataSourceMetaDataTest {

private DataSourceInfo dataSourceInfo;

@Before
public void setUp() {
dataSourceInfo = new DataSourceInfo();
dataSourceInfo.setUrl("jdbc:sql92_db:ds_0");
dataSourceInfo.setUsername("test");
}

@Test
public void assertDataSourceInfoParam() {
dataSourceInfo.setUrl("jdbc:sql92_db:ds_0");
DataSourceInfo dataSourceInfo = new DataSourceInfo("jdbc:sql92_db:ds_0", "test");
SQL92DataSourceMetaData actual = new SQL92DataSourceMetaData(dataSourceInfo);
assertThat(actual.getHostName(), is(""));
assertThat(actual.getPort(), is(-1));
@@ -49,7 +39,7 @@ public void assertDataSourceInfoParam() {

@Test
public void assertGetProperties() {
dataSourceInfo.setUrl("jdbc:sql92_db:ds_0");
DataSourceInfo dataSourceInfo = new DataSourceInfo("jdbc:sql92_db:ds_0", "test");
SQL92DataSourceMetaData actual = new SQL92DataSourceMetaData(dataSourceInfo);
assertThat(actual.getHostName(), is(""));
assertThat(actual.getPort(), is(-1));
@@ -59,7 +49,7 @@ public void assertGetProperties() {

@Test(expected = UnrecognizedDatabaseURLException.class)
public void assertGetPropertiesFailure() {
dataSourceInfo.setUrl("xxx:xxxx:xxxxxxxx");
DataSourceInfo dataSourceInfo = new DataSourceInfo("xxx:xxxx:xxxxxxxx", "test");
new SQL92DataSourceMetaData(dataSourceInfo);
}
}

0 comments on commit 1728ecb

Please sign in to comment.
You can’t perform that action at this time.