From 0449db7aa9e1f705cf9f64629e4c0b89aab564de Mon Sep 17 00:00:00 2001 From: Looly Date: Thu, 24 Oct 2024 18:59:50 +0800 Subject: [PATCH] add test --- .../cn/hutool/core/bean/IssueIAYGT0Test.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 hutool-core/src/test/java/cn/hutool/core/bean/IssueIAYGT0Test.java diff --git a/hutool-core/src/test/java/cn/hutool/core/bean/IssueIAYGT0Test.java b/hutool-core/src/test/java/cn/hutool/core/bean/IssueIAYGT0Test.java new file mode 100644 index 000000000..303cf477a --- /dev/null +++ b/hutool-core/src/test/java/cn/hutool/core/bean/IssueIAYGT0Test.java @@ -0,0 +1,32 @@ +package cn.hutool.core.bean; + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class IssueIAYGT0Test { + + /** + * BeanUtil.setProperty默认调用的是BeanPath方法,在设置值时,使用BeanUtil.setFieldValue这个方法。 + * 此方法默认直接给字段赋值。 + * 这里确实存在一定的歧义性,但是考虑到兼容性,不做处理。 + */ + @Test + void setPropertyTest() { + Cat cat = new Cat(); + BeanUtil.setProperty(cat, "name", "Kitty"); + Assertions.assertEquals("Kitty", cat.getName()); + } + + static class Cat { + private String name; + + public void setName(String name) { + this.name = "Red" + name; + } + + public String getName() { + return name; + } + } + +}