mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Compare commits
129 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c997d4018d | |||
| 91852546d9 | |||
| 802fa4d65e | |||
| 7052da4532 | |||
| 63817ce202 | |||
| 61bd79017f | |||
| ab6637c670 | |||
| c9b88b4ebd | |||
| 68c575ab14 | |||
| cb320468db | |||
| df828458fa | |||
| ff3f2937ab | |||
| d7450ce8e4 | |||
| 28f78f435e | |||
| a3705632c1 | |||
| 84221064c8 | |||
| 21f3b964fe | |||
| efb85d68ef | |||
| b3f01a7f92 | |||
| 22bcac1eb5 | |||
| 546ae15a44 | |||
| 78c32aa7d2 | |||
| 99b78adce3 | |||
| 644731c9f6 | |||
| e4d03f6625 | |||
| 6251b2c0c9 | |||
| 3d211b71b1 | |||
| 18b8f871aa | |||
| d7ddfe8d2e | |||
| 1687d90a8c | |||
| b8f1005897 | |||
| 0150c4ba06 | |||
| b560c7b85d | |||
| 0f05a2e153 | |||
| d4cc273c31 | |||
| f3b6c222f9 | |||
| 8d390f4e5a | |||
| f5a8c321c0 | |||
| 14466eef4c | |||
| 9d365906b5 | |||
| 97e10a5948 | |||
| bfbfe4a572 | |||
| 38464a15dc | |||
| c04b502866 | |||
| f2c0ad484e | |||
| d10460d775 | |||
| 1ead8bf1ab | |||
| 7b087d1a6c | |||
| 00fbd91cca | |||
| d87ebbff78 | |||
| e977bd7bf0 | |||
| 24c7d31ba7 | |||
| b6fc3a1b6f | |||
| d767806977 | |||
| c5b9c3d604 | |||
| 40ef6f6872 | |||
| b01fdb0140 | |||
| 3f01e3fe11 | |||
| e78af58af3 | |||
| aebf7c97f7 | |||
| 7b8d8693dd | |||
| 22adccd190 | |||
| d4d49fd546 | |||
| 730f824cad | |||
| 2dcd56bbaf | |||
| 00be6d3afd | |||
| ebe3b45743 | |||
| 9c4b246c8c | |||
| f850b051b5 | |||
| c9c137ec51 | |||
| b7a1157e66 | |||
| 27bc60e077 | |||
| 0abf97ff90 | |||
| f0f447a73d | |||
| b81a63fb5c | |||
| 529a6fc932 | |||
| e964ced1ad | |||
| ff30329861 | |||
| 6d3d3d11c4 | |||
| 9140ed6fa9 | |||
| 6cea397bd8 | |||
| 484599ecbb | |||
| 1ff369d1ce | |||
| ede46647e8 | |||
| 7f7f7c5f5b | |||
| d1950f598a | |||
| a01dd1cd79 | |||
| 86924d067b | |||
| f0472ea1c0 | |||
| 4b211643bb | |||
| f92e810831 | |||
| 9fba394b8a | |||
| 0005ec09c2 | |||
| 0e800538c0 | |||
| 43b01382ed | |||
| 3a35c4dbd0 | |||
| 4c854d564c | |||
| de562deab0 | |||
| 0b2e3900b9 | |||
| e1e4d52b61 | |||
| 8ca0262e2f | |||
| 29ea530525 | |||
| ac10d079df | |||
| 87c4acd7ac | |||
| 2ce21f7654 | |||
| 9e6504b05a | |||
| 399f779c43 | |||
| a40ec44cb7 | |||
| 4357bbd31b | |||
| 4548f1ec66 | |||
| 9e71dc6029 | |||
| 0daa5ce631 | |||
| 8817536e5a | |||
| cdbaee11c1 | |||
| 1256307c83 | |||
| 4c14abf0cd | |||
| a81367f686 | |||
| a21706c58a | |||
| de913642fb | |||
| c2c6130da5 | |||
| df817364b2 | |||
| bc07a451dc | |||
| 5eb0e99d58 | |||
| 17699103dc | |||
| 9b366b28b7 | |||
| 0f990e44a8 | |||
| e102bc4933 | |||
| be1bf91ce8 | |||
| 877825b4ab |
@@ -2,7 +2,7 @@ name: Build and Deploy Snapshot
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- 7.0.x
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
jobs:
|
||||
|
||||
@@ -17,7 +17,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
branch: [ '6.2.x', 'main' ]
|
||||
branch: [ '6.2.x', '7.0.x', 'main' ]
|
||||
steps:
|
||||
- uses: spring-io/spring-doc-actions/update-antora-spring-ui@5a57bcc6a0da2a1474136cf29571b277850432bc
|
||||
name: Update
|
||||
|
||||
@@ -9,6 +9,7 @@ ivy-cache
|
||||
argfile*
|
||||
activemq-data/
|
||||
classes/
|
||||
.cursor/
|
||||
|
||||
# Log files
|
||||
jxl.log
|
||||
|
||||
+3
-1
@@ -61,7 +61,9 @@ configure([rootProject] + javaProjects) { project ->
|
||||
testImplementation("org.junit.platform:junit-platform-suite")
|
||||
testImplementation("org.mockito:mockito-core")
|
||||
testImplementation("org.mockito:mockito-junit-jupiter")
|
||||
testImplementation("io.mockk:mockk")
|
||||
testImplementation("io.mockk:mockk") {
|
||||
exclude group: 'junit', module: 'junit'
|
||||
}
|
||||
testImplementation("org.assertj:assertj-core")
|
||||
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
|
||||
testRuntimeOnly("org.apache.logging.log4j:log4j-core")
|
||||
|
||||
@@ -50,7 +50,7 @@ public class CheckstyleConventions {
|
||||
project.getPlugins().apply(CheckstylePlugin.class);
|
||||
project.getTasks().withType(Checkstyle.class).forEach(checkstyle -> checkstyle.getMaxHeapSize().set("1g"));
|
||||
CheckstyleExtension checkstyle = project.getExtensions().getByType(CheckstyleExtension.class);
|
||||
checkstyle.setToolVersion("13.3.0");
|
||||
checkstyle.setToolVersion("13.4.0");
|
||||
checkstyle.getConfigDirectory().set(project.getRootProject().file("src/checkstyle"));
|
||||
String version = SpringJavaFormatPlugin.class.getPackage().getImplementationVersion();
|
||||
DependencySet checkstyleDependencies = project.getConfigurations().getByName("checkstyle").getDependencies();
|
||||
|
||||
@@ -15,8 +15,8 @@ content:
|
||||
# https://docs.antora.org/antora/latest/playbook/content-refname-matching/
|
||||
# branches: We include snapshots for main, 6.2.x, and 7.0.x to 9.*.x.
|
||||
branches: ['main', '6.2.x', '{7..9}.+({0..9}).x']
|
||||
# tags: We effectively include all releases from 6.0.9 to 9.*.*.
|
||||
tags: ['v{6..9}.+({0..9}).+({0..9})?(-{RC,M}*)', '!(v6.0.{0..8})', '!(v6.0.0-{RC,M}{0..9})']
|
||||
# tags: include all releases from 6.2.0 to 9.*.*.
|
||||
tags: ['v6.2.+({0..9})', 'v{7..9}.+({0..9}).+({0..9})?(-{RC,M}*)']
|
||||
start_path: framework-docs
|
||||
asciidoc:
|
||||
extensions:
|
||||
@@ -38,4 +38,4 @@ runtime:
|
||||
failure_level: warn
|
||||
ui:
|
||||
bundle:
|
||||
url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.4.25/ui-bundle.zip
|
||||
url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.4.26/ui-bundle.zip
|
||||
|
||||
@@ -31,7 +31,7 @@ asciidoc:
|
||||
spring-org: 'spring-projects'
|
||||
spring-github-org: "https://github.com/{spring-org}"
|
||||
spring-framework-github: "https://github.com/{spring-org}/spring-framework"
|
||||
spring-framework-code: '{spring-framework-github}/tree/main'
|
||||
spring-framework-code: '{spring-framework-github}/tree/7.0.x'
|
||||
spring-framework-issues: '{spring-framework-github}/issues'
|
||||
spring-framework-wiki: '{spring-framework-github}/wiki'
|
||||
# Docs
|
||||
|
||||
@@ -138,6 +138,11 @@ xref:testing/testcontext-framework/ctx-management/context-pausing.adoc[Context P
|
||||
in the _Spring TestContext Framework_. See
|
||||
xref:testing/testcontext-framework/ctx-management/failure-threshold.adoc[Context Failure Threshold].
|
||||
|
||||
| `spring.test.extension.context.scope`
|
||||
| The default _extension context scope_ used by the `SpringExtension` in `@Nested` test
|
||||
class hierarchies. See
|
||||
xref:testing/annotations/integration-junit-jupiter.adoc#integration-testing-annotations-springextensionconfig[`@SpringExtensionConfig`].
|
||||
|
||||
| `spring.test.enclosing.configuration`
|
||||
| The default _enclosing configuration inheritance mode_ to use if
|
||||
`@NestedTestConfiguration` is not present on a test class. See
|
||||
|
||||
@@ -378,7 +378,7 @@ The container also supports creating a bean with {spring-framework-api}++/beans/
|
||||
|
||||
. The custom arguments require dynamic introspection of a matching constructor or factory method.
|
||||
Those arguments cannot be detected by AOT, so the necessary reflection hints will have to be provided manually.
|
||||
. By-passing the instance supplier means that all other optimizations after creation are skipped as well.
|
||||
. Bypassing the instance supplier means that all other optimizations after creation are skipped as well.
|
||||
For instance, autowiring on fields and methods will be skipped as they are handled in the instance supplier.
|
||||
|
||||
Rather than having prototype-scoped beans created with custom arguments, we recommend a manual factory pattern where a bean is responsible for the creation of the instance.
|
||||
|
||||
+1
-1
@@ -274,7 +274,7 @@ Kotlin::
|
||||
Next, you can provide the information for the candidate bean definitions. You can add
|
||||
`<qualifier/>` tags as sub-elements of the `<bean/>` tag and then specify the `type` and
|
||||
`value` to match your custom qualifier annotations. The type is matched against the
|
||||
fully-qualified class name of the annotation. Alternately, as a convenience if no risk of
|
||||
fully-qualified class name of the annotation. Alternatively, as a convenience if no risk of
|
||||
conflicting names exists, you can use the short class name. The following example
|
||||
demonstrates both approaches:
|
||||
|
||||
|
||||
@@ -575,7 +575,7 @@ Kotlin::
|
||||
----
|
||||
======
|
||||
|
||||
NOTE: Do not define such beans to be lazy as the `ApplicationContext` will honour that and will not register the method to listen to events.
|
||||
NOTE: Do not define such beans to be lazy as the `ApplicationContext` will honor that and will not register the method to listen to events.
|
||||
|
||||
The method signature once again declares the event type to which it listens,
|
||||
but, this time, with a flexible name and without implementing a specific listener interface.
|
||||
|
||||
@@ -2,4 +2,12 @@
|
||||
= Language Reference
|
||||
:page-section-summary-toc: 1
|
||||
|
||||
This section describes how the Spring Expression Language works.
|
||||
Spring Expression Language (SpEL) expressions are composed of a sequence of tokens such
|
||||
as literals, operators, method invocations, and so forth.
|
||||
|
||||
Whitespace can be used freely between tokens to format and improve the readability of
|
||||
expressions. Specifically, the `\s` (space), `\t` (tab), `\r` (carriage return), and `\n`
|
||||
(newline) characters are all valid separators between tokens. However, whitespace is
|
||||
ignored by the expression parser unless it is part of a string literal.
|
||||
|
||||
The following sections describe the features and syntax of SpEL.
|
||||
|
||||
+1
-1
@@ -270,7 +270,7 @@ is applicable for typical implementations of indexed structures.
|
||||
NOTE: `ReflectiveIndexAccessor` also implements `CompilableIndexAccessor` in order to
|
||||
support xref:core/expressions/evaluation.adoc#expressions-spel-compilation[compilation]
|
||||
to bytecode for read access. Note, however, that the configured read-method must be
|
||||
invokable via a `public` class or `public` interface for compilation to succeed.
|
||||
invocable via a `public` class or `public` interface for compilation to succeed.
|
||||
|
||||
The following code listings define a `Color` enum and `FruitMap` type that behaves like a
|
||||
map but does not implement the `java.util.Map` interface. Thus, if you want to index into
|
||||
|
||||
@@ -25,7 +25,8 @@ public void sendNotification() {
|
||||
|
||||
By default, the method invocation will be retried for any exception thrown: with at most
|
||||
3 retry attempts (`maxRetries = 3`) after an initial failure, and a delay of 1 second
|
||||
between attempts.
|
||||
between attempts. If all attempts have failed and the retry policy has been exhausted,
|
||||
the last original exception from the target method will be propagated to the caller.
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
@@ -69,12 +70,12 @@ Or for 4 retry attempts and an exponential back-off strategy with a bit of jitte
|
||||
[source,java,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
@Retryable(
|
||||
includes = MessageDeliveryException.class,
|
||||
maxRetries = 4,
|
||||
delay = 100,
|
||||
jitter = 10,
|
||||
multiplier = 2,
|
||||
maxDelay = 1000)
|
||||
includes = MessageDeliveryException.class,
|
||||
maxRetries = 4,
|
||||
delay = 100,
|
||||
jitter = 10,
|
||||
multiplier = 2,
|
||||
maxDelay = 1000)
|
||||
public void sendNotification() {
|
||||
this.jmsClient.destination("notifications").send(...);
|
||||
}
|
||||
@@ -99,6 +100,13 @@ TIP: Several attributes in `@Retryable` have `String` variants that provide prop
|
||||
placeholder and SpEL support, as an alternative to the specifically typed annotation
|
||||
attributes used in the above examples.
|
||||
|
||||
[TIP]
|
||||
====
|
||||
During `@Retryable` processing, Spring publishes a `MethodRetryEvent` for every exception
|
||||
coming out of the target method. This can be used to track/log all original exceptions
|
||||
whereas the caller of the `@Retryable` method will only ever see the last exception.
|
||||
====
|
||||
|
||||
|
||||
[[resilience-annotations-concurrencylimit]]
|
||||
== `@ConcurrencyLimit`
|
||||
@@ -174,7 +182,7 @@ configured {spring-framework-api}/core/retry/RetryPolicy.html[`RetryPolicy`].
|
||||
----
|
||||
var retryTemplate = new RetryTemplate(); // <1>
|
||||
|
||||
retryTemplate.execute(
|
||||
retryTemplate.invoke(
|
||||
() -> jmsClient.destination("notifications").send(...));
|
||||
----
|
||||
<1> Implicitly uses `RetryPolicy.withDefaults()`.
|
||||
@@ -200,7 +208,7 @@ If you only need to customize the number of retry attempts, you can use the
|
||||
----
|
||||
var retryTemplate = new RetryTemplate(RetryPolicy.withMaxRetries(4)); // <1>
|
||||
|
||||
retryTemplate.execute(
|
||||
retryTemplate.invoke(
|
||||
() -> jmsClient.destination("notifications").send(...));
|
||||
----
|
||||
<1> Explicitly uses `RetryPolicy.withMaxRetries(4)`.
|
||||
@@ -218,7 +226,7 @@ matched against an exception thrown by a failed operation as well as nested caus
|
||||
|
||||
var retryTemplate = new RetryTemplate(retryPolicy);
|
||||
|
||||
retryTemplate.execute(
|
||||
retryTemplate.invoke(
|
||||
() -> jmsClient.destination("notifications").send(...));
|
||||
----
|
||||
<1> Specify one or more exception types to include.
|
||||
@@ -251,21 +259,101 @@ and an exponential back-off strategy with a bit of jitter.
|
||||
|
||||
var retryTemplate = new RetryTemplate(retryPolicy);
|
||||
|
||||
retryTemplate.execute(
|
||||
retryTemplate.invoke(
|
||||
() -> jmsClient.destination("notifications").send(...));
|
||||
----
|
||||
|
||||
[TIP]
|
||||
====
|
||||
A {spring-framework-api}/core/retry/RetryListener.html[`RetryListener`] can be registered
|
||||
with a `RetryTemplate` to react to events published during key retry phases (before a
|
||||
retry attempt, after a retry attempt, etc.), and you can compose multiple listeners via a
|
||||
{spring-framework-api}/core/retry/support/CompositeRetryListener.html[`CompositeRetryListener`].
|
||||
====
|
||||
|
||||
Although the factory methods and builder API for `RetryPolicy` cover most common
|
||||
configuration scenarios, you can implement a custom `RetryPolicy` for complete control
|
||||
over the types of exceptions that should trigger a retry as well as the
|
||||
{spring-framework-api}/util/backoff/BackOff.html[`BackOff`] strategy to use. Note that you
|
||||
can also configure a customized `BackOff` strategy via the `backOff()` method in the
|
||||
`RetryPolicy.Builder`.
|
||||
{spring-framework-api}/util/backoff/BackOff.html[`BackOff`] strategy to use. Note that
|
||||
you can also configure a customized `BackOff` strategy via the `backOff()` method in
|
||||
the `RetryPolicy.Builder`.
|
||||
====
|
||||
|
||||
Note that the examples above apply a pattern similar to `@Retryable` method invocations
|
||||
where the last original exception will be propagated to the caller, using the `invoke`
|
||||
variants on `RetryTemplate` which are available with and without a return value.
|
||||
The callback may throw unchecked exceptions, the last one of which is exposed for
|
||||
direct handling on the caller side:
|
||||
|
||||
[source,java,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
try {
|
||||
retryTemplate.invoke(
|
||||
() -> jmsClient.destination("notifications").send(...));
|
||||
}
|
||||
catch (MessageDeliveryException ex) {
|
||||
// coming out of the original JmsClient send method
|
||||
}
|
||||
----
|
||||
|
||||
[source,java,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
try {
|
||||
var result = retryTemplate.invoke(() -> {
|
||||
jmsClient.destination("notifications").send(...);
|
||||
return "result";
|
||||
});
|
||||
}
|
||||
catch (MessageDeliveryException ex) {
|
||||
// coming out of the original JmsClient send method
|
||||
}
|
||||
----
|
||||
|
||||
`RetryTemplate` instances are very light and can be created on the fly,
|
||||
potentially with a specific retry policy to use for a given invocation:
|
||||
|
||||
[source,java,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
try {
|
||||
new RetryTemplate(RetryPolicy.withMaxRetries(4)).invoke(
|
||||
() -> jmsClient.destination("notifications").send(...));
|
||||
}
|
||||
catch (MessageDeliveryException ex) {
|
||||
// coming out of the original JmsClient send method
|
||||
}
|
||||
----
|
||||
|
||||
For deeper interaction, you may use RetryTemplate's `execute` method. The caller will
|
||||
have to handle the checked `RetryException` thrown by `RetryTemplate`, exposing the
|
||||
outcome of all attempts:
|
||||
|
||||
[source,java,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
try {
|
||||
var result = retryTemplate.execute(() -> {
|
||||
jmsClient.destination("notifications").send(...);
|
||||
return "result";
|
||||
});
|
||||
}
|
||||
catch (RetryException ex) {
|
||||
// ex.getExceptions() / ex.getLastException() ...
|
||||
}
|
||||
----
|
||||
|
||||
A {spring-framework-api}/core/retry/RetryListener.html[`RetryListener`] can be registered
|
||||
with a `RetryTemplate` to react to key retry steps (before or after a retry attempt etc.)
|
||||
or simply to every invocation attempt, being able to track all exceptions coming out of
|
||||
the callback and all retry outcomes (exhaustion, interruption, timeout). This is
|
||||
particularly useful when using `invoke` where no retry state other than the last
|
||||
original exception is exposed otherwise:
|
||||
|
||||
[source,java,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
var retryTemplate = new RetryTemplate();
|
||||
retryTemplate.setRetryListener(new RetryListener() {
|
||||
@Override
|
||||
public void onRetryableExecution(RetryPolicy retryPolicy, Retryable<?> retryable, RetryState retryState) {
|
||||
...
|
||||
}
|
||||
});
|
||||
|
||||
retryTemplate.invoke(
|
||||
() -> jmsClient.destination("notifications").send(...));
|
||||
----
|
||||
|
||||
You can also compose multiple listeners via a
|
||||
{spring-framework-api}/core/retry/support/CompositeRetryListener.html[`CompositeRetryListener`].
|
||||
|
||||
@@ -347,10 +347,10 @@ recognized and used as the `PropertyEditor` for `Something`-typed properties.
|
||||
[literal,subs="verbatim,quotes"]
|
||||
----
|
||||
com
|
||||
chank
|
||||
pop
|
||||
Something
|
||||
SomethingEditor // the PropertyEditor for the Something class
|
||||
└── example
|
||||
└── things
|
||||
├── *Something*
|
||||
└── *SomethingEditor* // the PropertyEditor for the Something class
|
||||
----
|
||||
|
||||
Note that you can also use the standard `BeanInfo` JavaBeans mechanism here as well
|
||||
@@ -362,10 +362,10 @@ following example uses the `BeanInfo` mechanism to explicitly register one or mo
|
||||
[literal,subs="verbatim,quotes"]
|
||||
----
|
||||
com
|
||||
chank
|
||||
pop
|
||||
Something
|
||||
SomethingBeanInfo // the BeanInfo for the Something class
|
||||
└── example
|
||||
└── things
|
||||
├── *Something*
|
||||
└── *SomethingBeanInfo* // the BeanInfo for the Something class
|
||||
----
|
||||
|
||||
The following Java source code for the referenced `SomethingBeanInfo` class
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
[[observability]]
|
||||
= Observability Support
|
||||
|
||||
With https://docs.micrometer.io/micrometer/reference/concepts.html[Micrometer], developers can instrument libraries and applications for metrics (timers, gauges, counters)
|
||||
that collect statistics about their runtime behavior. Metrics can help you to track error rates, usage patterns, performance, and more.
|
||||
https://docs.micrometer.io/tracing/reference/[Micrometer can also produce traces], giving you a holistic view of an entire system, crossing application boundaries; you can zoom in on particular user requests and follow their entire completion across applications.
|
||||
|
||||
Micrometer defines an {micrometer-docs}/observation.html[Observation concept that enables both Metrics and Traces] in applications.
|
||||
Metrics support offers a way to create timers, gauges, or counters for collecting statistics about the runtime behavior of your application.
|
||||
Metrics can help you to track error rates, usage patterns, performance, and more.
|
||||
Traces provide a holistic view of an entire system, crossing application boundaries; you can zoom in on particular user requests and follow their entire completion across applications.
|
||||
Each observation will produce:
|
||||
|
||||
* https://docs.micrometer.io/micrometer/reference/observation/components.html#micrometer-observation-default-meter-handler[several metrics - a timer, a long task timer and many counters]
|
||||
* a https://docs.micrometer.io/tracing/reference/glossary.html[span for the current trace]
|
||||
|
||||
Spring Framework instruments various parts of its own codebase to publish observations if an `ObservationRegistry` is configured.
|
||||
You can learn more about {spring-boot-docs-ref}/actuator/observability.html[configuring the observability infrastructure in Spring Boot].
|
||||
|
||||
+22
-13
@@ -3,7 +3,7 @@
|
||||
|
||||
The following annotations are supported when used in conjunction with the
|
||||
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-extension[`SpringExtension`]
|
||||
and JUnit Jupiter (that is, the programming model in JUnit):
|
||||
and the JUnit Jupiter testing framework:
|
||||
|
||||
* xref:testing/annotations/integration-junit-jupiter.adoc#integration-testing-annotations-springextensionconfig[`@SpringExtensionConfig`]
|
||||
* xref:testing/annotations/integration-junit-jupiter.adoc#integration-testing-annotations-junit-jupiter-springjunitconfig[`@SpringJUnitConfig`]
|
||||
@@ -30,30 +30,39 @@ developer wishes to switch to test-class scoped semantics — the `SpringExtensi
|
||||
configured to use a test-class scoped `ExtensionContext` by annotating a top-level test
|
||||
class with `@SpringExtensionConfig(useTestClassScopedExtensionContext = true)`.
|
||||
|
||||
Alternatively, you can change the global default by setting the
|
||||
`spring.test.extension.context.scope` property to `test_class`. The property is resolved
|
||||
first via the xref:appendix.adoc#appendix-spring-properties[`SpringProperties`] mechanism
|
||||
which also supports JVM system properties — for example,
|
||||
`-Dspring.test.extension.context.scope=test_class`. If the Spring property has not been
|
||||
set, the `SpringExtension` will attempt to resolve the property as a
|
||||
https://docs.junit.org/current/running-tests/configuration-parameters.html[JUnit Platform configuration parameter]
|
||||
as a fallback mechanism. If the property has not been set via either of those mechanisms,
|
||||
the `SpringExtension` will use a test-method scoped extension context by default. Note,
|
||||
however, that a `@SpringExtensionConfig` declaration always takes precedence over this
|
||||
property.
|
||||
|
||||
[TIP]
|
||||
====
|
||||
If your top-level test class is configured to use JUnit Jupiter's
|
||||
`@TestInstance(Lifecycle.PER_CLASS)` semantics, the `SpringExtension` will always use a
|
||||
test-class scoped `ExtensionContext`, and there is no need to declare
|
||||
`@SpringExtensionConfig(useTestClassScopedExtensionContext = true)`.
|
||||
If a test class uses JUnit Jupiter's `@TestInstance(Lifecycle.PER_CLASS)` semantics, the
|
||||
`SpringExtension` will always use a test-class scoped `ExtensionContext`, and
|
||||
configuration via `@SpringExtensionConfig(useTestClassScopedExtensionContext = true)` or
|
||||
the `spring.test.extension.context.scope` property will have no effect for that test
|
||||
class.
|
||||
====
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
This annotation is currently only applicable to `@Nested` test class hierarchies and
|
||||
should be applied to the top-level enclosing class of a `@Nested` test class hierarchy.
|
||||
|
||||
Consequently, there is no need to declare this annotation on a test class that does not
|
||||
contain `@Nested` test classes.
|
||||
====
|
||||
|
||||
[NOTE]
|
||||
====
|
||||
In addition,
|
||||
xref:testing/annotations/integration-junit-jupiter.adoc#integration-testing-annotations-nestedtestconfiguration[`@NestedTestConfiguration`]
|
||||
does not apply to this annotation.
|
||||
|
||||
`@SpringExtensionConfig` will always be detected within a `@Nested` test class hierarchy,
|
||||
effectively disregarding any `@NestedTestConfiguration(OVERRIDE)` declarations.
|
||||
does not apply to this annotation. `@SpringExtensionConfig` will always be detected
|
||||
within a `@Nested` test class hierarchy, effectively disregarding any
|
||||
`@NestedTestConfiguration(OVERRIDE)` declarations.
|
||||
====
|
||||
|
||||
[[integration-testing-annotations-junit-jupiter-springjunitconfig]]
|
||||
|
||||
+7
@@ -72,6 +72,13 @@ bean definition profiles programmatically by implementing a custom
|
||||
xref:testing/testcontext-framework/ctx-management/env-profiles.adoc#testcontext-ctx-management-env-profiles-ActiveProfilesResolver[`ActiveProfilesResolver`]
|
||||
and registering it by using the `resolver` attribute of `@ActiveProfiles`.
|
||||
|
||||
NOTE: When `@ActiveProfiles` is declared on a test class, the `spring.profiles.active`
|
||||
property (whether configured as a JVM system property or environment variable) is not
|
||||
taken into account by the TestContext Framework when determining active profiles. If
|
||||
you need to allow `spring.profiles.active` to override the profiles configured via
|
||||
`@ActiveProfiles`, you can implement a custom `ActiveProfilesResolver` as described in
|
||||
xref:testing/testcontext-framework/ctx-management/env-profiles.adoc[Context Configuration with Environment Profiles].
|
||||
|
||||
See xref:testing/testcontext-framework/ctx-management/env-profiles.adoc[Context Configuration with Environment Profiles],
|
||||
xref:testing/testcontext-framework/support-classes.adoc#testcontext-junit-jupiter-nested-test-configuration[`@Nested` test class configuration], and the
|
||||
{spring-framework-api}/test/context/ActiveProfiles.html[`@ActiveProfiles`] javadoc for
|
||||
|
||||
+143
@@ -140,6 +140,21 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Replace the bean with type `CustomService` with a Mockito mock.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
@SpringJUnitConfig(TestConfig::class)
|
||||
class BeanOverrideTests {
|
||||
|
||||
@MockitoBean // <1>
|
||||
lateinit var customService: CustomService
|
||||
|
||||
// tests...
|
||||
}
|
||||
----
|
||||
<1> Replace the bean with type `CustomService` with a Mockito mock.
|
||||
======
|
||||
|
||||
In the example above, we are creating a mock for `CustomService`. If more than one bean
|
||||
@@ -168,6 +183,22 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Replace the bean named `service` with a Mockito mock.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
@SpringJUnitConfig(TestConfig::class)
|
||||
class BeanOverrideTests {
|
||||
|
||||
@MockitoBean("service") // <1>
|
||||
lateinit var customService: CustomService
|
||||
|
||||
// tests...
|
||||
|
||||
}
|
||||
----
|
||||
<1> Replace the bean named `service` with a Mockito mock.
|
||||
======
|
||||
|
||||
The following `@SharedMocks` annotation registers two mocks by-type and one mock by-name.
|
||||
@@ -187,6 +218,19 @@ Java::
|
||||
----
|
||||
<1> Register `OrderService` and `UserService` mocks by-type.
|
||||
<2> Register `PrintingService` mock by-name.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
@MockitoBean(types = [OrderService::class, UserService::class]) // <1>
|
||||
@MockitoBean(name = "ps1", types = [PrintingService::class]) // <2>
|
||||
annotation class SharedMocks
|
||||
----
|
||||
<1> Register `OrderService` and `UserService` mocks by-type.
|
||||
<2> Register `PrintingService` mock by-name.
|
||||
======
|
||||
|
||||
The following demonstrates how `@SharedMocks` can be used on a test class.
|
||||
@@ -217,6 +261,34 @@ Java::
|
||||
----
|
||||
<1> Register common mocks via the custom `@SharedMocks` annotation.
|
||||
<2> Optionally inject mocks to _stub_ or _verify_ them.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
@SpringJUnitConfig(TestConfig::class)
|
||||
@SharedMocks // <1>
|
||||
class BeanOverrideTests {
|
||||
|
||||
@Autowired
|
||||
lateinit var orderService: OrderService // <2>
|
||||
|
||||
@Autowired
|
||||
lateinit var userService: UserService // <2>
|
||||
|
||||
@Autowired
|
||||
lateinit var ps1: PrintingService // <2>
|
||||
|
||||
// Inject other components that rely on the mocks.
|
||||
|
||||
@Test
|
||||
fun testThatDependsOnMocks() {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
----
|
||||
<1> Register common mocks via the custom `@SharedMocks` annotation.
|
||||
<2> Optionally inject mocks to _stub_ or _verify_ them.
|
||||
======
|
||||
|
||||
TIP: The mocks can also be injected into `@Configuration` classes or other test-related
|
||||
@@ -246,6 +318,21 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Wrap the bean with type `CustomService` with a Mockito spy.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
@SpringJUnitConfig(TestConfig::class)
|
||||
class BeanOverrideTests {
|
||||
|
||||
@MockitoSpyBean // <1>
|
||||
lateinit var customService: CustomService
|
||||
|
||||
// tests...
|
||||
}
|
||||
----
|
||||
<1> Wrap the bean with type `CustomService` with a Mockito spy.
|
||||
======
|
||||
|
||||
In the example above, we are wrapping the bean with type `CustomService`. If more than
|
||||
@@ -271,6 +358,21 @@ Java::
|
||||
}
|
||||
----
|
||||
<1> Wrap the bean named `service` with a Mockito spy.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
@SpringJUnitConfig(TestConfig::class)
|
||||
class BeanOverrideTests {
|
||||
|
||||
@MockitoSpyBean("service") // <1>
|
||||
lateinit var customService: CustomService
|
||||
|
||||
// tests...
|
||||
}
|
||||
----
|
||||
<1> Wrap the bean named `service` with a Mockito spy.
|
||||
======
|
||||
|
||||
The following `@SharedSpies` annotation registers two spies by-type and one spy by-name.
|
||||
@@ -290,6 +392,19 @@ Java::
|
||||
----
|
||||
<1> Register `OrderService` and `UserService` spies by-type.
|
||||
<2> Register `PrintingService` spy by-name.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
@MockitoSpyBean(types = [OrderService::class, UserService::class]) // <1>
|
||||
@MockitoSpyBean(name = "ps1", types = [PrintingService::class]) // <2>
|
||||
annotation class SharedSpies
|
||||
----
|
||||
<1> Register `OrderService` and `UserService` spies by-type.
|
||||
<2> Register `PrintingService` spy by-name.
|
||||
======
|
||||
|
||||
The following demonstrates how `@SharedSpies` can be used on a test class.
|
||||
@@ -320,6 +435,34 @@ Java::
|
||||
----
|
||||
<1> Register common spies via the custom `@SharedSpies` annotation.
|
||||
<2> Optionally inject spies to _stub_ or _verify_ them.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
@SpringJUnitConfig(TestConfig::class)
|
||||
@SharedSpies // <1>
|
||||
class BeanOverrideTests {
|
||||
|
||||
@Autowired
|
||||
lateinit var orderService: OrderService // <2>
|
||||
|
||||
@Autowired
|
||||
lateinit var userService: UserService // <2>
|
||||
|
||||
@Autowired
|
||||
lateinit var ps1: PrintingService // <2>
|
||||
|
||||
// Inject other components that rely on the spies.
|
||||
|
||||
@Test
|
||||
fun testThatDependsOnMocks() {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
----
|
||||
<1> Register common spies via the custom `@SharedSpies` annotation.
|
||||
<2> Optionally inject spies to _stub_ or _verify_ them.
|
||||
======
|
||||
|
||||
TIP: The spies can also be injected into `@Configuration` classes or other test-related
|
||||
|
||||
+43
@@ -73,6 +73,27 @@ Java::
|
||||
----
|
||||
<1> Mark a field for overriding the bean with type `CustomService`.
|
||||
<2> The result of this static method will be used as the instance and injected into the field.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
class OverrideBeanTests {
|
||||
@TestBean // <1>
|
||||
lateinit var customService: CustomService
|
||||
|
||||
// test case body...
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun customService(): CustomService { // <2>
|
||||
return MyFakeCustomService()
|
||||
}
|
||||
}
|
||||
}
|
||||
----
|
||||
<1> Mark a field for overriding the bean with type `CustomService`.
|
||||
<2> The result of this static method will be used as the instance and injected into the field.
|
||||
======
|
||||
|
||||
In the example above, we are overriding the bean with type `CustomService`. If more than
|
||||
@@ -102,6 +123,28 @@ Java::
|
||||
<1> Mark a field for overriding the bean with name `service`, and specify that the
|
||||
factory method is named `createCustomService`.
|
||||
<2> The result of this static method will be used as the instance and injected into the field.
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
class OverrideBeanTests {
|
||||
@TestBean(name = "service", methodName = "createCustomService") // <1>
|
||||
lateinit var customService: CustomService
|
||||
|
||||
// test case body...
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun createCustomService(): CustomService { // <2>
|
||||
return MyFakeCustomService()
|
||||
}
|
||||
}
|
||||
}
|
||||
----
|
||||
<1> Mark a field for overriding the bean with name `service`, and specify that the
|
||||
factory method is named `createCustomService`.
|
||||
<2> The result of this static method will be used as the instance and injected into the field.
|
||||
======
|
||||
|
||||
[TIP]
|
||||
|
||||
@@ -19,6 +19,6 @@ meta-annotation. If a bootstrapper is not explicitly configured by using
|
||||
`WebTestContextBootstrapper` is used, depending on the presence of `@WebAppConfiguration`.
|
||||
|
||||
Since the `TestContextBootstrapper` SPI is likely to change in the future (to accommodate
|
||||
new requirements), we strongly encourage implementers not to implement this interface
|
||||
new requirements), we strongly encourage implementors not to implement this interface
|
||||
directly but rather to extend `AbstractTestContextBootstrapper` or one of its concrete
|
||||
subclasses instead.
|
||||
|
||||
+82
@@ -543,3 +543,85 @@ Kotlin::
|
||||
----
|
||||
======
|
||||
|
||||
The following example demonstrates how to implement and register a custom
|
||||
`SystemPropertyOverrideActiveProfilesResolver` that allows the `spring.profiles.active`
|
||||
property (when configured as a JVM system property) to override profiles configured via
|
||||
`@ActiveProfiles`:
|
||||
|
||||
[tabs]
|
||||
======
|
||||
Java::
|
||||
+
|
||||
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
|
||||
----
|
||||
// profiles resolved programmatically via a custom resolver that
|
||||
// allows "spring.profiles.active" to override @ActiveProfiles
|
||||
@ActiveProfiles(
|
||||
resolver = SystemPropertyOverrideActiveProfilesResolver.class,
|
||||
inheritProfiles = false)
|
||||
class TransferServiceTest extends AbstractIntegrationTest {
|
||||
// test body
|
||||
}
|
||||
----
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||
----
|
||||
// profiles resolved programmatically via a custom resolver that
|
||||
// allows "spring.profiles.active" to override @ActiveProfiles
|
||||
@ActiveProfiles(
|
||||
resolver = SystemPropertyOverrideActiveProfilesResolver::class,
|
||||
inheritProfiles = false)
|
||||
class TransferServiceTest : AbstractIntegrationTest() {
|
||||
// test body
|
||||
}
|
||||
----
|
||||
======
|
||||
|
||||
[tabs]
|
||||
======
|
||||
Java::
|
||||
+
|
||||
[source,java,indent=0,subs="verbatim,quotes",role="primary",fold="-imports"]
|
||||
----
|
||||
import org.springframework.core.env.AbstractEnvironment;
|
||||
import org.springframework.test.context.support.DefaultActiveProfilesResolver;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
public class SystemPropertyOverrideActiveProfilesResolver extends DefaultActiveProfilesResolver {
|
||||
|
||||
@Override
|
||||
public String[] resolve(Class<?> testClass) {
|
||||
String profiles = System.getProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME);
|
||||
if (StringUtils.hasText(profiles)) {
|
||||
return StringUtils.commaDelimitedListToStringArray(
|
||||
StringUtils.trimAllWhitespace(profiles));
|
||||
}
|
||||
return super.resolve(testClass);
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
Kotlin::
|
||||
+
|
||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary",fold="-imports"]
|
||||
----
|
||||
import org.springframework.core.env.AbstractEnvironment
|
||||
import org.springframework.test.context.support.DefaultActiveProfilesResolver
|
||||
import org.springframework.util.StringUtils
|
||||
|
||||
class SystemPropertyOverrideActiveProfilesResolver : DefaultActiveProfilesResolver() {
|
||||
|
||||
override fun resolve(testClass: Class<*>): Array<String> {
|
||||
val profiles = System.getProperty(AbstractEnvironment.ACTIVE_PROFILES_PROPERTY_NAME)
|
||||
if (StringUtils.hasText(profiles)) {
|
||||
return StringUtils.commaDelimitedListToStringArray(
|
||||
StringUtils.trimAllWhitespace(profiles)
|
||||
)
|
||||
}
|
||||
return super.resolve(testClass)
|
||||
}
|
||||
}
|
||||
----
|
||||
======
|
||||
|
||||
+4
-5
@@ -396,11 +396,10 @@ recursively.
|
||||
====
|
||||
As of Spring Framework 7.0, the `SpringExtension` uses a test-method scoped
|
||||
`ExtensionContext` within `@Nested` test class hierarchies by default. However, the
|
||||
`SpringExtension` can be configured to use a test-class scoped `ExtensionContext`.
|
||||
|
||||
See the documentation for
|
||||
xref:testing/annotations/integration-junit-jupiter.adoc#integration-testing-annotations-springextensionconfig[`@SpringExtensionConfig`]
|
||||
for details.
|
||||
`SpringExtension` can be configured to use a test-class scoped `ExtensionContext` — for
|
||||
example via `@SpringExtensionConfig` or the `spring.test.extension.context.scope` Spring
|
||||
property (see
|
||||
xref:testing/annotations/integration-junit-jupiter.adoc#integration-testing-annotations-springextensionconfig[`@SpringExtensionConfig`]).
|
||||
====
|
||||
|
||||
[TIP]
|
||||
|
||||
@@ -182,7 +182,7 @@ The parameters to any of the above macros have consistent meanings:
|
||||
For strictly sorted maps, you can use a `SortedMap` (such as a `TreeMap`) with a
|
||||
suitable `Comparator` and, for arbitrary Maps that should return values in insertion
|
||||
order, use a `LinkedHashMap` or a `LinkedMap` from `commons-collections`.
|
||||
* `separator`: Where multiple options are available as discreet elements (radio buttons
|
||||
* `separator`: Where multiple options are available as discrete elements (radio buttons
|
||||
or checkboxes), the sequence of characters used to separate each one in the list
|
||||
(such as `<br>`).
|
||||
* `attributes`: An additional string of arbitrary tags or text to be included within
|
||||
|
||||
+1
-1
@@ -188,7 +188,7 @@ the content negotiation during the error handling phase will decide which conten
|
||||
| `View`
|
||||
| A `View` instance to use for rendering together with the implicit model -- determined
|
||||
through command objects and `@ModelAttribute` methods. The handler method may also
|
||||
programmatically enrich the model by declaring a `Model` argument (descried earlier).
|
||||
programmatically enrich the model by declaring a `Model` argument (described earlier).
|
||||
|
||||
| `java.util.Map`, `org.springframework.ui.Model`
|
||||
| Attributes to be added to the implicit model with the view name implicitly determined
|
||||
|
||||
@@ -257,7 +257,7 @@ An `XhrTransport`, by definition, supports both `xhr-streaming` and `xhr-polling
|
||||
from a client perspective, there is no difference other than in the URL used to connect
|
||||
to the server. At present there are two implementations:
|
||||
|
||||
* `RestTemplateXhrTransport` uses Spring's `RestTemplate` for HTTP requests.
|
||||
* `RestClientXhrTransport` uses Spring's `RestClient` for HTTP requests.
|
||||
* `JettyXhrTransport` uses Jetty's `HttpClient` for HTTP requests.
|
||||
|
||||
The following example shows how to create a SockJS client and connect to a SockJS endpoint:
|
||||
@@ -266,7 +266,7 @@ The following example shows how to create a SockJS client and connect to a SockJ
|
||||
----
|
||||
List<Transport> transports = new ArrayList<>(2);
|
||||
transports.add(new WebSocketTransport(new StandardWebSocketClient()));
|
||||
transports.add(new RestTemplateXhrTransport());
|
||||
transports.add(new RestClientXhrTransport());
|
||||
|
||||
SockJsClient sockJsClient = new SockJsClient(transports);
|
||||
sockJsClient.doHandshake(new MyWebSocketHandler(), "ws://example.com:8080/sockjs");
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public class ExceptionController {
|
||||
|
||||
// tag::narrow[]
|
||||
@ExceptionHandler({FileSystemException.class, RemoteException.class})
|
||||
public ResponseEntity<String> handleIoException(IOException ex) {
|
||||
public ResponseEntity<String> handleIOException(IOException ex) {
|
||||
return ResponseEntity.internalServerError().body(ex.getMessage());
|
||||
}
|
||||
// end::narrow[]
|
||||
|
||||
+1
-1
@@ -54,6 +54,6 @@ class ConcurrentOperationExecutor : Ordered {
|
||||
lockFailureException = ex
|
||||
}
|
||||
} while (numAttempts <= this.maxRetries)
|
||||
throw lockFailureException!!
|
||||
throw lockFailureException
|
||||
}
|
||||
} // end::snippet[]
|
||||
+1
-1
@@ -27,7 +27,7 @@ class ExceptionController {
|
||||
|
||||
// tag::narrow[]
|
||||
@ExceptionHandler(FileSystemException::class, RemoteException::class)
|
||||
fun handleIoException(ex: IOException): ResponseEntity<String> {
|
||||
fun handleIOException(ex: IOException): ResponseEntity<String> {
|
||||
return ResponseEntity.internalServerError().body(ex.message)
|
||||
}
|
||||
// end::narrow[]
|
||||
|
||||
@@ -8,19 +8,19 @@ javaPlatform {
|
||||
|
||||
dependencies {
|
||||
api(platform("com.fasterxml.jackson:jackson-bom:2.20.2"))
|
||||
api(platform("io.micrometer:micrometer-bom:1.16.4"))
|
||||
api(platform("io.netty:netty-bom:4.2.10.Final"))
|
||||
api(platform("io.projectreactor:reactor-bom:2025.0.4"))
|
||||
api(platform("io.micrometer:micrometer-bom:1.16.5"))
|
||||
api(platform("io.netty:netty-bom:4.2.12.Final"))
|
||||
api(platform("io.projectreactor:reactor-bom:2025.0.5"))
|
||||
api(platform("io.rsocket:rsocket-bom:1.1.5"))
|
||||
api(platform("org.apache.groovy:groovy-bom:5.0.4"))
|
||||
api(platform("org.apache.logging.log4j:log4j-bom:2.25.3"))
|
||||
api(platform("org.apache.groovy:groovy-bom:5.0.5"))
|
||||
api(platform("org.apache.logging.log4j:log4j-bom:2.25.4"))
|
||||
api(platform("org.assertj:assertj-bom:3.27.7"))
|
||||
api(platform("org.eclipse.jetty:jetty-bom:12.1.7"))
|
||||
api(platform("org.eclipse.jetty.ee11:jetty-ee11-bom:12.1.7"))
|
||||
api(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.10.2"))
|
||||
api(platform("org.jetbrains.kotlinx:kotlinx-serialization-bom:1.9.0"))
|
||||
api(platform("org.junit:junit-bom:6.0.3"))
|
||||
api(platform("org.mockito:mockito-bom:5.22.0"))
|
||||
api(platform("org.mockito:mockito-bom:5.23.0"))
|
||||
api(platform("tools.jackson:jackson-bom:3.0.4"))
|
||||
|
||||
constraints {
|
||||
@@ -31,7 +31,7 @@ dependencies {
|
||||
api("com.google.code.findbugs:findbugs:3.0.1")
|
||||
api("com.google.code.findbugs:jsr305:3.0.2")
|
||||
api("com.google.code.gson:gson:2.13.2")
|
||||
api("com.google.protobuf:protobuf-java-util:4.34.0")
|
||||
api("com.google.protobuf:protobuf-java-util:4.34.1")
|
||||
api("com.h2database:h2:2.4.240")
|
||||
api("com.jayway.jsonpath:json-path:2.10.0")
|
||||
api("com.networknt:json-schema-validator:1.5.3")
|
||||
@@ -96,10 +96,10 @@ dependencies {
|
||||
api("org.apache.httpcomponents.client5:httpclient5:5.6")
|
||||
api("org.apache.httpcomponents.core5:httpcore5-reactive:5.4.2")
|
||||
api("org.apache.poi:poi-ooxml:5.5.1")
|
||||
api("org.apache.tomcat.embed:tomcat-embed-core:11.0.18")
|
||||
api("org.apache.tomcat.embed:tomcat-embed-websocket:11.0.18")
|
||||
api("org.apache.tomcat:tomcat-util:11.0.18")
|
||||
api("org.apache.tomcat:tomcat-websocket:11.0.18")
|
||||
api("org.apache.tomcat.embed:tomcat-embed-core:11.0.20")
|
||||
api("org.apache.tomcat.embed:tomcat-embed-websocket:11.0.20")
|
||||
api("org.apache.tomcat:tomcat-util:11.0.20")
|
||||
api("org.apache.tomcat:tomcat-websocket:11.0.20")
|
||||
api("org.aspectj:aspectjrt:1.9.25")
|
||||
api("org.aspectj:aspectjtools:1.9.25")
|
||||
api("org.aspectj:aspectjweaver:1.9.25")
|
||||
@@ -111,7 +111,7 @@ dependencies {
|
||||
api("org.easymock:easymock:5.6.0")
|
||||
api("org.eclipse.angus:angus-mail:2.0.3")
|
||||
api("org.eclipse.jetty:jetty-reactive-httpclient:4.1.4")
|
||||
api("org.eclipse.persistence:org.eclipse.persistence.jpa:5.0.0-RC1")
|
||||
api("org.eclipse.persistence:org.eclipse.persistence.jpa:5.0.0")
|
||||
api("org.eclipse:yasson:3.0.4")
|
||||
api("org.ehcache:ehcache:3.10.8")
|
||||
api("org.ehcache:jcache:1.0.1")
|
||||
@@ -120,7 +120,7 @@ dependencies {
|
||||
api("org.glassfish:jakarta.el:4.0.2")
|
||||
api("org.graalvm.sdk:graal-sdk:22.3.1")
|
||||
api("org.hamcrest:hamcrest:3.0")
|
||||
api("org.hibernate.orm:hibernate-core:7.2.6.Final")
|
||||
api("org.hibernate.orm:hibernate-core:7.2.11.Final")
|
||||
api("org.hibernate.validator:hibernate-validator:9.1.0.Final")
|
||||
api("org.hsqldb:hsqldb:2.7.4")
|
||||
api("org.htmlunit:htmlunit:4.21.0")
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
version=7.0.6-SNAPSHOT
|
||||
version=7.0.7
|
||||
|
||||
org.gradle.caching=true
|
||||
org.gradle.jvmargs=-Xmx2048m
|
||||
|
||||
@@ -84,19 +84,6 @@ eclipse.classpath.file.whenMerged {
|
||||
}
|
||||
}
|
||||
|
||||
// Due to an apparent bug in Gradle, even though we exclude the "main" classpath
|
||||
// entries for sources generated by XJC in spring-oxm.gradle, the Gradle eclipse
|
||||
// plugin still includes them in the generated .classpath file. So, we have to
|
||||
// manually remove those lingering "main" entries.
|
||||
if (project.name == "spring-oxm") {
|
||||
eclipse.classpath.file.whenMerged { classpath ->
|
||||
classpath.entries.removeAll {
|
||||
it.path =~ /build\/generated\/sources\/xjc\/.+/ &&
|
||||
it.entryAttributes.get("gradle_scope") == "main"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Include project specific settings
|
||||
tasks.register('eclipseSettings', Copy) {
|
||||
from rootProject.files(
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.0-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.4.1-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/b631911858264c0b6e4d6603d677ff5218766cee/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/2d6327017519d23b96af35865dc997fcb544fb40/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
|
||||
+8
-13
@@ -61,10 +61,9 @@ class AopNamespaceHandlerScopeIntegrationTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testSingletonScoping() throws Exception {
|
||||
void singletonScoping() throws Exception {
|
||||
assertThat(AopUtils.isAopProxy(singletonScoped)).as("Should be AOP proxy").isTrue();
|
||||
boolean condition = singletonScoped instanceof TestBean;
|
||||
assertThat(condition).as("Should be target class proxy").isTrue();
|
||||
assertThat(singletonScoped).as("Should be target class proxy").isInstanceOf(TestBean.class);
|
||||
String rob = "Rob Harrop";
|
||||
String bram = "Bram Smeets";
|
||||
assertThat(singletonScoped.getName()).isEqualTo(rob);
|
||||
@@ -75,19 +74,17 @@ class AopNamespaceHandlerScopeIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRequestScoping() {
|
||||
void requestScoping() {
|
||||
MockHttpServletRequest oldRequest = new MockHttpServletRequest();
|
||||
MockHttpServletRequest newRequest = new MockHttpServletRequest();
|
||||
|
||||
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(oldRequest));
|
||||
|
||||
assertThat(AopUtils.isAopProxy(requestScoped)).as("Should be AOP proxy").isTrue();
|
||||
boolean condition = requestScoped instanceof TestBean;
|
||||
assertThat(condition).as("Should be target class proxy").isTrue();
|
||||
assertThat(requestScoped).as("Should be target class proxy").isInstanceOf(TestBean.class);
|
||||
|
||||
assertThat(AopUtils.isAopProxy(testBean)).as("Should be AOP proxy").isTrue();
|
||||
boolean condition1 = testBean instanceof TestBean;
|
||||
assertThat(condition1).as("Regular bean should be JDK proxy").isFalse();
|
||||
assertThat(testBean).as("Regular bean should be JDK proxy").isNotInstanceOf(TestBean.class);
|
||||
|
||||
String rob = "Rob Harrop";
|
||||
String bram = "Bram Smeets";
|
||||
@@ -103,7 +100,7 @@ class AopNamespaceHandlerScopeIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSessionScoping() {
|
||||
void sessionScoping() {
|
||||
MockHttpSession oldSession = new MockHttpSession();
|
||||
MockHttpSession newSession = new MockHttpSession();
|
||||
|
||||
@@ -112,14 +109,12 @@ class AopNamespaceHandlerScopeIntegrationTests {
|
||||
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
|
||||
|
||||
assertThat(AopUtils.isAopProxy(sessionScoped)).as("Should be AOP proxy").isTrue();
|
||||
boolean condition1 = sessionScoped instanceof TestBean;
|
||||
assertThat(condition1).as("Should not be target class proxy").isFalse();
|
||||
assertThat(sessionScoped).as("Should not be target class proxy").isNotInstanceOf(TestBean.class);
|
||||
|
||||
assertThat(sessionScopedAlias).isSameAs(sessionScoped);
|
||||
|
||||
assertThat(AopUtils.isAopProxy(testBean)).as("Should be AOP proxy").isTrue();
|
||||
boolean condition = testBean instanceof TestBean;
|
||||
assertThat(condition).as("Regular bean should be JDK proxy").isFalse();
|
||||
assertThat(testBean).as("Regular bean should be JDK proxy").isNotInstanceOf(TestBean.class);
|
||||
|
||||
String rob = "Rob Harrop";
|
||||
String bram = "Bram Smeets";
|
||||
|
||||
+9
-10
@@ -65,7 +65,7 @@ class AdvisorAutoProxyCreatorIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDefaultExclusionPrefix() {
|
||||
void defaultExclusionPrefix() {
|
||||
DefaultAdvisorAutoProxyCreator aapc = (DefaultAdvisorAutoProxyCreator) getBeanFactory().getBean(ADVISOR_APC_BEAN_NAME);
|
||||
assertThat(aapc.getAdvisorBeanNamePrefix()).isEqualTo((ADVISOR_APC_BEAN_NAME + DefaultAdvisorAutoProxyCreator.SEPARATOR));
|
||||
assertThat(aapc.isUsePrefix()).isFalse();
|
||||
@@ -75,21 +75,21 @@ class AdvisorAutoProxyCreatorIntegrationTests {
|
||||
* If no pointcuts match (no attrs) there should be proxying.
|
||||
*/
|
||||
@Test
|
||||
void testNoProxy() {
|
||||
void noProxy() {
|
||||
BeanFactory bf = getBeanFactory();
|
||||
Object o = bf.getBean("noSetters");
|
||||
assertThat(AopUtils.isAopProxy(o)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTxIsProxied() {
|
||||
void txIsProxied() {
|
||||
BeanFactory bf = getBeanFactory();
|
||||
ITestBean test = (ITestBean) bf.getBean("test");
|
||||
assertThat(AopUtils.isAopProxy(test)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRegexpApplied() {
|
||||
void regexpApplied() {
|
||||
BeanFactory bf = getBeanFactory();
|
||||
ITestBean test = (ITestBean) bf.getBean("test");
|
||||
MethodCounter counter = (MethodCounter) bf.getBean("countingAdvice");
|
||||
@@ -99,7 +99,7 @@ class AdvisorAutoProxyCreatorIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTransactionAttributeOnMethod() {
|
||||
void transactionAttributeOnMethod() {
|
||||
BeanFactory bf = getBeanFactory();
|
||||
ITestBean test = (ITestBean) bf.getBean("test");
|
||||
|
||||
@@ -121,7 +121,7 @@ class AdvisorAutoProxyCreatorIntegrationTests {
|
||||
* Should not roll back on servlet exception.
|
||||
*/
|
||||
@Test
|
||||
void testRollbackRulesOnMethodCauseRollback() throws Exception {
|
||||
void rollbackRulesOnMethodCauseRollback() throws Exception {
|
||||
BeanFactory bf = getBeanFactory();
|
||||
Rollback rb = (Rollback) bf.getBean("rollback");
|
||||
|
||||
@@ -147,7 +147,7 @@ class AdvisorAutoProxyCreatorIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRollbackRulesOnMethodPreventRollback() throws Exception {
|
||||
void rollbackRulesOnMethodPreventRollback() throws Exception {
|
||||
BeanFactory bf = getBeanFactory();
|
||||
Rollback rb = (Rollback) bf.getBean("rollback");
|
||||
|
||||
@@ -164,12 +164,11 @@ class AdvisorAutoProxyCreatorIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testProgrammaticRollback() {
|
||||
void programmaticRollback() {
|
||||
BeanFactory bf = getBeanFactory();
|
||||
|
||||
Object bean = bf.getBean(TXMANAGER_BEAN_NAME);
|
||||
boolean condition = bean instanceof CallCountingTransactionManager;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(bean).isInstanceOf(CallCountingTransactionManager.class);
|
||||
CallCountingTransactionManager txMan = (CallCountingTransactionManager) bf.getBean(TXMANAGER_BEAN_NAME);
|
||||
|
||||
Rollback rb = (Rollback) bf.getBean("rollback");
|
||||
|
||||
+3
-3
@@ -50,13 +50,13 @@ class ComponentBeanDefinitionParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBionicBasic() {
|
||||
void bionicBasic() {
|
||||
Component cp = getBionicFamily();
|
||||
assertThat(cp.getName()).isEqualTo("Bionic-1");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBionicFirstLevelChildren() {
|
||||
void bionicFirstLevelChildren() {
|
||||
Component cp = getBionicFamily();
|
||||
List<Component> components = cp.getComponents();
|
||||
assertThat(components).hasSize(2);
|
||||
@@ -65,7 +65,7 @@ class ComponentBeanDefinitionParserTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testBionicSecondLevelChildren() {
|
||||
void bionicSecondLevelChildren() {
|
||||
Component cp = getBionicFamily();
|
||||
List<Component> components = cp.getComponents().get(0).getComponents();
|
||||
assertThat(components).hasSize(2);
|
||||
|
||||
+15
-20
@@ -83,7 +83,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testPrototype() {
|
||||
void prototype() {
|
||||
ApplicationContext context = createContext(ScopedProxyMode.NO);
|
||||
ScopedTestBean bean = (ScopedTestBean) context.getBean("prototype");
|
||||
assertThat(bean).isNotNull();
|
||||
@@ -92,7 +92,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSingletonScopeWithNoProxy() {
|
||||
void singletonScopeWithNoProxy() {
|
||||
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
||||
ApplicationContext context = createContext(ScopedProxyMode.NO);
|
||||
ScopedTestBean bean = (ScopedTestBean) context.getBean("singleton");
|
||||
@@ -115,7 +115,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSingletonScopeIgnoresProxyInterfaces() {
|
||||
void singletonScopeIgnoresProxyInterfaces() {
|
||||
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
||||
ApplicationContext context = createContext(ScopedProxyMode.INTERFACES);
|
||||
ScopedTestBean bean = (ScopedTestBean) context.getBean("singleton");
|
||||
@@ -136,7 +136,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSingletonScopeIgnoresProxyTargetClass() {
|
||||
void singletonScopeIgnoresProxyTargetClass() {
|
||||
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
||||
ApplicationContext context = createContext(ScopedProxyMode.TARGET_CLASS);
|
||||
ScopedTestBean bean = (ScopedTestBean) context.getBean("singleton");
|
||||
@@ -157,7 +157,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRequestScopeWithNoProxy() {
|
||||
void requestScopeWithNoProxy() {
|
||||
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
||||
ApplicationContext context = createContext(ScopedProxyMode.NO);
|
||||
ScopedTestBean bean = (ScopedTestBean) context.getBean("request");
|
||||
@@ -178,15 +178,14 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRequestScopeWithProxiedInterfaces() {
|
||||
void requestScopeWithProxiedInterfaces() {
|
||||
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
||||
ApplicationContext context = createContext(ScopedProxyMode.INTERFACES);
|
||||
IScopedTestBean bean = (IScopedTestBean) context.getBean("request");
|
||||
|
||||
// should be dynamic proxy, implementing both interfaces
|
||||
assertThat(AopUtils.isJdkDynamicProxy(bean)).isTrue();
|
||||
boolean condition = bean instanceof AnotherScopeTestInterface;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(bean).isInstanceOf(AnotherScopeTestInterface.class);
|
||||
|
||||
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
|
||||
bean.setName(MODIFIED_NAME);
|
||||
@@ -200,15 +199,14 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRequestScopeWithProxiedTargetClass() {
|
||||
void requestScopeWithProxiedTargetClass() {
|
||||
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
|
||||
ApplicationContext context = createContext(ScopedProxyMode.TARGET_CLASS);
|
||||
IScopedTestBean bean = (IScopedTestBean) context.getBean("request");
|
||||
|
||||
// should be a class-based proxy
|
||||
assertThat(AopUtils.isCglibProxy(bean)).isTrue();
|
||||
boolean condition = bean instanceof RequestScopedTestBean;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(bean).isInstanceOf(RequestScopedTestBean.class);
|
||||
|
||||
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
|
||||
bean.setName(MODIFIED_NAME);
|
||||
@@ -222,7 +220,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSessionScopeWithNoProxy() {
|
||||
void sessionScopeWithNoProxy() {
|
||||
RequestContextHolder.setRequestAttributes(oldRequestAttributesWithSession);
|
||||
ApplicationContext context = createContext(ScopedProxyMode.NO);
|
||||
ScopedTestBean bean = (ScopedTestBean) context.getBean("session");
|
||||
@@ -243,15 +241,14 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSessionScopeWithProxiedInterfaces() {
|
||||
void sessionScopeWithProxiedInterfaces() {
|
||||
RequestContextHolder.setRequestAttributes(oldRequestAttributesWithSession);
|
||||
ApplicationContext context = createContext(ScopedProxyMode.INTERFACES);
|
||||
IScopedTestBean bean = (IScopedTestBean) context.getBean("session");
|
||||
|
||||
// should be dynamic proxy, implementing both interfaces
|
||||
assertThat(AopUtils.isJdkDynamicProxy(bean)).isTrue();
|
||||
boolean condition = bean instanceof AnotherScopeTestInterface;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(bean).isInstanceOf(AnotherScopeTestInterface.class);
|
||||
|
||||
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
|
||||
bean.setName(MODIFIED_NAME);
|
||||
@@ -271,17 +268,15 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSessionScopeWithProxiedTargetClass() {
|
||||
void sessionScopeWithProxiedTargetClass() {
|
||||
RequestContextHolder.setRequestAttributes(oldRequestAttributesWithSession);
|
||||
ApplicationContext context = createContext(ScopedProxyMode.TARGET_CLASS);
|
||||
IScopedTestBean bean = (IScopedTestBean) context.getBean("session");
|
||||
|
||||
// should be a class-based proxy
|
||||
assertThat(AopUtils.isCglibProxy(bean)).isTrue();
|
||||
boolean condition1 = bean instanceof ScopedTestBean;
|
||||
assertThat(condition1).isTrue();
|
||||
boolean condition = bean instanceof SessionScopedTestBean;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(bean).isInstanceOf(ScopedTestBean.class);
|
||||
assertThat(bean).isInstanceOf(SessionScopedTestBean.class);
|
||||
|
||||
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
|
||||
bean.setName(MODIFIED_NAME);
|
||||
|
||||
+5
-10
@@ -166,8 +166,7 @@ class ClassPathBeanDefinitionScannerScopeIntegrationTests {
|
||||
|
||||
// should be dynamic proxy, implementing both interfaces
|
||||
assertThat(AopUtils.isJdkDynamicProxy(bean)).isTrue();
|
||||
boolean condition = bean instanceof AnotherScopeTestInterface;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(bean).isInstanceOf(AnotherScopeTestInterface.class);
|
||||
|
||||
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
|
||||
bean.setName(MODIFIED_NAME);
|
||||
@@ -188,8 +187,7 @@ class ClassPathBeanDefinitionScannerScopeIntegrationTests {
|
||||
|
||||
// should be a class-based proxy
|
||||
assertThat(AopUtils.isCglibProxy(bean)).isTrue();
|
||||
boolean condition = bean instanceof RequestScopedTestBean;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(bean).isInstanceOf(RequestScopedTestBean.class);
|
||||
|
||||
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
|
||||
bean.setName(MODIFIED_NAME);
|
||||
@@ -231,8 +229,7 @@ class ClassPathBeanDefinitionScannerScopeIntegrationTests {
|
||||
|
||||
// should be dynamic proxy, implementing both interfaces
|
||||
assertThat(AopUtils.isJdkDynamicProxy(bean)).isTrue();
|
||||
boolean condition = bean instanceof AnotherScopeTestInterface;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(bean).isInstanceOf(AnotherScopeTestInterface.class);
|
||||
|
||||
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
|
||||
bean.setName(MODIFIED_NAME);
|
||||
@@ -259,10 +256,8 @@ class ClassPathBeanDefinitionScannerScopeIntegrationTests {
|
||||
|
||||
// should be a class-based proxy
|
||||
assertThat(AopUtils.isCglibProxy(bean)).isTrue();
|
||||
boolean condition1 = bean instanceof ScopedTestBean;
|
||||
assertThat(condition1).isTrue();
|
||||
boolean condition = bean instanceof SessionScopedTestBean;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(bean).isInstanceOf(ScopedTestBean.class);
|
||||
assertThat(bean).isInstanceOf(SessionScopedTestBean.class);
|
||||
|
||||
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
|
||||
bean.setName(MODIFIED_NAME);
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2002-present the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.core.env;
|
||||
|
||||
/**
|
||||
* Constants used both locally and in scan* sub-packages
|
||||
*/
|
||||
public class Constants {
|
||||
|
||||
public static final String XML_PATH = "org/springframework/core/env/EnvironmentSystemIntegrationTests-context.xml";
|
||||
|
||||
public static final String ENVIRONMENT_AWARE_BEAN_NAME = "envAwareBean";
|
||||
|
||||
public static final String PROD_BEAN_NAME = "prodBean";
|
||||
public static final String DEV_BEAN_NAME = "devBean";
|
||||
public static final String DERIVED_DEV_BEAN_NAME = "derivedDevBean";
|
||||
public static final String TRANSITIVE_BEAN_NAME = "transitiveBean";
|
||||
|
||||
public static final String PROD_ENV_NAME = "prod";
|
||||
public static final String DEV_ENV_NAME = "dev";
|
||||
public static final String DERIVED_DEV_ENV_NAME = "derivedDev";
|
||||
}
|
||||
Vendored
+11
-31
@@ -58,15 +58,15 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
import static org.springframework.beans.factory.support.BeanDefinitionBuilder.rootBeanDefinition;
|
||||
import static org.springframework.context.ConfigurableApplicationContext.ENVIRONMENT_BEAN_NAME;
|
||||
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DERIVED_DEV_BEAN_NAME;
|
||||
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DERIVED_DEV_ENV_NAME;
|
||||
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_BEAN_NAME;
|
||||
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_ENV_NAME;
|
||||
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.ENVIRONMENT_AWARE_BEAN_NAME;
|
||||
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_BEAN_NAME;
|
||||
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_ENV_NAME;
|
||||
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.TRANSITIVE_BEAN_NAME;
|
||||
import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.XML_PATH;
|
||||
import static org.springframework.core.env.Constants.DERIVED_DEV_BEAN_NAME;
|
||||
import static org.springframework.core.env.Constants.DERIVED_DEV_ENV_NAME;
|
||||
import static org.springframework.core.env.Constants.DEV_BEAN_NAME;
|
||||
import static org.springframework.core.env.Constants.DEV_ENV_NAME;
|
||||
import static org.springframework.core.env.Constants.ENVIRONMENT_AWARE_BEAN_NAME;
|
||||
import static org.springframework.core.env.Constants.PROD_BEAN_NAME;
|
||||
import static org.springframework.core.env.Constants.PROD_ENV_NAME;
|
||||
import static org.springframework.core.env.Constants.TRANSITIVE_BEAN_NAME;
|
||||
import static org.springframework.core.env.Constants.XML_PATH;
|
||||
|
||||
/**
|
||||
* System integration tests for container support of the {@link Environment} API.
|
||||
@@ -87,7 +87,7 @@ import static org.springframework.core.env.EnvironmentSystemIntegrationTests.Con
|
||||
* @author Sam Brannen
|
||||
* @see org.springframework.context.support.EnvironmentIntegrationTests
|
||||
*/
|
||||
public class EnvironmentSystemIntegrationTests {
|
||||
class EnvironmentSystemIntegrationTests {
|
||||
|
||||
private final ConfigurableEnvironment prodEnv = new StandardEnvironment();
|
||||
|
||||
@@ -648,7 +648,7 @@ public class EnvironmentSystemIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Profile(DERIVED_DEV_ENV_NAME)
|
||||
@Profile(Constants.DERIVED_DEV_ENV_NAME)
|
||||
@Configuration
|
||||
static class DerivedDevConfig extends DevConfig {
|
||||
@Bean
|
||||
@@ -666,24 +666,4 @@ public class EnvironmentSystemIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constants used both locally and in scan* sub-packages
|
||||
*/
|
||||
public static class Constants {
|
||||
|
||||
public static final String XML_PATH = "org/springframework/core/env/EnvironmentSystemIntegrationTests-context.xml";
|
||||
|
||||
public static final String ENVIRONMENT_AWARE_BEAN_NAME = "envAwareBean";
|
||||
|
||||
public static final String PROD_BEAN_NAME = "prodBean";
|
||||
public static final String DEV_BEAN_NAME = "devBean";
|
||||
public static final String DERIVED_DEV_BEAN_NAME = "derivedDevBean";
|
||||
public static final String TRANSITIVE_BEAN_NAME = "transitiveBean";
|
||||
|
||||
public static final String PROD_ENV_NAME = "prod";
|
||||
public static final String DEV_ENV_NAME = "dev";
|
||||
public static final String DERIVED_DEV_ENV_NAME = "derivedDev";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_ENV_NAME)
|
||||
@Profile(org.springframework.core.env.Constants.DEV_ENV_NAME)
|
||||
@Configuration
|
||||
class DevConfig {
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
|
||||
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_ENV_NAME)
|
||||
@Profile(org.springframework.core.env.Constants.PROD_ENV_NAME)
|
||||
@Configuration
|
||||
class ProdConfig {
|
||||
|
||||
|
||||
+2
-2
@@ -19,7 +19,7 @@ package org.springframework.core.env.scan2;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_ENV_NAME)
|
||||
@Component(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_BEAN_NAME)
|
||||
@Profile(org.springframework.core.env.Constants.DEV_ENV_NAME)
|
||||
@Component(org.springframework.core.env.Constants.DEV_BEAN_NAME)
|
||||
class DevBean {
|
||||
}
|
||||
|
||||
+2
-2
@@ -19,8 +19,8 @@ package org.springframework.core.env.scan2;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_ENV_NAME)
|
||||
@Component(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_BEAN_NAME)
|
||||
@Profile(org.springframework.core.env.Constants.PROD_ENV_NAME)
|
||||
@Component(org.springframework.core.env.Constants.PROD_BEAN_NAME)
|
||||
class ProdBean {
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ public class AspectJProxyFactory extends ProxyCreatorSupport {
|
||||
|
||||
/**
|
||||
* Add the supplied aspect instance to the chain. The type of the aspect instance
|
||||
* supplied must be a singleton aspect. True singleton lifecycle is not honoured when
|
||||
* supplied must be a singleton aspect. True singleton lifecycle is not honored when
|
||||
* using this method - the caller is responsible for managing the lifecycle of any
|
||||
* aspects added in this way.
|
||||
* @param aspectInstance the AspectJ aspect instance
|
||||
|
||||
+2
-2
@@ -119,7 +119,7 @@ final class InstantiationModelAwarePointcutAdvisorImpl
|
||||
|
||||
/**
|
||||
* The pointcut for Spring AOP to use.
|
||||
* Actual behaviour of the pointcut will change depending on the state of the advice.
|
||||
* Actual behavior of the pointcut will change depending on the state of the advice.
|
||||
*/
|
||||
@Override
|
||||
public Pointcut getPointcut() {
|
||||
@@ -258,7 +258,7 @@ final class InstantiationModelAwarePointcutAdvisorImpl
|
||||
|
||||
|
||||
/**
|
||||
* Pointcut implementation that changes its behaviour when the advice is instantiated.
|
||||
* Pointcut implementation that changes its behavior when the advice is instantiated.
|
||||
* Note that this is a <i>dynamic</i> pointcut; otherwise it might be optimized out
|
||||
* if it does not at first match statically.
|
||||
*/
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ public class DelegatePerTargetObjectIntroductionInterceptor extends Introduction
|
||||
|
||||
/**
|
||||
* Subclasses may need to override this if they want to perform custom
|
||||
* behaviour in around advice. However, subclasses should invoke this
|
||||
* behavior in around advice. However, subclasses should invoke this
|
||||
* method, which handles introduced interfaces and forwarding to the target.
|
||||
*/
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -97,7 +97,7 @@ public class DelegatingIntroductionInterceptor extends IntroductionInfoSupport
|
||||
|
||||
/**
|
||||
* Subclasses may need to override this if they want to perform custom
|
||||
* behaviour in around advice. However, subclasses should invoke this
|
||||
* behavior in around advice. However, subclasses should invoke this
|
||||
* method, which handles introduced interfaces and forwarding to the target.
|
||||
*/
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ import org.springframework.aop.Pointcut;
|
||||
* Convenient superclass when we want to force subclasses to
|
||||
* implement MethodMatcher interface, but subclasses
|
||||
* will want to be pointcuts. The getClassFilter() method can
|
||||
* be overridden to customize ClassFilter behaviour as well.
|
||||
* be overridden to customize ClassFilter behavior as well.
|
||||
*
|
||||
* @author Rod Johnson
|
||||
*/
|
||||
|
||||
+36
-44
@@ -23,7 +23,6 @@ import java.util.Map;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import test.annotation.EmptySpringAnnotation;
|
||||
import test.annotation.transaction.Tx;
|
||||
@@ -37,6 +36,7 @@ import org.springframework.beans.testfixture.beans.IOther;
|
||||
import org.springframework.beans.testfixture.beans.ITestBean;
|
||||
import org.springframework.beans.testfixture.beans.TestBean;
|
||||
import org.springframework.beans.testfixture.beans.subpkg.DeepBean;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
@@ -50,30 +50,22 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
*/
|
||||
class AspectJExpressionPointcutTests {
|
||||
|
||||
private Method getAge;
|
||||
|
||||
private Method setAge;
|
||||
|
||||
private Method setSomeNumber;
|
||||
|
||||
private final Method getAge = ClassUtils.getMethod(TestBean.class, "getAge");
|
||||
private final Method setAge = ClassUtils.getMethod(TestBean.class, "setAge", int.class);
|
||||
private final Method setSomeNumber = ClassUtils.getMethod(TestBean.class, "setSomeNumber", Number.class);
|
||||
private final Map<String, Method> methodsOnHasGeneric = new HashMap<>();
|
||||
|
||||
|
||||
@BeforeEach
|
||||
void setup() throws NoSuchMethodException {
|
||||
getAge = TestBean.class.getMethod("getAge");
|
||||
setAge = TestBean.class.getMethod("setAge", int.class);
|
||||
setSomeNumber = TestBean.class.getMethod("setSomeNumber", Number.class);
|
||||
|
||||
AspectJExpressionPointcutTests() throws NoSuchMethodException {
|
||||
// Assumes no overloading
|
||||
for (Method method : HasGeneric.class.getMethods()) {
|
||||
methodsOnHasGeneric.put(method.getName(), method);
|
||||
this.methodsOnHasGeneric.put(method.getName(), method);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testMatchExplicit() {
|
||||
void matchExplicit() {
|
||||
String expression = "execution(int org.springframework.beans.testfixture.beans.TestBean.getAge())";
|
||||
|
||||
Pointcut pointcut = getPointcut(expression);
|
||||
@@ -91,7 +83,7 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMatchWithTypePattern() {
|
||||
void matchWithTypePattern() {
|
||||
String expression = "execution(* *..TestBean.*Age(..))";
|
||||
|
||||
Pointcut pointcut = getPointcut(expression);
|
||||
@@ -110,12 +102,12 @@ class AspectJExpressionPointcutTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testThis() throws SecurityException, NoSuchMethodException{
|
||||
void thisCase() throws SecurityException, NoSuchMethodException{
|
||||
testThisOrTarget("this");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testTarget() throws SecurityException, NoSuchMethodException {
|
||||
void target() throws SecurityException, NoSuchMethodException {
|
||||
testThisOrTarget("target");
|
||||
}
|
||||
|
||||
@@ -139,12 +131,12 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithinRootPackage() throws SecurityException, NoSuchMethodException {
|
||||
void withinRootPackage() throws SecurityException, NoSuchMethodException {
|
||||
testWithinPackage(false);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithinRootAndSubpackages() throws SecurityException, NoSuchMethodException {
|
||||
void withinRootAndSubpackages() throws SecurityException, NoSuchMethodException {
|
||||
testWithinPackage(true);
|
||||
}
|
||||
|
||||
@@ -168,7 +160,7 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFriendlyErrorOnNoLocationClassMatching() {
|
||||
void friendlyErrorOnNoLocationClassMatching() {
|
||||
AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> pc.getClassFilter().matches(ITestBean.class))
|
||||
@@ -176,7 +168,7 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFriendlyErrorOnNoLocation2ArgMatching() {
|
||||
void friendlyErrorOnNoLocation2ArgMatching() {
|
||||
AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> pc.getMethodMatcher().matches(getAge, ITestBean.class))
|
||||
@@ -184,7 +176,7 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFriendlyErrorOnNoLocation3ArgMatching() {
|
||||
void friendlyErrorOnNoLocation3ArgMatching() {
|
||||
AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> pc.getMethodMatcher().matches(getAge, ITestBean.class, (Object[]) null))
|
||||
@@ -193,7 +185,7 @@ class AspectJExpressionPointcutTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testMatchWithArgs() {
|
||||
void matchWithArgs() {
|
||||
String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number)) && args(Double)";
|
||||
|
||||
Pointcut pointcut = getPointcut(expression);
|
||||
@@ -214,7 +206,7 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSimpleAdvice() {
|
||||
void simpleAdvice() {
|
||||
String expression = "execution(int org.springframework.beans.testfixture.beans.TestBean.getAge())";
|
||||
CallCountingInterceptor interceptor = new CallCountingInterceptor();
|
||||
TestBean testBean = getAdvisedProxy(expression, interceptor);
|
||||
@@ -227,7 +219,7 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDynamicMatchingProxy() {
|
||||
void dynamicMatchingProxy() {
|
||||
String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number)) && args(Double)";
|
||||
CallCountingInterceptor interceptor = new CallCountingInterceptor();
|
||||
TestBean testBean = getAdvisedProxy(expression, interceptor);
|
||||
@@ -241,7 +233,7 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInvalidExpression() {
|
||||
void invalidExpression() {
|
||||
String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number) && args(Double)";
|
||||
assertThat(getPointcut(expression).getClassFilter().matches(Object.class)).isFalse();
|
||||
}
|
||||
@@ -271,20 +263,20 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithUnsupportedPointcutPrimitive() {
|
||||
void withUnsupportedPointcutPrimitive() {
|
||||
String expression = "call(int org.springframework.beans.testfixture.beans.TestBean.getAge())";
|
||||
assertThat(getPointcut(expression).getClassFilter().matches(Object.class)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAndSubstitution() {
|
||||
void andSubstitution() {
|
||||
AspectJExpressionPointcut pc = getPointcut("execution(* *(..)) and args(String)");
|
||||
String expr = pc.getPointcutExpression().getPointcutExpression();
|
||||
assertThat(expr).isEqualTo("execution(* *(..)) && args(String)");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMultipleAndSubstitutions() {
|
||||
void multipleAndSubstitutions() {
|
||||
AspectJExpressionPointcut pc = getPointcut("execution(* *(..)) and args(String) and this(Object)");
|
||||
String expr = pc.getPointcutExpression().getPointcutExpression();
|
||||
assertThat(expr).isEqualTo("execution(* *(..)) && args(String) && this(Object)");
|
||||
@@ -297,7 +289,7 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMatchGenericArgument() {
|
||||
void matchGenericArgument() {
|
||||
String expression = "execution(* set*(java.util.List<org.springframework.beans.testfixture.beans.TestBean>) )";
|
||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||
ajexp.setExpression(expression);
|
||||
@@ -316,7 +308,7 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMatchVarargs() throws Exception {
|
||||
void matchVarargs() throws Exception {
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
class MyTemplate {
|
||||
@@ -342,19 +334,19 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMatchAnnotationOnClassWithAtWithin() throws Exception {
|
||||
void matchAnnotationOnClassWithAtWithin() throws Exception {
|
||||
String expression = "@within(test.annotation.transaction.Tx)";
|
||||
testMatchAnnotationOnClass(expression);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMatchAnnotationOnClassWithoutBinding() throws Exception {
|
||||
void matchAnnotationOnClassWithoutBinding() throws Exception {
|
||||
String expression = "within(@test.annotation.transaction.Tx *)";
|
||||
testMatchAnnotationOnClass(expression);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMatchAnnotationOnClassWithSubpackageWildcard() throws Exception {
|
||||
void matchAnnotationOnClassWithSubpackageWildcard() throws Exception {
|
||||
String expression = "within(@(test.annotation..*) *)";
|
||||
AspectJExpressionPointcut springAnnotatedPc = testMatchAnnotationOnClass(expression);
|
||||
assertThat(springAnnotatedPc.matches(TestBean.class.getMethod("setName", String.class), TestBean.class)).isFalse();
|
||||
@@ -366,7 +358,7 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMatchAnnotationOnClassWithExactPackageWildcard() throws Exception {
|
||||
void matchAnnotationOnClassWithExactPackageWildcard() throws Exception {
|
||||
String expression = "within(@(test.annotation.transaction.*) *)";
|
||||
testMatchAnnotationOnClass(expression);
|
||||
}
|
||||
@@ -384,7 +376,7 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAnnotationOnMethodWithFQN() throws Exception {
|
||||
void annotationOnMethodWithFQN() throws Exception {
|
||||
String expression = "@annotation(test.annotation.transaction.Tx)";
|
||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||
ajexp.setExpression(expression);
|
||||
@@ -398,7 +390,7 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAnnotationOnCglibProxyMethod() throws Exception {
|
||||
void annotationOnCglibProxyMethod() throws Exception {
|
||||
String expression = "@annotation(test.annotation.transaction.Tx)";
|
||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||
ajexp.setExpression(expression);
|
||||
@@ -410,7 +402,7 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNotAnnotationOnCglibProxyMethod() throws Exception {
|
||||
void notAnnotationOnCglibProxyMethod() throws Exception {
|
||||
String expression = "!@annotation(test.annotation.transaction.Tx)";
|
||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||
ajexp.setExpression(expression);
|
||||
@@ -422,7 +414,7 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAnnotationOnDynamicProxyMethod() throws Exception {
|
||||
void annotationOnDynamicProxyMethod() throws Exception {
|
||||
String expression = "@annotation(test.annotation.transaction.Tx)";
|
||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||
ajexp.setExpression(expression);
|
||||
@@ -434,7 +426,7 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNotAnnotationOnDynamicProxyMethod() throws Exception {
|
||||
void notAnnotationOnDynamicProxyMethod() throws Exception {
|
||||
String expression = "!@annotation(test.annotation.transaction.Tx)";
|
||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||
ajexp.setExpression(expression);
|
||||
@@ -446,7 +438,7 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAnnotationOnMethodWithWildcard() throws Exception {
|
||||
void annotationOnMethodWithWildcard() throws Exception {
|
||||
String expression = "execution(@(test.annotation..*) * *(..))";
|
||||
AspectJExpressionPointcut anySpringMethodAnnotation = new AspectJExpressionPointcut();
|
||||
anySpringMethodAnnotation.setExpression(expression);
|
||||
@@ -462,7 +454,7 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAnnotationOnMethodArgumentsWithFQN() throws Exception {
|
||||
void annotationOnMethodArgumentsWithFQN() throws Exception {
|
||||
String expression = "@args(*, test.annotation.EmptySpringAnnotation))";
|
||||
AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut();
|
||||
takesSpringAnnotatedArgument2.setExpression(expression);
|
||||
@@ -491,7 +483,7 @@ class AspectJExpressionPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAnnotationOnMethodArgumentsWithWildcards() throws Exception {
|
||||
void annotationOnMethodArgumentsWithWildcards() throws Exception {
|
||||
String expression = "execution(* *(*, @(test..*) *))";
|
||||
AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut();
|
||||
takesSpringAnnotatedArgument2.setExpression(expression);
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class BeanNamePointcutMatchingTests {
|
||||
|
||||
@Test
|
||||
void testMatchingPointcuts() {
|
||||
void matchingPointcuts() {
|
||||
assertMatch("someName", "bean(someName)");
|
||||
|
||||
// Spring bean names are less restrictive compared to AspectJ names (methods, types etc.)
|
||||
@@ -66,7 +66,7 @@ class BeanNamePointcutMatchingTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNonMatchingPointcuts() {
|
||||
void nonMatchingPointcuts() {
|
||||
assertMisMatch("someName", "bean(someNamex)");
|
||||
assertMisMatch("someName", "bean(someX*Name)");
|
||||
|
||||
|
||||
+7
-8
@@ -17,7 +17,6 @@
|
||||
package org.springframework.aop.aspectj;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
@@ -49,17 +48,17 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
||||
class MethodInvocationProceedingJoinPointTests {
|
||||
|
||||
@Test
|
||||
void testingBindingWithJoinPoint() {
|
||||
void bindingWithJoinPoint() {
|
||||
assertThatIllegalStateException().isThrownBy(AbstractAspectJAdvice::currentJoinPoint);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testingBindingWithProceedingJoinPoint() {
|
||||
void bindingWithProceedingJoinPoint() {
|
||||
assertThatIllegalStateException().isThrownBy(AbstractAspectJAdvice::currentJoinPoint);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCanGetMethodSignatureFromJoinPoint() {
|
||||
void canGetMethodSignatureFromJoinPoint() {
|
||||
final Object raw = new TestBean();
|
||||
// Will be set by advice during a method call
|
||||
final int newAge = 23;
|
||||
@@ -106,9 +105,9 @@ class MethodInvocationProceedingJoinPointTests {
|
||||
assertThat(AbstractAspectJAdvice.currentJoinPoint().getSignature()).as("Return same MethodSignature repeatedly").isSameAs(msig);
|
||||
assertThat(AbstractAspectJAdvice.currentJoinPoint()).as("Return same JoinPoint repeatedly").isSameAs(AbstractAspectJAdvice.currentJoinPoint());
|
||||
assertThat(msig.getDeclaringType()).isEqualTo(method.getDeclaringClass());
|
||||
assertThat(Arrays.equals(method.getParameterTypes(), msig.getParameterTypes())).isTrue();
|
||||
assertThat(method.getParameterTypes()).isEqualTo(msig.getParameterTypes());
|
||||
assertThat(msig.getReturnType()).isEqualTo(method.getReturnType());
|
||||
assertThat(Arrays.equals(method.getExceptionTypes(), msig.getExceptionTypes())).isTrue();
|
||||
assertThat(method.getExceptionTypes()).isEqualTo(msig.getExceptionTypes());
|
||||
msig.toLongString();
|
||||
msig.toShortString();
|
||||
});
|
||||
@@ -118,7 +117,7 @@ class MethodInvocationProceedingJoinPointTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCanGetSourceLocationFromJoinPoint() {
|
||||
void canGetSourceLocationFromJoinPoint() {
|
||||
final Object raw = new TestBean();
|
||||
ProxyFactory pf = new ProxyFactory(raw);
|
||||
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
|
||||
@@ -135,7 +134,7 @@ class MethodInvocationProceedingJoinPointTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCanGetStaticPartFromJoinPoint() {
|
||||
void canGetStaticPartFromJoinPoint() {
|
||||
final Object raw = new TestBean();
|
||||
ProxyFactory pf = new ProxyFactory(raw);
|
||||
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
|
||||
|
||||
+5
-5
@@ -43,14 +43,14 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
class TrickyAspectJPointcutExpressionTests {
|
||||
|
||||
@Test
|
||||
void testManualProxyJavaWithUnconditionalPointcut() {
|
||||
void manualProxyJavaWithUnconditionalPointcut() {
|
||||
TestService target = new TestServiceImpl();
|
||||
LogUserAdvice logAdvice = new LogUserAdvice();
|
||||
testAdvice(new DefaultPointcutAdvisor(logAdvice), logAdvice, target, "TestServiceImpl");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testManualProxyJavaWithStaticPointcut() {
|
||||
void manualProxyJavaWithStaticPointcut() {
|
||||
TestService target = new TestServiceImpl();
|
||||
LogUserAdvice logAdvice = new LogUserAdvice();
|
||||
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
|
||||
@@ -59,7 +59,7 @@ class TrickyAspectJPointcutExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testManualProxyJavaWithDynamicPointcut() {
|
||||
void manualProxyJavaWithDynamicPointcut() {
|
||||
TestService target = new TestServiceImpl();
|
||||
LogUserAdvice logAdvice = new LogUserAdvice();
|
||||
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
|
||||
@@ -68,7 +68,7 @@ class TrickyAspectJPointcutExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testManualProxyJavaWithDynamicPointcutAndProxyTargetClass() {
|
||||
void manualProxyJavaWithDynamicPointcutAndProxyTargetClass() {
|
||||
TestService target = new TestServiceImpl();
|
||||
LogUserAdvice logAdvice = new LogUserAdvice();
|
||||
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
|
||||
@@ -77,7 +77,7 @@ class TrickyAspectJPointcutExpressionTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testManualProxyJavaWithStaticPointcutAndTwoClassLoaders() throws Exception {
|
||||
void manualProxyJavaWithStaticPointcutAndTwoClassLoaders() throws Exception {
|
||||
|
||||
LogUserAdvice logAdvice = new LogUserAdvice();
|
||||
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
|
||||
|
||||
+3
-3
@@ -97,7 +97,7 @@ class TypePatternClassFilterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEquals() {
|
||||
void equals() {
|
||||
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*");
|
||||
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*");
|
||||
TypePatternClassFilter filter3 = new TypePatternClassFilter("org.springframework.tests.*");
|
||||
@@ -107,7 +107,7 @@ class TypePatternClassFilterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHashCode() {
|
||||
void hashCodeBehavior() {
|
||||
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*");
|
||||
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*");
|
||||
TypePatternClassFilter filter3 = new TypePatternClassFilter("org.springframework.tests.*");
|
||||
@@ -117,7 +117,7 @@ class TypePatternClassFilterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToString() {
|
||||
void toStringOutput() {
|
||||
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*");
|
||||
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*");
|
||||
|
||||
|
||||
+2
-2
@@ -430,8 +430,8 @@ abstract class AbstractAspectJAdvisorFactoryTests {
|
||||
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(itb::getAge);
|
||||
}
|
||||
|
||||
// TODO document this behaviour.
|
||||
// Is it different AspectJ behaviour, at least for checked exceptions?
|
||||
// TODO document this behavior.
|
||||
// Is it different AspectJ behavior, at least for checked exceptions?
|
||||
@Test
|
||||
void aspectMethodThrowsExceptionIllegalOnSignature() {
|
||||
TestBean target = new TestBean();
|
||||
|
||||
+5
-6
@@ -39,7 +39,7 @@ class AspectJPointcutAdvisorTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testSingleton() throws SecurityException, NoSuchMethodException {
|
||||
void singleton() throws SecurityException, NoSuchMethodException {
|
||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||
ajexp.setExpression(CommonExpressions.MATCH_ALL_METHODS);
|
||||
|
||||
@@ -53,7 +53,7 @@ class AspectJPointcutAdvisorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPerTarget() throws SecurityException, NoSuchMethodException {
|
||||
void perTarget() throws SecurityException, NoSuchMethodException {
|
||||
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
|
||||
ajexp.setExpression(CommonExpressions.MATCH_ALL_METHODS);
|
||||
|
||||
@@ -63,8 +63,7 @@ class AspectJPointcutAdvisorTests {
|
||||
1, "someBean");
|
||||
|
||||
assertThat(ajpa.getAspectMetadata().getPerClausePointcut()).isNotSameAs(Pointcut.TRUE);
|
||||
boolean condition = ajpa.getAspectMetadata().getPerClausePointcut() instanceof AspectJExpressionPointcut;
|
||||
assertThat(condition).isTrue();
|
||||
assertThat(ajpa.getAspectMetadata().getPerClausePointcut()).isInstanceOf(AspectJExpressionPointcut.class);
|
||||
assertThat(ajpa.isPerInstance()).isTrue();
|
||||
|
||||
assertThat(ajpa.getAspectMetadata().getPerClausePointcut().getClassFilter().matches(TestBean.class)).isTrue();
|
||||
@@ -76,13 +75,13 @@ class AspectJPointcutAdvisorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPerCflowTarget() {
|
||||
void perCflowTarget() {
|
||||
assertThatExceptionOfType(AopConfigException.class).isThrownBy(() ->
|
||||
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowAspect.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPerCflowBelowTarget() {
|
||||
void perCflowBelowTarget() {
|
||||
assertThatExceptionOfType(AopConfigException.class).isThrownBy(() ->
|
||||
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowBelowAspect.class));
|
||||
}
|
||||
|
||||
+9
-9
@@ -39,13 +39,13 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
class AspectProxyFactoryTests {
|
||||
|
||||
@Test
|
||||
void testWithNonAspect() {
|
||||
void withNonAspect() {
|
||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> proxyFactory.addAspect(TestBean.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithSimpleAspect() {
|
||||
void withSimpleAspect() {
|
||||
TestBean bean = new TestBean();
|
||||
bean.setAge(2);
|
||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(bean);
|
||||
@@ -55,7 +55,7 @@ class AspectProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithPerThisAspect() {
|
||||
void withPerThisAspect() {
|
||||
TestBean bean1 = new TestBean();
|
||||
TestBean bean2 = new TestBean();
|
||||
|
||||
@@ -75,14 +75,14 @@ class AspectProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithInstanceWithNonAspect() {
|
||||
void withInstanceWithNonAspect() {
|
||||
AspectJProxyFactory pf = new AspectJProxyFactory();
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> pf.addAspect(new TestBean()));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void testSerializable() throws Exception {
|
||||
void serializable() throws Exception {
|
||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
|
||||
proxyFactory.addAspect(LoggingAspectOnVarargs.class);
|
||||
ITestBean proxy = proxyFactory.getProxy();
|
||||
@@ -92,7 +92,7 @@ class AspectProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithInstance() throws Exception {
|
||||
void withInstance() throws Exception {
|
||||
MultiplyReturnValue aspect = new MultiplyReturnValue();
|
||||
int multiple = 3;
|
||||
aspect.setMultiple(multiple);
|
||||
@@ -111,14 +111,14 @@ class AspectProxyFactoryTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithNonSingletonAspectInstance() {
|
||||
void withNonSingletonAspectInstance() {
|
||||
AspectJProxyFactory pf = new AspectJProxyFactory();
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> pf.addAspect(new PerThisAspect()));
|
||||
}
|
||||
|
||||
@Test // SPR-13328
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testProxiedVarargsWithEnumArray() {
|
||||
void proxiedVarargsWithEnumArray() {
|
||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
|
||||
proxyFactory.addAspect(LoggingAspectOnVarargs.class);
|
||||
ITestBean proxy = proxyFactory.getProxy();
|
||||
@@ -127,7 +127,7 @@ class AspectProxyFactoryTests {
|
||||
|
||||
@Test // SPR-13328
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testUnproxiedVarargsWithEnumArray() {
|
||||
void unproxiedVarargsWithEnumArray() {
|
||||
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
|
||||
proxyFactory.addAspect(LoggingAspectOnSetter.class);
|
||||
ITestBean proxy = proxyFactory.getProxy();
|
||||
|
||||
+5
-5
@@ -47,7 +47,7 @@ class AspectJNamespaceHandlerTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
void setUp() {
|
||||
SourceExtractor sourceExtractor = new PassThroughSourceExtractor();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.registry);
|
||||
XmlReaderContext readerContext =
|
||||
@@ -56,7 +56,7 @@ class AspectJNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRegisterAutoProxyCreator() {
|
||||
void registerAutoProxyCreator() {
|
||||
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
|
||||
assertThat(registry.getBeanDefinitionCount()).as("Incorrect number of definitions registered").isEqualTo(1);
|
||||
|
||||
@@ -65,7 +65,7 @@ class AspectJNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRegisterAspectJAutoProxyCreator() {
|
||||
void registerAspectJAutoProxyCreator() {
|
||||
AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
|
||||
assertThat(registry.getBeanDefinitionCount()).as("Incorrect number of definitions registered").isEqualTo(1);
|
||||
|
||||
@@ -77,7 +77,7 @@ class AspectJNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRegisterAspectJAutoProxyCreatorWithExistingAutoProxyCreator() {
|
||||
void registerAspectJAutoProxyCreatorWithExistingAutoProxyCreator() {
|
||||
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
|
||||
assertThat(registry.getBeanDefinitionCount()).isEqualTo(1);
|
||||
|
||||
@@ -89,7 +89,7 @@ class AspectJNamespaceHandlerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRegisterAutoProxyCreatorWhenAspectJAutoProxyCreatorAlreadyExists() {
|
||||
void registerAutoProxyCreatorWhenAspectJAutoProxyCreatorAlreadyExists() {
|
||||
AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
|
||||
assertThat(registry.getBeanDefinitionCount()).isEqualTo(1);
|
||||
|
||||
|
||||
+21
-16
@@ -33,6 +33,7 @@ import org.springframework.aop.aspectj.AspectJExpressionPointcut;
|
||||
import org.springframework.aop.aspectj.AspectJMethodBeforeAdvice;
|
||||
import org.springframework.aop.aspectj.AspectJPointcutAdvisor;
|
||||
import org.springframework.aop.support.DefaultPointcutAdvisor;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@@ -48,24 +49,21 @@ class AspectJPrecedenceComparatorTests {
|
||||
private static final int LATE_ADVICE_DECLARATION_ORDER = 10;
|
||||
|
||||
|
||||
private AspectJPrecedenceComparator comparator;
|
||||
private final AspectJPrecedenceComparator comparator = new AspectJPrecedenceComparator();
|
||||
|
||||
private Method anyOldMethod;
|
||||
private final Method anyOldMethod = ClassUtils.getMethod(MessageService.class, "getMessage");
|
||||
|
||||
private AspectJExpressionPointcut anyOldPointcut;
|
||||
private final AspectJExpressionPointcut anyOldPointcut = new AspectJExpressionPointcut();
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
this.comparator = new AspectJPrecedenceComparator();
|
||||
this.anyOldMethod = getClass().getMethods()[0];
|
||||
this.anyOldPointcut = new AspectJExpressionPointcut();
|
||||
void setUp() {
|
||||
this.anyOldPointcut.setExpression("execution(* *(..))");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testSameAspectNoAfterAdvice() {
|
||||
void sameAspectNoAfterAdvice() {
|
||||
Advisor advisor1 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
Advisor advisor2 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor1 sorted before advisor2").isEqualTo(-1);
|
||||
@@ -76,7 +74,7 @@ class AspectJPrecedenceComparatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSameAspectAfterAdvice() {
|
||||
void sameAspectAfterAdvice() {
|
||||
Advisor advisor1 = createAspectJAfterAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
Advisor advisor2 = createAspectJAroundAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor2 sorted before advisor1").isEqualTo(1);
|
||||
@@ -87,14 +85,14 @@ class AspectJPrecedenceComparatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSameAspectOneOfEach() {
|
||||
void sameAspectOneOfEach() {
|
||||
Advisor advisor1 = createAspectJAfterAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
Advisor advisor2 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor1 and advisor2 not comparable").isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSameAdvisorPrecedenceDifferentAspectNoAfterAdvice() {
|
||||
void sameAdvisorPrecedenceDifferentAspectNoAfterAdvice() {
|
||||
Advisor advisor1 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
Advisor advisor2 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someOtherAspect");
|
||||
assertThat(this.comparator.compare(advisor1, advisor2)).as("nothing to say about order here").isEqualTo(0);
|
||||
@@ -105,7 +103,7 @@ class AspectJPrecedenceComparatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSameAdvisorPrecedenceDifferentAspectAfterAdvice() {
|
||||
void sameAdvisorPrecedenceDifferentAspectAfterAdvice() {
|
||||
Advisor advisor1 = createAspectJAfterAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
Advisor advisor2 = createAspectJAroundAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someOtherAspect");
|
||||
assertThat(this.comparator.compare(advisor1, advisor2)).as("nothing to say about order here").isEqualTo(0);
|
||||
@@ -116,7 +114,7 @@ class AspectJPrecedenceComparatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHigherAdvisorPrecedenceNoAfterAdvice() {
|
||||
void higherAdvisorPrecedenceNoAfterAdvice() {
|
||||
Advisor advisor1 = createSpringAOPBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER);
|
||||
Advisor advisor2 = createAspectJBeforeAdvice(LOW_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someOtherAspect");
|
||||
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor1 sorted before advisor2").isEqualTo(-1);
|
||||
@@ -127,7 +125,7 @@ class AspectJPrecedenceComparatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHigherAdvisorPrecedenceAfterAdvice() {
|
||||
void higherAdvisorPrecedenceAfterAdvice() {
|
||||
Advisor advisor1 = createAspectJAfterAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
Advisor advisor2 = createAspectJAroundAdvice(LOW_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someOtherAspect");
|
||||
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor1 sorted before advisor2").isEqualTo(-1);
|
||||
@@ -138,7 +136,7 @@ class AspectJPrecedenceComparatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLowerAdvisorPrecedenceNoAfterAdvice() {
|
||||
void lowerAdvisorPrecedenceNoAfterAdvice() {
|
||||
Advisor advisor1 = createAspectJBeforeAdvice(LOW_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
Advisor advisor2 = createAspectJBeforeAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someOtherAspect");
|
||||
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor1 sorted after advisor2").isEqualTo(1);
|
||||
@@ -149,7 +147,7 @@ class AspectJPrecedenceComparatorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testLowerAdvisorPrecedenceAfterAdvice() {
|
||||
void lowerAdvisorPrecedenceAfterAdvice() {
|
||||
Advisor advisor1 = createAspectJAfterAdvice(LOW_PRECEDENCE_ADVISOR_ORDER, EARLY_ADVICE_DECLARATION_ORDER, "someAspect");
|
||||
Advisor advisor2 = createAspectJAroundAdvice(HIGH_PRECEDENCE_ADVISOR_ORDER, LATE_ADVICE_DECLARATION_ORDER, "someOtherAspect");
|
||||
assertThat(this.comparator.compare(advisor1, advisor2)).as("advisor1 sorted after advisor2").isEqualTo(1);
|
||||
@@ -209,4 +207,11 @@ class AspectJPrecedenceComparatorTests {
|
||||
return advisor;
|
||||
}
|
||||
|
||||
static class MessageService {
|
||||
|
||||
public String getMessage() {
|
||||
return "test";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class MethodInvocationTests {
|
||||
|
||||
@Test
|
||||
void testValidInvocation() throws Throwable {
|
||||
void validInvocation() throws Throwable {
|
||||
Method method = Object.class.getMethod("hashCode");
|
||||
Object proxy = new Object();
|
||||
Object returnValue = new Object();
|
||||
@@ -49,7 +49,7 @@ class MethodInvocationTests {
|
||||
* toString on target can cause failure.
|
||||
*/
|
||||
@Test
|
||||
void testToStringDoesntHitTarget() throws Throwable {
|
||||
void toStringDoesntHitTarget() throws Throwable {
|
||||
Object target = new TestBean() {
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
@@ -36,7 +36,7 @@ class NullPrimitiveTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNullPrimitiveWithJdkProxy() {
|
||||
void nullPrimitiveWithJdkProxy() {
|
||||
|
||||
class SimpleFoo implements Foo {
|
||||
@Override
|
||||
@@ -62,7 +62,7 @@ class NullPrimitiveTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNullPrimitiveWithCglibProxy() {
|
||||
void nullPrimitiveWithCglibProxy() {
|
||||
|
||||
Bar target = new Bar();
|
||||
ProxyFactory factory = new ProxyFactory(target);
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@ class PrototypeTargetTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testPrototypeProxyWithPrototypeTarget() {
|
||||
void prototypeProxyWithPrototypeTarget() {
|
||||
TestBeanImpl.constructionCount = 0;
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
|
||||
@@ -52,7 +52,7 @@ class PrototypeTargetTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSingletonProxyWithPrototypeTarget() {
|
||||
void singletonProxyWithPrototypeTarget() {
|
||||
TestBeanImpl.constructionCount = 0;
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
|
||||
|
||||
+6
-6
@@ -40,14 +40,14 @@ import static org.mockito.Mockito.mock;
|
||||
class ThrowsAdviceInterceptorTests {
|
||||
|
||||
@Test
|
||||
void testNoHandlerMethods() {
|
||||
void noHandlerMethods() {
|
||||
// should require one handler method at least
|
||||
assertThatExceptionOfType(AopConfigException.class).isThrownBy(() ->
|
||||
new ThrowsAdviceInterceptor(new Object()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNotInvoked() throws Throwable {
|
||||
void notInvoked() throws Throwable {
|
||||
MyThrowsHandler th = new MyThrowsHandler();
|
||||
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
||||
Object ret = new Object();
|
||||
@@ -58,7 +58,7 @@ class ThrowsAdviceInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNoHandlerMethodForThrowable() throws Throwable {
|
||||
void noHandlerMethodForThrowable() throws Throwable {
|
||||
MyThrowsHandler th = new MyThrowsHandler();
|
||||
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
||||
assertThat(ti.getHandlerMethodCount()).isEqualTo(2);
|
||||
@@ -70,7 +70,7 @@ class ThrowsAdviceInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCorrectHandlerUsed() throws Throwable {
|
||||
void correctHandlerUsed() throws Throwable {
|
||||
MyThrowsHandler th = new MyThrowsHandler();
|
||||
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
||||
FileNotFoundException ex = new FileNotFoundException();
|
||||
@@ -84,7 +84,7 @@ class ThrowsAdviceInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCorrectHandlerUsedForSubclass() throws Throwable {
|
||||
void correctHandlerUsedForSubclass() throws Throwable {
|
||||
MyThrowsHandler th = new MyThrowsHandler();
|
||||
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
|
||||
// Extends RemoteException
|
||||
@@ -97,7 +97,7 @@ class ThrowsAdviceInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHandlerMethodThrowsException() throws Throwable {
|
||||
void handlerMethodThrowsException() throws Throwable {
|
||||
final Throwable t = new Throwable();
|
||||
|
||||
MyThrowsHandler th = new MyThrowsHandler() {
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@ import static org.mockito.Mockito.verify;
|
||||
class DebugInterceptorTests {
|
||||
|
||||
@Test
|
||||
void testSunnyDayPathLogsCorrectly() throws Throwable {
|
||||
void sunnyDayPathLogsCorrectly() throws Throwable {
|
||||
MethodInvocation methodInvocation = mock();
|
||||
|
||||
Log log = mock();
|
||||
@@ -52,7 +52,7 @@ class DebugInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExceptionPathStillLogsCorrectly() throws Throwable {
|
||||
void exceptionPathStillLogsCorrectly() throws Throwable {
|
||||
MethodInvocation methodInvocation = mock();
|
||||
|
||||
IllegalArgumentException exception = new IllegalArgumentException();
|
||||
|
||||
+4
-6
@@ -46,7 +46,7 @@ class ExposeBeanNameAdvisorsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNoIntroduction() {
|
||||
void noIntroduction() {
|
||||
String beanName = "foo";
|
||||
TestBean target = new RequiresBeanNameBoundTestBean(beanName);
|
||||
ProxyFactory pf = new ProxyFactory(target);
|
||||
@@ -54,14 +54,13 @@ class ExposeBeanNameAdvisorsTests {
|
||||
pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorWithoutIntroduction(beanName));
|
||||
ITestBean proxy = (ITestBean) pf.getProxy();
|
||||
|
||||
boolean condition = proxy instanceof NamedBean;
|
||||
assertThat(condition).as("No introduction").isFalse();
|
||||
assertThat(proxy).as("No introduction").isNotInstanceOf(NamedBean.class);
|
||||
// Requires binding
|
||||
proxy.getAge();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testWithIntroduction() {
|
||||
void withIntroduction() {
|
||||
String beanName = "foo";
|
||||
TestBean target = new RequiresBeanNameBoundTestBean(beanName);
|
||||
ProxyFactory pf = new ProxyFactory(target);
|
||||
@@ -69,8 +68,7 @@ class ExposeBeanNameAdvisorsTests {
|
||||
pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorIntroducingNamedBean(beanName));
|
||||
ITestBean proxy = (ITestBean) pf.getProxy();
|
||||
|
||||
boolean condition = proxy instanceof NamedBean;
|
||||
assertThat(condition).as("Introduction was made").isTrue();
|
||||
assertThat(proxy).as("Introduction was made").isInstanceOf(NamedBean.class);
|
||||
// Requires binding
|
||||
proxy.getAge();
|
||||
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
|
||||
class ExposeInvocationInterceptorTests {
|
||||
|
||||
@Test
|
||||
void testXmlConfig() {
|
||||
void xmlConfig() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
qualifiedResource(ExposeInvocationInterceptorTests.class, "context.xml"));
|
||||
|
||||
+3
-3
@@ -35,7 +35,7 @@ import static org.mockito.Mockito.verify;
|
||||
class PerformanceMonitorInterceptorTests {
|
||||
|
||||
@Test
|
||||
void testSuffixAndPrefixAssignment() {
|
||||
void suffixAndPrefixAssignment() {
|
||||
PerformanceMonitorInterceptor interceptor = new PerformanceMonitorInterceptor();
|
||||
|
||||
assertThat(interceptor.getPrefix()).isNotNull();
|
||||
@@ -49,7 +49,7 @@ class PerformanceMonitorInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSunnyDayPathLogsPerformanceMetricsCorrectly() throws Throwable {
|
||||
void sunnyDayPathLogsPerformanceMetricsCorrectly() throws Throwable {
|
||||
MethodInvocation mi = mock();
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
|
||||
|
||||
@@ -62,7 +62,7 @@ class PerformanceMonitorInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExceptionPathStillLogsPerformanceMetricsCorrectly() throws Throwable {
|
||||
void exceptionPathStillLogsPerformanceMetricsCorrectly() throws Throwable {
|
||||
MethodInvocation mi = mock();
|
||||
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ import static org.mockito.Mockito.verify;
|
||||
class SimpleTraceInterceptorTests {
|
||||
|
||||
@Test
|
||||
void testSunnyDayPathLogsCorrectly() throws Throwable {
|
||||
void sunnyDayPathLogsCorrectly() throws Throwable {
|
||||
MethodInvocation mi = mock();
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
|
||||
given(mi.getThis()).willReturn(this);
|
||||
@@ -51,7 +51,7 @@ class SimpleTraceInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExceptionPathStillLogsCorrectly() throws Throwable {
|
||||
void exceptionPathStillLogsCorrectly() throws Throwable {
|
||||
MethodInvocation mi = mock();
|
||||
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
|
||||
given(mi.getThis()).willReturn(this);
|
||||
|
||||
+4
-4
@@ -35,25 +35,25 @@ class DefaultScopedObjectTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testCtorWithNullBeanFactory() {
|
||||
void ctorWithNullBeanFactory() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new DefaultScopedObject(null, GOOD_BEAN_NAME));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCtorWithNullTargetBeanName() {
|
||||
void ctorWithNullTargetBeanName() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
testBadTargetBeanName(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCtorWithEmptyTargetBeanName() {
|
||||
void ctorWithEmptyTargetBeanName() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
testBadTargetBeanName(""));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCtorWithJustWhitespacedTargetBeanName() {
|
||||
void ctorWithJustWhitespacedTargetBeanName() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
testBadTargetBeanName(" "));
|
||||
}
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
|
||||
class ScopedProxyAutowireTests {
|
||||
|
||||
@Test
|
||||
void testScopedProxyInheritsAutowireCandidateFalse() {
|
||||
void scopedProxyInheritsAutowireCandidateFalse() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
qualifiedResource(ScopedProxyAutowireTests.class, "scopedAutowireFalse.xml"));
|
||||
@@ -48,7 +48,7 @@ class ScopedProxyAutowireTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testScopedProxyReplacesAutowireCandidateTrue() {
|
||||
void scopedProxyReplacesAutowireCandidateTrue() {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
|
||||
qualifiedResource(ScopedProxyAutowireTests.class, "scopedAutowireTrue.xml"));
|
||||
|
||||
@@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class AopUtilsTests {
|
||||
|
||||
@Test
|
||||
void testPointcutCanNeverApply() {
|
||||
void pointcutCanNeverApply() {
|
||||
class TestPointcut extends StaticMethodMatcherPointcut {
|
||||
@Override
|
||||
public boolean matches(Method method, @Nullable Class<?> clazzy) {
|
||||
@@ -58,13 +58,13 @@ class AopUtilsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPointcutAlwaysApplies() {
|
||||
void pointcutAlwaysApplies() {
|
||||
assertThat(AopUtils.canApply(new DefaultPointcutAdvisor(new NopInterceptor()), Object.class)).isTrue();
|
||||
assertThat(AopUtils.canApply(new DefaultPointcutAdvisor(new NopInterceptor()), TestBean.class)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPointcutAppliesToOneMethodOnObject() {
|
||||
void pointcutAppliesToOneMethodOnObject() {
|
||||
class TestPointcut extends StaticMethodMatcherPointcut {
|
||||
@Override
|
||||
public boolean matches(Method method, @Nullable Class<?> clazz) {
|
||||
@@ -84,7 +84,7 @@ class AopUtilsTests {
|
||||
* that's subverted the singleton construction limitation.
|
||||
*/
|
||||
@Test
|
||||
void testCanonicalFrameworkClassesStillCanonicalOnDeserialization() throws Exception {
|
||||
void canonicalFrameworkClassesStillCanonicalOnDeserialization() throws Exception {
|
||||
assertThat(SerializationTestUtils.serializeAndDeserialize(MethodMatcher.TRUE)).isSameAs(MethodMatcher.TRUE);
|
||||
assertThat(SerializationTestUtils.serializeAndDeserialize(ClassFilter.TRUE)).isSameAs(ClassFilter.TRUE);
|
||||
assertThat(SerializationTestUtils.serializeAndDeserialize(Pointcut.TRUE)).isSameAs(Pointcut.TRUE);
|
||||
@@ -95,7 +95,7 @@ class AopUtilsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testInvokeJoinpointUsingReflection() throws Throwable {
|
||||
void invokeJoinpointUsingReflection() throws Throwable {
|
||||
String name = "foo";
|
||||
TestBean testBean = new TestBean(name);
|
||||
Method method = ReflectionUtils.findMethod(TestBean.class, "getName");
|
||||
|
||||
+5
-5
@@ -58,14 +58,14 @@ class ComposablePointcutTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testMatchAll() throws NoSuchMethodException {
|
||||
void matchAll() throws NoSuchMethodException {
|
||||
Pointcut pc = new ComposablePointcut();
|
||||
assertThat(pc.getClassFilter().matches(Object.class)).isTrue();
|
||||
assertThat(pc.getMethodMatcher().matches(Object.class.getMethod("hashCode"), Exception.class)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFilterByClass() {
|
||||
void filterByClass() {
|
||||
ComposablePointcut pc = new ComposablePointcut();
|
||||
|
||||
assertThat(pc.getClassFilter().matches(Object.class)).isTrue();
|
||||
@@ -85,7 +85,7 @@ class ComposablePointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUnionMethodMatcher() {
|
||||
void unionMethodMatcher() {
|
||||
// Matches the getAge() method in any class
|
||||
ComposablePointcut pc = new ComposablePointcut(ClassFilter.TRUE, GET_AGE_METHOD_MATCHER);
|
||||
assertThat(Pointcuts.matches(pc, PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.class)).isFalse();
|
||||
@@ -108,7 +108,7 @@ class ComposablePointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIntersectionMethodMatcher() {
|
||||
void intersectionMethodMatcher() {
|
||||
ComposablePointcut pc = new ComposablePointcut();
|
||||
assertThat(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_ABSQUATULATE, TestBean.class)).isTrue();
|
||||
assertThat(pc.getMethodMatcher().matches(PointcutsTests.TEST_BEAN_GET_AGE, TestBean.class)).isTrue();
|
||||
@@ -125,7 +125,7 @@ class ComposablePointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEqualsAndHashCode() {
|
||||
void equalsAndHashCode() {
|
||||
ComposablePointcut pc1 = new ComposablePointcut();
|
||||
ComposablePointcut pc2 = new ComposablePointcut();
|
||||
|
||||
|
||||
+1
-1
@@ -152,7 +152,7 @@ class ControlFlowPointcutTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToString() {
|
||||
void toStringOutput() {
|
||||
String pointcutType = ControlFlowPointcut.class.getName();
|
||||
String componentType = MyComponent.class.getName();
|
||||
|
||||
|
||||
+10
-10
@@ -47,14 +47,14 @@ import static org.mockito.Mockito.mock;
|
||||
class DelegatingIntroductionInterceptorTests {
|
||||
|
||||
@Test
|
||||
void testNullTarget() {
|
||||
void nullTarget() {
|
||||
// Shouldn't accept null target
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new DelegatingIntroductionInterceptor(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIntroductionInterceptorWithDelegation() {
|
||||
void introductionInterceptorWithDelegation() {
|
||||
TestBean raw = new TestBean();
|
||||
assertThat(raw).isNotInstanceOf(TimeStamped.class);
|
||||
ProxyFactory factory = new ProxyFactory(raw);
|
||||
@@ -70,7 +70,7 @@ class DelegatingIntroductionInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIntroductionInterceptorWithInterfaceHierarchy() {
|
||||
void introductionInterceptorWithInterfaceHierarchy() {
|
||||
TestBean raw = new TestBean();
|
||||
assertThat(raw).isNotInstanceOf(SubTimeStamped.class);
|
||||
ProxyFactory factory = new ProxyFactory(raw);
|
||||
@@ -86,7 +86,7 @@ class DelegatingIntroductionInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIntroductionInterceptorWithSuperInterface() {
|
||||
void introductionInterceptorWithSuperInterface() {
|
||||
TestBean raw = new TestBean();
|
||||
assertThat(raw).isNotInstanceOf(TimeStamped.class);
|
||||
ProxyFactory factory = new ProxyFactory(raw);
|
||||
@@ -103,7 +103,7 @@ class DelegatingIntroductionInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testAutomaticInterfaceRecognitionInDelegate() throws Exception {
|
||||
void automaticInterfaceRecognitionInDelegate() throws Exception {
|
||||
final long t = 1001L;
|
||||
class Tester implements TimeStamped, ITester {
|
||||
@Override
|
||||
@@ -133,7 +133,7 @@ class DelegatingIntroductionInterceptorTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testAutomaticInterfaceRecognitionInSubclass() throws Exception {
|
||||
void automaticInterfaceRecognitionInSubclass() throws Exception {
|
||||
final long t = 1001L;
|
||||
@SuppressWarnings("serial")
|
||||
class TestII extends DelegatingIntroductionInterceptor implements TimeStamped, ITester {
|
||||
@@ -178,7 +178,7 @@ class DelegatingIntroductionInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testIntroductionInterceptorDoesNotReplaceToString() {
|
||||
void introductionInterceptorDoesNotReplaceToString() {
|
||||
TestBean raw = new TestBean();
|
||||
assertThat(raw).isNotInstanceOf(TimeStamped.class);
|
||||
ProxyFactory factory = new ProxyFactory(raw);
|
||||
@@ -199,7 +199,7 @@ class DelegatingIntroductionInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDelegateReturnsThisIsMassagedToReturnProxy() {
|
||||
void delegateReturnsThisIsMassagedToReturnProxy() {
|
||||
NestedTestBean target = new NestedTestBean();
|
||||
String company = "Interface21";
|
||||
target.setCompany(company);
|
||||
@@ -220,7 +220,7 @@ class DelegatingIntroductionInterceptorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSerializableDelegatingIntroductionInterceptorSerializable() throws Exception {
|
||||
void serializableDelegatingIntroductionInterceptorSerializable() throws Exception {
|
||||
SerializablePerson serializableTarget = new SerializablePerson();
|
||||
String name = "Tony";
|
||||
serializableTarget.setName("Tony");
|
||||
@@ -245,7 +245,7 @@ class DelegatingIntroductionInterceptorTests {
|
||||
|
||||
// Test when target implements the interface: should get interceptor by preference.
|
||||
@Test
|
||||
void testIntroductionMasksTargetImplementation() {
|
||||
void introductionMasksTargetImplementation() {
|
||||
final long t = 1001L;
|
||||
@SuppressWarnings("serial")
|
||||
class TestII extends DelegatingIntroductionInterceptor implements TimeStamped {
|
||||
|
||||
@@ -56,19 +56,19 @@ class MethodMatchersTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testDefaultMatchesAll() {
|
||||
void defaultMatchesAll() {
|
||||
MethodMatcher defaultMm = MethodMatcher.TRUE;
|
||||
assertThat(defaultMm.matches(EXCEPTION_GETMESSAGE, Exception.class)).isTrue();
|
||||
assertThat(defaultMm.matches(ITESTBEAN_SETAGE, TestBean.class)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodMatcherTrueSerializable() throws Exception {
|
||||
void methodMatcherTrueSerializable() throws Exception {
|
||||
assertThat(MethodMatcher.TRUE).isSameAs(SerializationTestUtils.serializeAndDeserialize(MethodMatcher.TRUE));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSingle() {
|
||||
void single() {
|
||||
MethodMatcher defaultMm = MethodMatcher.TRUE;
|
||||
assertThat(defaultMm.matches(EXCEPTION_GETMESSAGE, Exception.class)).isTrue();
|
||||
assertThat(defaultMm.matches(ITESTBEAN_SETAGE, TestBean.class)).isTrue();
|
||||
@@ -80,7 +80,7 @@ class MethodMatchersTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testDynamicAndStaticMethodMatcherIntersection() {
|
||||
void dynamicAndStaticMethodMatcherIntersection() {
|
||||
MethodMatcher mm1 = MethodMatcher.TRUE;
|
||||
MethodMatcher mm2 = new TestDynamicMethodMatcherWhichMatches();
|
||||
MethodMatcher intersection = MethodMatchers.intersection(mm1, mm2);
|
||||
@@ -95,7 +95,7 @@ class MethodMatchersTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStaticMethodMatcherUnion() {
|
||||
void staticMethodMatcherUnion() {
|
||||
MethodMatcher getterMatcher = new StartsWithMatcher("get");
|
||||
MethodMatcher setterMatcher = new StartsWithMatcher("set");
|
||||
MethodMatcher union = MethodMatchers.union(getterMatcher, setterMatcher);
|
||||
@@ -107,7 +107,7 @@ class MethodMatchersTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUnionEquals() {
|
||||
void unionEquals() {
|
||||
MethodMatcher first = MethodMatchers.union(MethodMatcher.TRUE, MethodMatcher.TRUE);
|
||||
MethodMatcher second = new ComposablePointcut(MethodMatcher.TRUE).union(new ComposablePointcut(MethodMatcher.TRUE)).getMethodMatcher();
|
||||
assertThat(first).isEqualTo(second);
|
||||
|
||||
@@ -120,7 +120,7 @@ class PointcutsTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testTrue() {
|
||||
void trueCase() {
|
||||
assertThat(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_SET_AGE, TestBean.class, 6)).isTrue();
|
||||
assertThat(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_GET_AGE, TestBean.class)).isTrue();
|
||||
assertThat(Pointcuts.matches(Pointcut.TRUE, TEST_BEAN_ABSQUATULATE, TestBean.class)).isTrue();
|
||||
@@ -130,7 +130,7 @@ class PointcutsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMatches() {
|
||||
void matches() {
|
||||
assertThat(Pointcuts.matches(allClassSetterPointcut, TEST_BEAN_SET_AGE, TestBean.class, 6)).isTrue();
|
||||
assertThat(Pointcuts.matches(allClassSetterPointcut, TEST_BEAN_GET_AGE, TestBean.class)).isFalse();
|
||||
assertThat(Pointcuts.matches(allClassSetterPointcut, TEST_BEAN_ABSQUATULATE, TestBean.class)).isFalse();
|
||||
@@ -143,7 +143,7 @@ class PointcutsTests {
|
||||
* Should match all setters and getters on any class
|
||||
*/
|
||||
@Test
|
||||
void testUnionOfSettersAndGetters() {
|
||||
void unionOfSettersAndGetters() {
|
||||
Pointcut union = Pointcuts.union(allClassGetterPointcut, allClassSetterPointcut);
|
||||
assertThat(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, 6)).isTrue();
|
||||
assertThat(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class)).isTrue();
|
||||
@@ -151,7 +151,7 @@ class PointcutsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUnionOfSpecificGetters() {
|
||||
void unionOfSpecificGetters() {
|
||||
Pointcut union = Pointcuts.union(allClassGetAgePointcut, allClassGetNamePointcut);
|
||||
assertThat(Pointcuts.matches(union, TEST_BEAN_SET_AGE, TestBean.class, 6)).isFalse();
|
||||
assertThat(Pointcuts.matches(union, TEST_BEAN_GET_AGE, TestBean.class)).isTrue();
|
||||
@@ -175,7 +175,7 @@ class PointcutsTests {
|
||||
* Second one matches all getters in the MyTestBean class. TestBean getters shouldn't pass.
|
||||
*/
|
||||
@Test
|
||||
void testUnionOfAllSettersAndSubclassSetters() {
|
||||
void unionOfAllSettersAndSubclassSetters() {
|
||||
assertThat(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_SET_AGE, TestBean.class, 6)).isFalse();
|
||||
assertThat(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_SET_AGE, MyTestBean.class, 6)).isTrue();
|
||||
assertThat(Pointcuts.matches(myTestBeanSetterPointcut, TEST_BEAN_GET_AGE, TestBean.class)).isFalse();
|
||||
@@ -193,7 +193,7 @@ class PointcutsTests {
|
||||
* it's the union of allClassGetAge and subclass getters
|
||||
*/
|
||||
@Test
|
||||
void testIntersectionOfSpecificGettersAndSubclassGetters() {
|
||||
void intersectionOfSpecificGettersAndSubclassGetters() {
|
||||
assertThat(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_AGE, TestBean.class)).isTrue();
|
||||
assertThat(Pointcuts.matches(allClassGetAgePointcut, TEST_BEAN_GET_AGE, MyTestBean.class)).isTrue();
|
||||
assertThat(Pointcuts.matches(myTestBeanGetterPointcut, TEST_BEAN_GET_NAME, TestBean.class)).isFalse();
|
||||
@@ -239,7 +239,7 @@ class PointcutsTests {
|
||||
* The intersection of these two pointcuts leaves nothing.
|
||||
*/
|
||||
@Test
|
||||
void testSimpleIntersection() {
|
||||
void simpleIntersection() {
|
||||
Pointcut intersection = Pointcuts.intersection(allClassGetterPointcut, allClassSetterPointcut);
|
||||
assertThat(Pointcuts.matches(intersection, TEST_BEAN_SET_AGE, TestBean.class, 6)).isFalse();
|
||||
assertThat(Pointcuts.matches(intersection, TEST_BEAN_GET_AGE, TestBean.class)).isFalse();
|
||||
|
||||
+3
-3
@@ -43,7 +43,7 @@ class RegexpMethodPointcutAdvisorIntegrationTests {
|
||||
|
||||
|
||||
@Test
|
||||
void testSinglePattern() throws Throwable {
|
||||
void singlePattern() throws Throwable {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
|
||||
ITestBean advised = (ITestBean) bf.getBean("settersAdvised");
|
||||
@@ -62,7 +62,7 @@ class RegexpMethodPointcutAdvisorIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMultiplePatterns() throws Throwable {
|
||||
void multiplePatterns() throws Throwable {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
|
||||
// This is a CGLIB proxy, so we can proxy it to the target class
|
||||
@@ -86,7 +86,7 @@ class RegexpMethodPointcutAdvisorIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSerialization() throws Throwable {
|
||||
void serialization() throws Throwable {
|
||||
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
|
||||
// This is a CGLIB proxy, so we can proxy it to the target class
|
||||
|
||||
@@ -44,19 +44,19 @@ class RootClassFilterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEquals() {
|
||||
void equals() {
|
||||
assertThat(filter1).isEqualTo(filter2);
|
||||
assertThat(filter1).isNotEqualTo(filter3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHashCode() {
|
||||
void hashCodeBehavior() {
|
||||
assertThat(filter1.hashCode()).isEqualTo(filter2.hashCode());
|
||||
assertThat(filter1.hashCode()).isNotEqualTo(filter3.hashCode());
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToString() {
|
||||
void toStringOutput() {
|
||||
assertThat(filter1.toString()).isEqualTo("org.springframework.aop.support.RootClassFilter: java.lang.Exception");
|
||||
assertThat(filter1.toString()).isEqualTo(filter2.toString());
|
||||
}
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ class CommonsPool2TargetSourceProxyTests {
|
||||
qualifiedResource(CommonsPool2TargetSourceProxyTests.class, "context.xml");
|
||||
|
||||
@Test
|
||||
void testProxy() {
|
||||
void proxy() {
|
||||
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
|
||||
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
|
||||
reader.loadBeanDefinitions(CONTEXT);
|
||||
|
||||
+7
-7
@@ -48,7 +48,7 @@ class HotSwappableTargetSourceTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
|
||||
qualifiedResource(HotSwappableTargetSourceTests.class, "context.xml"));
|
||||
@@ -58,7 +58,7 @@ class HotSwappableTargetSourceTests {
|
||||
* We must simulate container shutdown, which should clear threads.
|
||||
*/
|
||||
@AfterEach
|
||||
public void close() {
|
||||
void close() {
|
||||
// Will call pool.close()
|
||||
this.beanFactory.destroySingletons();
|
||||
}
|
||||
@@ -68,7 +68,7 @@ class HotSwappableTargetSourceTests {
|
||||
* Check it works like a normal invoker
|
||||
*/
|
||||
@Test
|
||||
void testBasicFunctionality() {
|
||||
void basicFunctionality() {
|
||||
SideEffectBean proxied = (SideEffectBean) beanFactory.getBean("swappable");
|
||||
assertThat(proxied.getCount()).isEqualTo(INITIAL_COUNT);
|
||||
proxied.doWork();
|
||||
@@ -80,7 +80,7 @@ class HotSwappableTargetSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testValidSwaps() {
|
||||
void validSwaps() {
|
||||
SideEffectBean target1 = (SideEffectBean) beanFactory.getBean("target1");
|
||||
SideEffectBean target2 = (SideEffectBean) beanFactory.getBean("target2");
|
||||
|
||||
@@ -107,17 +107,17 @@ class HotSwappableTargetSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRejectsSwapToNull() {
|
||||
void rejectsSwapToNull() {
|
||||
HotSwappableTargetSource swapper = (HotSwappableTargetSource) beanFactory.getBean("swapper");
|
||||
assertThatIllegalArgumentException().as("Shouldn't be able to swap to invalid value").isThrownBy(() ->
|
||||
swapper.swap(null))
|
||||
.withMessageContaining("null");
|
||||
// It shouldn't be corrupted, it should still work
|
||||
testBasicFunctionality();
|
||||
basicFunctionality();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSerialization() throws Exception {
|
||||
void serialization() throws Exception {
|
||||
SerializablePerson sp1 = new SerializablePerson();
|
||||
sp1.setName("Tony");
|
||||
SerializablePerson sp2 = new SerializablePerson();
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class LazyCreationTargetSourceTests {
|
||||
|
||||
@Test
|
||||
void testCreateLazy() {
|
||||
void createLazy() {
|
||||
TargetSource targetSource = new AbstractLazyCreationTargetSource() {
|
||||
@Override
|
||||
protected Object createObject() {
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class PrototypeBasedTargetSourceTests {
|
||||
|
||||
@Test
|
||||
void testSerializability() throws Exception {
|
||||
void serializability() throws Exception {
|
||||
MutablePropertyValues tsPvs = new MutablePropertyValues();
|
||||
tsPvs.add("targetBeanName", "person");
|
||||
RootBeanDefinition tsBd = new RootBeanDefinition(TestTargetSource.class);
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ class PrototypeTargetSourceTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
|
||||
qualifiedResource(PrototypeTargetSourceTests.class, "context.xml"));
|
||||
@@ -52,7 +52,7 @@ class PrototypeTargetSourceTests {
|
||||
* With the singleton, there will be change.
|
||||
*/
|
||||
@Test
|
||||
void testPrototypeAndSingletonBehaveDifferently() {
|
||||
void prototypeAndSingletonBehaveDifferently() {
|
||||
SideEffectBean singleton = (SideEffectBean) beanFactory.getBean("singleton");
|
||||
assertThat(singleton.getCount()).isEqualTo(INITIAL_COUNT);
|
||||
singleton.doWork();
|
||||
|
||||
+6
-6
@@ -40,7 +40,7 @@ class ThreadLocalTargetSourceTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
this.beanFactory = new DefaultListableBeanFactory();
|
||||
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(
|
||||
qualifiedResource(ThreadLocalTargetSourceTests.class, "context.xml"));
|
||||
@@ -60,7 +60,7 @@ class ThreadLocalTargetSourceTests {
|
||||
* with one another.
|
||||
*/
|
||||
@Test
|
||||
void testUseDifferentManagedInstancesInSameThread() {
|
||||
void useDifferentManagedInstancesInSameThread() {
|
||||
SideEffectBean apartment = (SideEffectBean) beanFactory.getBean("apartment");
|
||||
assertThat(apartment.getCount()).isEqualTo(INITIAL_COUNT);
|
||||
apartment.doWork();
|
||||
@@ -72,7 +72,7 @@ class ThreadLocalTargetSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testReuseInSameThread() {
|
||||
void reuseInSameThread() {
|
||||
SideEffectBean apartment = (SideEffectBean) beanFactory.getBean("apartment");
|
||||
assertThat(apartment.getCount()).isEqualTo(INITIAL_COUNT);
|
||||
apartment.doWork();
|
||||
@@ -86,7 +86,7 @@ class ThreadLocalTargetSourceTests {
|
||||
* Relies on introduction.
|
||||
*/
|
||||
@Test
|
||||
void testCanGetStatsViaMixin() {
|
||||
void canGetStatsViaMixin() {
|
||||
ThreadLocalTargetSourceStats stats = (ThreadLocalTargetSourceStats) beanFactory.getBean("apartment");
|
||||
// +1 because creating target for stats call counts
|
||||
assertThat(stats.getInvocationCount()).isEqualTo(1);
|
||||
@@ -104,7 +104,7 @@ class ThreadLocalTargetSourceTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNewThreadHasOwnInstance() throws InterruptedException {
|
||||
void newThreadHasOwnInstance() throws InterruptedException {
|
||||
SideEffectBean apartment = (SideEffectBean) beanFactory.getBean("apartment");
|
||||
assertThat(apartment.getCount()).isEqualTo(INITIAL_COUNT);
|
||||
apartment.doWork();
|
||||
@@ -144,7 +144,7 @@ class ThreadLocalTargetSourceTests {
|
||||
* Test for SPR-1442. Destroyed target should re-associated with thread and not throw NPE.
|
||||
*/
|
||||
@Test
|
||||
void testReuseDestroyedTarget() {
|
||||
void reuseDestroyedTarget() {
|
||||
ThreadLocalTargetSource source = (ThreadLocalTargetSource)this.beanFactory.getBean("threadLocalTs");
|
||||
|
||||
// try first time
|
||||
|
||||
+6
-6
@@ -33,7 +33,7 @@ class RefreshableTargetSourceTests {
|
||||
* Test what happens when checking for refresh but not refreshing object.
|
||||
*/
|
||||
@Test
|
||||
void testRefreshCheckWithNonRefresh() throws Exception {
|
||||
void refreshCheckWithNonRefresh() throws Exception {
|
||||
CountingRefreshableTargetSource ts = new CountingRefreshableTargetSource();
|
||||
ts.setRefreshCheckDelay(0);
|
||||
|
||||
@@ -49,7 +49,7 @@ class RefreshableTargetSourceTests {
|
||||
* Test what happens when checking for refresh and refresh occurs.
|
||||
*/
|
||||
@Test
|
||||
void testRefreshCheckWithRefresh() throws Exception {
|
||||
void refreshCheckWithRefresh() throws Exception {
|
||||
CountingRefreshableTargetSource ts = new CountingRefreshableTargetSource(true);
|
||||
ts.setRefreshCheckDelay(0);
|
||||
|
||||
@@ -65,7 +65,7 @@ class RefreshableTargetSourceTests {
|
||||
* Test what happens when no refresh occurs.
|
||||
*/
|
||||
@Test
|
||||
void testWithNoRefreshCheck() {
|
||||
void withNoRefreshCheck() {
|
||||
CountingRefreshableTargetSource ts = new CountingRefreshableTargetSource(true);
|
||||
ts.setRefreshCheckDelay(-1);
|
||||
|
||||
@@ -78,7 +78,7 @@ class RefreshableTargetSourceTests {
|
||||
|
||||
@Test
|
||||
@EnabledForTestGroups(LONG_RUNNING)
|
||||
public void testRefreshOverTime() throws Exception {
|
||||
void refreshOverTime() throws Exception {
|
||||
CountingRefreshableTargetSource ts = new CountingRefreshableTargetSource(true);
|
||||
ts.setRefreshCheckDelay(100);
|
||||
|
||||
@@ -95,7 +95,7 @@ class RefreshableTargetSourceTests {
|
||||
|
||||
Object d = ts.getTarget();
|
||||
assertThat(d).as("D should not be null").isNotNull();
|
||||
assertThat(a.equals(d)).as("A and D should not be equal").isFalse();
|
||||
assertThat(a).as("A and D should not be equal").isNotEqualTo(d);
|
||||
|
||||
Object e = ts.getTarget();
|
||||
assertThat(e).as("D and E should be equal").isEqualTo(d);
|
||||
@@ -103,7 +103,7 @@ class RefreshableTargetSourceTests {
|
||||
Thread.sleep(110);
|
||||
|
||||
Object f = ts.getTarget();
|
||||
assertThat(e.equals(f)).as("E and F should be different").isFalse();
|
||||
assertThat(e).as("E and F should be different").isNotEqualTo(f);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vendored
+64
-63
@@ -49,7 +49,7 @@ import static org.assertj.core.api.Assertions.assertThatIOException;
|
||||
* @author Phillip Webb
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public abstract class AbstractCacheAnnotationTests {
|
||||
abstract class AbstractCacheAnnotationTests {
|
||||
|
||||
protected ConfigurableApplicationContext ctx;
|
||||
|
||||
@@ -67,7 +67,7 @@ public abstract class AbstractCacheAnnotationTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
this.ctx = getApplicationContext();
|
||||
this.cs = ctx.getBean("service", CacheableService.class);
|
||||
this.ccs = ctx.getBean("classService", CacheableService.class);
|
||||
@@ -78,7 +78,7 @@ public abstract class AbstractCacheAnnotationTests {
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void close() {
|
||||
void close() {
|
||||
if (this.ctx != null) {
|
||||
this.ctx.close();
|
||||
}
|
||||
@@ -555,133 +555,134 @@ public abstract class AbstractCacheAnnotationTests {
|
||||
assertThat(secondary.get(key2)).isNull();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCacheable() {
|
||||
void cacheable() {
|
||||
testCacheable(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCacheableNull() {
|
||||
void cacheableNull() {
|
||||
testCacheableNull(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCacheableSync() {
|
||||
void cacheableSync() {
|
||||
testCacheableSync(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCacheableSyncNull() {
|
||||
void cacheableSyncNull() {
|
||||
testCacheableSyncNull(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEvict() {
|
||||
void evict() {
|
||||
testEvict(this.cs, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEvictEarly() {
|
||||
void evictEarly() {
|
||||
testEvictEarly(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEvictWithException() {
|
||||
void evictWithException() {
|
||||
testEvictException(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEvictAll() {
|
||||
void evictAll() {
|
||||
testEvictAll(this.cs, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEvictAllEarly() {
|
||||
void evictAllEarly() {
|
||||
testEvictAllEarly(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEvictWithKey() {
|
||||
void evictWithKey() {
|
||||
testEvictWithKey(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testEvictWithKeyEarly() {
|
||||
void evictWithKeyEarly() {
|
||||
testEvictWithKeyEarly(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConditionalExpression() {
|
||||
void conditionalExpression() {
|
||||
testConditionalExpression(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConditionalExpressionSync() {
|
||||
void conditionalExpressionSync() {
|
||||
testConditionalExpressionSync(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUnlessExpression() {
|
||||
void unlessExpression() {
|
||||
testUnlessExpression(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassCacheUnlessExpression() {
|
||||
void classCacheUnlessExpression() {
|
||||
testUnlessExpression(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testKeyExpression() {
|
||||
void keyExpression() {
|
||||
testKeyExpression(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testVarArgsKey() {
|
||||
void varArgsKey() {
|
||||
testVarArgsKey(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassCacheCacheable() {
|
||||
void classCacheCacheable() {
|
||||
testCacheable(this.ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassCacheEvict() {
|
||||
void classCacheEvict() {
|
||||
testEvict(this.ccs, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassEvictEarly() {
|
||||
void classEvictEarly() {
|
||||
testEvictEarly(this.ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassEvictAll() {
|
||||
void classEvictAll() {
|
||||
testEvictAll(this.ccs, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassEvictWithException() {
|
||||
void classEvictWithException() {
|
||||
testEvictException(this.ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassCacheEvictWithWKey() {
|
||||
void classCacheEvictWithWKey() {
|
||||
testEvictWithKey(this.ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassEvictWithKeyEarly() {
|
||||
void classEvictWithKeyEarly() {
|
||||
testEvictWithKeyEarly(this.ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNullValue() {
|
||||
void nullValue() {
|
||||
testNullValue(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassNullValue() {
|
||||
void classNullValue() {
|
||||
Object key = new Object();
|
||||
assertThat(this.ccs.nullValue(key)).isNull();
|
||||
int nr = this.ccs.nullInvocations().intValue();
|
||||
@@ -694,27 +695,27 @@ public abstract class AbstractCacheAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMethodName() {
|
||||
void methodName() {
|
||||
testMethodName(this.cs, "name");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassMethodName() {
|
||||
void classMethodName() {
|
||||
testMethodName(this.ccs, "nametestCache");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRootVars() {
|
||||
void rootVars() {
|
||||
testRootVars(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassRootVars() {
|
||||
void classRootVars() {
|
||||
testRootVars(this.ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomKeyGenerator() {
|
||||
void customKeyGenerator() {
|
||||
Object param = new Object();
|
||||
Object r1 = this.cs.customKeyGenerator(param);
|
||||
assertThat(this.cs.customKeyGenerator(param)).isSameAs(r1);
|
||||
@@ -725,14 +726,14 @@ public abstract class AbstractCacheAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUnknownCustomKeyGenerator() {
|
||||
void unknownCustomKeyGenerator() {
|
||||
Object param = new Object();
|
||||
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() ->
|
||||
this.cs.unknownCustomKeyGenerator(param));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomCacheManager() {
|
||||
void customCacheManager() {
|
||||
CacheManager customCm = this.ctx.getBean("customCacheManager", CacheManager.class);
|
||||
Object key = new Object();
|
||||
Object r1 = this.cs.customCacheManager(key);
|
||||
@@ -743,139 +744,139 @@ public abstract class AbstractCacheAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUnknownCustomCacheManager() {
|
||||
void unknownCustomCacheManager() {
|
||||
Object param = new Object();
|
||||
assertThatExceptionOfType(NoSuchBeanDefinitionException.class).isThrownBy(() ->
|
||||
this.cs.unknownCustomCacheManager(param));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNullArg() {
|
||||
void nullArg() {
|
||||
testNullArg(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassNullArg() {
|
||||
void classNullArg() {
|
||||
testNullArg(this.ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCheckedException() {
|
||||
void checkedException() {
|
||||
testCheckedThrowable(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassCheckedException() {
|
||||
void classCheckedException() {
|
||||
testCheckedThrowable(this.ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCheckedExceptionSync() {
|
||||
void checkedExceptionSync() {
|
||||
testCheckedThrowableSync(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassCheckedExceptionSync() {
|
||||
void classCheckedExceptionSync() {
|
||||
testCheckedThrowableSync(this.ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUncheckedException() {
|
||||
void uncheckedException() {
|
||||
testUncheckedThrowable(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassUncheckedException() {
|
||||
void classUncheckedException() {
|
||||
testUncheckedThrowable(this.ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUncheckedExceptionSync() {
|
||||
void uncheckedExceptionSync() {
|
||||
testUncheckedThrowableSync(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassUncheckedExceptionSync() {
|
||||
void classUncheckedExceptionSync() {
|
||||
testUncheckedThrowableSync(this.ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUpdate() {
|
||||
void update() {
|
||||
testCacheUpdate(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassUpdate() {
|
||||
void classUpdate() {
|
||||
testCacheUpdate(this.ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConditionalUpdate() {
|
||||
void conditionalUpdate() {
|
||||
testConditionalCacheUpdate(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassConditionalUpdate() {
|
||||
void classConditionalUpdate() {
|
||||
testConditionalCacheUpdate(this.ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMultiCache() {
|
||||
void multiCache() {
|
||||
testMultiCache(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassMultiCache() {
|
||||
void classMultiCache() {
|
||||
testMultiCache(this.ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMultiEvict() {
|
||||
void multiEvict() {
|
||||
testMultiEvict(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassMultiEvict() {
|
||||
void classMultiEvict() {
|
||||
testMultiEvict(this.ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMultiPut() {
|
||||
void multiPut() {
|
||||
testMultiPut(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassMultiPut() {
|
||||
void classMultiPut() {
|
||||
testMultiPut(this.ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testPutRefersToResult() {
|
||||
void putRefersToResult() {
|
||||
testPutRefersToResult(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassPutRefersToResult() {
|
||||
void classPutRefersToResult() {
|
||||
testPutRefersToResult(this.ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMultiCacheAndEvict() {
|
||||
void multiCacheAndEvict() {
|
||||
testMultiCacheAndEvict(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassMultiCacheAndEvict() {
|
||||
void classMultiCacheAndEvict() {
|
||||
testMultiCacheAndEvict(this.ccs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMultiConditionalCacheAndEvict() {
|
||||
void multiConditionalCacheAndEvict() {
|
||||
testMultiConditionalCacheAndEvict(this.cs);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testClassMultiConditionalCacheAndEvict() {
|
||||
void classMultiConditionalCacheAndEvict() {
|
||||
testMultiConditionalCacheAndEvict(this.ccs);
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -37,7 +37,7 @@ class AspectJCacheAnnotationTests extends AbstractCacheAnnotationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testKeyStrategy() {
|
||||
void keyStrategy() {
|
||||
AnnotationCacheAspect aspect = ctx.getBean(
|
||||
"org.springframework.cache.config.internalCacheAspect", AnnotationCacheAspect.class);
|
||||
assertThat(aspect.getKeyGenerator()).isSameAs(ctx.getBean("keyGenerator"));
|
||||
|
||||
+6
-11
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.cache.aspectj;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.AutoClose;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
@@ -51,6 +51,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
class AspectJEnableCachingIsolatedTests {
|
||||
|
||||
@AutoClose
|
||||
private ConfigurableApplicationContext ctx;
|
||||
|
||||
|
||||
@@ -58,23 +59,16 @@ class AspectJEnableCachingIsolatedTests {
|
||||
this.ctx = new AnnotationConfigApplicationContext(config);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void closeContext() {
|
||||
if (this.ctx != null) {
|
||||
this.ctx.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testKeyStrategy() {
|
||||
void keyStrategy() {
|
||||
load(EnableCachingConfig.class);
|
||||
AnnotationCacheAspect aspect = this.ctx.getBean(AnnotationCacheAspect.class);
|
||||
assertThat(aspect.getKeyGenerator()).isSameAs(this.ctx.getBean("keyGenerator", KeyGenerator.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCacheErrorHandler() {
|
||||
void cacheErrorHandler() {
|
||||
load(EnableCachingConfig.class);
|
||||
AnnotationCacheAspect aspect = this.ctx.getBean(AnnotationCacheAspect.class);
|
||||
assertThat(aspect.getErrorHandler()).isSameAs(this.ctx.getBean("errorHandler", CacheErrorHandler.class));
|
||||
@@ -129,7 +123,7 @@ class AspectJEnableCachingIsolatedTests {
|
||||
|
||||
@Test
|
||||
@Disabled("AspectJ has some sort of caching that makes this one fail")
|
||||
public void emptyConfigSupport() {
|
||||
void emptyConfigSupport() {
|
||||
load(EmptyConfigSupportConfig.class);
|
||||
AnnotationCacheAspect aspect = this.ctx.getBean(AnnotationCacheAspect.class);
|
||||
assertThat(aspect.getCacheResolver()).isNotNull();
|
||||
@@ -284,4 +278,5 @@ class AspectJEnableCachingIsolatedTests {
|
||||
return new NamedCacheResolver(cacheManager(), "foo");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -46,7 +46,7 @@ import static org.springframework.core.testfixture.TestGroup.LONG_RUNNING;
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@EnabledForTestGroups(LONG_RUNNING)
|
||||
public class AnnotationAsyncExecutionAspectTests {
|
||||
class AnnotationAsyncExecutionAspectTests {
|
||||
|
||||
private static final long WAIT_TIME = 1000; //milliseconds
|
||||
|
||||
@@ -56,7 +56,7 @@ public class AnnotationAsyncExecutionAspectTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
void setUp() {
|
||||
executor = new CountingExecutor();
|
||||
AnnotationAsyncExecutionAspect.aspectOf().setExecutor(executor);
|
||||
}
|
||||
|
||||
+4
-4
@@ -37,13 +37,13 @@ class AnnotationDrivenBeanDefinitionParserTests {
|
||||
private ConfigurableApplicationContext context;
|
||||
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
void setup() {
|
||||
this.context = new ClassPathXmlApplicationContext(
|
||||
"annotationDrivenContext.xml", AnnotationDrivenBeanDefinitionParserTests.class);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void after() {
|
||||
void after() {
|
||||
if (this.context != null) {
|
||||
this.context.close();
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class AnnotationDrivenBeanDefinitionParserTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void asyncPostProcessorExecutorReference() {
|
||||
void asyncPostProcessorExecutorReference() {
|
||||
Object executor = context.getBean("testExecutor");
|
||||
Object aspect = context.getBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME);
|
||||
assertThat(((Supplier) new DirectFieldAccessor(aspect).getPropertyValue("defaultExecutor")).get()).isSameAs(executor);
|
||||
@@ -64,7 +64,7 @@ class AnnotationDrivenBeanDefinitionParserTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void asyncPostProcessorExceptionHandlerReference() {
|
||||
void asyncPostProcessorExceptionHandlerReference() {
|
||||
Object exceptionHandler = context.getBean("testExceptionHandler");
|
||||
Object aspect = context.getBean(TaskManagementConfigUtils.ASYNC_EXECUTION_ASPECT_BEAN_NAME);
|
||||
assertThat(((Supplier) new DirectFieldAccessor(aspect).getPropertyValue("exceptionHandler")).get()).isSameAs(exceptionHandler);
|
||||
|
||||
+2
-2
@@ -36,13 +36,13 @@ import static org.assertj.core.api.Assertions.assertThatIOException;
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
@SpringJUnitConfig(JtaTransactionAspectsTests.Config.class)
|
||||
public class JtaTransactionAspectsTests {
|
||||
class JtaTransactionAspectsTests {
|
||||
|
||||
@Autowired
|
||||
private CallCountingTransactionManager txManager;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
void setUp() {
|
||||
this.txManager.clear();
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -50,13 +50,13 @@ class TransactionAspectTests {
|
||||
|
||||
|
||||
@BeforeEach
|
||||
public void initContext() {
|
||||
void initContext() {
|
||||
AnnotationTransactionAspect.aspectOf().setTransactionManager(txManager);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
void testCommitOnAnnotatedClass() throws Throwable {
|
||||
void commitOnAnnotatedClass() throws Throwable {
|
||||
txManager.clear();
|
||||
assertThat(txManager.begun).isEqualTo(0);
|
||||
annotationOnlyOnClassWithNoInterface.echo(null);
|
||||
|
||||
+11
-10
@@ -25,6 +25,7 @@ import org.jspecify.annotations.Nullable;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanRegistrar;
|
||||
import org.springframework.beans.factory.BeanRegistry;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
@@ -81,6 +82,12 @@ public class BeanRegistryAdapter implements BeanRegistry {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void register(BeanRegistrar registrar) {
|
||||
Assert.notNull(registrar, "BeanRegistrar must not be null");
|
||||
registrar.register(this, this.environment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerAlias(String name, String alias) {
|
||||
this.beanRegistry.registerAlias(name, alias);
|
||||
@@ -169,12 +176,6 @@ public class BeanRegistryAdapter implements BeanRegistry {
|
||||
this.beanRegistry.registerBeanDefinition(name, beanDefinition);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(BeanRegistrar registrar) {
|
||||
Assert.notNull(registrar, "'registrar' must not be null");
|
||||
registrar.register(this, this.environment);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@link RootBeanDefinition} subclass for {@code #registerBean} based
|
||||
@@ -218,9 +219,9 @@ public class BeanRegistryAdapter implements BeanRegistry {
|
||||
|
||||
private final RootBeanDefinition beanDefinition;
|
||||
|
||||
private final ListableBeanFactory beanFactory;
|
||||
private final BeanFactory beanFactory;
|
||||
|
||||
public BeanSpecAdapter(RootBeanDefinition beanDefinition, ListableBeanFactory beanFactory) {
|
||||
public BeanSpecAdapter(RootBeanDefinition beanDefinition, BeanFactory beanFactory) {
|
||||
this.beanDefinition = beanDefinition;
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
@@ -296,9 +297,9 @@ public class BeanRegistryAdapter implements BeanRegistry {
|
||||
|
||||
private static class SupplierContextAdapter implements SupplierContext {
|
||||
|
||||
private final ListableBeanFactory beanFactory;
|
||||
private final BeanFactory beanFactory;
|
||||
|
||||
public SupplierContextAdapter(ListableBeanFactory beanFactory) {
|
||||
public SupplierContextAdapter(BeanFactory beanFactory) {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -211,7 +211,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader {
|
||||
/**
|
||||
* Specify which {@link org.springframework.beans.factory.parsing.ProblemReporter} to use.
|
||||
* <p>The default implementation is {@link org.springframework.beans.factory.parsing.FailFastProblemReporter}
|
||||
* which exhibits fail fast behaviour. External tools can provide an alternative implementation
|
||||
* which exhibits fail fast behavior. External tools can provide an alternative implementation
|
||||
* that collates errors and warnings for display in the tool UI.
|
||||
*/
|
||||
public void setProblemReporter(@Nullable ProblemReporter problemReporter) {
|
||||
|
||||
+14
-14
@@ -375,7 +375,7 @@ abstract class AbstractPropertyAccessorTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testErrorMessageOfNestedProperty() {
|
||||
void errorMessageOfNestedProperty() {
|
||||
ITestBean target = new TestBean();
|
||||
ITestBean child = new DifferentTestBean();
|
||||
child.setName("test");
|
||||
@@ -599,11 +599,11 @@ abstract class AbstractPropertyAccessorTests {
|
||||
AbstractPropertyAccessor accessor = createAccessor(target);
|
||||
|
||||
accessor.setPropertyValue("bool2", "true");
|
||||
assertThat(Boolean.TRUE.equals(accessor.getPropertyValue("bool2"))).as("Correct bool2 value").isTrue();
|
||||
assertThat(accessor.getPropertyValue("bool2")).as("Correct bool2 value").isEqualTo(Boolean.TRUE);
|
||||
assertThat(target.getBool2()).as("Correct bool2 value").isTrue();
|
||||
|
||||
accessor.setPropertyValue("bool2", "false");
|
||||
assertThat(Boolean.FALSE.equals(accessor.getPropertyValue("bool2"))).as("Correct bool2 value").isTrue();
|
||||
assertThat(accessor.getPropertyValue("bool2")).as("Correct bool2 value").isEqualTo(Boolean.FALSE);
|
||||
assertThat(target.getBool2()).as("Correct bool2 value").isFalse();
|
||||
}
|
||||
|
||||
@@ -628,7 +628,7 @@ abstract class AbstractPropertyAccessorTests {
|
||||
assertThat(new BigInteger("3")).as("Correct bigInteger value").isEqualTo(target.getBigInteger());
|
||||
assertThat(Float.valueOf("8.1")).as("Correct float2 value").isEqualTo(accessor.getPropertyValue("float2"));
|
||||
assertThat(Float.valueOf("8.1")).as("Correct float2 value").isEqualTo(target.getFloat2());
|
||||
assertThat(Double.valueOf("6.1").equals(accessor.getPropertyValue("double2"))).as("Correct double2 value").isTrue();
|
||||
assertThat(Double.valueOf("6.1")).as("Correct double2 value").isEqualTo(accessor.getPropertyValue("double2"));
|
||||
assertThat(Double.valueOf("6.1")).as("Correct double2 value").isEqualTo(target.getDouble2());
|
||||
assertThat(new BigDecimal("4.0")).as("Correct bigDecimal value").isEqualTo(accessor.getPropertyValue("bigDecimal"));
|
||||
assertThat(new BigDecimal("4.0")).as("Correct bigDecimal value").isEqualTo(target.getBigDecimal());
|
||||
@@ -651,7 +651,7 @@ abstract class AbstractPropertyAccessorTests {
|
||||
assertThat(Integer.valueOf("8")).as("Correct int2 value").isEqualTo(target.getInt2());
|
||||
assertThat(Long.valueOf("6")).as("Correct long2 value").isEqualTo(accessor.getPropertyValue("long2"));
|
||||
assertThat(Long.valueOf("6")).as("Correct long2 value").isEqualTo(target.getLong2());
|
||||
assertThat(new BigInteger("3").equals(accessor.getPropertyValue("bigInteger"))).as("Correct bigInteger value").isTrue();
|
||||
assertThat(new BigInteger("3")).as("Correct bigInteger value").isEqualTo(accessor.getPropertyValue("bigInteger"));
|
||||
assertThat(new BigInteger("3")).as("Correct bigInteger value").isEqualTo(target.getBigInteger());
|
||||
assertThat(Float.valueOf("8.1")).as("Correct float2 value").isEqualTo(accessor.getPropertyValue("float2"));
|
||||
assertThat(Float.valueOf("8.1")).as("Correct float2 value").isEqualTo(target.getFloat2());
|
||||
@@ -1495,15 +1495,15 @@ abstract class AbstractPropertyAccessorTests {
|
||||
accessor.setPropertyValues(pvs);
|
||||
assertThat(target.getArray()[0]).isEqualTo(tb5);
|
||||
assertThat(target.getArray()[1]).isEqualTo(tb4);
|
||||
assertThat((target.getList().get(0))).isEqualTo(tb3);
|
||||
assertThat((target.getList().get(1))).isEqualTo(tb2);
|
||||
assertThat((target.getList().get(2))).isEqualTo(tb0);
|
||||
assertThat((target.getList().get(3))).isNull();
|
||||
assertThat((target.getList().get(4))).isEqualTo(tb1);
|
||||
assertThat((target.getMap().get("key1"))).isEqualTo(tb1);
|
||||
assertThat((target.getMap().get("key2"))).isEqualTo(tb0);
|
||||
assertThat((target.getMap().get("key5"))).isEqualTo(tb4);
|
||||
assertThat((target.getMap().get("key9"))).isEqualTo(tb5);
|
||||
assertThat(target.getList().get(0)).isEqualTo(tb3);
|
||||
assertThat(target.getList().get(1)).isEqualTo(tb2);
|
||||
assertThat(target.getList().get(2)).isEqualTo(tb0);
|
||||
assertThat(target.getList().get(3)).isNull();
|
||||
assertThat(target.getList().get(4)).isEqualTo(tb1);
|
||||
assertThat(target.getMap().get("key1")).isEqualTo(tb1);
|
||||
assertThat(target.getMap().get("key2")).isEqualTo(tb0);
|
||||
assertThat(target.getMap().get("key5")).isEqualTo(tb4);
|
||||
assertThat(target.getMap().get("key9")).isEqualTo(tb5);
|
||||
assertThat(accessor.getPropertyValue("array[0]")).isEqualTo(tb5);
|
||||
assertThat(accessor.getPropertyValue("array[1]")).isEqualTo(tb4);
|
||||
assertThat(accessor.getPropertyValue("list[0]")).isEqualTo(tb3);
|
||||
|
||||
@@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
class BeanWrapperEnumTests {
|
||||
|
||||
@Test
|
||||
void testCustomEnum() {
|
||||
void customEnum() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("customEnum", "VALUE_1");
|
||||
@@ -42,7 +42,7 @@ class BeanWrapperEnumTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomEnumWithNull() {
|
||||
void customEnumWithNull() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("customEnum", null);
|
||||
@@ -50,7 +50,7 @@ class BeanWrapperEnumTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomEnumWithEmptyString() {
|
||||
void customEnumWithEmptyString() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("customEnum", "");
|
||||
@@ -58,7 +58,7 @@ class BeanWrapperEnumTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomEnumArrayWithSingleValue() {
|
||||
void customEnumArrayWithSingleValue() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("customEnumArray", "VALUE_1");
|
||||
@@ -67,7 +67,7 @@ class BeanWrapperEnumTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomEnumArrayWithMultipleValues() {
|
||||
void customEnumArrayWithMultipleValues() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("customEnumArray", new String[] {"VALUE_1", "VALUE_2"});
|
||||
@@ -77,7 +77,7 @@ class BeanWrapperEnumTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomEnumArrayWithMultipleValuesAsCsv() {
|
||||
void customEnumArrayWithMultipleValuesAsCsv() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("customEnumArray", "VALUE_1,VALUE_2");
|
||||
@@ -87,7 +87,7 @@ class BeanWrapperEnumTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomEnumSetWithSingleValue() {
|
||||
void customEnumSetWithSingleValue() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("customEnumSet", "VALUE_1");
|
||||
@@ -96,7 +96,7 @@ class BeanWrapperEnumTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomEnumSetWithMultipleValues() {
|
||||
void customEnumSetWithMultipleValues() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("customEnumSet", new String[] {"VALUE_1", "VALUE_2"});
|
||||
@@ -106,7 +106,7 @@ class BeanWrapperEnumTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomEnumSetWithMultipleValuesAsCsv() {
|
||||
void customEnumSetWithMultipleValuesAsCsv() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("customEnumSet", "VALUE_1,VALUE_2");
|
||||
@@ -116,7 +116,7 @@ class BeanWrapperEnumTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCustomEnumSetWithGetterSetterMismatch() {
|
||||
void customEnumSetWithGetterSetterMismatch() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("customEnumSetMismatch", new String[] {"VALUE_1", "VALUE_2"});
|
||||
@@ -126,7 +126,7 @@ class BeanWrapperEnumTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStandardEnumSetWithMultipleValues() {
|
||||
void standardEnumSetWithMultipleValues() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setConversionService(new DefaultConversionService());
|
||||
@@ -138,7 +138,7 @@ class BeanWrapperEnumTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStandardEnumSetWithAutoGrowing() {
|
||||
void standardEnumSetWithAutoGrowing() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setAutoGrowNestedPaths(true);
|
||||
@@ -148,7 +148,7 @@ class BeanWrapperEnumTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStandardEnumMapWithMultipleValues() {
|
||||
void standardEnumMapWithMultipleValues() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setConversionService(new DefaultConversionService());
|
||||
@@ -163,7 +163,7 @@ class BeanWrapperEnumTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testStandardEnumMapWithAutoGrowing() {
|
||||
void standardEnumMapWithAutoGrowing() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setAutoGrowNestedPaths(true);
|
||||
@@ -174,7 +174,7 @@ class BeanWrapperEnumTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNonPublicEnum() {
|
||||
void nonPublicEnum() {
|
||||
NonPublicEnumHolder holder = new NonPublicEnumHolder();
|
||||
BeanWrapper bw = new BeanWrapperImpl(holder);
|
||||
bw.setPropertyValue("nonPublicEnum", "VALUE_1");
|
||||
|
||||
+42
-42
@@ -52,7 +52,7 @@ import static org.assertj.core.api.InstanceOfAssertFactories.LIST;
|
||||
class BeanWrapperGenericsTests {
|
||||
|
||||
@Test
|
||||
void testGenericSet() {
|
||||
void genericSet() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
Set<String> input = new HashSet<>();
|
||||
@@ -64,7 +64,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericLowerBoundedSet() {
|
||||
void genericLowerBoundedSet() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, true));
|
||||
@@ -77,7 +77,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericSetWithConversionFailure() {
|
||||
void genericSetWithConversionFailure() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
Set<TestBean> input = new HashSet<>();
|
||||
@@ -88,7 +88,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericList() throws Exception {
|
||||
void genericList() throws Exception {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
List<String> input = new ArrayList<>();
|
||||
@@ -100,7 +100,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericListElement() throws Exception {
|
||||
void genericListElement() throws Exception {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
gb.setResourceList(new ArrayList<>());
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
@@ -109,7 +109,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericMap() {
|
||||
void genericMap() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
Map<String, String> input = new HashMap<>();
|
||||
@@ -121,7 +121,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericMapElement() {
|
||||
void genericMapElement() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
gb.setShortMap(new HashMap<>());
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
@@ -131,7 +131,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericMapWithKeyType() {
|
||||
void genericMapWithKeyType() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
Map<String, String> input = new HashMap<>();
|
||||
@@ -143,7 +143,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericMapElementWithKeyType() {
|
||||
void genericMapElementWithKeyType() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
gb.setLongMap(new HashMap<>());
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
@@ -153,7 +153,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericMapWithCollectionValue() {
|
||||
void genericMapWithCollectionValue() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.registerCustomEditor(Number.class, new CustomNumberEditor(Integer.class, false));
|
||||
@@ -170,7 +170,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericMapElementWithCollectionValue() {
|
||||
void genericMapElementWithCollectionValue() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
gb.setCollectionMap(new HashMap<>());
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
@@ -182,7 +182,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericMapFromProperties() {
|
||||
void genericMapFromProperties() {
|
||||
GenericBean<?> gb = new GenericBean<>();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
Properties input = new Properties();
|
||||
@@ -194,7 +194,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericListOfLists() {
|
||||
void genericListOfLists() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
List<List<Integer>> list = new ArrayList<>();
|
||||
list.add(new ArrayList<>());
|
||||
@@ -206,7 +206,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericListOfListsWithElementConversion() {
|
||||
void genericListOfListsWithElementConversion() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
List<List<Integer>> list = new ArrayList<>();
|
||||
list.add(new ArrayList<>());
|
||||
@@ -218,7 +218,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericListOfArrays() {
|
||||
void genericListOfArrays() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
ArrayList<String[]> list = new ArrayList<>();
|
||||
list.add(new String[] {"str1", "str2"});
|
||||
@@ -230,7 +230,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericListOfArraysWithElementConversion() {
|
||||
void genericListOfArraysWithElementConversion() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
ArrayList<String[]> list = new ArrayList<>();
|
||||
list.add(new String[] {"str1", "str2"});
|
||||
@@ -243,7 +243,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericListOfMaps() {
|
||||
void genericListOfMaps() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
List<Map<Integer, Long>> list = new ArrayList<>();
|
||||
list.add(new HashMap<>());
|
||||
@@ -255,7 +255,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericListOfMapsWithElementConversion() {
|
||||
void genericListOfMapsWithElementConversion() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
List<Map<Integer, Long>> list = new ArrayList<>();
|
||||
list.add(new HashMap<>());
|
||||
@@ -267,7 +267,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericMapOfMaps() {
|
||||
void genericMapOfMaps() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
Map<String, Map<Integer, Long>> map = new HashMap<>();
|
||||
map.put("mykey", new HashMap<>());
|
||||
@@ -279,7 +279,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericMapOfMapsWithElementConversion() {
|
||||
void genericMapOfMapsWithElementConversion() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
Map<String, Map<Integer, Long>> map = new HashMap<>();
|
||||
map.put("mykey", new HashMap<>());
|
||||
@@ -291,7 +291,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericMapOfLists() {
|
||||
void genericMapOfLists() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
Map<Integer, List<Integer>> map = new HashMap<>();
|
||||
map.put(1, new ArrayList<>());
|
||||
@@ -303,7 +303,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericMapOfListsWithElementConversion() {
|
||||
void genericMapOfListsWithElementConversion() {
|
||||
GenericBean<String> gb = new GenericBean<>();
|
||||
Map<Integer, List<Integer>> map = new HashMap<>();
|
||||
map.put(1, new ArrayList<>());
|
||||
@@ -315,7 +315,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericTypeNestingMapOfInteger() {
|
||||
void genericTypeNestingMapOfInteger() {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("testKey", "100");
|
||||
|
||||
@@ -328,7 +328,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericTypeNestingMapOfListOfInteger() {
|
||||
void genericTypeNestingMapOfListOfInteger() {
|
||||
Map<String, List<String>> map = new HashMap<>();
|
||||
List<String> list = Arrays.asList("1", "2", "3");
|
||||
map.put("testKey", list);
|
||||
@@ -343,7 +343,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericTypeNestingListOfMapOfInteger() {
|
||||
void genericTypeNestingListOfMapOfInteger() {
|
||||
List<Map<String, String>> list = new ArrayList<>();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("testKey", "5");
|
||||
@@ -359,7 +359,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericTypeNestingMapOfListOfListOfInteger() {
|
||||
void genericTypeNestingMapOfListOfListOfInteger() {
|
||||
Map<String, List<List<String>>> map = new HashMap<>();
|
||||
List<String> list = Arrays.asList("1", "2", "3");
|
||||
map.put("testKey", Collections.singletonList(list));
|
||||
@@ -374,7 +374,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testComplexGenericMap() {
|
||||
void complexGenericMap() {
|
||||
Map<List<String>, List<String>> inputMap = new HashMap<>();
|
||||
List<String> inputKey = new ArrayList<>();
|
||||
inputKey.add("1");
|
||||
@@ -390,7 +390,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testComplexGenericMapWithCollectionConversion() {
|
||||
void complexGenericMapWithCollectionConversion() {
|
||||
Map<Set<String>, Set<String>> inputMap = new HashMap<>();
|
||||
Set<String> inputKey = new HashSet<>();
|
||||
inputKey.add("1");
|
||||
@@ -406,7 +406,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testComplexGenericIndexedMapEntry() {
|
||||
void complexGenericIndexedMapEntry() {
|
||||
List<String> inputValue = new ArrayList<>();
|
||||
inputValue.add("10");
|
||||
|
||||
@@ -418,7 +418,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testComplexGenericIndexedMapEntryWithCollectionConversion() {
|
||||
void complexGenericIndexedMapEntryWithCollectionConversion() {
|
||||
Set<String> inputValue = new HashSet<>();
|
||||
inputValue.add("10");
|
||||
|
||||
@@ -430,7 +430,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testComplexGenericIndexedMapEntryWithPlainValue() {
|
||||
void complexGenericIndexedMapEntryWithPlainValue() {
|
||||
String inputValue = "10";
|
||||
|
||||
ComplexMapHolder holder = new ComplexMapHolder();
|
||||
@@ -441,7 +441,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testComplexDerivedIndexedMapEntry() {
|
||||
void complexDerivedIndexedMapEntry() {
|
||||
List<String> inputValue = new ArrayList<>();
|
||||
inputValue.add("10");
|
||||
|
||||
@@ -453,7 +453,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testComplexDerivedIndexedMapEntryWithCollectionConversion() {
|
||||
void complexDerivedIndexedMapEntryWithCollectionConversion() {
|
||||
Set<String> inputValue = new HashSet<>();
|
||||
inputValue.add("10");
|
||||
|
||||
@@ -465,7 +465,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testComplexDerivedIndexedMapEntryWithPlainValue() {
|
||||
void complexDerivedIndexedMapEntryWithPlainValue() {
|
||||
String inputValue = "10";
|
||||
|
||||
ComplexMapHolder holder = new ComplexMapHolder();
|
||||
@@ -476,7 +476,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testComplexMultiValueMapEntry() {
|
||||
void complexMultiValueMapEntry() {
|
||||
List<String> inputValue = new ArrayList<>();
|
||||
inputValue.add("10");
|
||||
|
||||
@@ -488,7 +488,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testComplexMultiValueMapEntryWithCollectionConversion() {
|
||||
void complexMultiValueMapEntryWithCollectionConversion() {
|
||||
Set<String> inputValue = new HashSet<>();
|
||||
inputValue.add("10");
|
||||
|
||||
@@ -500,7 +500,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testComplexMultiValueMapEntryWithPlainValue() {
|
||||
void complexMultiValueMapEntryWithPlainValue() {
|
||||
String inputValue = "10";
|
||||
|
||||
ComplexMapHolder holder = new ComplexMapHolder();
|
||||
@@ -511,7 +511,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericallyTypedIntegerBean() {
|
||||
void genericallyTypedIntegerBean() {
|
||||
GenericIntegerBean gb = new GenericIntegerBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("genericProperty", "10");
|
||||
@@ -521,7 +521,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testGenericallyTypedSetOfIntegerBean() {
|
||||
void genericallyTypedSetOfIntegerBean() {
|
||||
GenericSetOfIntegerBean gb = new GenericSetOfIntegerBean();
|
||||
BeanWrapper bw = new BeanWrapperImpl(gb);
|
||||
bw.setPropertyValue("genericProperty", "10");
|
||||
@@ -532,7 +532,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSettingGenericPropertyWithReadOnlyInterface() {
|
||||
void settingGenericPropertyWithReadOnlyInterface() {
|
||||
Bar bar = new Bar();
|
||||
BeanWrapper bw = new BeanWrapperImpl(bar);
|
||||
bw.setPropertyValue("version", "10");
|
||||
@@ -540,7 +540,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testSettingLongPropertyWithGenericInterface() {
|
||||
void settingLongPropertyWithGenericInterface() {
|
||||
Promotion bean = new Promotion();
|
||||
BeanWrapper bw = new BeanWrapperImpl(bean);
|
||||
bw.setPropertyValue("id", "10");
|
||||
@@ -548,7 +548,7 @@ class BeanWrapperGenericsTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUntypedPropertyWithMapAtRuntime() {
|
||||
void untypedPropertyWithMapAtRuntime() {
|
||||
class Holder<D> {
|
||||
private final D data;
|
||||
public Holder(D data) {
|
||||
|
||||
@@ -264,7 +264,7 @@ class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
||||
accessor.setPropertyValue("object", tb);
|
||||
assertThat(target.value).isSameAs(tb);
|
||||
assertThat(target.getObject()).containsSame(tb);
|
||||
assertThat(((Optional<TestBean>) accessor.getPropertyValue("object"))).containsSame(tb);
|
||||
assertThat((Optional<TestBean>) accessor.getPropertyValue("object")).containsSame(tb);
|
||||
assertThat(target.value.getName()).isEqualTo("x");
|
||||
assertThat(target.getObject().get().getName()).isEqualTo("x");
|
||||
assertThat(accessor.getPropertyValue("object.name")).isEqualTo("x");
|
||||
@@ -272,7 +272,7 @@ class BeanWrapperTests extends AbstractPropertyAccessorTests {
|
||||
accessor.setPropertyValue("object.name", "y");
|
||||
assertThat(target.value).isSameAs(tb);
|
||||
assertThat(target.getObject()).containsSame(tb);
|
||||
assertThat(((Optional<TestBean>) accessor.getPropertyValue("object"))).containsSame(tb);
|
||||
assertThat((Optional<TestBean>) accessor.getPropertyValue("object")).containsSame(tb);
|
||||
assertThat(target.value.getName()).isEqualTo("y");
|
||||
assertThat(target.getObject().get().getName()).isEqualTo("y");
|
||||
assertThat(accessor.getPropertyValue("object.name")).isEqualTo("y");
|
||||
|
||||
+2
-2
@@ -45,12 +45,12 @@ class ConcurrentBeanWrapperTests {
|
||||
private Throwable ex = null;
|
||||
|
||||
@RepeatedTest(100)
|
||||
void testSingleThread() {
|
||||
void singleThread() {
|
||||
performSet();
|
||||
}
|
||||
|
||||
@Test
|
||||
void testConcurrent() {
|
||||
void concurrent() {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
TestRun run = new TestRun(this);
|
||||
set.add(run);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user