summaryrefslogtreecommitdiff
path: root/src/test/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com')
-rw-r--r--src/test/java/com/mesasoft/cn/SketchApplicationTest.java27
-rw-r--r--src/test/java/com/mesasoft/cn/common/CommonTest.java46
-rw-r--r--src/test/java/com/mesasoft/cn/common/SketchTest.java20
-rw-r--r--src/test/java/com/mesasoft/cn/config/SettingConfigTest.java27
-rw-r--r--src/test/java/com/mesasoft/cn/dao/AuthDAOTest.java30
-rw-r--r--src/test/java/com/mesasoft/cn/dao/CategoryDAOTest.java48
-rw-r--r--src/test/java/com/mesasoft/cn/dao/DownloadedDAOTest.java30
-rw-r--r--src/test/java/com/mesasoft/cn/dao/FileDAOTest.java32
-rw-r--r--src/test/java/com/mesasoft/cn/dao/UserDAOTest.java63
-rw-r--r--src/test/java/com/mesasoft/cn/dao/sqlprovider/FileSqlProviderTest.java41
-rw-r--r--src/test/java/com/mesasoft/cn/service/CategoryServiceTest.java24
11 files changed, 388 insertions, 0 deletions
diff --git a/src/test/java/com/mesasoft/cn/SketchApplicationTest.java b/src/test/java/com/mesasoft/cn/SketchApplicationTest.java
new file mode 100644
index 0000000..25e262b
--- /dev/null
+++ b/src/test/java/com/mesasoft/cn/SketchApplicationTest.java
@@ -0,0 +1,27 @@
+package com.mesasoft.cn;
+
+import com.zhazhapan.config.JsonParser;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+import java.io.IOException;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SketchApplicationTest {
+
+ public static void setSettings() {
+ try {
+ SketchApplication.settings = new JsonParser(SketchApplicationTest.class.getResource("/config.json"));
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/src/test/java/com/mesasoft/cn/common/CommonTest.java b/src/test/java/com/mesasoft/cn/common/CommonTest.java
new file mode 100644
index 0000000..ced07d6
--- /dev/null
+++ b/src/test/java/com/mesasoft/cn/common/CommonTest.java
@@ -0,0 +1,46 @@
+package com.mesasoft.cn.common;
+
+import com.mesasoft.cn.SketchApplication;
+import com.mesasoft.cn.SketchApplicationTest;
+import com.mesasoft.cn.modules.constant.ConfigConsts;
+import com.zhazhapan.util.FileExecutor;
+import com.zhazhapan.util.Formatter;
+import com.zhazhapan.util.MailSender;
+import org.junit.Test;
+
+import javax.swing.filechooser.FileSystemView;
+import java.io.File;
+
+/**
+ * @author pantao
+ * @since 2018/1/23
+ */
+public class CommonTest {
+
+ @Test
+ public void testSendEmail() throws Exception {
+ SketchApplicationTest.setSettings();
+ MailSender.config(SketchApplication.settings.getObjectUseEval(ConfigConsts.EMAIL_CONFIG_OF_SETTINGS));
+ MailSender.sendMail("[email protected]", "test", "test");
+ }
+
+ @Test
+ public void testGetDriver() {
+ FileSystemView fsv = FileSystemView.getFileSystemView();
+ File[] fs = File.listRoots();
+ for (File f : fs) {
+ System.out.println(fsv.getSystemDisplayName(f));
+ System.out.print("总大小" + Formatter.formatSize(f.getTotalSpace()));
+ System.out.println("剩余" + Formatter.formatSize(f.getFreeSpace()));
+ System.out.println(f.isDirectory());
+ }
+ }
+
+ @Test
+ public void testListRoot() {
+ File[] files = FileExecutor.listFile("/c:/");
+ for (File file : files) {
+ System.out.println(file.getName());
+ }
+ }
+}
diff --git a/src/test/java/com/mesasoft/cn/common/SketchTest.java b/src/test/java/com/mesasoft/cn/common/SketchTest.java
new file mode 100644
index 0000000..ad2aea4
--- /dev/null
+++ b/src/test/java/com/mesasoft/cn/common/SketchTest.java
@@ -0,0 +1,20 @@
+package com.mesasoft.cn.common;
+
+import org.junit.Test;
+
+/**
+ * @description:
+ * @author: zhq
+ * @create: 2022-03-18
+ **/
+public class SketchTest {
+
+
+ @Test
+ public void testSendEmail() throws Exception {
+ String searchPath = "D://test//test";
+ searchPath= searchPath.replace("\\\\","");
+ searchPath =searchPath.replace("//","");
+ System.err.println(searchPath);
+ }
+}
diff --git a/src/test/java/com/mesasoft/cn/config/SettingConfigTest.java b/src/test/java/com/mesasoft/cn/config/SettingConfigTest.java
new file mode 100644
index 0000000..9808586
--- /dev/null
+++ b/src/test/java/com/mesasoft/cn/config/SettingConfigTest.java
@@ -0,0 +1,27 @@
+package com.mesasoft.cn.config;
+
+import com.mesasoft.cn.SketchApplication;
+import com.mesasoft.cn.SketchApplicationTest;
+import com.mesasoft.cn.modules.constant.ConfigConsts;
+import org.junit.Test;
+
+import java.util.regex.Pattern;
+
+/**
+ * @author pantao
+ * @since 2018/1/26
+ */
+public class SettingConfigTest {
+
+ @Test
+ public void testFileSuffixPattern() {
+ SketchApplicationTest.setSettings();
+ assert Pattern.compile(SketchApplication.settings.getStringUseEval(ConfigConsts.FILE_SUFFIX_MATCH_OF_SETTING)).matcher("jpg").matches();
+ }
+
+ @Test
+ public void testGetStoragePath() {
+ SketchApplicationTest.setSettings();
+ System.out.println(SettingConfig.getStoragePath(ConfigConsts.TOKEN_OF_SETTINGS));
+ }
+}
diff --git a/src/test/java/com/mesasoft/cn/dao/AuthDAOTest.java b/src/test/java/com/mesasoft/cn/dao/AuthDAOTest.java
new file mode 100644
index 0000000..c3eb364
--- /dev/null
+++ b/src/test/java/com/mesasoft/cn/dao/AuthDAOTest.java
@@ -0,0 +1,30 @@
+package com.mesasoft.cn.dao;
+
+import com.mesasoft.cn.SketchApplicationTest;
+import com.zhazhapan.util.Formatter;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * @author pantao
+ * @since 2018/1/19
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class AuthDAOTest {
+
+ static {
+ SketchApplicationTest.setSettings();
+ }
+
+ @Autowired
+ private AuthDAO authDAO;
+
+ @Test
+ public void testGetAuthBy() {
+ System.out.println(Formatter.listToJson(authDAO.listAuthBy(0, 0, 0, "", 0)));
+ }
+}
diff --git a/src/test/java/com/mesasoft/cn/dao/CategoryDAOTest.java b/src/test/java/com/mesasoft/cn/dao/CategoryDAOTest.java
new file mode 100644
index 0000000..c389c5a
--- /dev/null
+++ b/src/test/java/com/mesasoft/cn/dao/CategoryDAOTest.java
@@ -0,0 +1,48 @@
+package com.mesasoft.cn.dao;
+
+import com.zhazhapan.util.Formatter;
+import com.zhazhapan.util.RandomUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * @author pantao
+ * @since 2018/1/18
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class CategoryDAOTest {
+
+ @Autowired
+ CategoryDAO categoryDAO;
+
+ @Test
+ public void testInsertCategory() {
+ for (int i = 0; i < 10; i++) {
+ categoryDAO.insertCategory(RandomUtils.getRandomStringOnlyLowerCase(6));
+ }
+ }
+
+ @Test
+ public void testRemoveCategoryById() {
+ categoryDAO.removeCategoryById(1);
+ }
+
+ @Test
+ public void testUpdateName() {
+ categoryDAO.updateNameById(3, "update");
+ }
+
+ @Test
+ public void testGetAllCategory() {
+ System.out.println(Formatter.listToJson(categoryDAO.listCategory()));
+ }
+
+ @Test
+ public void testGetCategoryById() {
+ System.out.println(categoryDAO.getCategoryById(6).toString());
+ }
+}
diff --git a/src/test/java/com/mesasoft/cn/dao/DownloadedDAOTest.java b/src/test/java/com/mesasoft/cn/dao/DownloadedDAOTest.java
new file mode 100644
index 0000000..df8ec44
--- /dev/null
+++ b/src/test/java/com/mesasoft/cn/dao/DownloadedDAOTest.java
@@ -0,0 +1,30 @@
+package com.mesasoft.cn.dao;
+
+import com.mesasoft.cn.SketchApplicationTest;
+import com.zhazhapan.modules.constant.ValueConsts;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * @author pantao
+ * @since 2018/1/19
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class DownloadedDAOTest {
+
+ static {
+ SketchApplicationTest.setSettings();
+ }
+
+ @Autowired
+ DownloadedDAO downloadDAO;
+
+ @Test
+ public void testGetDownloadBy() {
+ System.out.println(downloadDAO.listDownloadedBy(1, 1, "", ValueConsts.ZERO_INT, 0));
+ }
+}
diff --git a/src/test/java/com/mesasoft/cn/dao/FileDAOTest.java b/src/test/java/com/mesasoft/cn/dao/FileDAOTest.java
new file mode 100644
index 0000000..d96328c
--- /dev/null
+++ b/src/test/java/com/mesasoft/cn/dao/FileDAOTest.java
@@ -0,0 +1,32 @@
+package com.mesasoft.cn.dao;
+
+import com.mesasoft.cn.SketchApplicationTest;
+import com.zhazhapan.util.Formatter;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * @author pantao
+ * @since 2018/2/5
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class FileDAOTest {
+
+ @Autowired
+ FileDAO fileDAO;
+
+ @Test
+ public void testRemoveFile() {
+ assert fileDAO.removeById(3);
+ }
+
+ @Test
+ public void testGetUserDownloaded() {
+ SketchApplicationTest.setSettings();
+ System.out.println(Formatter.listToJson(fileDAO.listUserDownloaded(2, 0, "")));
+ }
+}
diff --git a/src/test/java/com/mesasoft/cn/dao/UserDAOTest.java b/src/test/java/com/mesasoft/cn/dao/UserDAOTest.java
new file mode 100644
index 0000000..214e325
--- /dev/null
+++ b/src/test/java/com/mesasoft/cn/dao/UserDAOTest.java
@@ -0,0 +1,63 @@
+package com.mesasoft.cn.dao;
+
+import com.mesasoft.cn.SketchApplicationTest;
+import com.mesasoft.cn.entity.User;
+import com.zhazhapan.util.Checker;
+import com.zhazhapan.util.Formatter;
+import com.zhazhapan.util.RandomUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * @author pantao
+ * @since 2018/1/18
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class UserDAOTest {
+
+ static {
+ SketchApplicationTest.setSettings();
+ }
+
+ @Autowired
+ private UserDAO userDAO;
+
+ @Test
+ public void testUpdateUserAuth() {
+ assert userDAO.updateAuthById(1, 1, 1, 1, 1, 1);
+ }
+
+ @Test
+ public void testUpdateUserLoginTime() {
+ assert userDAO.updateUserLoginTime(1);
+ }
+
+ @Test
+ public void testDoLogin() {
+ assert Checker.isNotNull(userDAO.login("system", "123456"));
+ }
+
+ @Test
+ public void testInsertUser() {
+ String username = RandomUtils.getRandomStringOnlyLowerCase(6);
+ String realName = RandomUtils.getRandomStringOnlyLowerCase(6);
+ String email = RandomUtils.getRandomEmail();
+ String password = RandomUtils.getRandomStringWithoutSymbol(16);
+ User user = new User(username, realName, email, password);
+ assert userDAO.insertUser(user);
+ }
+
+ @Test
+ public void testGetAllUser() {
+ System.out.println(Formatter.listToJson(userDAO.listUserBy(3, "", 0)));
+ }
+
+ @Test
+ public void testGetUser() {
+ System.out.println(userDAO.getUserById(1).toString());
+ }
+}
diff --git a/src/test/java/com/mesasoft/cn/dao/sqlprovider/FileSqlProviderTest.java b/src/test/java/com/mesasoft/cn/dao/sqlprovider/FileSqlProviderTest.java
new file mode 100644
index 0000000..1d1d201
--- /dev/null
+++ b/src/test/java/com/mesasoft/cn/dao/sqlprovider/FileSqlProviderTest.java
@@ -0,0 +1,41 @@
+package com.mesasoft.cn.dao.sqlprovider;
+
+import com.mesasoft.cn.SketchApplicationTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * @author pantao
+ * @since 2018/2/6
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class FileSqlProviderTest {
+
+ @Autowired
+ FileSqlProvider fileSqlProvider;
+
+ @Test
+ public void updateAuthById() {
+ System.out.println(fileSqlProvider.updateAuthById());
+ }
+
+ @Test
+ public void getAll() {
+ SketchApplicationTest.setSettings();
+ System.out.println(fileSqlProvider.getAll(0, 0, "", ""));
+ }
+
+ @Test
+ public void getUserUploaded() {
+ System.out.println(fileSqlProvider.getUserUploaded(0, ""));
+ }
+
+ @Test
+ public void getUserDownloaded() {
+ System.out.println(fileSqlProvider.getUserDownloaded(0, ""));
+ }
+}
diff --git a/src/test/java/com/mesasoft/cn/service/CategoryServiceTest.java b/src/test/java/com/mesasoft/cn/service/CategoryServiceTest.java
new file mode 100644
index 0000000..1245c03
--- /dev/null
+++ b/src/test/java/com/mesasoft/cn/service/CategoryServiceTest.java
@@ -0,0 +1,24 @@
+package com.mesasoft.cn.service;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+/**
+ * @author pantao
+ * @since 2018/2/9
+ */
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class CategoryServiceTest {
+
+ @Autowired
+ ICategoryService categoryService;
+
+ @Test
+ public void testGetIdByName() {
+ System.out.println(categoryService.getIdByName("fff"));
+ }
+}