Skip to content

Commit

Permalink
add test case for #567
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Jan 17, 2018
1 parent 06c1979 commit 35f73ba
Showing 1 changed file with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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`"));
}
}

0 comments on commit 35f73ba

Please sign in to comment.