-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Fixes #1997 : make mockito-junit-jupiter workin in OSGiMockitoExtensi… #2047
Conversation
Codecov Report
@@ Coverage Diff @@
## release/3.x #2047 +/- ##
=================================================
+ Coverage 84.89% 84.92% +0.02%
Complexity 2704 2704
=================================================
Files 325 325
Lines 8204 8204
Branches 979 979
=================================================
+ Hits 6965 6967 +2
Misses 968 968
+ Partials 271 269 -2
Continue to review full report at Codecov.
|
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 understand the usage of the apiguardian, but I am not thrilled of adding another compile dependency to Mockito. I am going to ponder on it a bit to understand why it is used and whether there are alternative solutions available.
* in https://github.com/gradle/gradle/blob/58538513a3bff3b7015718976fe1304e23f40694/subprojects/core/src/main/java/org/gradle/api/internal/file/archive/ZipCopyAction.java#L42-L57 | ||
*/ | ||
|
||
class RemoveOsgiLastModifiedHeader { |
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.
It's not clear to me why this part was removed and what changed it. Could you please add a comment to the functionality that replaces it to explain why we need it? (E.g. reproducible jars) And could you update your commit message to explain the change that was made.
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.
bnd has this feature builtin! I enabled it by adding -noextraheaders: true
rendering this code obsolete.
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.
if you diff the results before and after (which I did to double check) you will see what I mean :)
} | ||
|
||
// Bnd's Resolve task is what verifies that a jar can be used in OSGi and | ||
// that its metadata is valid. If the metadata is invalid this task will |
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.
Could you add an example in the comment what would be invalid?
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.
An error will cause the build to fail with something like this:
> Task :junit-jupiter:verifyOSGi FAILED
Resolution failed. Capabilities satisfying the following requirements could not be found:
[<<INITIAL>>]
⇒ osgi.identity: (osgi.identity=org.mockito.junit-jupiter)
⇒ [org.mockito.junit-jupiter version=3.5.11]
⇒ osgi.wiring.package: (osgi.wiring.package=com.foo)
I triggered this failure by manually importing a fake package com.foo
(to replicate some package which cannot be satisfied by the available runtime dependencies) which is the same effect for any change that would inadvertently break the OSGi support.
If such a failure ever happens, you can ping me and I would be more than happy to help track down the reason (though I think it might become obvious to you pretty quickly :) )
@TimvdLippe we could avoid using apiguardian if you prefer. There are three main options:
Let's consider the differences that would be involved: HTH a little. |
whichever option you choose I can refactor the PR into... it's not a problem. I immediately opted to go with the most ideal solution from the OSGi perspective. but I understand if you opt to chose something less invasive! :) |
Thanks for the explanations! I will think a bit about it and then get back to you 😄 |
I have filed apiguardian-team/apiguardian#19 to explore adding the annotation on a package statement. Then we would only need to add it to the |
@rotty3000 Do you think it would be worth reconsidering the fragment approach?
I'm not sure that I agree that being a fragment would give a poor OSGi experience. The Mockito JUnit 5 "bundle" contains types that are explicitly referenced and used in test classes in an "API" package, and then those make use of internal packages from Mockito. It's not like JUnit 5, where I need a bunch of types that I don't have a direct dependency chain to (e.g. the JUnit engine and launcher). Essentially if I make use of While I'm sure the enhanced API Guardian support will be useful in the future I am keen to see this issue fixed in Mockito sooner if possible. |
@rotty3000 Could you give an update on this PR? |
I'm doing an updated check on this. Sorry for the delay. |
…Extension cannot be used with JUnit 5 in OSGi integration tests without a) giving up the internal nature of some packages b) resorting to substandard solutions like OSGi fragements Signed-off-by: Raymond Augé <raymond.auge@liferay.com>
65c3bb9
to
83a1bcb
Compare
I'm made small changes that I think simplify the solution and don't require API guardian to be updated or even used directly, but still leverage it's support in bnd (without any changes being required). i.e. this solution is complete and mergeable as is. |
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 all the work that was involved into this!
Thanks a lot! It's great to see a fix for the issue merged. 👍 |
…on
without
a) giving up the internal nature of some packages
b) resorting to substandard solutions like OSGi fragements
Signed-off-by: Raymond Augé raymond.auge@liferay.com
check list
including project members to get a better picture of the change
commit is meaningful and help the people that will explore a change in 2 years
Fixes #<issue number>
in the description if relevantFixes #<issue number>
if relevant