-
Notifications
You must be signed in to change notification settings - Fork 45
Support running Spring integration tests in instrumentation process #2335
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
7d54e3f
Add basement for SpringTestContextManagerAPI
sofurihafe fc4452c
Adapt annotation patching
sofurihafe e924fe3
Refactor `patchAnnotation`
IlyaMuravjov 117299d
Refactor dummy test classes
IlyaMuravjov 071661a
Make `SpringContextWrapper` use `TestContextManager`
IlyaMuravjov 6103e36
Refactor `InstrumentationContext`
IlyaMuravjov 1d328f9
Trigger interactions with `TestContextManager` from `SpringUtExecutio…
IlyaMuravjov 753ddb6
Remove unused `RepositoryWrapperBeanPostProcessor`
IlyaMuravjov e31994e
Remove not yet relevant comment
IlyaMuravjov 0abd62a
Make `SpringUtExecutionInstrumentation` only transform user sources
IlyaMuravjov e9cbeb6
Address comments from #2335
IlyaMuravjov 76f0daa
Remove no longer used `tableName` from `RepositoryDescription`
IlyaMuravjov 500b199
Rename `MockValueConstructor` to `ContextAwareValueConstructor`
IlyaMuravjov 877847f
Improve naming
IlyaMuravjov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
utbot-core/src/main/kotlin/org/utbot/common/AnnotationUtil.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package org.utbot.common | ||
|
|
||
| import java.lang.reflect.InvocationHandler | ||
| import java.lang.reflect.Proxy | ||
|
|
||
| /** | ||
| * Assigns [newValue] to specified [property] of [annotation]. | ||
| * | ||
| * NOTE! [annotation] instance is expected to be a [Proxy] | ||
| * using [sun.reflect.annotation.AnnotationInvocationHandler] | ||
| * making this function depend on JDK vendor and version. | ||
| * | ||
| * Example: `@ImportResource -> @ImportResource(value = "classpath:shark-config.xml")` | ||
| */ | ||
| fun patchAnnotation( | ||
| annotation: Annotation, | ||
| property: String, | ||
| newValue: Any? | ||
| ) { | ||
| val proxyClass = Proxy::class.java | ||
| val hField = proxyClass.getDeclaredField("h") | ||
| hField.isAccessible = true | ||
|
|
||
| val invocationHandler = hField[annotation] as InvocationHandler | ||
|
|
||
| val annotationInvocationHandlerClass = Class.forName("sun.reflect.annotation.AnnotationInvocationHandler") | ||
| val memberValuesField = annotationInvocationHandlerClass.getDeclaredField("memberValues") | ||
| memberValuesField.isAccessible = true | ||
|
|
||
| @Suppress("UNCHECKED_CAST") // unavoidable because of reflection | ||
| val memberValues = memberValuesField[invocationHandler] as MutableMap<String, Any?> | ||
| memberValues[property] = newValue | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.