-
Notifications
You must be signed in to change notification settings - Fork 468
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
ByteBuddyMockFactory adds @Internal
annotation to Groovy MOP methods
#1729
ByteBuddyMockFactory adds @Internal
annotation to Groovy MOP methods
#1729
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #1729 +/- ##
============================================
+ Coverage 79.83% 79.85% +0.02%
- Complexity 4084 4096 +12
============================================
Files 425 425
Lines 12953 12964 +11
Branches 1640 1642 +2
============================================
+ Hits 10341 10353 +12
+ Misses 2000 1999 -1
Partials 612 612
☔ View full report in Codecov by Sentry. |
70bc712
to
ff8b78c
Compare
@Internal
annotation to Groovy MOP methods
12de4f8
to
99306f3
Compare
99306f3
to
e9f15e4
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, just some small changes
spock-core/src/main/java/org/spockframework/mock/runtime/ByteBuddyMockFactory.java
Outdated
Show resolved
Hide resolved
spock-specs/src/test/groovy/org/spockframework/mock/AccessProtectedPropsSpec.groovy
Outdated
Show resolved
Hide resolved
spock-specs/src/test/groovy/org/spockframework/smoke/mock/JavaMocksForGroovyClasses.groovy
Outdated
Show resolved
Hide resolved
spock-specs/src/test/groovy/org/spockframework/smoke/mock/JavaMocksForGroovyClasses.groovy
Outdated
Show resolved
Hide resolved
23e1799
to
20d3f26
Compare
spock-specs/src/test/groovy/org/spockframework/mock/AccessProtectedPropsSpec.groovy
Outdated
Show resolved
Hide resolved
spock-specs/src/test/groovy/org/spockframework/smoke/mock/JavaMocksForGroovyClasses.groovy
Outdated
Show resolved
Hide resolved
spock-specs/src/test/groovy/org/spockframework/smoke/mock/JavaMocksForGroovyClasses.groovy
Outdated
Show resolved
Hide resolved
20d3f26
to
cf69f0b
Compare
cf69f0b
to
843d670
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.
You mentioned this will fix #1608, but no @Issue
mentions it.
If an already existing test covers it, please add a second @Issue
annotation, if not please add a test for that case.
spock-core/src/main/java/org/spockframework/mock/runtime/ByteBuddyMockFactory.java
Outdated
Show resolved
Hide resolved
spock-core/src/main/java/org/spockframework/mock/runtime/ByteBuddyMockFactory.java
Outdated
Show resolved
Hide resolved
spock-core/src/main/java/org/spockframework/mock/runtime/ByteBuddyMockFactory.java
Outdated
Show resolved
Hide resolved
spock-core/src/main/java/org/spockframework/mock/runtime/ByteBuddyMockFactory.java
Show resolved
Hide resolved
spock-core/src/main/java/org/spockframework/mock/runtime/ByteBuddyMockFactory.java
Outdated
Show resolved
Hide resolved
spock-core/src/main/java/org/spockframework/mock/runtime/ByteBuddyMockFactory.java
Outdated
Show resolved
Hide resolved
spock-specs/src/test/groovy/org/spockframework/mock/MockMapDelegateSpec.groovy
Show resolved
Hide resolved
spock-core/src/main/java/org/spockframework/mock/runtime/ByteBuddyMockFactory.java
Outdated
Show resolved
Hide resolved
6b6c1cb
to
6505a77
Compare
The Groovy 3 & 4 runtime expects to have the @internal annotation on the MOP methods from GroovyObject. That AbstractCallSite.createGroovyObjectGetPropertySite() processes it as GroovyObject. So the ByteBuddyMockFactory now adds the @internal annotation to the intercepted MOP methods. After that the "Unable to access protected constant when spying instances" problems are gone, because we take the normal Groovy route. Also some strange inconsistencies for Groovy 2 <=> 3,4 are now gone, but a new inconsistency appeared Groovy 4 prefers is over get for boolean. But this is not a Spock issue, because in Groovy only code the same thing happens. See tests in JavaMocksForGroovyClasses. The test "Access protected fields Issue spockframework#1452" covers the "MissingMethodException when accessing fields without explicit @" issue. This fixes spockframework#1145, spockframework#1452, spockframework#1501, spockframework#1608 Co-authored-by: Björn Kautler <[email protected]>
6505a77
to
95c6ee5
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.
The more often I look, the more I find. 🙈
spock-specs/src/test/groovy/org/spockframework/mock/AccessProtectedPropsSpec.groovy
Outdated
Show resolved
Hide resolved
spock-specs/src/test/groovy/org/spockframework/mock/AccessProtectedPropsSpec.groovy
Outdated
Show resolved
Hide resolved
spock-specs/src/test/groovy/org/spockframework/mock/AccessProtectedPropsSpec.groovy
Outdated
Show resolved
Hide resolved
spock-specs/src/test/groovy/org/spockframework/mock/AccessProtectedPropsSpec.groovy
Outdated
Show resolved
Hide resolved
spock-specs/src/test/groovy/org/spockframework/mock/AccessProtectedPropsSpec.groovy
Outdated
Show resolved
Hide resolved
spock-specs/src/test/groovy/org/spockframework/mock/AccessProtectedPropsSpec.groovy
Outdated
Show resolved
Hide resolved
spock-specs/src/test/groovy/org/spockframework/mock/MockMapDelegateSpec.groovy
Outdated
Show resolved
Hide resolved
spock-specs/src/test/groovy/org/spockframework/mock/AccessProtectedJavaBaseClass.java
Outdated
Show resolved
Hide resolved
…ectedPropsSpec.groovy Co-authored-by: Björn Kautler <[email protected]>
…ectedPropsSpec.groovy Co-authored-by: Björn Kautler <[email protected]>
…ectedPropsSpec.groovy Co-authored-by: Björn Kautler <[email protected]>
…ectedPropsSpec.groovy Co-authored-by: Björn Kautler <[email protected]>
…ectedPropsSpec.groovy Co-authored-by: Björn Kautler <[email protected]>
…ectedPropsSpec.groovy Co-authored-by: Björn Kautler <[email protected]>
…egateSpec.groovy Co-authored-by: Björn Kautler <[email protected]>
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.
LGTM, thx
…ctedConst * spockframework/master: Use multiple locks in ByteBuddyMockFactory to reduce lock contention (spockframework#1778) Fixup LICENSE file after change to geantyref (spockframework#1773) # Conflicts: # spock-core/src/main/java/org/spockframework/mock/runtime/ByteBuddyMockFactory.java
Thanks @AndreasTu |
The Groovy 3 & 4 runtime expects to have the
@Internal
annotation on the MOP methods fromGroovyObject
. ThatAbstractCallSite.createGroovyObjectGetPropertySite()
processes it asGroovyObject
. So theByteBuddyMockFactory
now adds the@Internal
annotation to the intercepted MOP methods.After that the "Unable to access protected constant when spying instances" problems are gone, because we take the normal Groovy route.
Also some strange inconsistencies for Groovy 2 <=> 3,4 are now gone, but a new inconsistency appeared Groovy 4 prefers is over get for boolean. But this is not a Spock issue, because in Groovy only code the same thing happens. See tests in JavaMocksForGroovyClasses.
This fixes #1501, #1452, #1608 and #1145.