Skip to content

Commit 8c07b16

Browse files
binarywangCopilot
andauthored
Update weixin-java-cp/src/test/java/me/chanjar/weixin/cp/config/impl/WxCpRedisConfigImplTest.java
Co-authored-by: Copilot <[email protected]>
1 parent 32158d2 commit 8c07b16

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

weixin-java-cp/src/test/java/me/chanjar/weixin/cp/config/impl/WxCpRedisConfigImplTest.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,17 @@ public void testGetWebhookKeyNoInfiniteRecursion() {
3030
// 我们通过反射来设置这个字段以测试 getter 的正确性
3131
try {
3232
java.lang.reflect.Field field = WxCpRedisConfigImpl.class.getDeclaredField("webhookKey");
33+
boolean originalAccessible = field.isAccessible();
3334
field.setAccessible(true);
34-
String testWebhookKey = "test-webhook-key-123";
35-
field.set(config, testWebhookKey);
36-
37-
String retrievedKey = config.getWebhookKey();
38-
Assert.assertEquals(retrievedKey, testWebhookKey, "应该返回设置的 webhookKey 值");
35+
try {
36+
String testWebhookKey = "test-webhook-key-123";
37+
field.set(config, testWebhookKey);
38+
39+
String retrievedKey = config.getWebhookKey();
40+
Assert.assertEquals(retrievedKey, testWebhookKey, "应该返回设置的 webhookKey 值");
41+
} finally {
42+
field.setAccessible(originalAccessible);
43+
}
3944
} catch (NoSuchFieldException | IllegalAccessException e) {
4045
Assert.fail("反射设置 webhookKey 失败: " + e.getMessage());
4146
}

0 commit comments

Comments
 (0)