From c55633172a999a6ef2563ba5aa9b49e485eca6a2 Mon Sep 17 00:00:00 2001
From: Suomm <1474983351@qq.com>
Date: Sat, 27 Jan 2024 19:46:05 +0800
Subject: [PATCH] =?UTF-8?q?test:=20=E7=A7=BB=E9=99=A4=20TestContainer=20?=
=?UTF-8?q?=E4=BE=9D=E8=B5=96=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../mybatis-flex-spring-boot-test/pom.xml | 18 ----------
.../mybatisflex/test/TestInfrastructure.java | 33 -------------------
.../test/mapper/AccountMapperTest.java | 11 ++++---
.../test/mapper/ActiveRecordTest.java | 10 +++---
.../test/mapper/CombinedMapperTest.java | 3 +-
.../test/mapper/MyAccountMapperTest.java | 3 +-
.../test/mapper/OuterMapperTest.java | 3 +-
.../test/mapper/PatientMapperTest.java | 3 +-
.../test/mapper/QueryChainTest.java | 3 +-
.../test/mapper/UserMapperTest.java | 11 +++++--
.../test/service/ArticleServiceTest.java | 3 +-
.../test/service/FieldMappingTest.java | 3 +-
12 files changed, 27 insertions(+), 77 deletions(-)
delete mode 100644 mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/TestInfrastructure.java
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/pom.xml b/mybatis-flex-test/mybatis-flex-spring-boot-test/pom.xml
index 3d62505f..cd0d5a91 100644
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/pom.xml
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/pom.xml
@@ -83,24 +83,6 @@
test
-
- org.testcontainers
- testcontainers
- test
-
-
- com.fasterxml.jackson.core
- jackson-annotations
-
-
-
-
-
- org.testcontainers
- mysql
- test
-
-
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/TestInfrastructure.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/TestInfrastructure.java
deleted file mode 100644
index 128a4c0e..00000000
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/TestInfrastructure.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.mybatisflex.test;
-
-import org.junit.jupiter.api.AfterAll;
-import org.junit.jupiter.api.BeforeAll;
-import org.testcontainers.containers.BindMode;
-import org.testcontainers.containers.GenericContainer;
-import org.testcontainers.containers.MySQLContainer;
-import org.testcontainers.containers.wait.strategy.Wait;
-import org.testcontainers.utility.DockerImageName;
-
-import java.util.Collections;
-
-public class TestInfrastructure {
-
- static final String FLEX_TEST_DDL = TestInfrastructure.class.getClassLoader().getResource("flex_test.sql").getPath();
- static final String FIELD_MAPPING_TEST_DDL = TestInfrastructure.class.getClassLoader().getResource("field_mapping_test.sql").getPath();
- static final String PATIENT_DATA_SPLIT_TEST_DDL = TestInfrastructure.class.getClassLoader().getResource("patient_data_split_test.sql").getPath();
- static final String DOCKER_INITDB_PATH = "/docker-entrypoint-initdb.d/";
- static GenericContainer> mysql = new MySQLContainer<>(DockerImageName.parse("mysql:8.2.0"))
- .waitingFor(Wait.forLogMessage(".*ready for connections.*\\n", 1))
- .withFileSystemBind(FLEX_TEST_DDL, DOCKER_INITDB_PATH + "flex_test.sql", BindMode.READ_ONLY)
- .withFileSystemBind(FIELD_MAPPING_TEST_DDL, DOCKER_INITDB_PATH + "field_mapping_test.sql", BindMode.READ_ONLY)
- .withFileSystemBind(PATIENT_DATA_SPLIT_TEST_DDL, DOCKER_INITDB_PATH + "patient_data_split_test.sql", BindMode.READ_ONLY)
- .withDatabaseName("flex_test")
- .withReuse(true)
- .withPassword("123456");
-
- @BeforeAll
- public static void start() {
- mysql.setPortBindings(Collections.singletonList("3306:3306"));
- mysql.start();
- }
-}
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/AccountMapperTest.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/AccountMapperTest.java
index f0b2ebe6..c0fa15c2 100644
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/AccountMapperTest.java
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/AccountMapperTest.java
@@ -19,7 +19,6 @@ package com.mybatisflex.test.mapper;
import com.mybatisflex.core.logicdelete.LogicDeleteManager;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.row.Db;
-import com.mybatisflex.test.TestInfrastructure;
import com.mybatisflex.test.model.Account;
import com.mybatisflex.test.model.AccountVO;
import com.mybatisflex.test.model.AccountVO2;
@@ -30,7 +29,9 @@ import org.springframework.boot.test.context.SpringBootTest;
import java.util.Date;
-import static com.mybatisflex.core.query.QueryMethods.*;
+import static com.mybatisflex.core.query.QueryMethods.column;
+import static com.mybatisflex.core.query.QueryMethods.concat;
+import static com.mybatisflex.core.query.QueryMethods.distinct;
import static com.mybatisflex.test.model.table.AccountTableDef.ACCOUNT;
import static com.mybatisflex.test.model.table.RoleTableDef.ROLE;
import static com.mybatisflex.test.model.table.UserRoleTableDef.USER_ROLE;
@@ -42,7 +43,7 @@ import static com.mybatisflex.test.model.table.UserTableDef.USER;
*/
@SpringBootTest
@SuppressWarnings("all")
-class AccountMapperTest extends TestInfrastructure {
+class AccountMapperTest {
@Autowired
private AccountMapper accountMapper;
@@ -136,13 +137,13 @@ class AccountMapperTest extends TestInfrastructure {
Account account = new Account();
account.setAge(10);
Assertions.assertThrows(Exception.class, () ->
- LogicDeleteManager.execWithoutLogicDelete(()->accountMapper.updateByQuery(account, QueryWrapper.create())));
+ LogicDeleteManager.execWithoutLogicDelete(() -> accountMapper.updateByQuery(account, QueryWrapper.create())));
}
@Test
void testDeleteAll() {
Assertions.assertThrows(Exception.class, () ->
- LogicDeleteManager.execWithoutLogicDelete(()-> accountMapper.deleteByQuery(QueryWrapper.create())));
+ LogicDeleteManager.execWithoutLogicDelete(() -> accountMapper.deleteByQuery(QueryWrapper.create())));
}
@Test
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/ActiveRecordTest.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/ActiveRecordTest.java
index 82c185eb..fc0a74d3 100644
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/ActiveRecordTest.java
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/ActiveRecordTest.java
@@ -18,7 +18,6 @@ package com.mybatisflex.test.mapper;
import com.mybatisflex.core.mybatis.Mappers;
import com.mybatisflex.core.query.QueryWrapper;
-import com.mybatisflex.test.TestInfrastructure;
import com.mybatisflex.test.model.Good;
import com.mybatisflex.test.model.User;
import org.junit.jupiter.api.Assertions;
@@ -35,7 +34,7 @@ import static com.mybatisflex.test.model.table.UserTableDef.USER;
* @since 2023-07-23
*/
@SpringBootTest
-class ActiveRecordTest extends TestInfrastructure {
+class ActiveRecordTest {
@Test
void testMapper() {
@@ -125,11 +124,14 @@ class ActiveRecordTest extends TestInfrastructure {
@Test
void testRelation() {
- User user1 = User.create().select(USER.ALL_COLUMNS, ROLE.ALL_COLUMNS)
+ User user1 = User.create()
+ .as("u")
+ .select(USER.DEFAULT_COLUMNS, ROLE.DEFAULT_COLUMNS)
.leftJoin(USER_ROLE).as("ur").on(USER_ROLE.USER_ID.eq(USER.USER_ID))
.leftJoin(ROLE).as("r").on(USER_ROLE.ROLE_ID.eq(ROLE.ROLE_ID))
.where(USER.USER_ID.eq(2))
- .list().get(0);
+ .list()
+ .get(0);
User user2 = User.create()
.where(USER.USER_ID.eq(2))
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/CombinedMapperTest.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/CombinedMapperTest.java
index c62bece2..0b1e401a 100644
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/CombinedMapperTest.java
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/CombinedMapperTest.java
@@ -17,7 +17,6 @@
package com.mybatisflex.test.mapper;
import com.mybatisflex.core.query.QueryWrapper;
-import com.mybatisflex.test.TestInfrastructure;
import com.mybatisflex.test.model.Account;
import com.mybatisflex.test.model.Article;
import org.junit.jupiter.api.Test;
@@ -27,7 +26,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
@SpringBootTest
-public class CombinedMapperTest extends TestInfrastructure {
+public class CombinedMapperTest {
@Autowired
private AccountMapper accountMapper;
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/MyAccountMapperTest.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/MyAccountMapperTest.java
index 948510ab..cecbc390 100644
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/MyAccountMapperTest.java
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/MyAccountMapperTest.java
@@ -16,7 +16,6 @@
package com.mybatisflex.test.mapper;
-import com.mybatisflex.test.TestInfrastructure;
import com.mybatisflex.test.model.Account;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -33,7 +32,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
* @since 2023/4/24 19:37
*/
@SpringBootTest
-class MyAccountMapperTest extends TestInfrastructure {
+class MyAccountMapperTest {
@Autowired
private MyAccountMapper mapper;
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/OuterMapperTest.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/OuterMapperTest.java
index b672e963..93f3c872 100644
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/OuterMapperTest.java
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/OuterMapperTest.java
@@ -17,7 +17,6 @@
package com.mybatisflex.test.mapper;
import com.mybatisflex.core.query.QueryWrapper;
-import com.mybatisflex.test.TestInfrastructure;
import com.mybatisflex.test.entity.Outer;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
@@ -32,7 +31,7 @@ import static com.mybatisflex.test.entity.table.OuterTableDef.OUTER;
* @since 2023-07-01
*/
@SpringBootTest
-class OuterMapperTest extends TestInfrastructure {
+class OuterMapperTest {
@Autowired
private OuterMapper outerMapper;
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/PatientMapperTest.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/PatientMapperTest.java
index c2058846..6a53111a 100644
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/PatientMapperTest.java
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/PatientMapperTest.java
@@ -1,6 +1,5 @@
package com.mybatisflex.test.mapper;
-import com.mybatisflex.test.TestInfrastructure;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@@ -14,7 +13,7 @@ import javax.annotation.Resource;
*/
@SpringBootTest
@SuppressWarnings("all")
-public class PatientMapperTest extends TestInfrastructure {
+public class PatientMapperTest {
@Resource
private PatientMapper patientMapper;
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/QueryChainTest.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/QueryChainTest.java
index 07dcc0b2..2e3f6e46 100644
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/QueryChainTest.java
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/QueryChainTest.java
@@ -20,7 +20,6 @@ import com.mybatisflex.core.field.QueryBuilder;
import com.mybatisflex.core.query.QueryChain;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
-import com.mybatisflex.test.TestInfrastructure;
import com.mybatisflex.test.model.Gender;
import com.mybatisflex.test.model.User;
import org.junit.jupiter.api.Assertions;
@@ -37,7 +36,7 @@ import static com.mybatisflex.test.model.table.UserTableDef.USER;
* @since 2023-08-08
*/
@SpringBootTest
-class QueryChainTest extends TestInfrastructure {
+class QueryChainTest {
@Autowired
UserMapper userMapper;
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/UserMapperTest.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/UserMapperTest.java
index 077f49d5..608b7b45 100644
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/UserMapperTest.java
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/mapper/UserMapperTest.java
@@ -18,8 +18,13 @@ package com.mybatisflex.test.mapper;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
-import com.mybatisflex.test.TestInfrastructure;
-import com.mybatisflex.test.model.*;
+import com.mybatisflex.test.model.OrderInfo;
+import com.mybatisflex.test.model.User;
+import com.mybatisflex.test.model.UserInfo;
+import com.mybatisflex.test.model.UserVO;
+import com.mybatisflex.test.model.UserVO1;
+import com.mybatisflex.test.model.UserVO2;
+import com.mybatisflex.test.model.UserVO3;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
@@ -43,7 +48,7 @@ import static com.mybatisflex.test.model.table.UserTableDef.USER;
*/
@SpringBootTest
@SuppressWarnings("all")
-class UserMapperTest extends TestInfrastructure {
+class UserMapperTest {
@Autowired
private UserMapper userMapper;
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/service/ArticleServiceTest.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/service/ArticleServiceTest.java
index 989f545a..7062152e 100644
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/service/ArticleServiceTest.java
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/service/ArticleServiceTest.java
@@ -17,7 +17,6 @@
package com.mybatisflex.test.service;
import com.mybatisflex.core.query.QueryWrapper;
-import com.mybatisflex.test.TestInfrastructure;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
@@ -29,7 +28,7 @@ import static com.mybatisflex.test.model.table.ArticleTableDef.ARTICLE;
* @since 2023-07-22
*/
@SpringBootTest
-class ArticleServiceTest extends TestInfrastructure {
+class ArticleServiceTest {
@Autowired
ArticleService articleService;
diff --git a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/service/FieldMappingTest.java b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/service/FieldMappingTest.java
index 539082b7..af8baf1c 100644
--- a/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/service/FieldMappingTest.java
+++ b/mybatis-flex-test/mybatis-flex-spring-boot-test/src/test/java/com/mybatisflex/test/service/FieldMappingTest.java
@@ -2,7 +2,6 @@ package com.mybatisflex.test.service;
import com.mybatisflex.test.mapper.FieldMappingInnerMapper;
import com.mybatisflex.test.mapper.FieldMappingMapper;
-import com.mybatisflex.test.TestInfrastructure;
import com.mybatisflex.test.model.FieldMapping;
import com.mybatisflex.test.model.FieldMappingInner;
import org.junit.jupiter.api.Test;
@@ -12,7 +11,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import java.util.Date;
@SpringBootTest
-class FieldMappingTest extends TestInfrastructure {
+class FieldMappingTest {
@Autowired
FieldMappingMapper fieldMappingMapper;
@Autowired