initialize

This commit is contained in:
zhanghongqing
2022-08-09 16:54:16 +08:00
parent d8a2be0d09
commit b3fa11d4b1
247 changed files with 64494 additions and 78 deletions

View File

@@ -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() {
}
}

View File

@@ -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("tao@zhazhapan.com", "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());
}
}
}

View File

@@ -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);
}
}

View File

@@ -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));
}
}

View File

@@ -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)));
}
}

View File

@@ -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());
}
}

View File

@@ -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));
}
}

View File

@@ -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, "")));
}
}

View File

@@ -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());
}
}

View File

@@ -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, ""));
}
}

View File

@@ -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"));
}
}