From d6bcf999cc2533a75b77246ae734176047de8e66 Mon Sep 17 00:00:00 2001 From: Suomm <1474983351@qq.com> Date: Thu, 10 Aug 2023 15:19:02 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E6=89=B9=E9=87=8F=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/mybatisflex/test/ArticleTester.java | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/ArticleTester.java diff --git a/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/ArticleTester.java b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/ArticleTester.java new file mode 100644 index 00000000..f195dd04 --- /dev/null +++ b/mybatis-flex-test/mybatis-flex-native-test/src/main/java/com/mybatisflex/test/ArticleTester.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2022-2023, Mybatis-Flex (fuhai999@gmail.com). + *
+ * 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.
+ */
+
+package com.mybatisflex.test;
+
+import com.mybatisflex.core.MybatisFlexBootstrap;
+import com.mybatisflex.core.audit.AuditManager;
+import com.mybatisflex.core.audit.ConsoleMessageCollector;
+import com.mybatisflex.core.audit.MessageCollector;
+import com.mybatisflex.core.row.Db;
+import com.mybatisflex.mapper.ArticleMapper;
+import org.apache.ibatis.logging.nologging.NoLoggingImpl;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
+import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
+
+import javax.sql.DataSource;
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ * @author 王帅
+ * @since 2023-08-10
+ */
+public class ArticleTester {
+
+ static ArticleMapper articleMapper;
+
+ @BeforeClass
+ public static void init() {
+ DataSource dataSource = new EmbeddedDatabaseBuilder()
+ .setType(EmbeddedDatabaseType.H2)
+ .addScript("schema.sql")
+ .addScript("data.sql")
+ .build();
+
+ MybatisFlexBootstrap bootstrap = MybatisFlexBootstrap.getInstance()
+ .setDataSource(dataSource)
+ .setLogImpl(NoLoggingImpl.class)
+ .addMapper(ArticleMapper.class)
+ .start();
+
+ //开启审计功能
+ AuditManager.setAuditEnable(true);
+
+ //设置 SQL 审计收集器
+ MessageCollector collector = new ConsoleMessageCollector();
+ AuditManager.setMessageCollector(collector);
+
+
+ articleMapper = bootstrap.getMapper(ArticleMapper.class);
+ }
+
+ @Test
+ public void testBatch() {
+ int count = 10;
+
+ Collection