diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/NoSuchMethodFailureAnalyzerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/NoSuchMethodFailureAnalyzerTests.java index ad0f3fc89f4..5b44c5f161b 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/NoSuchMethodFailureAnalyzerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/NoSuchMethodFailureAnalyzerTests.java @@ -20,9 +20,6 @@ import javax.servlet.ServletContext; import javax.servlet.http.HttpServlet; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.DisabledOnJre; -import org.junit.jupiter.api.condition.EnabledOnJre; -import org.junit.jupiter.api.condition.JRE; import org.springframework.boot.diagnostics.FailureAnalysis; import org.springframework.boot.diagnostics.analyzer.NoSuchMethodFailureAnalyzer.NoSuchMethodDescriptor; @@ -50,12 +47,12 @@ class NoSuchMethodFailureAnalyzerTests { .isEqualTo("javax.servlet.ServletContext.addServlet(Ljava/lang/String;Ljavax/servlet/Servlet;)" + "Ljavax/servlet/ServletRegistration$Dynamic;"); assertThat(descriptor.getClassName()).isEqualTo("javax.servlet.ServletContext"); - assertThat(descriptor.getCandidateLocations()).isNotEmpty(); + assertThat(descriptor.getCandidateLocations().size()).isGreaterThan(1); assertThat(descriptor.getActualLocation()).asString().contains("servlet-api-2.5.jar"); } @Test - void parseJava13OpenJ9ErrorMessage() { + void parseJavaOpenJ9ErrorMessage() { NoSuchMethodDescriptor descriptor = new NoSuchMethodFailureAnalyzer().getNoSuchMethodDescriptor( "javax/servlet/ServletContext.addServlet(Ljava/lang/String;Ljavax/servlet/Servlet;)" + "Ljavax/servlet/ServletRegistration$Dynamic; (loaded from file..."); @@ -64,12 +61,12 @@ class NoSuchMethodFailureAnalyzerTests { .isEqualTo("javax/servlet/ServletContext.addServlet(Ljava/lang/String;Ljavax/servlet/Servlet;)" + "Ljavax/servlet/ServletRegistration$Dynamic;"); assertThat(descriptor.getClassName()).isEqualTo("javax.servlet.ServletContext"); - assertThat(descriptor.getCandidateLocations()).isNotEmpty(); + assertThat(descriptor.getCandidateLocations().size()).isGreaterThan(1); assertThat(descriptor.getActualLocation()).asString().contains("servlet-api-2.5.jar"); } @Test - void parseJava13HotspotErrorMessage() { + void parseJavaImprovedHotspotErrorMessage() { NoSuchMethodDescriptor descriptor = new NoSuchMethodFailureAnalyzer().getNoSuchMethodDescriptor( "'javax.servlet.ServletRegistration$Dynamic javax.servlet.ServletContext.addServlet(" + "java.lang.String, javax.servlet.Servlet)'"); @@ -78,34 +75,19 @@ class NoSuchMethodFailureAnalyzerTests { .isEqualTo("'javax.servlet.ServletRegistration$Dynamic javax.servlet.ServletContext.addServlet(" + "java.lang.String, javax.servlet.Servlet)'"); assertThat(descriptor.getClassName()).isEqualTo("javax.servlet.ServletContext"); - assertThat(descriptor.getCandidateLocations()).isNotEmpty(); + assertThat(descriptor.getCandidateLocations().size()).isGreaterThan(1); assertThat(descriptor.getActualLocation()).asString().contains("servlet-api-2.5.jar"); } @Test - @EnabledOnJre({ JRE.JAVA_8, JRE.JAVA_11, JRE.JAVA_12 }) - void noSuchMethodErrorIsAnalyzedJava8To12() { - testNoSuchMethodErrorFailureAnalysis( - "javax.servlet.ServletContext.addServlet(Ljava/lang/String;Ljavax/servlet/Servlet;)" - + "Ljavax/servlet/ServletRegistration$Dynamic;"); - } - - @Test - @DisabledOnJre({ JRE.JAVA_8, JRE.JAVA_11, JRE.JAVA_12 }) - void noSuchMethodErrorIsAnalyzedJava13AndLater() { - testNoSuchMethodErrorFailureAnalysis( - "'javax.servlet.ServletRegistration$Dynamic javax.servlet.ServletContext.addServlet(" - + "java.lang.String, javax.servlet.Servlet)'"); - } - - private void testNoSuchMethodErrorFailureAnalysis(String expectedMethodRepresentation) { + void noSuchMethodErrorIsAnalyzed() { Throwable failure = createFailure(); assertThat(failure).isNotNull(); FailureAnalysis analysis = new NoSuchMethodFailureAnalyzer().analyze(failure); assertThat(analysis).isNotNull(); assertThat(analysis.getDescription()) - .contains(NoSuchMethodFailureAnalyzerTests.class.getName() + ".createFailure(") - .contains(expectedMethodRepresentation).contains("class, javax.servlet.ServletContext,"); + .contains(NoSuchMethodFailureAnalyzerTests.class.getName() + ".createFailure(").contains("addServlet(") + .contains("class, javax.servlet.ServletContext,"); } private Throwable createFailure() {