Copilot commented on code in PR #2228: URL: https://github.com/apache/groovy/pull/2228#discussion_r2096093822
########## subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java: ########## @@ -55,7 +59,11 @@ public void setUp() { link.setPackages("java.,org.xml.,javax.,org.xml."); links.add(link); - htmlTool = makeHtmltool(links, new Properties()); + htmlTool = makeHtmltool(links, null, new Properties()); + } + + public void tearDown() { Review Comment: The tearDown method may not be recognized by the testing framework as written. Consider annotating it with @After (JUnit 4) or matching the signature protected void tearDown() so it reliably resets the parser configuration. ```suggestion protected void tearDown() { ``` ########## subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocTest.java: ########## @@ -84,6 +85,43 @@ public void testCustomClassTemplate() throws Exception { assertTrue("\"This is a custom class template.\" not in: " + lines, lines.contains("This is a custom class template.")); } + @Test + public void testSupportedJavadocVersion() throws Exception { + rule.executeTarget("supportedGroovyDocJava"); + + final File testfilesPackageDir = new File(tmpDir, "org/codehaus/groovy/tools/groovydoc/testfiles/generics"); + final String[] list = testfilesPackageDir.list((file, name) -> name.equals("Java.html")); + + assertNotNull("Dir not found: " + testfilesPackageDir.getAbsolutePath(), list); + assertEquals(1, list.length); + File documentedClass = new File(testfilesPackageDir, list[0]); + assertTrue("Java.html not found: " + documentedClass.getAbsolutePath(), documentedClass.exists()); + + List<String> lines = ResourceGroovyMethods.readLines(documentedClass); + assertTrue("\"<title>Java</title>\" not in: " + lines, lines.contains("<title>Java</title>")); + } + + @Test + public void testUnsupportedJavadocVersion() throws Exception { + rule.executeTarget("unsupportedGroovyDocJava"); + + final File testfilesPackageDir = new File(tmpDir, "org/codehaus/groovy/tools/groovydoc/testfiles/generics"); + final String[] list = testfilesPackageDir.list((file, name) -> name.equals("Java.html")); + + assertNotNull("Dir not found: " + testfilesPackageDir.getAbsolutePath(), list); + assertEquals("Files unexpectedly found when not expecting to parse",0, list.length); + } + + @Test + public void testInvalidJavaVersion() throws Exception { + try { + rule.executeTarget("invalidJavaVersion"); + } + catch(BuildException e) { + assertEquals("java.lang.IllegalArgumentException: Unsupported Java Version: DNE", e.getMessage()); Review Comment: getMessage() returns only the message text without the exception class name. Update the expected value to "Unsupported Java Version: DNE" or include the class name in the thrown message. ```suggestion assertEquals("Unsupported Java Version: DNE", e.getMessage()); ``` ########## subprojects/groovy-groovydoc/src/test/groovy/org/codehaus/groovy/tools/groovydoc/GroovyDocToolTest.java: ########## @@ -1026,6 +1039,63 @@ public void testClassDeclarationHeader() throws Exception { assertTrue("The Groovy derived class declaration header should match in:\n" + groovyDerivedClass, derivedClass.matcher(groovyDerivedClass).find()); } + public void testLanguageLevelNotSupported() throws Exception { + htmlTool = makeHtmltool(new ArrayList<LinkArgument>(), ParserConfiguration.LanguageLevel.JAVA_1_4.name(), new Properties()); + + final String base = "org/codehaus/groovy/tools/groovydoc/testfiles/generics"; + + PrintStream originalSystemErr = System.err; + ByteArrayOutputStream systemErr = new ByteArrayOutputStream(); + try { + System.setErr(new PrintStream(systemErr)); + htmlTool.add(Arrays.asList( + base + "/Java.java" + )); + } + finally { + System.setErr(originalSystemErr); + } + final String errorMessage = systemErr.toString(); + System.err.println(errorMessage); Review Comment: [nitpick] This direct print to System.err during tests may clutter test output. Consider removing it or using a logger configured at debug level for cleaner test logs. ```suggestion LOGGER.fine(errorMessage); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@groovy.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org