Loading sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/internal/AllInternalTests.java +3 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package io.shardingjdbc.orchestration.internal; import io.shardingjdbc.orchestration.internal.jdbc.AllJdbcTests; import io.shardingjdbc.orchestration.internal.json.DataSourceJsonConverterTest; import io.shardingjdbc.orchestration.internal.json.ShardingRuleConfigurationConverterTest; import org.junit.runner.RunWith; Loading @@ -25,7 +26,8 @@ import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({ DataSourceJsonConverterTest.class, ShardingRuleConfigurationConverterTest.class ShardingRuleConfigurationConverterTest.class, AllJdbcTests.class }) public class AllInternalTests { } sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/internal/config/ConfigurationNodeTest.java 0 → 100644 +33 −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 io.shardingjdbc.orchestration.internal.config; import org.junit.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; public final class ConfigurationNodeTest { private ConfigurationNode configurationNode = new ConfigurationNode("test_job"); @Test public void assertIsShardingRuleNodePath() { assertThat(configurationNode.getFullPath(ConfigurationNode.SHARDING_RULE_NODE_PATH), is("/test_job/config/sharding/rule")); } } sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/internal/jdbc/AllJdbcTests.java 0 → 100644 +33 −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 io.shardingjdbc.orchestration.internal.jdbc; import io.shardingjdbc.orchestration.internal.jdbc.connection.CircuitBreakerConnectionTest; import io.shardingjdbc.orchestration.internal.jdbc.datasource.CircuitBreakerDataSourceTest; import io.shardingjdbc.orchestration.internal.jdbc.metadata.CircuitBreakerDatabaseMetaDataTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({ CircuitBreakerConnectionTest.class, CircuitBreakerDataSourceTest.class, CircuitBreakerDatabaseMetaDataTest.class }) public class AllJdbcTests { } sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/internal/jdbc/connection/CircuitBreakerConnectionTest.java 0 → 100644 +135 −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 io.shardingjdbc.orchestration.internal.jdbc.connection; import io.shardingjdbc.orchestration.internal.jdbc.metadata.CircuitBreakerDatabaseMetaData; import io.shardingjdbc.orchestration.internal.jdbc.statement.CircuitBreakerPreparedStatement; import io.shardingjdbc.orchestration.internal.jdbc.statement.CircuitBreakerStatement; import org.junit.Test; import java.sql.Connection; import java.sql.SQLException; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; public final class CircuitBreakerConnectionTest { private CircuitBreakerConnection connection = new CircuitBreakerConnection(); private final String sql = "select 1"; @Test public void assertGetMetaData() throws SQLException { assertTrue(connection.getMetaData() instanceof CircuitBreakerDatabaseMetaData); } @Test public void setReadOnly() throws SQLException { connection.setReadOnly(true); assertFalse(connection.isReadOnly()); } @Test public void assertIsReadOnly() throws SQLException { assertFalse(connection.isReadOnly()); } @Test public void assertSetTransactionIsolation() throws SQLException { connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); assertThat(connection.getTransactionIsolation(), is(Connection.TRANSACTION_NONE)); } @Test public void assertGetTransactionIsolation() throws SQLException { assertThat(connection.getTransactionIsolation(), is(Connection.TRANSACTION_NONE)); } @Test public void assertGetWarnings() throws SQLException { assertNull(connection.getWarnings()); } @Test public void assertClearWarnings() throws SQLException { connection.clearWarnings(); } @Test public void assertSetAutoCommit() throws SQLException { connection.setAutoCommit(true); assertFalse(connection.getAutoCommit()); } @Test public void assertGetAutoCommit() throws SQLException { assertFalse(connection.getAutoCommit()); } @Test public void assertCommit() throws SQLException { connection.commit(); } @Test public void assertRollback() throws SQLException { connection.rollback(); } @Test public void assertSetHoldability() throws SQLException { connection.setHoldability(-1); assertThat(connection.getHoldability(), is(0)); } @Test public void assertGetHoldability() throws SQLException { assertThat(connection.getHoldability(), is(0)); } @Test public void assertPrepareStatement() throws SQLException { assertTrue(connection.prepareStatement(sql) instanceof CircuitBreakerPreparedStatement); assertTrue(connection.prepareStatement(sql, 0, 0) instanceof CircuitBreakerPreparedStatement); assertTrue(connection.prepareStatement(sql, 0, 0, 0) instanceof CircuitBreakerPreparedStatement); assertTrue(connection.prepareStatement(sql, 0) instanceof CircuitBreakerPreparedStatement); assertTrue(connection.prepareStatement(sql, new int[]{0}) instanceof CircuitBreakerPreparedStatement); assertTrue(connection.prepareStatement(sql, new String[]{""}) instanceof CircuitBreakerPreparedStatement); } @Test public void assertCreateStatement() throws SQLException { assertTrue(connection.createStatement() instanceof CircuitBreakerStatement); assertTrue(connection.createStatement(0, 0) instanceof CircuitBreakerStatement); assertTrue(connection.createStatement(0, 0, 0) instanceof CircuitBreakerStatement); } @Test public void assertClose() throws SQLException { connection.close(); } @Test public void assertIsClosed() throws SQLException { assertFalse(connection.isClosed()); } } sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/internal/jdbc/datasource/CircuitBreakerDataSourceTest.java 0 → 100644 +59 −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 io.shardingjdbc.orchestration.internal.jdbc.datasource; import io.shardingjdbc.orchestration.internal.jdbc.connection.CircuitBreakerConnection; import org.junit.Test; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; public final class CircuitBreakerDataSourceTest { private CircuitBreakerDataSource dataSource = new CircuitBreakerDataSource(); @Test public void assertClose() throws Exception { dataSource.close(); } @Test public void assertGetConnection() throws SQLException { assertTrue(dataSource.getConnection() instanceof CircuitBreakerConnection); assertTrue(dataSource.getConnection("", "") instanceof CircuitBreakerConnection); } @Test public void assertGetLogWriter() throws SQLException { assertNull(dataSource.getLogWriter()); } @Test public void assertSetLogWriter() throws Exception { dataSource.setLogWriter(null); assertNull(dataSource.getLogWriter()); } @Test public void assertGetParentLogger() throws SQLFeatureNotSupportedException { assertNull(dataSource.getParentLogger()); } } Loading
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/internal/AllInternalTests.java +3 −1 Original line number Diff line number Diff line Loading @@ -17,6 +17,7 @@ package io.shardingjdbc.orchestration.internal; import io.shardingjdbc.orchestration.internal.jdbc.AllJdbcTests; import io.shardingjdbc.orchestration.internal.json.DataSourceJsonConverterTest; import io.shardingjdbc.orchestration.internal.json.ShardingRuleConfigurationConverterTest; import org.junit.runner.RunWith; Loading @@ -25,7 +26,8 @@ import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({ DataSourceJsonConverterTest.class, ShardingRuleConfigurationConverterTest.class ShardingRuleConfigurationConverterTest.class, AllJdbcTests.class }) public class AllInternalTests { }
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/internal/config/ConfigurationNodeTest.java 0 → 100644 +33 −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 io.shardingjdbc.orchestration.internal.config; import org.junit.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; public final class ConfigurationNodeTest { private ConfigurationNode configurationNode = new ConfigurationNode("test_job"); @Test public void assertIsShardingRuleNodePath() { assertThat(configurationNode.getFullPath(ConfigurationNode.SHARDING_RULE_NODE_PATH), is("/test_job/config/sharding/rule")); } }
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/internal/jdbc/AllJdbcTests.java 0 → 100644 +33 −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 io.shardingjdbc.orchestration.internal.jdbc; import io.shardingjdbc.orchestration.internal.jdbc.connection.CircuitBreakerConnectionTest; import io.shardingjdbc.orchestration.internal.jdbc.datasource.CircuitBreakerDataSourceTest; import io.shardingjdbc.orchestration.internal.jdbc.metadata.CircuitBreakerDatabaseMetaDataTest; import org.junit.runner.RunWith; import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({ CircuitBreakerConnectionTest.class, CircuitBreakerDataSourceTest.class, CircuitBreakerDatabaseMetaDataTest.class }) public class AllJdbcTests { }
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/internal/jdbc/connection/CircuitBreakerConnectionTest.java 0 → 100644 +135 −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 io.shardingjdbc.orchestration.internal.jdbc.connection; import io.shardingjdbc.orchestration.internal.jdbc.metadata.CircuitBreakerDatabaseMetaData; import io.shardingjdbc.orchestration.internal.jdbc.statement.CircuitBreakerPreparedStatement; import io.shardingjdbc.orchestration.internal.jdbc.statement.CircuitBreakerStatement; import org.junit.Test; import java.sql.Connection; import java.sql.SQLException; import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; public final class CircuitBreakerConnectionTest { private CircuitBreakerConnection connection = new CircuitBreakerConnection(); private final String sql = "select 1"; @Test public void assertGetMetaData() throws SQLException { assertTrue(connection.getMetaData() instanceof CircuitBreakerDatabaseMetaData); } @Test public void setReadOnly() throws SQLException { connection.setReadOnly(true); assertFalse(connection.isReadOnly()); } @Test public void assertIsReadOnly() throws SQLException { assertFalse(connection.isReadOnly()); } @Test public void assertSetTransactionIsolation() throws SQLException { connection.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); assertThat(connection.getTransactionIsolation(), is(Connection.TRANSACTION_NONE)); } @Test public void assertGetTransactionIsolation() throws SQLException { assertThat(connection.getTransactionIsolation(), is(Connection.TRANSACTION_NONE)); } @Test public void assertGetWarnings() throws SQLException { assertNull(connection.getWarnings()); } @Test public void assertClearWarnings() throws SQLException { connection.clearWarnings(); } @Test public void assertSetAutoCommit() throws SQLException { connection.setAutoCommit(true); assertFalse(connection.getAutoCommit()); } @Test public void assertGetAutoCommit() throws SQLException { assertFalse(connection.getAutoCommit()); } @Test public void assertCommit() throws SQLException { connection.commit(); } @Test public void assertRollback() throws SQLException { connection.rollback(); } @Test public void assertSetHoldability() throws SQLException { connection.setHoldability(-1); assertThat(connection.getHoldability(), is(0)); } @Test public void assertGetHoldability() throws SQLException { assertThat(connection.getHoldability(), is(0)); } @Test public void assertPrepareStatement() throws SQLException { assertTrue(connection.prepareStatement(sql) instanceof CircuitBreakerPreparedStatement); assertTrue(connection.prepareStatement(sql, 0, 0) instanceof CircuitBreakerPreparedStatement); assertTrue(connection.prepareStatement(sql, 0, 0, 0) instanceof CircuitBreakerPreparedStatement); assertTrue(connection.prepareStatement(sql, 0) instanceof CircuitBreakerPreparedStatement); assertTrue(connection.prepareStatement(sql, new int[]{0}) instanceof CircuitBreakerPreparedStatement); assertTrue(connection.prepareStatement(sql, new String[]{""}) instanceof CircuitBreakerPreparedStatement); } @Test public void assertCreateStatement() throws SQLException { assertTrue(connection.createStatement() instanceof CircuitBreakerStatement); assertTrue(connection.createStatement(0, 0) instanceof CircuitBreakerStatement); assertTrue(connection.createStatement(0, 0, 0) instanceof CircuitBreakerStatement); } @Test public void assertClose() throws SQLException { connection.close(); } @Test public void assertIsClosed() throws SQLException { assertFalse(connection.isClosed()); } }
sharding-jdbc-orchestration/src/test/java/io/shardingjdbc/orchestration/internal/jdbc/datasource/CircuitBreakerDataSourceTest.java 0 → 100644 +59 −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 io.shardingjdbc.orchestration.internal.jdbc.datasource; import io.shardingjdbc.orchestration.internal.jdbc.connection.CircuitBreakerConnection; import org.junit.Test; import java.sql.SQLException; import java.sql.SQLFeatureNotSupportedException; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; public final class CircuitBreakerDataSourceTest { private CircuitBreakerDataSource dataSource = new CircuitBreakerDataSource(); @Test public void assertClose() throws Exception { dataSource.close(); } @Test public void assertGetConnection() throws SQLException { assertTrue(dataSource.getConnection() instanceof CircuitBreakerConnection); assertTrue(dataSource.getConnection("", "") instanceof CircuitBreakerConnection); } @Test public void assertGetLogWriter() throws SQLException { assertNull(dataSource.getLogWriter()); } @Test public void assertSetLogWriter() throws Exception { dataSource.setLogWriter(null); assertNull(dataSource.getLogWriter()); } @Test public void assertGetParentLogger() throws SQLFeatureNotSupportedException { assertNull(dataSource.getParentLogger()); } }