From 35f73ba6339cac157928da3f7512e9cf6a0d0456 Mon Sep 17 00:00:00 2001 From: terrymanu Date: Wed, 17 Jan 2018 18:56:52 +0800 Subject: [PATCH] add test case for #567 --- .../shardingjdbc/core/util/SQLUtilTest.java | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/sharding-jdbc-core/src/test/java/io/shardingjdbc/core/util/SQLUtilTest.java b/sharding-jdbc-core/src/test/java/io/shardingjdbc/core/util/SQLUtilTest.java index 0a37e40e72bb6..395fe45d6f945 100644 --- a/sharding-jdbc-core/src/test/java/io/shardingjdbc/core/util/SQLUtilTest.java +++ b/sharding-jdbc-core/src/test/java/io/shardingjdbc/core/util/SQLUtilTest.java @@ -17,6 +17,7 @@ package io.shardingjdbc.core.util; +import io.shardingjdbc.core.constant.DatabaseType; import org.junit.Test; import static org.hamcrest.core.Is.is; @@ -25,10 +26,33 @@ public class SQLUtilTest { @Test - public void assertGetExactlyValue() throws Exception { + public void assertGetExactlyValue() { assertThat(SQLUtil.getExactlyValue("`xxx`"), is("xxx")); assertThat(SQLUtil.getExactlyValue("[xxx]"), is("xxx")); assertThat(SQLUtil.getExactlyValue("\"xxx\""), is("xxx")); assertThat(SQLUtil.getExactlyValue("'xxx'"), is("xxx")); } + + @Test + public void assertGetOriginalValueForOtherDatabase() { + assertThat(SQLUtil.getOriginalValue("select", DatabaseType.H2), is("select")); + assertThat(SQLUtil.getOriginalValue("select", DatabaseType.Oracle), is("select")); + assertThat(SQLUtil.getOriginalValue("select", DatabaseType.SQLServer), is("select")); + assertThat(SQLUtil.getOriginalValue("select", DatabaseType.PostgreSQL), is("select")); + } + + @Test + public void assertGetOriginalValueForMySQLWithoutKeyword() { + assertThat(SQLUtil.getOriginalValue("test", DatabaseType.MySQL), is("test")); + } + + @Test + public void assertGetOriginalValueForMySQLWithDefaultKeyword() { + assertThat(SQLUtil.getOriginalValue("select", DatabaseType.MySQL), is("`select`")); + } + + @Test + public void assertGetOriginalValueForMySQLWithMySQLKeyword() { + assertThat(SQLUtil.getOriginalValue("show", DatabaseType.MySQL), is("`show`")); + } }