Suppress deprecation warnings in tests

This commit is contained in:
Sam Brannen 2023-07-15 12:16:38 +02:00
parent 37ac3d8764
commit 8629182822
1 changed files with 14 additions and 0 deletions

View File

@ -360,6 +360,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
void onlyBonaFideMBeanIsExportedWhenAutodetectIsMBeanOnly() throws Exception { void onlyBonaFideMBeanIsExportedWhenAutodetectIsMBeanOnly() throws Exception {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(Person.class); BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(Person.class);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
@ -380,6 +381,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
void bonaFideMBeanAndRegularBeanExporterWithAutodetectAll() throws Exception { void bonaFideMBeanAndRegularBeanExporterWithAutodetectAll() throws Exception {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(Person.class); BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(Person.class);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
@ -403,6 +405,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
void bonaFideMBeanIsNotExportedWithAutodetectAssembler() throws Exception { void bonaFideMBeanIsNotExportedWithAutodetectAssembler() throws Exception {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(Person.class); BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(Person.class);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
@ -425,6 +428,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
* Want to ensure that said MBean is not exported twice. * Want to ensure that said MBean is not exported twice.
*/ */
@Test @Test
@SuppressWarnings("deprecation")
void bonaFideMBeanExplicitlyExportedAndAutodetectionIsOn() throws Exception { void bonaFideMBeanExplicitlyExportedAndAutodetectionIsOn() throws Exception {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(Person.class); BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(Person.class);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
@ -442,6 +446,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
void setAutodetectModeToOutOfRangeNegativeValue() { void setAutodetectModeToOutOfRangeNegativeValue() {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> exporter.setAutodetectMode(-1)) .isThrownBy(() -> exporter.setAutodetectMode(-1))
@ -450,6 +455,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
void setAutodetectModeToOutOfRangePositiveValue() { void setAutodetectModeToOutOfRangePositiveValue() {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> exporter.setAutodetectMode(5)) .isThrownBy(() -> exporter.setAutodetectMode(5))
@ -462,6 +468,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
* configured for all autodetect constants defined in {@link MBeanExporter}. * configured for all autodetect constants defined in {@link MBeanExporter}.
*/ */
@Test @Test
@SuppressWarnings("deprecation")
void setAutodetectModeToAllSupportedValues() { void setAutodetectModeToAllSupportedValues() {
streamAutodetectConstants() streamAutodetectConstants()
.map(MBeanExporterTests::getFieldValue) .map(MBeanExporterTests::getFieldValue)
@ -469,12 +476,14 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
void setAutodetectModeToSupportedValue() { void setAutodetectModeToSupportedValue() {
exporter.setAutodetectMode(MBeanExporter.AUTODETECT_ASSEMBLER); exporter.setAutodetectMode(MBeanExporter.AUTODETECT_ASSEMBLER);
assertThat(exporter.autodetectMode).isEqualTo(MBeanExporter.AUTODETECT_ASSEMBLER); assertThat(exporter.autodetectMode).isEqualTo(MBeanExporter.AUTODETECT_ASSEMBLER);
} }
@Test @Test
@SuppressWarnings("deprecation")
void setAutodetectModeNameToNull() { void setAutodetectModeNameToNull() {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> exporter.setAutodetectModeName(null)) .isThrownBy(() -> exporter.setAutodetectModeName(null))
@ -483,6 +492,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
void setAutodetectModeNameToAnEmptyString() { void setAutodetectModeNameToAnEmptyString() {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> exporter.setAutodetectModeName("")) .isThrownBy(() -> exporter.setAutodetectModeName(""))
@ -491,6 +501,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
void setAutodetectModeNameToWhitespace() { void setAutodetectModeNameToWhitespace() {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> exporter.setAutodetectModeName(" \t")) .isThrownBy(() -> exporter.setAutodetectModeName(" \t"))
@ -499,6 +510,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
void setAutodetectModeNameToBogusValue() { void setAutodetectModeNameToBogusValue() {
assertThatIllegalArgumentException() assertThatIllegalArgumentException()
.isThrownBy(() -> exporter.setAutodetectModeName("Bogus")) .isThrownBy(() -> exporter.setAutodetectModeName("Bogus"))
@ -511,6 +523,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
* configured for all autodetect constants defined in {@link MBeanExporter}. * configured for all autodetect constants defined in {@link MBeanExporter}.
*/ */
@Test @Test
@SuppressWarnings("deprecation")
void setAutodetectModeNameToAllSupportedValues() { void setAutodetectModeNameToAllSupportedValues() {
streamAutodetectConstants() streamAutodetectConstants()
.map(Field::getName) .map(Field::getName)
@ -518,6 +531,7 @@ public class MBeanExporterTests extends AbstractMBeanServerTests {
} }
@Test @Test
@SuppressWarnings("deprecation")
void setAutodetectModeNameToSupportedValue() { void setAutodetectModeNameToSupportedValue() {
exporter.setAutodetectModeName("AUTODETECT_ASSEMBLER"); exporter.setAutodetectModeName("AUTODETECT_ASSEMBLER");
assertThat(exporter.autodetectMode).isEqualTo(MBeanExporter.AUTODETECT_ASSEMBLER); assertThat(exporter.autodetectMode).isEqualTo(MBeanExporter.AUTODETECT_ASSEMBLER);