mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix test
This commit is contained in:
parent
4949756dd6
commit
68ad664fec
@ -1,5 +1,8 @@
|
||||
package cn.hutool.core.thread;
|
||||
|
||||
import cn.hutool.core.builder.Builder;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
@ -11,12 +14,16 @@ import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import cn.hutool.core.builder.Builder;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
||||
/**
|
||||
* {@link ThreadPoolExecutor} 建造者
|
||||
*
|
||||
* <pre>
|
||||
* 1. 如果池中任务数 < corePoolSize -》 放入立即执行
|
||||
* 2. 如果池中任务数 > corePoolSize -》 放入队列等待
|
||||
* 3. 队列满 -》 新建线程立即执行
|
||||
* 4. 执行中的线程 > maxPoolSize -》 触发handler(RejectedExecutionHandler)异常
|
||||
* </pre>
|
||||
*
|
||||
* @author looly
|
||||
* @since 4.1.9
|
||||
*/
|
||||
@ -39,7 +46,7 @@ public class ExecutorBuilder implements Builder<ThreadPoolExecutor> {
|
||||
*/
|
||||
private long keepAliveTime = TimeUnit.SECONDS.toNanos(60);
|
||||
/**
|
||||
* 队列,用于存在未执行的线程
|
||||
* 队列,用于存放未执行的线程
|
||||
*/
|
||||
private BlockingQueue<Runnable> workQueue;
|
||||
/**
|
||||
@ -105,7 +112,7 @@ public class ExecutorBuilder implements Builder<ThreadPoolExecutor> {
|
||||
*
|
||||
* <pre>
|
||||
* 1. {@link SynchronousQueue} 它将任务直接提交给线程而不保持它们。当运行线程小于maxPoolSize时会创建新线程,否则触发异常策略
|
||||
* 2. {@link LinkedBlockingQueue} 默认无界队列,当运行线程大于corePoolSize时始终放入此队列,此时maximumPoolSize无效。
|
||||
* 2. {@link LinkedBlockingQueue} 默认无界队列,当运行线程大于corePoolSize时始终放入此队列,此时maxPoolSize无效。
|
||||
* 当构造LinkedBlockingQueue对象时传入参数,变为有界队列,队列满时,运行线程小于maxPoolSize时会创建新线程,否则触发异常策略
|
||||
* 3. {@link ArrayBlockingQueue} 有界队列,相对无界队列有利于控制队列大小,队列满时,运行线程小于maxPoolSize时会创建新线程,否则触发异常策略
|
||||
* </pre>
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.crypto.test;
|
||||
package cn.hutool.crypto.test.asymmetric;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.asymmetric.ECIES;
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.crypto.test;
|
||||
package cn.hutool.crypto.test.asymmetric;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.crypto.test;
|
||||
package cn.hutool.crypto.test.asymmetric;
|
||||
|
||||
import cn.hutool.core.codec.Base64;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
@ -21,7 +21,6 @@ import java.security.PublicKey;
|
||||
* SM2算法单元测试
|
||||
*
|
||||
* @author Looly, Gsealy
|
||||
*
|
||||
*/
|
||||
public class SM2Test {
|
||||
|
||||
@ -138,6 +137,19 @@ public class SM2Test {
|
||||
|
||||
KeyPair pair = SecureUtil.generateKeyPair("SM2");
|
||||
|
||||
final SM2 sm2 = new SM2(pair.getPrivate(), pair.getPublic());
|
||||
|
||||
byte[] sign = sm2.sign(content.getBytes());
|
||||
boolean verify = sm2.verify(content.getBytes(), sign);
|
||||
Assert.assertTrue(verify);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sm2SignAndVerifyUseKeyTest2() {
|
||||
String content = "我是Hanley.";
|
||||
|
||||
KeyPair pair = SecureUtil.generateKeyPair("SM2");
|
||||
|
||||
final SM2 sm2 = new SM2(//
|
||||
HexUtil.encodeHexStr(pair.getPrivate().getEncoded()), //
|
||||
HexUtil.encodeHexStr(pair.getPublic().getEncoded())//
|
||||
@ -162,7 +174,7 @@ public class SM2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sm2WithPointTest(){
|
||||
public void sm2WithPointTest() {
|
||||
String d = "FAB8BBE670FAE338C9E9382B9FB6485225C11A3ECB84C938F10F20A93B6215F0";
|
||||
String x = "9EF573019D9A03B16B0BE44FC8A5B4E8E098F56034C97B312282DD0B4810AFC3";
|
||||
String y = "CC759673ED0FC9B9DC7E6FA38F0E2B121E02654BF37EA6B63FAF2A0D6013EADF";
|
||||
@ -176,7 +188,7 @@ public class SM2Test {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sm2PlainWithPointTest(){
|
||||
public void sm2PlainWithPointTest() {
|
||||
// 测试地址:https://i.goto327.top/CryptTools/SM2.aspx?tdsourcetag=s_pctim_aiomsg
|
||||
|
||||
String d = "FAB8BBE670FAE338C9E9382B9FB6485225C11A3ECB84C938F10F20A93B6215F0";
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.crypto.test;
|
||||
package cn.hutool.crypto.test.asymmetric;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import org.junit.Assert;
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.crypto.test;
|
||||
package cn.hutool.crypto.test.digest;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.crypto.test;
|
||||
package cn.hutool.crypto.test.symmetric;
|
||||
|
||||
import cn.hutool.crypto.Mode;
|
||||
import cn.hutool.crypto.Padding;
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.crypto.test;
|
||||
package cn.hutool.crypto.test.symmetric;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.Mode;
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.crypto.test;
|
||||
package cn.hutool.crypto.test.symmetric;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
@ -1,4 +1,4 @@
|
||||
package cn.hutool.crypto.test;
|
||||
package cn.hutool.crypto.test.symmetric;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
Loading…
x
Reference in New Issue
Block a user