-
Notifications
You must be signed in to change notification settings - Fork 5
[SLING-12493] Progressive cleanup of test cases #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
yuansc
commented
Nov 20, 2024
- Updated sling-bundle-parent to version 48.
- Upgraded test dependencies to the latest compatible versions.
- Migrated unit tests to use Mockito 5.
RhinoJavaScriptEngineFactory factory = new RhinoJavaScriptEngineFactory(); | ||
Whitebox.setInternalState(factory, "scriptCache", scriptCache); | ||
// RhinoJavaScriptEngineFactory factory = new RhinoJavaScriptEngineFactory(); | ||
// Whitebox.setInternalState(factory, "scriptCache", scriptCache); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't comment the code, but rather remove it. We have the git history to restore it if we ever need it again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR looks good! A couple of small notes on top of what Joerg added and we should be good to merge.
@@ -25,7 +25,6 @@ | |||
import org.apache.sling.commons.testing.jcr.RepositoryTestBase; | |||
import org.apache.sling.scripting.javascript.internal.ScriptEngineHelper; | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: please don't no whitespace only changes, it make it harder to track history of file changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still appears in the latest changeset.
@@ -142,16 +142,22 @@ | |||
<scope>provided</scope> | |||
</dependency> | |||
<!-- Testing --> | |||
<dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this dependency needed? If I remove it locally your PR works just fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines #145-150: The org.apache.sling.commons.osgi 2.4.2 dependency is required to resolve java.lang.NoClassDefFoundError: org/apache/sling/commons/osgi/Order test failures encountered when building with JDK 11 + Maven 3.9.6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see that when building locally with
Apache Maven 3.9.9
Maven home: /usr/share/maven
Java version: 11.0.25, vendor: Oracle Corporation, runtime: /usr/lib64/jvm/java-11-openjdk-11
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.11.8-1-default", arch: "amd64", family: "unix"
but it might be caused by the fact that we now declare the dependency twice
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.apache.sling:org.apache.sling.scripting.javascript:jar:3.1.5-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.apache.sling:org.apache.sling.commons.osgi:jar -> version 2.1.0 vs 2.4.2 @ line 145, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
I suggest you bump the existing Commons OSGi dependency to the version that is needed for the tests to pass and remove this one.
@yuansc - FWIW the build should pass but the SonarCloud checks fail (project is not onboarded). I opened SLING-12496 to track that. |
Oh, and the commit seems to belong to a different GitHub user - is that intended? https://github.com/scottyuancoc |
It was unintentional. I will fix it in the updated PR. |
3ac3691
to
6baa827
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick update @yuansc - some follow-up comments.
@@ -142,16 +142,22 @@ | |||
<scope>provided</scope> | |||
</dependency> | |||
<!-- Testing --> | |||
<dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see that when building locally with
Apache Maven 3.9.9
Maven home: /usr/share/maven
Java version: 11.0.25, vendor: Oracle Corporation, runtime: /usr/lib64/jvm/java-11-openjdk-11
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.11.8-1-default", arch: "amd64", family: "unix"
but it might be caused by the fact that we now declare the dependency twice
[WARNING]
[WARNING] Some problems were encountered while building the effective model for org.apache.sling:org.apache.sling.scripting.javascript:jar:3.1.5-SNAPSHOT
[WARNING] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.apache.sling:org.apache.sling.commons.osgi:jar -> version 2.1.0 vs 2.4.2 @ line 145, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
I suggest you bump the existing Commons OSGi dependency to the version that is needed for the tests to pass and remove this one.
@@ -25,7 +25,6 @@ | |||
import org.apache.sling.commons.testing.jcr.RepositoryTestBase; | |||
import org.apache.sling.scripting.javascript.internal.ScriptEngineHelper; | |||
|
|||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still appears in the latest changeset.
Hi @rombert, Thank you for your prompt response and feedback. The differing compilation results with Maven 3.9.9 and JDK 11.0.25 on Linux are indeed interesting. I will try the recommended approach and update the PR once the local build issue with Maven 3.9.6 and Oracle JDK 11.0.22 on Windows is resolved. Thanks! |
6baa827
to
bc66b2e
Compare
* Updated sling-bundle-parent to version 48. * Upgraded test dependencies to the latest compatible versions. * Migrated unit tests to use Mockito 5.
bc66b2e
to
f27e1e6
Compare
* Removed usage of deprecated initMocks() method. * Resolved local variable shadowing object field declarations. * Eliminated usage of deprecated MockResourceResolver.
Hello Everyone, To also address the issues reported by SonarQube Quality Gateway, I've push an additional commit to clean up the issue migrate all test cases to JUnit 5 discussed in https://issues.apache.org/jira/browse/SLING-12493. Hopefully, this additional commit would help with an cleaner start work to getting JDK 17 and JDK 21 in place through MOCK_JCR. Best Regards, |
I’ve added another commit to ensure proper closure of the JCR session upon completion of each test. With this latest commit, the JDK 17 and JDK 21 builds have been successful and clean. Could you kindly review and merge this pull request? If there are any additional improvements that could further enhance the codebase, please let me know, and I’ll be happy to make adjustments. Thank you very much! Best Regards, |
|
@yuansc - thanks for the follow-up. I would prefer a single Jira issue/PR for a single topic, so I would use one for fixing the tests, one for the JUnit 5 migration, etc. I will try to cherry-pick your initial commit to a separate PR and merge it directly, then we can iterate on the JUnit 5 fixes and other improvements. Hope that works for you. |
@yuansc - I merged your initial changes, please rebase on top of those (it's your exact first commit) and we can follow-up on the JUnit 5 migration. Thanks for the contribution! |