geonetwork / core-geonetwork

GeoNetwork is a catalog application to manage spatially referenced resources. It provides powerful metadata editing and search functions as well as an interactive web map viewer. It is currently used in numerous Spatial Data Infrastructure initiatives across the world.
http://geonetwork-opensource.org/
GNU General Public License v2.0
433 stars 489 forks source link

Unit test XslUtilTest.testHtml2textSubstituteHtmlToTextLayoutElement fails on Windows. #8517

Open Desharin opened 1 week ago

Desharin commented 1 week ago

Describe the bug When building GeoNetwork 4.2.11 and running the unit tests, the test XslUtilTest.testHtml2textSubstituteHtmlToTextLayoutElement fails only on Windows machines. The following error is given: [ERROR] Failures: [ERROR] XslUtilTest.testHtml2textSubstituteHtmlToTextLayoutElement:47 expected:<Sample text[ Sample text 2] Sample text 3> but was:<Sample text[ ]ample text 2 Sample text 3>

This unit test tries to substitute the following html <div><span>Sample text</span><br/><span>Sample text 2</span><br/><span>Sample text 3</span></div>, but before passing it to the html parser it replaces all <br/> elements with System.getProperty("line.separator"). On Unix machines this is \n, but on Windows it's \r\n. I'm not entirely sure how or why this causes problems further down the line, but it makes the unit test fail and halts the generation build process. The function can be found here.

To Reproduce Steps to reproduce the behavior:

  1. Checkout tags/4.2.11 to your Windows machine.
  2. Run mvn clean install -Penv-prod
  3. Maven throws an error on the unit tests.

Expected behavior All unit tests to pass and complete the build.

Screenshots image

Desktop (please complete the following information):

tobias-hotz commented 6 days ago

FYI: This is not the only issue on windows currently. There is a PR to fix various broken tests and other code paths on windows: #8355