소스 검색

增加测试代码;以及相关的依赖

dinglan 2 년 전
부모
커밋
4f22288bca
5개의 변경된 파일98개의 추가작업 그리고 19개의 파일을 삭제
  1. 24 14
      pom.xml
  2. 4 2
      src/main/java/com/sw/domain/SysUser.java
  3. 3 3
      src/main/resources/application.yml
  4. 31 0
      src/test/java/com/sw/AddUserTest.java
  5. 36 0
      src/test/java/com/sw/RedisTest.java

+ 24 - 14
pom.xml

@@ -8,6 +8,7 @@
         <version>2.6.3</version>
         <relativePath/> <!-- lookup parent from repository -->
     </parent>
+
     <groupId>com.sw</groupId>
     <artifactId>mask</artifactId>
     <version>0.0.1-SNAPSHOT</version>
@@ -20,30 +21,35 @@
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
-            <version>2.6.1</version>
         </dependency>
-
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.boot</groupId>-->
+<!--            <artifactId>spring-boot-starter</artifactId>-->
+<!--        </dependency>-->
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-test</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>druid</artifactId>
+            <version>1.2.5</version>
+        </dependency>
         <!-- mysql -->
         <dependency>
             <groupId>mysql</groupId>
             <artifactId>mysql-connector-java</artifactId>
-            <version>5.1.47</version>
         </dependency>
         <!-- mybatis plus -->
         <dependency>
             <groupId>com.baomidou</groupId>
             <artifactId>mybatis-plus-boot-starter</artifactId>
-            <version>3.0.7.1</version>
+            <version>3.5.1</version>
         </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-activemq</artifactId>
-            <version>2.0.0.RELEASE</version>
         </dependency>
         <!-- lombok -->
         <dependency>
@@ -56,17 +62,21 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-data-redis</artifactId>
         </dependency>
-        <!--hutool工具类-->
-        <dependency>
-            <groupId>cn.hutool</groupId>
-            <artifactId>hutool-core</artifactId>
-            <version>4.4.0</version>
-        </dependency>
         <dependency>
-            <groupId>cn.hutool</groupId>
-            <artifactId>hutool-all</artifactId>
-            <version>4.5.7</version>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
         </dependency>
+        <!--hutool工具类-->
+<!--        <dependency>-->
+<!--            <groupId>cn.hutool</groupId>-->
+<!--            <artifactId>hutool-core</artifactId>-->
+<!--            <version>4.4.0</version>-->
+<!--        </dependency>-->
+<!--        <dependency>-->
+<!--            <groupId>cn.hutool</groupId>-->
+<!--            <artifactId>hutool-all</artifactId>-->
+<!--            <version>4.5.7</version>-->
+<!--        </dependency>-->
     </dependencies>
 
 

+ 4 - 2
src/main/java/com/sw/domain/SysUser.java

@@ -1,6 +1,7 @@
 package com.sw.domain;
 
 import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.AllArgsConstructor;
 import lombok.Data;
 
 import java.io.Serializable;
@@ -12,11 +13,12 @@ import java.io.Serializable;
  * @since 2022-02-18 10:27:19
  */
 @Data
+@AllArgsConstructor
 @TableName("sys_user")
 public class SysUser implements Serializable {
     private static final long serialVersionUID = 616589298019846813L;
 
-    private String id;
+    private Integer id;
 
 
-}
+}

+ 3 - 3
src/main/resources/application.yml

@@ -4,10 +4,10 @@ spring:
   application:
     name: mask
   datasource:
-    url: jdbc:mysql://124.70.152.102:3306/mask
+    url: jdbc:mysql://124.70.152.102:3306/mask?useSSL=false
     username: sunwin
     password: Sunwin@2020
-    driver-class-name: com.mysql.jdbc.Driver
+    driver-class-name: com.mysql.cj.jdbc.Driver
   redis:
     # 数据库索引,默认0
     database: 4
@@ -42,4 +42,4 @@ mybatis-plus:
     variables:
       nextTermDays: 90
       #mybatis-plus配置控制台打印完整带参数SQL语句
-    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

+ 31 - 0
src/test/java/com/sw/AddUserTest.java

@@ -0,0 +1,31 @@
+package com.sw;
+
+import com.sw.dao.SysUserDao;
+import com.sw.domain.SysUser;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import javax.annotation.Resource;
+
+/**
+ * @Description 手动录入大量用户
+ * @Author DingLan
+ * @Date 2022/2/18 10:18
+ **/
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class AddUserTest {
+
+    @Resource
+    private SysUserDao userDao;
+
+    @Test
+    private void addUser(){
+        for (int i = 0;i < 1000; i++){
+            SysUser user = new SysUser(i + 1);
+            userDao.insert(user);
+        }
+    }
+}

+ 36 - 0
src/test/java/com/sw/RedisTest.java

@@ -0,0 +1,36 @@
+package com.sw;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.jupiter.api.Order;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Description TODO
+ * @Author DingLan
+ * @Date 2022/2/18 10:29
+ **/
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class RedisTest {
+    @Autowired
+    private RedisTemplate redisTemplate;
+
+    @Test
+    @Order(2)
+    public void addSetTest(){
+        List<Integer> uids = new ArrayList<>();
+        for (int i = 0;i < 1000; i++){
+            uids.add(i + 1);
+        }
+        redisTemplate.opsForSet().add("userUid", uids.toArray());
+        Assert.assertEquals(1000l, redisTemplate.opsForSet().size("userUid").longValue());
+    }
+}