mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add test and fix method
This commit is contained in:
parent
dc3d6079cc
commit
ae070453aa
@ -25,6 +25,7 @@ import org.dromara.hutool.http.client.cookie.CookieStoreSpi;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -70,9 +71,21 @@ public class HttpClient5CookieStore extends SimpleWrapper<CookieStoreSpi> implem
|
||||
|
||||
@Override
|
||||
public boolean clearExpired(final Date date) {
|
||||
// get时检查过期
|
||||
this.raw.getCookies();
|
||||
return true;
|
||||
return clearExpired(date.toInstant());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean clearExpired(final Instant date) {
|
||||
boolean removeSome = false;
|
||||
for (final URI uri : this.raw.getURIs()) {
|
||||
for (final CookieSpi cookie : this.raw.get(uri)) {
|
||||
if (cookie.isExpired(date)) {
|
||||
this.raw.remove(uri, cookie);
|
||||
removeSome = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return removeSome;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -444,10 +444,13 @@ public class JSONObjectTest {
|
||||
beanWithAlias.setValue1("张三");
|
||||
beanWithAlias.setValue2(35);
|
||||
|
||||
// 测试对象字段中使用alias注解转换json后是否成功
|
||||
final JSONObject jsonObject = JSONUtil.parseObj(beanWithAlias);
|
||||
assertEquals("{\"name\":\"张三\",\"age\":35}", jsonObject.toString());
|
||||
assertEquals("张三", jsonObject.getStr("name"));
|
||||
assertEquals(Integer.valueOf(35), jsonObject.getInt("age"));
|
||||
|
||||
// 测试json转对象时,是否使用了alias注解
|
||||
final JSONObject json = JSONUtil.ofObj()
|
||||
.putValue("name", "张三")
|
||||
.putValue("age", 35);
|
||||
|
Loading…
x
Reference in New Issue
Block a user