Skip to content

Commit 13efc22

Browse files
committed
Test status quo for @⁠Repeatable annotation support in AnnotationJmxAttributeSource
1 parent 6e1706a commit 13efc22

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationMetadataAssemblerTests.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.jmx.export.annotation;
1818

19+
import javax.management.MBeanNotificationInfo;
1920
import javax.management.modelmbean.ModelMBeanAttributeInfo;
2021
import javax.management.modelmbean.ModelMBeanInfo;
2122
import javax.management.modelmbean.ModelMBeanOperationInfo;
@@ -36,6 +37,17 @@ class AnnotationMetadataAssemblerTests extends AbstractMetadataAssemblerTests {
3637

3738
private static final String OBJECT_NAME = "bean:name=testBean4";
3839

40+
@Test
41+
@Override
42+
protected void notificationMetadata() throws Exception {
43+
ModelMBeanInfo info = (ModelMBeanInfo) getMBeanInfo();
44+
MBeanNotificationInfo[] notifications = info.getNotifications();
45+
assertThat(notifications).as("Incorrect number of notifications").hasSize(2);
46+
assertThat(notifications[0].getName()).as("Incorrect notification name").isEqualTo("My Notification 1");
47+
assertThat(notifications[0].getNotifTypes()).as("notification types").containsExactly("type.foo", "type.bar");
48+
assertThat(notifications[1].getName()).as("Incorrect notification name").isEqualTo("My Notification 2");
49+
assertThat(notifications[1].getNotifTypes()).as("notification types").containsExactly("type.enigma");
50+
}
3951

4052
@Test
4153
void testAttributeFromInterface() throws Exception {
@@ -111,4 +123,5 @@ protected int getExpectedAttributeCount() {
111123
protected int getExpectedOperationCount() {
112124
return super.getExpectedOperationCount() + 4;
113125
}
126+
114127
}

spring-context/src/test/java/org/springframework/jmx/export/annotation/AnnotationTestBean.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,10 +25,11 @@
2525
* @author Juergen Hoeller
2626
*/
2727
@Service("testBean")
28-
@ManagedResource(objectName = "bean:name=testBean4", description = "My Managed Bean", log = true,
28+
@ManagedResource(value = "bean:name=testBean4", description = "My Managed Bean", log = true,
2929
logFile = "build/jmx.log", currencyTimeLimit = 15, persistPolicy = "OnUpdate", persistPeriod = 200,
3030
persistLocation = "./foo", persistName = "bar.jmx")
31-
@ManagedNotification(name = "My Notification", notificationTypes = { "type.foo", "type.bar" })
31+
@ManagedNotification(name = "My Notification 1", notificationTypes = { "type.foo", "type.bar" })
32+
@ManagedNotification(name = "My Notification 2", notificationTypes = "type.enigma")
3233
public class AnnotationTestBean implements ITestBean {
3334

3435
private String name;

spring-context/src/test/java/org/springframework/jmx/export/assembler/AbstractJmxAssemblerTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -150,7 +150,7 @@ void attributeHasCorrespondingOperations() throws Exception {
150150
}
151151

152152
@Test
153-
void notificationMetadata() throws Exception {
153+
protected void notificationMetadata() throws Exception {
154154
ModelMBeanInfo info = (ModelMBeanInfo) getMBeanInfo();
155155
MBeanNotificationInfo[] notifications = info.getNotifications();
156156
assertThat(notifications).as("Incorrect number of notifications").hasSize(1);

0 commit comments

Comments
 (0)