eugenp / tutorials

Just Announced - "Learn Spring Security OAuth":

Home Page:http://bit.ly/github-lsso

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[ISSUE] unit test core-java-jvm3 fails - with bugfix in description

Andromeda-DBSYSTEL opened this issue · comments

Article and Module Links
Difference Between Class.getResource() and ClassLoader.getResource()
https://www.baeldung.com/java-class-vs-classloader-getresource

Describe the Issue
The unit test of the corresponding code to the article fails
project: https://github.com/eugenp/tutorials/tree/master/core-java-modules/core-java-jvm-3

To Reproduce
Steps to reproduce the behavior:
git clone https://github.com/eugenp/tutorials.git baeldung
cd baeldung/core-java-modules/core-java-jvm-3
mvn test
[WARNING] Tests run: 6, Failures: 0, Errors: 0, Skipped: 2

removed @disabled annotation in 2 files
core-java-modules/core-java-jvm-3/src/test/java/com/baeldung/resource/ClassGetResourceUnitTest.java
core-java-modules/core-java-jvm-3/src/test/java/com/baeldung/resource/ClassLoaderGetResourceUnitTest.java

mvn test

[ERROR] Tests run: 2, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 0.167 s <<< FAILURE! - in com.baeldung.resource.ClassGetResourceUnitTest
[ERROR] givenRelativeResourcePath_whenGetResource_thenReturnResource Time elapsed: 0.116 s <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: not
at com.baeldung.resource.ClassGetResourceUnitTest.givenRelativeResourcePath_whenGetResource_thenReturnResource(ClassGetResourceUnitTest.java:15)

[ERROR] givenAbsoluteResourcePath_whenGetResource_thenReturnResource Time elapsed: 0.004 s <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: not
at com.baeldung.resource.ClassGetResourceUnitTest.givenAbsoluteResourcePath_whenGetResource_thenReturnResource(ClassGetResourceUnitTest.java:21)

this fixes the bug in the unit test

moved
core-java-modules/core-java-jvm-3/src/resources/com/baeldung/resource/example.txt

to
core-java-modules/core-java-jvm-3/src/main/resources/com/baeldung/resource/example.txt

after the movement of the example.txt location, the unit tests work fine
mvn test
[INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0

Expected Behavior
After mvn test, expecting no skipped tests nor errors
[INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • OS: [win10]
  • Browser [chrome]
  • Version [122.0.6261.129]

Additional Context

Hello Andromeda-DBSYSTEL
Thank you very much for raising the issue and giving us the solution. I am happy to confirm you that the problem has been fixed (#16283).
Kind regards,