VIVIMAN
3 years ago
11 changed files with 268 additions and 104 deletions
@ -1,48 +0,0 @@ |
|||
package com.insigma.utils; |
|||
|
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.context.MessageSource; |
|||
import org.springframework.context.i18n.LocaleContextHolder; |
|||
import org.springframework.stereotype.Component; |
|||
import org.springframework.web.servlet.support.RequestContextUtils; |
|||
|
|||
import javax.servlet.http.HttpServletRequest; |
|||
|
|||
/** |
|||
* @author Vivim |
|||
*/ |
|||
@Component |
|||
@Slf4j |
|||
public class MessageSourceHandler { |
|||
// https://blog.csdn.net/P397226804/article/details/103960592
|
|||
@Autowired |
|||
private HttpServletRequest request; |
|||
|
|||
@Autowired |
|||
private MessageSource messageSource; |
|||
|
|||
/** |
|||
* 如果是根据Request请求的语言来决定国际化: |
|||
* |
|||
* @param messageKey |
|||
* @return |
|||
*/ |
|||
public String getMessage(String messageKey) { |
|||
String message = messageSource.getMessage(messageKey, null, RequestContextUtils.getLocale(request)); |
|||
return message; |
|||
} |
|||
|
|||
/** |
|||
* 如果是根据应用部署的服务器系统来决定国际化: |
|||
* |
|||
* @param messageKey |
|||
* @return |
|||
*/ |
|||
public String getMessageServer(String messageKey) { |
|||
String message = messageSource.getMessage(messageKey, null, LocaleContextHolder.getLocale()); |
|||
return message; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,16 @@ |
|||
package com.insigma.utils; |
|||
|
|||
import cn.hutool.db.Session; |
|||
import org.junit.Test; |
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
import java.sql.SQLException; |
|||
|
|||
public class DbUtilTest { |
|||
|
|||
@Test |
|||
public void getSessionTest() throws SQLException { |
|||
Session session = DbUtil.getSession("jdbc:mysql://127.0.0.1:35017/hy_qggwy", "root", "admin"); |
|||
String queryString = session.queryString("select count(1) from a01 limit 1"); |
|||
assertNotEquals("0", queryString); |
|||
} |
|||
} |
@ -0,0 +1,55 @@ |
|||
package com.insigma.utils; |
|||
|
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.junit.Test; |
|||
|
|||
import java.io.*; |
|||
|
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
@Slf4j |
|||
public class FileUtilTest { |
|||
|
|||
@Test |
|||
public void replaceLine() throws IOException { |
|||
String path = "D:\\EPWork\\idea\\java_tool\\src\\test\\java\\com\\insigma\\utils\\my.ini"; |
|||
String key = "read_rnd_buffer_size"; |
|||
String val = "read_rnd_buffer_size = 64M"; |
|||
FileUtil.replaceLine(path, key, val); |
|||
String temp = getValByKey(path, key); |
|||
assertEquals(val, temp); |
|||
log.info("完成测试!"); |
|||
} |
|||
|
|||
/*** |
|||
* 读取某行数据 |
|||
* @param path |
|||
* @param key |
|||
* @return |
|||
* @throws IOException |
|||
*/ |
|||
private String getValByKey(String path, String key) throws IOException { |
|||
File file = new File(path); |
|||
FileInputStream fis = new FileInputStream(file); |
|||
InputStreamReader isr = new InputStreamReader(fis); |
|||
BufferedReader br = new BufferedReader(isr); |
|||
String temp; |
|||
// 保存该行前面的内容
|
|||
while ((temp = br.readLine()) != null) { |
|||
if (temp.trim().startsWith(key)) { |
|||
return temp; |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
@Test |
|||
public void delAllFile() { |
|||
String path = "D:\\hzb2021\\mysql\\data-jyb"; |
|||
FileUtil.delAllFile(path); |
|||
File file = new File(path); |
|||
assertFalse(file.exists()); |
|||
log.info("完成测试!"); |
|||
} |
|||
} |
@ -0,0 +1,23 @@ |
|||
package com.insigma.utils; |
|||
|
|||
|
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.junit.Test; |
|||
|
|||
import java.io.File; |
|||
|
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
@Slf4j |
|||
public class WinCommandUtilTest { |
|||
|
|||
@Test |
|||
public void run() { |
|||
// 注意:该部分需要注意使用的分割线 下划线-
|
|||
String dir = "e:\\ccc"; |
|||
new WinCommandUtil("mkdir " + dir).run(); |
|||
File file = new File(dir); |
|||
assertTrue(file.exists()); |
|||
log.info("测试完成!"); |
|||
} |
|||
} |
@ -0,0 +1,38 @@ |
|||
package com.insigma.utils; |
|||
|
|||
|
|||
import com.insigma.config.AppCfg; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.junit.Test; |
|||
|
|||
import java.io.File; |
|||
|
|||
import static org.junit.jupiter.api.Assertions.*; |
|||
|
|||
@Slf4j |
|||
public class ZipUtilTest { |
|||
|
|||
static { |
|||
AppCfg.HZB = "D:\\hzb2021"; |
|||
} |
|||
|
|||
@Test |
|||
public void zip7Z() { |
|||
String dir = "E:\\aaa"; |
|||
String zip = "E:\\aaa.zip"; |
|||
ZipUtil.zip7Z(dir, zip); |
|||
File file = new File(zip); |
|||
assertTrue(file.exists()); |
|||
log.info("测试完成!"); |
|||
} |
|||
|
|||
@Test |
|||
public void unZip7Z() { |
|||
String dir = "E:\\bbb"; |
|||
String zip = "E:\\aaa.zip"; |
|||
ZipUtil.unZip7Z(zip, dir); |
|||
File file = new File(dir); |
|||
assertTrue(file.exists()); |
|||
log.info("测试完成!"); |
|||
} |
|||
} |
@ -0,0 +1,79 @@ |
|||
#high |
|||
[client] |
|||
port = 35017 |
|||
socket = MySQL |
|||
|
|||
[mysqld] |
|||
port = 35017 |
|||
socket = MySQL |
|||
max_allowed_packet = 64M |
|||
key_buffer_size = 32M |
|||
table_open_cache = 2048 |
|||
sort_buffer_size = 32M |
|||
read_buffer_size = 8M |
|||
read_rnd_buffer_size = 64M |
|||
myisam_sort_buffer_size = 64M |
|||
net_buffer_length = 1M |
|||
thread_cache_size = 16 |
|||
thread_stack = 16M |
|||
query_cache_size = 256M |
|||
# Try number of CPU's*2 for thread_concurrency |
|||
thread_concurrency = 8 |
|||
log_bin_trust_function_creators=1 |
|||
server-id = 1 |
|||
character-set-server=utf8 |
|||
default-storage-engine=INNODB |
|||
innodb_buffer_pool_size=3000M |
|||
innodb_additional_mem_pool_size=64M |
|||
innodb_flush_log_at_trx_commit =0 |
|||
innodb_log_buffer_size=32M |
|||
innodb_log_file_size=128M |
|||
sync_binlog = 1000 |
|||
innodb_autoextend_increment=32M |
|||
innodb_stats_on_metadata=OFF |
|||
innodb_read_io_threads=4 |
|||
innodb_write_io_threads = 4 |
|||
innodb_file_per_table = ON |
|||
innodb_file_per_table=1 |
|||
tmp_table_size = 256M |
|||
|
|||
max_connections = 500 |
|||
max_connect_errors = 30 |
|||
binlog_cache_size = 4M |
|||
max_heap_table_size = 128M |
|||
join_buffer_size = 32M |
|||
|
|||
sort_buffer_size = 12M |
|||
|
|||
[mysqldump] |
|||
quick |
|||
max_allowed_packet = 64M |
|||
key_buffer_size=128M |
|||
tmp_table_size =128M |
|||
|
|||
|
|||
[myisamchk] |
|||
read_buffer = 2M |
|||
write_buffer = 2M |
|||
|
|||
[mysql] |
|||
no-auto-rehash |
|||
default-character-set=utf8 |
|||
|
|||
[mysqlhotcopy] |
|||
interactive-timeout |
|||
max_allowed_packet = 64M |
|||
thread_cache_size = 16 |
|||
thread_concurrency = 8 |
|||
#table_cache = 4096 5.1.3 table_open_cache |
|||
#memlock |
|||
tmp_table_size = 128M |
|||
transaction_isolation = REPEATABLE-READ |
|||
#external-locking |
|||
#skip-networking |
|||
#log_slave_updates |
|||
#log |
|||
#log_warnings |
|||
#log_slow_queries |
|||
#long_query_time = 6 |
|||
#log_long_format |
Loading…
Reference in new issue