Skip to content

Commit

Permalink
🆙update:
Browse files Browse the repository at this point in the history
h2のupdateによって'user'が予約語に追加されていた。
テスト用のテーブル名だったのでescapeではなくテーブル名称変更で対応した。
  • Loading branch information
itsuki-yamada committed Aug 6, 2024
1 parent 76e65fd commit 4be8ae1
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 17 deletions.
73 changes: 65 additions & 8 deletions playtest-db/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@

<properties>
<project.version>0.1.3</project.version>
<kotlin.version>1.7.10</kotlin.version>
<kluent.version>1.68</kluent.version>
<mockk.version>1.12.5</mockk.version>
<kotlin-juni5.version>1.3.61</kotlin-juni5.version>
<kotlin.version>1.9.25</kotlin.version>
<kluent.version>1.73</kluent.version>
<mockk.version>1.13.12</mockk.version>
<maven_surefire_plugin.version>2.22.2</maven_surefire_plugin.version>
<maven_source_plugin.version>3.2.1</maven_source_plugin.version>
<maven_assembly_plugin.version>3.3.0</maven_assembly_plugin.version>
Expand All @@ -54,8 +53,8 @@
<kotlin_as_java_plugin.version>1.5.31</kotlin_as_java_plugin.version>
<javadoc.version>2.9.1</javadoc.version>
<db_unit.version>2.7.2</db_unit.version>
<h2.version>1.4.200</h2.version>
<dbunit.version>2.7.3</dbunit.version>
<h2.version>2.2.220</h2.version>
<dbunit.version>2.8.0</dbunit.version>
<assertj-db.version>2.0.2</assertj-db.version>
<nexus-staging-maven-plugin.version>1.6.13</nexus-staging-maven-plugin.version>
<nexus-staging-maven-plugin.nexusUrl>https://oss.sonatype.org/</nexus-staging-maven-plugin.nexusUrl>
Expand All @@ -80,7 +79,7 @@
</dependency>
<dependency>
<groupId>io.mockk</groupId>
<artifactId>mockk</artifactId>
<artifactId>mockk-jvm</artifactId>
<version>${mockk.version}</version>
<scope>test</scope>
</dependency>
Expand All @@ -97,7 +96,7 @@
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit5</artifactId>
<version>${kotlin-juni5.version}</version>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
Expand All @@ -110,10 +109,68 @@
<artifactId>assertj-db</artifactId>
<version>${assertj-db.version}</version>
</dependency>

<!--dbunitの脆弱性対応バージョンが出るまでの暫定対応-->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.10.3</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.3.0</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>42.7.3</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.6</version>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>9.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.17.1.0</version>
</dependency>
<dependency>
<groupId>org.dbunit</groupId>
<artifactId>dbunit</artifactId>
<version>${dbunit.version}</version>
<exclusions>
<exclusion>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</exclusion>
<exclusion>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</exclusion>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
<exclusion>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import java.sql.DriverManager
data class User(
val user_id: Int,
val name: String
) : Entity("user")
) : Entity("user_profile")

internal class DatabaseTest {
companion object {
Expand Down Expand Up @@ -53,14 +53,14 @@ internal class DatabaseTest {
)
conn.createStatement().execute(
"""
CREATE TABLE IF NOT EXISTS test_schema.user (
CREATE TABLE IF NOT EXISTS test_schema.user_profile (
user_id INTEGER primary key,
name varchar
)
""".trimIndent()
)
conn.createStatement().execute("delete from test_schema.todo;")
conn.createStatement().execute("delete from test_schema.user;")
conn.createStatement().execute("delete from test_schema.user_profile;")
}

@AfterEach
Expand Down Expand Up @@ -130,7 +130,7 @@ internal class DatabaseTest {
fun `テーブルの1レコードをinsertする`() {
val table = org.assertj.db.type.Table(
Source("jdbc:h2:mem:test;MODE=PostgreSQL;DB_CLOSE_DELAY=-1", "sa", ""),
"test_schema.user"
"test_schema.user_profile"
)
target.insert(User(1, "taro"))
Assertions.assertThat(table)
Expand All @@ -143,11 +143,11 @@ internal class DatabaseTest {
fun `テーブルの1レコードをdeleteする`() {
val table = org.assertj.db.type.Table(
Source("jdbc:h2:mem:test;MODE=PostgreSQL;DB_CLOSE_DELAY=-1", "sa", ""),
"test_schema.user"
"test_schema.user_profile"
)
conn.createStatement().execute(
"""
INSERT INTO test_schema.user VALUES (1, 'taro')
INSERT INTO test_schema.user_profile VALUES (1, 'taro')
""".trimIndent()
)

Expand All @@ -163,7 +163,7 @@ internal class DatabaseTest {
)
val user = org.assertj.db.type.Table(
Source("jdbc:h2:mem:test;MODE=PostgreSQL;DB_CLOSE_DELAY=-1", "sa", ""),
"test_schema.user"
"test_schema.user_profile"
)
conn.createStatement().execute(
"""
Expand All @@ -172,11 +172,11 @@ internal class DatabaseTest {
)
conn.createStatement().execute(
"""
INSERT INTO test_schema.user VALUES (1, 'taro')
INSERT INTO test_schema.user_profile VALUES (1, 'taro')
""".trimIndent()
)

target.truncate("todo", "user")
target.truncate("todo", "user_profile")

Assertions.assertThat(todo).isEmpty
Assertions.assertThat(user).isEmpty
Expand Down

0 comments on commit 4be8ae1

Please sign in to comment.