Skip to content

Commit c418118

Browse files
committed
Polishing
1 parent fb3f308 commit c418118

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ void setAutodetectModeToOutOfRangePositiveValue() {
463463
*/
464464
@Test
465465
void setAutodetectModeToAllSupportedValues() {
466-
streamConstants(MBeanExporter.class)
466+
streamAutodetectConstants()
467467
.map(MBeanExporterTests::getFieldValue)
468468
.forEach(mode -> assertThatNoException().isThrownBy(() -> exporter.setAutodetectMode(mode)));
469469
}
@@ -512,7 +512,7 @@ void setAutodetectModeNameToBogusValue() {
512512
*/
513513
@Test
514514
void setAutodetectModeNameToAllSupportedValues() {
515-
streamConstants(MBeanExporter.class)
515+
streamAutodetectConstants()
516516
.map(Field::getName)
517517
.forEach(name -> assertThatNoException().isThrownBy(() -> exporter.setAutodetectModeName(name)));
518518
}
@@ -703,8 +703,10 @@ public ModelMBeanInfo getMBeanInfo(Object managedResource, String beanKey) throw
703703
}
704704
}
705705

706-
private static Stream<Field> streamConstants(Class<?> clazz) {
707-
return Arrays.stream(clazz.getFields()).filter(ReflectionUtils::isPublicStaticFinal);
706+
private static Stream<Field> streamAutodetectConstants() {
707+
return Arrays.stream(MBeanExporter.class.getFields())
708+
.filter(ReflectionUtils::isPublicStaticFinal)
709+
.filter(field -> field.getName().startsWith("AUTODETECT_"));
708710
}
709711

710712
private static Integer getFieldValue(Field field) {

0 commit comments

Comments
 (0)