Compare commits

..

1 Commits

Author SHA1 Message Date
Brian Clozel 053d8e25f4 Release v6.2.16 2026-02-12 09:33:48 +01:00
1145 changed files with 6131 additions and 9508 deletions
-1
View File
@@ -9,7 +9,6 @@ ivy-cache
argfile*
activemq-data/
classes/
.cursor/
# Log files
jxl.log
+4
View File
@@ -94,6 +94,10 @@ configure([rootProject] + javaProjects) { project ->
//"https://hc.apache.org/httpcomponents-client-5.5.x/current/httpclient5/apidocs/",
"https://projectreactor.io/docs/test/release/api/",
"https://junit.org/junit4/javadoc/4.13.2/",
// TODO Uncomment link to JUnit 5 docs once we execute Gradle with Java 18+.
// See https://github.com/spring-projects/spring-framework/issues/27497
//
// "https://junit.org/junit5/docs/5.14.2/api/",
"https://www.reactive-streams.org/reactive-streams-1.0.4-javadoc/",
//"https://javadoc.io/static/io.rsocket/rsocket-core/1.1.1/",
"https://r2dbc.io/spec/1.0.0.RELEASE/api/",
+3 -3
View File
@@ -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: include all releases from 6.2.0 to 9.*.*.
tags: ['v6.2.+({0..9})', 'v{7..9}.+({0..9}).+({0..9})?(-{RC,M}*)']
# 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})']
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.26/ui-bundle.zip
url: https://github.com/spring-io/antora-ui-spring/releases/download/v0.4.25/ui-bundle.zip
-4
View File
@@ -17,10 +17,6 @@ antora {
]
}
node {
version = '24.15.0'
}
tasks.named("generateAntoraYml") {
asciidocAttributes = project.provider( {
return ["spring-version": project.version ]
+1 -1
View File
@@ -326,9 +326,9 @@
*** xref:testing/testcontext-framework/application-events.adoc[]
*** xref:testing/testcontext-framework/test-execution-events.adoc[]
*** xref:testing/testcontext-framework/ctx-management.adoc[]
**** xref:testing/testcontext-framework/ctx-management/javaconfig.adoc[]
**** xref:testing/testcontext-framework/ctx-management/xml.adoc[]
**** xref:testing/testcontext-framework/ctx-management/groovy.adoc[]
**** xref:testing/testcontext-framework/ctx-management/javaconfig.adoc[]
**** xref:testing/testcontext-framework/ctx-management/mixed-config.adoc[]
**** xref:testing/testcontext-framework/ctx-management/context-customizers.adoc[]
**** xref:testing/testcontext-framework/ctx-management/initializers.adoc[]
@@ -74,11 +74,6 @@ expressions used in XML bean definitions, `@Value`, etc.
| The mode to use when compiling expressions for the
xref:core/expressions/evaluation.adoc#expressions-compiler-configuration[Spring Expression Language].
| `spring.expression.maxOperations`
| The default maximum number of operations permitted during
xref:core/expressions/evaluation.adoc#expressions-parser-configuration[Spring Expression Language]
expression evaluation.
| `spring.getenv.ignore`
| Instructs Spring to ignore operating system environment variables if a Spring
`Environment` property -- for example, a placeholder in a configuration String -- isn't
@@ -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.
. Bypassing the instance supplier means that all other optimizations after creation are skipped as well.
. By-passing 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.
@@ -151,17 +151,17 @@ injected into a `Set<MovieCatalog>` annotated with `@Qualifier("action")`.
[TIP]
====
Letting qualifier values select against target bean names, within the type-matching
candidates, does not require a `@Qualifier` annotation at the injection point. If there
is no other resolution indicator (such as a qualifier, a primary marker, or a fallback
marker), for a non-unique dependency situation, Spring matches the injection point name
(that is, the field name or parameter name) against the target bean names and chooses the
same-named candidate, if any (either by bean name or by associated alias).
candidates, does not require a `@Qualifier` annotation at the injection point.
If there is no other resolution indicator (such as a qualifier or a primary marker),
for a non-unique dependency situation, Spring matches the injection point name
(that is, the field name or parameter name) against the target bean names and chooses
the same-named candidate, if any (either by bean name or by associated alias).
Since version 6.1, this requires the `-parameters` Java compiler flag to be present. As
of 6.2, the container applies fast shortcut resolution for bean name matches, bypassing
the full type matching algorithm when the parameter name matches the bean name and no
type, qualifier, primary, or fallback conditions override the match. It is therefore
recommendable for your parameter names to match the target bean names.
Since version 6.1, this requires the `-parameters` Java compiler flag to be present.
As of 6.2, the container applies fast shortcut resolution for bean name matches,
bypassing the full type matching algorithm when the parameter name matches the
bean name and no type, qualifier or primary conditions override the match. It is
therefore recommendable for your parameter names to match the target bean names.
====
As an alternative for injection by name, consider the JSR-250 `@Resource` annotation
@@ -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. Alternatively, as a convenience if no risk of
fully-qualified class name of the annotation. Alternately, as a convenience if no risk of
conflicting names exists, you can use the short class name. The following example
demonstrates both approaches:
@@ -308,8 +308,7 @@ set of multiple matches for the specific bean type (as returned by the factory m
Note that the standard `jakarta.annotation.Priority` annotation is not available at the
`@Bean` level, since it cannot be declared on methods. Its semantics can be modeled
through `@Order` values in combination with `@Primary` or `@Fallback` on a single bean
for each type.
through `@Order` values in combination with `@Primary` on a single bean for each type.
====
Even typed `Map` instances can be autowired as long as the expected key type is `String`.
@@ -27,5 +27,4 @@ with the `CustomAutowireConfigurer`
When multiple beans qualify as autowire candidates, the determination of a "`primary`" is
as follows: If exactly one bean definition among the candidates has a `primary`
attribute set to `true`, it is selected. For annotation-based configuration, see
xref:core/beans/annotation-config/autowired-primary.adoc[Fine-tuning with `@Primary` or `@Fallback`].
attribute set to `true`, it is selected.
@@ -575,7 +575,7 @@ Kotlin::
----
======
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.
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.
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.
@@ -67,13 +67,6 @@ interface, clearly indicating the post-processor nature of that bean. Otherwise,
Since a `BeanPostProcessor` needs to be instantiated early in order to apply to the
initialization of other beans in the context, this early type detection is critical.
Furthermore, when registering a `BeanPostProcessor` via an `@Bean` factory method,
declare the method as `static` and ideally with no dependencies. Doing so avoids eager
initialization of the configuration class and other beans, which would make them
ineligible for full post-processing (such as auto-proxying). See the
"BeanPostProcessor-returning `@Bean` methods" section in the
{spring-framework-api}/context/annotation/Bean.html[`@Bean`] javadoc for details.
[[beans-factory-programmatically-registering-beanpostprocessors]]
.Programmatically registering `BeanPostProcessor` instances
NOTE: While the recommended approach for `BeanPostProcessor` registration is through
@@ -87,7 +80,7 @@ of execution. Note also that `BeanPostProcessor` instances registered programmat
are always processed before those registered through auto-detection, regardless of any
explicit ordering.
.`BeanPostProcessor` instances and early initialization
.`BeanPostProcessor` instances and AOP auto-proxying
[NOTE]
====
Classes that implement the `BeanPostProcessor` interface are special and are treated
@@ -97,23 +90,17 @@ of the `ApplicationContext`. Next, all `BeanPostProcessor` instances are registe
in a sorted fashion and applied to all further beans in the container. Because AOP
auto-proxying is implemented as a `BeanPostProcessor` itself, neither `BeanPostProcessor`
instances nor the beans they directly reference are eligible for auto-proxying and,
thus, do not have aspects woven into them. More generally, any bean that is instantiated
during this early phase is not eligible for full post-processing by all
`BeanPostProcessor` instances.
thus, do not have aspects woven into them.
For any such bean, you should see a WARN-level log message similar to the following.
For any such bean, you should see an informational log message: `Bean someBean is not
eligible for getting processed by all BeanPostProcessor interfaces (for example: not
eligible for auto-proxying)`.
[quote]
Bean 'someBean' of type [org.example.SomeType] is not eligible for getting processed by
all BeanPostProcessors (for example: not eligible for auto-proxying).
To minimize the number of beans affected, register a `BeanPostProcessor` with a
`static` `@Bean` method that has no dependencies (see the note above). If you have
beans wired into your `BeanPostProcessor` by using autowiring or `@Resource` (which
may fall back to autowiring), Spring might access unexpected beans when searching
for type-matching dependency candidates and, therefore, make them ineligible for
auto-proxying or other kinds of bean post-processing. For example, if you have a
dependency annotated with `@Resource` where the field or setter name does not
If you have beans wired into your `BeanPostProcessor` by using autowiring or
`@Resource` (which may fall back to autowiring), Spring might access unexpected beans
when searching for type-matching dependency candidates and, therefore, make them
ineligible for auto-proxying or other kinds of bean post-processing. For example, if you
have a dependency annotated with `@Resource` where the field or setter name does not
directly correspond to the declared name of a bean and no name attribute is used,
Spring accesses other beans for matching them by type.
====
@@ -148,7 +135,7 @@ Java::
}
public Object postProcessAfterInitialization(Object bean, String beanName) {
System.out.println("Bean '" + beanName + "' created : " + bean);
System.out.println("Bean '" + beanName + "' created : " + bean.toString());
return bean;
}
}
@@ -177,48 +164,7 @@ Kotlin::
----
======
You can register the `InstantiationTracingBeanPostProcessor` with Java configuration
by using a `static` `@Bean` method (recommended to avoid eager initialization of the
configuration class and other beans):
[tabs]
======
Java::
+
[source,java,indent=0,subs="verbatim,quotes",chomp="-packages"]
----
@Configuration
public class AppConfig {
@Bean
public static InstantiationTracingBeanPostProcessor instantiationTracingBeanPostProcessor() {
return new InstantiationTracingBeanPostProcessor();
}
// ... other bean definitions
}
----
Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes",chomp="-packages"]
----
@Configuration
class AppConfig {
@Bean
companion object {
@JvmStatic
fun instantiationTracingBeanPostProcessor() = InstantiationTracingBeanPostProcessor()
}
// ... other bean definitions
}
----
======
Alternatively, the `InstantiationTracingBeanPostProcessor` can be registered via the
`bean` element with XML configuration:
The following `beans` element uses the `InstantiationTracingBeanPostProcessor`:
[source,xml,indent=0,subs="verbatim,quotes"]
----
@@ -246,7 +192,7 @@ Alternatively, the `InstantiationTracingBeanPostProcessor` can be registered via
----
Notice how the `InstantiationTracingBeanPostProcessor` is merely defined. It does not
even have a name, and, because it is a bean, it can be dependency-injected as with any
even have a name, and, because it is a bean, it can be dependency-injected as you would any
other bean. (The preceding configuration also defines a bean that is backed by a Groovy
script. The Spring dynamic language support is detailed in the chapter entitled
xref:languages/dynamic.adoc[Dynamic Language Support].)
@@ -355,23 +301,6 @@ implement the `BeanFactoryPostProcessor` interface. It uses these beans as bean
post-processors, at the appropriate time. You can deploy these post-processor beans as
you would any other bean.
When registering a `BeanFactoryPostProcessor` via an `@Bean` factory method in a
`@Configuration` class, declare the method as `static` to avoid lifecycle conflicts
with annotation processing (such as `@Autowired`, `@Value`, and `@PostConstruct`) in the
configuration class. See the "BeanFactoryPostProcessor-returning `@Bean` methods"
section in the {spring-framework-api}/context/annotation/Bean.html[`@Bean`] javadoc
for details and an example.
For any non-static `@Bean` factory method with a `BeanFactoryPostProcessor` return type,
you should see an INFO-level log message similar to the following.
[quote]
@Bean method MyConfig.myBfpp is non-static and returns an object assignable to Spring's
BeanFactoryPostProcessor interface. This will result in a failure to process annotations
such as @Autowired, @Resource, and @PostConstruct within the method's declaring
@Configuration class. Add the 'static' modifier to this method to avoid these container
lifecycle issues; see @Bean javadoc for complete details.
NOTE: As with ``BeanPostProcessor``s , you typically do not want to configure
``BeanFactoryPostProcessor``s for lazy initialization. If no other bean references a
`Bean(Factory)PostProcessor`, that post-processor will not get instantiated at all.
@@ -395,16 +395,6 @@ set a JVM system property or Spring property named `spring.context.expression.ma
to the maximum expression length needed by your application (see
xref:appendix.adoc#appendix-spring-properties[Supported Spring Properties]).
Similarly, the number of operations performed during the evaluation of a SpEL expression
cannot exceed 10,000 by default; however, the `maxOperations` value is configurable. If
you create a `SpelExpressionParser` programmatically (the recommend approach), you can
specify a custom `maxOperations` value when creating the `SpelParserConfiguration` that
you provide to the `SpelExpressionParser`. If you are not able to configure an explicit
value for `maxOperations` via `SpelParserConfiguration`, you can set a JVM system
property or Spring property named `spring.expression.maxOperations` to the maximum number
of operations required by your application (see
xref:appendix.adoc#appendix-spring-properties[Supported Spring Properties]).
[[expressions-spel-compilation]]
== SpEL Compilation
@@ -2,12 +2,4 @@
= Language Reference
:page-section-summary-toc: 1
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.
This section describes how the Spring Expression Language works.
@@ -53,7 +53,7 @@ Kotlin::
val trueValue = parser.parseExpression("'black' < 'block'").getValue(Boolean::class.java)
// uses CustomValue:::compareTo
val trueValue = parser.parseExpression("new CustomValue(1) < new CustomValue(2)").getValue(Boolean::class.java)
val trueValue = parser.parseExpression("new CustomValue(1) < new CustomValue(2)").getValue(Boolean::class.java);
----
======
@@ -167,7 +167,7 @@ Kotlin::
[CAUTION]
====
The syntax for the `between` operator is `<input> between {<range_begin>, <range_end>}`,
which is effectively a shortcut for `<input> >= <range_begin> && <input> \<= <range_end>`.
which is effectively a shortcut for `<input> >= <range_begin> && <input> \<= <range_end>}`.
Consequently, `1 between {1, 5}` evaluates to `true`, while `1 between {5, 1}` evaluates
to `false`.
@@ -312,13 +312,13 @@ Kotlin::
// evaluates to 'a'
val ch = parser.parseExpression("'d' - 3")
.getValue(Char::class.java)
.getValue(Character::class.java);
// -- Repeat --
// evaluates to "abcabc"
val repeated = parser.parseExpression("'abc' * 2")
.getValue(String::class.java)
.getValue(String::class.java);
----
======
@@ -485,7 +485,7 @@ Kotlin::
// -- Operator precedence --
val minusTwentyOne = parser.parseExpression("1+2-3*8").getValue(Int::class.java) // -21
val minusTwentyOne = parser.parseExpression("1+2-3*8").getValue(Int::class.java) // -21
----
======
@@ -541,7 +541,32 @@ For example, if we want to overload the `ADD` operator to allow two lists to be
concatenated using the `+` sign, we can implement a custom `OperatorOverloader` as
follows.
include-code::./ListConcatenation[]
[source,java,indent=0,subs="verbatim,quotes"]
----
pubic class ListConcatenation implements OperatorOverloader {
@Override
public boolean overridesOperation(Operation operation, Object left, Object right) {
return (operation == Operation.ADD &&
left instanceof List && right instanceof List);
}
@Override
@SuppressWarnings("unchecked")
public Object operate(Operation operation, Object left, Object right) {
if (operation == Operation.ADD &&
left instanceof List list1 && right instanceof List list2) {
List result = new ArrayList(list1);
result.addAll(list2);
return result;
}
throw new UnsupportedOperationException(
"No overload for operation %s and operands [%s] and [%s]"
.formatted(operation, left, right));
}
}
----
If we register `ListConcatenation` as the `OperatorOverloader` in a
`StandardEvaluationContext`, we can then evaluate expressions like `{1, 2, 3} + {4, 5}`
@@ -564,8 +589,8 @@ Kotlin::
+
[source,kotlin,indent=0,subs="verbatim,quotes"]
----
val context = StandardEvaluationContext()
context.operatorOverloader = ListConcatenation()
StandardEvaluationContext context = StandardEvaluationContext()
context.setOperatorOverloader(ListConcatenation())
// evaluates to a new list: [1, 2, 3, 4, 5]
parser.parseExpression("{1, 2, 3} + {2 + 2, 5}").getValue(context, List::class.java)
@@ -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
invocable via a `public` class or `public` interface for compilation to succeed.
invokable 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
@@ -351,10 +351,10 @@ recognized and used as the `PropertyEditor` for `Something`-typed properties.
[literal,subs="verbatim,quotes"]
----
com
└── example
└── things
├── *Something*
└── *SomethingEditor* // the PropertyEditor for the Something class
chank
pop
Something
SomethingEditor // the PropertyEditor for the Something class
----
Note that you can also use the standard `BeanInfo` JavaBeans mechanism here as well
@@ -366,10 +366,10 @@ following example uses the `BeanInfo` mechanism to explicitly register one or mo
[literal,subs="verbatim,quotes"]
----
com
└── example
└── things
├── *Something*
└── *SomethingBeanInfo* // the BeanInfo for the Something class
chank
pop
Something
SomethingBeanInfo // the BeanInfo for the Something class
----
The following Java source code for the referenced `SomethingBeanInfo` class
@@ -22,7 +22,7 @@ where all the underlying resources have to participate in the service-level tran
NOTE: By default, a participating transaction joins the characteristics of the outer scope,
silently ignoring the local isolation level, timeout value, or read-only flag (if any).
Consider switching the `validateExistingTransaction` flag to `true` on your transaction
Consider switching the `validateExistingTransactions` flag to `true` on your transaction
manager if you want isolation level declarations to be rejected when participating in
an existing transaction with a different isolation level. This non-lenient mode also
rejects read-only mismatches (that is, an inner read-write transaction that tries to participate
@@ -72,13 +72,6 @@ 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
@@ -130,21 +130,6 @@ 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
@@ -173,22 +158,6 @@ 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.
@@ -208,19 +177,6 @@ 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.
@@ -251,34 +207,6 @@ 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
@@ -308,21 +236,6 @@ 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
@@ -348,21 +261,6 @@ 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.
@@ -382,19 +280,6 @@ 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.
@@ -425,34 +310,6 @@ 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
@@ -73,27 +73,6 @@ 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
@@ -123,28 +102,6 @@ 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]
@@ -3,7 +3,7 @@
In the previous sections, we have seen how to use MockMvc in conjunction with the raw
HtmlUnit APIs. In this section, we use additional abstractions within the Selenium
https://www.selenium.dev/documentation/webdriver/[WebDriver] to make things even easier.
https://docs.seleniumhq.org/projects/webdriver/[WebDriver] to make things even easier.
[[mockmvc-server-htmlunit-webdriver-why]]
== Why WebDriver and MockMvc?
@@ -12,8 +12,8 @@ We can already use HtmlUnit and MockMvc, so why would we want to use WebDriver?
Selenium WebDriver provides a very elegant API that lets us easily organize our code. To
better show how it works, we explore an example in this section.
NOTE: Despite being a part of https://www.selenium.dev/documentation/[Selenium],
WebDriver does not require a Selenium Server to run your tests.
NOTE: Despite being a part of https://docs.seleniumhq.org/[Selenium], WebDriver does not
require a Selenium Server to run your tests.
Suppose we need to ensure that a message is created properly. The tests involve finding
the HTML form input elements, filling them out, and making various assertions.
@@ -308,7 +308,7 @@ interested. These are of type `WebElement`. WebDriver's
https://github.com/SeleniumHQ/selenium/wiki/PageFactory[`PageFactory`] lets us remove a
lot of code from the HtmlUnit version of `CreateMessagePage` by automatically resolving
each `WebElement`. The
https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/PageFactory.html#initElements-org.openqa.selenium.WebDriver-java.lang.Class-[`PageFactory#initElements(WebDriver,Class<T>)`]
https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/PageFactory.html#initElements-org.openqa.selenium.WebDriver-java.lang.Class-[`PageFactory#initElements(WebDriver,Class<T>)`]
method automatically resolves each `WebElement` by using the field name and looking it up
by the `id` or `name` of the element within the HTML page.
<3> We can use the
@@ -352,7 +352,7 @@ interested. These are of type `WebElement`. WebDriver's
https://github.com/SeleniumHQ/selenium/wiki/PageFactory[`PageFactory`] lets us remove a
lot of code from the HtmlUnit version of `CreateMessagePage` by automatically resolving
each `WebElement`. The
https://www.selenium.dev/selenium/docs/api/java/org/openqa/selenium/support/PageFactory.html#initElements-org.openqa.selenium.WebDriver-java.lang.Class-[`PageFactory#initElements(WebDriver,Class<T>)`]
https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/support/PageFactory.html#initElements-org.openqa.selenium.WebDriver-java.lang.Class-[`PageFactory#initElements(WebDriver,Class<T>)`]
method automatically resolves each `WebElement` by using the field name and looking it up
by the `id` or `name` of the element within the HTML page.
<3> We can use the
@@ -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 implementors not to implement this interface
new requirements), we strongly encourage implementers not to implement this interface
directly but rather to extend `AbstractTestContextBootstrapper` or one of its concrete
subclasses instead.
@@ -49,6 +49,7 @@ Kotlin::
<1> Injecting the `ApplicationContext`.
======
Similarly, if your test is configured to load a `WebApplicationContext`, you can inject
the web application context into your test, as follows:
@@ -86,6 +87,7 @@ Kotlin::
<2> Injecting the `WebApplicationContext`.
======
Dependency injection by using `@Autowired` is provided by the
`DependencyInjectionTestExecutionListener`, which is configured by default
(see xref:testing/testcontext-framework/fixture-di.adoc[Dependency Injection of Test Fixtures]).
@@ -94,23 +96,22 @@ Dependency injection by using `@Autowired` is provided by the
Test classes that use the TestContext framework do not need to extend any particular
class or implement a specific interface to configure their application context. Instead,
configuration is achieved by declaring the `@ContextConfiguration` annotation at the
class level. If your test class does not explicitly declare component classes or resource
locations, the configured `ContextLoader` determines how to load a context from _default_
configuration classes or a _default_ location. In addition to component classes and
context resource locations, an application context can also be configured through
xref:testing/testcontext-framework/ctx-management/context-customizers.adoc[context customizers]
or xref:testing/testcontext-framework/ctx-management/initializers.adoc[context initializers].
class level. If your test class does not explicitly declare application context resource
locations or component classes, the configured `ContextLoader` determines how to load a
context from a default location or default configuration classes. In addition to context
resource locations and component classes, an application context can also be configured
through application context initializers.
The following sections explain how to use `@ContextConfiguration` and related annotations
to configure a test `ApplicationContext` by using component classes (typically
`@Configuration` classes), XML configuration files, Groovy scripts, context customizers,
or context initializers. Alternatively, you can implement and configure your own custom
`SmartContextLoader` for advanced use cases.
The following sections explain how to use Spring's `@ContextConfiguration` annotation to
configure a test `ApplicationContext` by using XML configuration files, Groovy scripts,
component classes (typically `@Configuration` classes), or context initializers.
Alternatively, you can implement and configure your own custom `SmartContextLoader` for
advanced use cases.
* xref:testing/testcontext-framework/ctx-management/javaconfig.adoc[Context Configuration with Component Classes]
* xref:testing/testcontext-framework/ctx-management/xml.adoc[Context Configuration with XML resources]
* xref:testing/testcontext-framework/ctx-management/groovy.adoc[Context Configuration with Groovy Scripts]
* xref:testing/testcontext-framework/ctx-management/mixed-config.adoc[Mixing Component Classes, XML, and Groovy Scripts]
* xref:testing/testcontext-framework/ctx-management/javaconfig.adoc[Context Configuration with Component Classes]
* xref:testing/testcontext-framework/ctx-management/mixed-config.adoc[Mixing XML, Groovy Scripts, and Component Classes]
* xref:testing/testcontext-framework/ctx-management/context-customizers.adoc[Context Configuration with Context Customizers]
* xref:testing/testcontext-framework/ctx-management/initializers.adoc[Context Configuration with Context Initializers]
* xref:testing/testcontext-framework/ctx-management/inheritance.adoc[Context Configuration Inheritance]
@@ -543,85 +543,3 @@ 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)
}
}
----
======
@@ -1,32 +1,33 @@
[[testcontext-ctx-management-mixed-config]]
= Mixing Component Classes, XML, and Groovy Scripts
= Mixing XML, Groovy Scripts, and Component Classes
It may sometimes be desirable to mix component classes (typically `@Configuration`
classes), XML configuration files, or Groovy scripts to configure an `ApplicationContext`
for your tests. For example, if you use XML configuration in production for legacy
reasons, you may decide that you want to use `@Configuration` classes to configure
It may sometimes be desirable to mix XML configuration files, Groovy scripts, and
component classes (typically `@Configuration` classes) to configure an
`ApplicationContext` for your tests. For example, if you use XML configuration in
production, you may decide that you want to use `@Configuration` classes to configure
specific Spring-managed components for your tests, or vice versa.
Furthermore, some third-party frameworks (such as Spring Boot) provide first-class
support for loading an `ApplicationContext` from different types of resources
simultaneously (for example, `@Configuration` classes, XML configuration files, and
Groovy scripts). The Spring Framework, historically, has not supported this for standard
deployments. Consequently, most of the `SmartContextLoader` implementations that the
Spring Framework delivers in the `spring-test` module support only one resource type for
each test context. However, this does not mean that you cannot use a mixture of resource
types. One exception to the general rule is that the `GenericGroovyXmlContextLoader` and
simultaneously (for example, XML configuration files, Groovy scripts, and
`@Configuration` classes). The Spring Framework, historically, has not supported this for
standard deployments. Consequently, most of the `SmartContextLoader` implementations that
the Spring Framework delivers in the `spring-test` module support only one resource type
for each test context. However, this does not mean that you cannot use both. One
exception to the general rule is that the `GenericGroovyXmlContextLoader` and
`GenericGroovyXmlWebContextLoader` support both XML configuration files and Groovy
scripts simultaneously. Furthermore, third-party frameworks may choose to support the
declaration of both `classes` and `locations` through `@ContextConfiguration`, and, with
declaration of both `locations` and `classes` through `@ContextConfiguration`, and, with
the standard testing support in the TestContext framework, you have the following options.
If you want to use `@Configuration` classes and resource locations (for example, XML or
Groovy) to configure your tests, you must pick one as the entry point, and that one must
import or include the other. For example, in a `@Configuration` class, you can use
`@ImportResource` to import XML configuration files or Groovy scripts; whereas, in XML or
Groovy scripts, you can include `@Configuration` classes by using component scanning or
defining them as normal Spring beans. Note that this behavior is semantically equivalent
If you want to use resource locations (for example, XML or Groovy) and `@Configuration`
classes to configure your tests, you must pick one as the entry point, and that one must
include or import the other. For example, in XML or Groovy scripts, you can include
`@Configuration` classes by using component scanning or defining them as normal Spring
beans, whereas, in a `@Configuration` class, you can use `@ImportResource` to import XML
configuration files or Groovy scripts. Note that this behavior is semantically equivalent
to how you configure your application in production: In production configuration, you
define either a set of `@Configuration` classes or a set of XML or Groovy resource
locations from which your production `ApplicationContext` is loaded, but you still have
the freedom to import or include the other type of configuration.
define either a set of XML or Groovy resource locations or a set of `@Configuration`
classes from which your production `ApplicationContext` is loaded, but you still have the
freedom to include or import the other type of configuration.
@@ -251,8 +251,7 @@ Kotlin::
======
TIP: If you need to have a `LocalValidatorFactoryBean` injected somewhere, create a bean and
mark it with `@Primary`, or mark the one declared in the MVC config with `@Fallback`, in
order to avoid conflict.
mark it with `@Primary` in order to avoid conflict with the one declared in the MVC config.
[[webflux-config-content-negotiation]]
@@ -269,7 +269,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 discrete elements (radio buttons
* `separator`: Where multiple options are available as discreet 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
@@ -19,5 +19,4 @@ example shows:
include-code::./MyController[tag=snippet,indent=0]
TIP: If you need to have a `LocalValidatorFactoryBean` injected somewhere, create a bean and
mark it with `@Primary`, or mark the one declared in the MVC configuration with
`@Fallback`, in order to avoid conflict.
mark it with `@Primary` in order to avoid conflict with the one declared in the MVC configuration.
@@ -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 (described earlier).
programmatically enrich the model by declaring a `Model` argument (descried earlier).
| `java.util.Map`, `org.springframework.ui.Model`
| Attributes to be added to the implicit model with the view name implicitly determined
@@ -3,7 +3,7 @@
[.small]#xref:web/webflux/uri-building.adoc[See equivalent in the Reactive stack]#
This section describes various options available in the Spring Framework to work with URIs.
This section describes various options available in the Spring Framework to work with URI's.
include::partial$web/web-uris.adoc[leveloffset=+1]
@@ -2,7 +2,7 @@
= UriComponents
[.small]#Spring MVC and Spring WebFlux#
`UriComponentsBuilder` helps to build URIs from URI templates with variables, as the following example shows:
`UriComponentsBuilder` helps to build URI's from URI templates with variables, as the following example shows:
[tabs]
======
@@ -128,7 +128,7 @@ Kotlin::
= UriBuilder
[.small]#Spring MVC and Spring WebFlux#
<<uricomponents, `UriComponentsBuilder`>> implements `UriBuilder`. You can create a
<<web-uricomponents, `UriComponentsBuilder`>> implements `UriBuilder`. You can create a
`UriBuilder`, in turn, with a `UriBuilderFactory`. Together, `UriBuilderFactory` and
`UriBuilder` provide a pluggable mechanism to build URIs from URI templates, based on
shared configuration, such as a base URL, encoding preferences, and other details.
@@ -247,7 +247,7 @@ and treats deviations from the syntax as illegal.
https://github.com/web-platform-tests/wpt/tree/master/url[URL parsing algorithm] in the
https://url.spec.whatwg.org[WhatWG URL Living standard]. It provides lenient handling of
a wide range of cases of unexpected input. Browsers implement this in order to handle
leniently user typed URLs. For more details, see the URL Living Standard and URL parsing
leniently user typed URL's. For more details, see the URL Living Standard and URL parsing
https://github.com/web-platform-tests/wpt/tree/master/url[test cases].
By default, `RestClient`, `WebClient`, and `RestTemplate` use the RFC parser type, and
@@ -255,10 +255,10 @@ expect applications to provide with URL templates that conform to RFC syntax. To
that you can customize the `UriBuilderFactory` on any of the clients.
Applications and frameworks may further rely on `UriComponentsBuilder` for their own needs
to parse user provided URLs in order to inspect and possibly validated URI components
to parse user provided URL's in order to inspect and possibly validated URI components
such as the scheme, host, port, path, and query. Such components can decide to use the
WhatWG parser type in order to handle URLs more leniently, and to align with the way
browsers parse URIs, in case of a redirect to the input URL or if it is included in a
WhatWG parser type in order to handle URL's more leniently, and to align with the way
browsers parse URI's, in case of a redirect to the input URL or if it is included in a
response to a browser.
@@ -373,14 +373,14 @@ Java::
[source,java,indent=0,subs="verbatim,quotes"]
----
String baseUrl = "https://example.com";
DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(baseUrl);
DefaultUriBuilderFactory factory = new DefaultUriBuilderFactory(baseUrl)
factory.setEncodingMode(EncodingMode.TEMPLATE_AND_VALUES);
// Customize the RestTemplate.
// Customize the RestTemplate..
RestTemplate restTemplate = new RestTemplate();
restTemplate.setUriTemplateHandler(factory);
// Customize the WebClient.
// Customize the WebClient..
WebClient client = WebClient.builder().uriBuilderFactory(factory).build();
----
@@ -393,12 +393,12 @@ Kotlin::
encodingMode = EncodingMode.TEMPLATE_AND_VALUES
}
// Customize the RestTemplate.
// Customize the RestTemplate..
val restTemplate = RestTemplate().apply {
uriTemplateHandler = factory
}
// Customize the WebClient.
// Customize the WebClient..
val client = WebClient.builder().uriBuilderFactory(factory).build()
----
======
+5 -5
View File
@@ -1,11 +1,11 @@
{
"dependencies": {
"antora": "3.2.0-alpha.12",
"antora": "3.2.0-alpha.11",
"@antora/atlas-extension": "1.0.0-alpha.5",
"@antora/collector-extension": "1.0.3",
"@antora/collector-extension": "1.0.2",
"@asciidoctor/tabs": "1.0.0-beta.6",
"@springio/antora-extensions": "1.14.12",
"fast-xml-parser": "5.7.0",
"@springio/asciidoctor-extensions": "1.0.0-alpha.18"
"@springio/antora-extensions": "1.14.7",
"fast-xml-parser": "5.3.4",
"@springio/asciidoctor-extensions": "1.0.0-alpha.17"
}
}
@@ -1,47 +0,0 @@
/*
* 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.docs.core.expressions.languageref.expressionsoperatorsoverloaded;
import org.springframework.expression.Operation;
import org.springframework.expression.OperatorOverloader;
import java.util.ArrayList;
import java.util.List;
public class ListConcatenation implements OperatorOverloader {
@Override
public boolean overridesOperation(Operation operation, Object left, Object right) {
return (operation == Operation.ADD && left instanceof List && right instanceof List);
}
@Override
@SuppressWarnings({"rawtypes", "unchecked"})
public Object operate(Operation operation, Object left, Object right) {
if (operation == Operation.ADD &&
left instanceof List list1 && right instanceof List list2) {
List result = new ArrayList(list1);
result.addAll(list2);
return result;
}
throw new UnsupportedOperationException(
"No overload for operation %s and operands [%s] and [%s]"
.formatted(operation, left, right));
}
}
@@ -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,37 +0,0 @@
/*
* 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.docs.core.expressions.languageref.expressionsoperatorsoverloaded
import org.springframework.expression.Operation
import org.springframework.expression.OperatorOverloader
class ListConcatenation: OperatorOverloader {
override fun overridesOperation(operation: Operation, left: Any?, right: Any?): Boolean {
return operation == Operation.ADD && left is List<*> && right is List<*>
}
override fun operate(operation: Operation, left: Any?, right: Any?): Any {
if (operation == Operation.ADD && left is List<*> && right is List<*>) {
return left + right
}
throw UnsupportedOperationException(
"No overload for operation $operation and operands [$left] and [$right]")
}
}
@@ -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[]
+14 -14
View File
@@ -8,20 +8,20 @@ javaPlatform {
dependencies {
api(platform("com.fasterxml.jackson:jackson-bom:2.18.5"))
api(platform("io.micrometer:micrometer-bom:1.15.12"))
api(platform("io.netty:netty-bom:4.1.134.Final"))
api(platform("io.micrometer:micrometer-bom:1.15.9"))
api(platform("io.netty:netty-bom:4.1.130.Final"))
api(platform("io.netty:netty5-bom:5.0.0.Alpha5"))
api(platform("io.projectreactor:reactor-bom:2024.0.18"))
api(platform("io.projectreactor:reactor-bom:2024.0.15"))
api(platform("io.rsocket:rsocket-bom:1.1.5"))
api(platform("org.apache.groovy:groovy-bom:4.0.31"))
api(platform("org.apache.groovy:groovy-bom:4.0.30"))
api(platform("org.apache.logging.log4j:log4j-bom:2.21.1"))
api(platform("org.assertj:assertj-bom:3.27.7"))
api(platform("org.eclipse.jetty:jetty-bom:12.0.33"))
api(platform("org.eclipse.jetty.ee10:jetty-ee10-bom:12.0.33"))
api(platform("org.eclipse.jetty:jetty-bom:12.0.30"))
api(platform("org.eclipse.jetty.ee10:jetty-ee10-bom:12.0.30"))
api(platform("org.jetbrains.kotlinx:kotlinx-coroutines-bom:1.8.1"))
api(platform("org.jetbrains.kotlinx:kotlinx-serialization-bom:1.6.3"))
api(platform("org.junit:junit-bom:5.14.4"))
api(platform("org.mockito:mockito-bom:5.23.0"))
api(platform("org.junit:junit-bom:5.14.2"))
api(platform("org.mockito:mockito-bom:5.21.0"))
constraints {
api("com.fasterxml:aalto-xml:1.3.4")
@@ -31,8 +31,8 @@ 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.1")
api("com.h2database:h2:2.4.240")
api("com.google.protobuf:protobuf-java-util:4.33.4")
api("com.h2database:h2:2.3.232")
api("com.jayway.jsonpath:json-path:2.10.0")
api("com.oracle.database.jdbc:ojdbc11:21.9.0.0")
api("com.rometools:rome:1.19.0")
@@ -50,7 +50,7 @@ dependencies {
api("io.mockk:mockk:1.13.17")
api("io.projectreactor.netty:reactor-netty5-http:2.0.0-M3")
api("io.projectreactor.tools:blockhound:1.0.8.RELEASE")
api("io.r2dbc:r2dbc-h2:1.1.0.RELEASE")
api("io.r2dbc:r2dbc-h2:1.0.0.RELEASE")
api("io.r2dbc:r2dbc-spi-test:1.0.0.RELEASE")
api("io.r2dbc:r2dbc-spi:1.0.0.RELEASE")
api("io.reactivex.rxjava3:rxjava:3.1.12")
@@ -137,8 +137,8 @@ dependencies {
api("org.ogce:xpp3:1.1.6")
api("org.python:jython-standalone:2.7.4")
api("org.quartz-scheduler:quartz:2.3.2")
api("org.seleniumhq.selenium:htmlunit3-driver:4.41.0")
api("org.seleniumhq.selenium:selenium-java:4.41.0")
api("org.seleniumhq.selenium:htmlunit3-driver:4.40.0")
api("org.seleniumhq.selenium:selenium-java:4.40.0")
api("org.skyscreamer:jsonassert:1.5.3")
api("org.slf4j:slf4j-api:2.0.17")
api("org.testng:testng:7.11.0")
@@ -147,6 +147,6 @@ dependencies {
api("org.webjars:webjars-locator-lite:1.1.0")
api("org.xmlunit:xmlunit-assertj:2.10.4")
api("org.xmlunit:xmlunit-matchers:2.10.4")
api("org.yaml:snakeyaml:2.6")
api("org.yaml:snakeyaml:2.5")
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
version=6.2.19
version=6.2.16
org.gradle.caching=true
org.gradle.jvmargs=-Xmx2048m
+13
View File
@@ -84,6 +84,19 @@ 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(
@@ -61,9 +61,10 @@ class AopNamespaceHandlerScopeIntegrationTests {
@Test
void singletonScoping() throws Exception {
void testSingletonScoping() throws Exception {
assertThat(AopUtils.isAopProxy(singletonScoped)).as("Should be AOP proxy").isTrue();
assertThat(singletonScoped).as("Should be target class proxy").isInstanceOf(TestBean.class);
boolean condition = singletonScoped instanceof TestBean;
assertThat(condition).as("Should be target class proxy").isTrue();
String rob = "Rob Harrop";
String bram = "Bram Smeets";
assertThat(singletonScoped.getName()).isEqualTo(rob);
@@ -74,17 +75,19 @@ class AopNamespaceHandlerScopeIntegrationTests {
}
@Test
void requestScoping() {
void testRequestScoping() {
MockHttpServletRequest oldRequest = new MockHttpServletRequest();
MockHttpServletRequest newRequest = new MockHttpServletRequest();
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(oldRequest));
assertThat(AopUtils.isAopProxy(requestScoped)).as("Should be AOP proxy").isTrue();
assertThat(requestScoped).as("Should be target class proxy").isInstanceOf(TestBean.class);
boolean condition = requestScoped instanceof TestBean;
assertThat(condition).as("Should be target class proxy").isTrue();
assertThat(AopUtils.isAopProxy(testBean)).as("Should be AOP proxy").isTrue();
assertThat(testBean).as("Regular bean should be JDK proxy").isNotInstanceOf(TestBean.class);
boolean condition1 = testBean instanceof TestBean;
assertThat(condition1).as("Regular bean should be JDK proxy").isFalse();
String rob = "Rob Harrop";
String bram = "Bram Smeets";
@@ -100,7 +103,7 @@ class AopNamespaceHandlerScopeIntegrationTests {
}
@Test
void sessionScoping() {
void testSessionScoping() {
MockHttpSession oldSession = new MockHttpSession();
MockHttpSession newSession = new MockHttpSession();
@@ -109,12 +112,14 @@ class AopNamespaceHandlerScopeIntegrationTests {
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
assertThat(AopUtils.isAopProxy(sessionScoped)).as("Should be AOP proxy").isTrue();
assertThat(sessionScoped).as("Should not be target class proxy").isNotInstanceOf(TestBean.class);
boolean condition1 = sessionScoped instanceof TestBean;
assertThat(condition1).as("Should not be target class proxy").isFalse();
assertThat(sessionScopedAlias).isSameAs(sessionScoped);
assertThat(AopUtils.isAopProxy(testBean)).as("Should be AOP proxy").isTrue();
assertThat(testBean).as("Regular bean should be JDK proxy").isNotInstanceOf(TestBean.class);
boolean condition = testBean instanceof TestBean;
assertThat(condition).as("Regular bean should be JDK proxy").isFalse();
String rob = "Rob Harrop";
String bram = "Bram Smeets";
@@ -65,7 +65,7 @@ class AdvisorAutoProxyCreatorIntegrationTests {
}
@Test
void defaultExclusionPrefix() {
void testDefaultExclusionPrefix() {
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 noProxy() {
void testNoProxy() {
BeanFactory bf = getBeanFactory();
Object o = bf.getBean("noSetters");
assertThat(AopUtils.isAopProxy(o)).isFalse();
}
@Test
void txIsProxied() {
void testTxIsProxied() {
BeanFactory bf = getBeanFactory();
ITestBean test = (ITestBean) bf.getBean("test");
assertThat(AopUtils.isAopProxy(test)).isTrue();
}
@Test
void regexpApplied() {
void testRegexpApplied() {
BeanFactory bf = getBeanFactory();
ITestBean test = (ITestBean) bf.getBean("test");
MethodCounter counter = (MethodCounter) bf.getBean("countingAdvice");
@@ -99,7 +99,7 @@ class AdvisorAutoProxyCreatorIntegrationTests {
}
@Test
void transactionAttributeOnMethod() {
void testTransactionAttributeOnMethod() {
BeanFactory bf = getBeanFactory();
ITestBean test = (ITestBean) bf.getBean("test");
@@ -121,7 +121,7 @@ class AdvisorAutoProxyCreatorIntegrationTests {
* Should not roll back on servlet exception.
*/
@Test
void rollbackRulesOnMethodCauseRollback() throws Exception {
void testRollbackRulesOnMethodCauseRollback() throws Exception {
BeanFactory bf = getBeanFactory();
Rollback rb = (Rollback) bf.getBean("rollback");
@@ -147,7 +147,7 @@ class AdvisorAutoProxyCreatorIntegrationTests {
}
@Test
void rollbackRulesOnMethodPreventRollback() throws Exception {
void testRollbackRulesOnMethodPreventRollback() throws Exception {
BeanFactory bf = getBeanFactory();
Rollback rb = (Rollback) bf.getBean("rollback");
@@ -165,11 +165,12 @@ class AdvisorAutoProxyCreatorIntegrationTests {
}
@Test
void programmaticRollback() {
void testProgrammaticRollback() {
BeanFactory bf = getBeanFactory();
Object bean = bf.getBean(TXMANAGER_BEAN_NAME);
assertThat(bean).isInstanceOf(CallCountingTransactionManager.class);
boolean condition = bean instanceof CallCountingTransactionManager;
assertThat(condition).isTrue();
CallCountingTransactionManager txMan = (CallCountingTransactionManager) bf.getBean(TXMANAGER_BEAN_NAME);
Rollback rb = (Rollback) bf.getBean("rollback");
@@ -50,13 +50,13 @@ class ComponentBeanDefinitionParserTests {
}
@Test
void bionicBasic() {
void testBionicBasic() {
Component cp = getBionicFamily();
assertThat(cp.getName()).isEqualTo("Bionic-1");
}
@Test
void bionicFirstLevelChildren() {
void testBionicFirstLevelChildren() {
Component cp = getBionicFamily();
List<Component> components = cp.getComponents();
assertThat(components).hasSize(2);
@@ -65,7 +65,7 @@ class ComponentBeanDefinitionParserTests {
}
@Test
void bionicSecondLevelChildren() {
void testBionicSecondLevelChildren() {
Component cp = getBionicFamily();
List<Component> components = cp.getComponents().get(0).getComponents();
assertThat(components).hasSize(2);
@@ -83,7 +83,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
@Test
void prototype() {
void testPrototype() {
ApplicationContext context = createContext(ScopedProxyMode.NO);
ScopedTestBean bean = (ScopedTestBean) context.getBean("prototype");
assertThat(bean).isNotNull();
@@ -92,7 +92,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@Test
void singletonScopeWithNoProxy() {
void testSingletonScopeWithNoProxy() {
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
ApplicationContext context = createContext(ScopedProxyMode.NO);
ScopedTestBean bean = (ScopedTestBean) context.getBean("singleton");
@@ -115,7 +115,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@Test
void singletonScopeIgnoresProxyInterfaces() {
void testSingletonScopeIgnoresProxyInterfaces() {
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
ApplicationContext context = createContext(ScopedProxyMode.INTERFACES);
ScopedTestBean bean = (ScopedTestBean) context.getBean("singleton");
@@ -136,7 +136,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@Test
void singletonScopeIgnoresProxyTargetClass() {
void testSingletonScopeIgnoresProxyTargetClass() {
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
ApplicationContext context = createContext(ScopedProxyMode.TARGET_CLASS);
ScopedTestBean bean = (ScopedTestBean) context.getBean("singleton");
@@ -157,7 +157,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@Test
void requestScopeWithNoProxy() {
void testRequestScopeWithNoProxy() {
RequestContextHolder.setRequestAttributes(oldRequestAttributes);
ApplicationContext context = createContext(ScopedProxyMode.NO);
ScopedTestBean bean = (ScopedTestBean) context.getBean("request");
@@ -178,14 +178,15 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@Test
void requestScopeWithProxiedInterfaces() {
void testRequestScopeWithProxiedInterfaces() {
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();
assertThat(bean).isInstanceOf(AnotherScopeTestInterface.class);
boolean condition = bean instanceof AnotherScopeTestInterface;
assertThat(condition).isTrue();
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
bean.setName(MODIFIED_NAME);
@@ -199,14 +200,15 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@Test
void requestScopeWithProxiedTargetClass() {
void testRequestScopeWithProxiedTargetClass() {
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();
assertThat(bean).isInstanceOf(RequestScopedTestBean.class);
boolean condition = bean instanceof RequestScopedTestBean;
assertThat(condition).isTrue();
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
bean.setName(MODIFIED_NAME);
@@ -220,7 +222,7 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@Test
void sessionScopeWithNoProxy() {
void testSessionScopeWithNoProxy() {
RequestContextHolder.setRequestAttributes(oldRequestAttributesWithSession);
ApplicationContext context = createContext(ScopedProxyMode.NO);
ScopedTestBean bean = (ScopedTestBean) context.getBean("session");
@@ -241,14 +243,15 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@Test
void sessionScopeWithProxiedInterfaces() {
void testSessionScopeWithProxiedInterfaces() {
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();
assertThat(bean).isInstanceOf(AnotherScopeTestInterface.class);
boolean condition = bean instanceof AnotherScopeTestInterface;
assertThat(condition).isTrue();
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
bean.setName(MODIFIED_NAME);
@@ -268,15 +271,17 @@ class ClassPathBeanDefinitionScannerJsr330ScopeIntegrationTests {
}
@Test
void sessionScopeWithProxiedTargetClass() {
void testSessionScopeWithProxiedTargetClass() {
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();
assertThat(bean).isInstanceOf(ScopedTestBean.class);
assertThat(bean).isInstanceOf(SessionScopedTestBean.class);
boolean condition1 = bean instanceof ScopedTestBean;
assertThat(condition1).isTrue();
boolean condition = bean instanceof SessionScopedTestBean;
assertThat(condition).isTrue();
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
bean.setName(MODIFIED_NAME);
@@ -166,7 +166,8 @@ class ClassPathBeanDefinitionScannerScopeIntegrationTests {
// should be dynamic proxy, implementing both interfaces
assertThat(AopUtils.isJdkDynamicProxy(bean)).isTrue();
assertThat(bean).isInstanceOf(AnotherScopeTestInterface.class);
boolean condition = bean instanceof AnotherScopeTestInterface;
assertThat(condition).isTrue();
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
bean.setName(MODIFIED_NAME);
@@ -187,7 +188,8 @@ class ClassPathBeanDefinitionScannerScopeIntegrationTests {
// should be a class-based proxy
assertThat(AopUtils.isCglibProxy(bean)).isTrue();
assertThat(bean).isInstanceOf(RequestScopedTestBean.class);
boolean condition = bean instanceof RequestScopedTestBean;
assertThat(condition).isTrue();
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
bean.setName(MODIFIED_NAME);
@@ -229,7 +231,8 @@ class ClassPathBeanDefinitionScannerScopeIntegrationTests {
// should be dynamic proxy, implementing both interfaces
assertThat(AopUtils.isJdkDynamicProxy(bean)).isTrue();
assertThat(bean).isInstanceOf(AnotherScopeTestInterface.class);
boolean condition = bean instanceof AnotherScopeTestInterface;
assertThat(condition).isTrue();
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
bean.setName(MODIFIED_NAME);
@@ -256,8 +259,10 @@ class ClassPathBeanDefinitionScannerScopeIntegrationTests {
// should be a class-based proxy
assertThat(AopUtils.isCglibProxy(bean)).isTrue();
assertThat(bean).isInstanceOf(ScopedTestBean.class);
assertThat(bean).isInstanceOf(SessionScopedTestBean.class);
boolean condition1 = bean instanceof ScopedTestBean;
assertThat(condition1).isTrue();
boolean condition = bean instanceof SessionScopedTestBean;
assertThat(condition).isTrue();
assertThat(bean.getName()).isEqualTo(DEFAULT_NAME);
bean.setName(MODIFIED_NAME);
@@ -1,36 +0,0 @@
/*
* 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";
}
@@ -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.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;
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;
/**
* System integration tests for container support of the {@link Environment} API.
@@ -87,7 +87,7 @@ import static org.springframework.core.env.Constants.XML_PATH;
* @author Sam Brannen
* @see org.springframework.context.support.EnvironmentIntegrationTests
*/
class EnvironmentSystemIntegrationTests {
public class EnvironmentSystemIntegrationTests {
private final ConfigurableEnvironment prodEnv = new StandardEnvironment();
@@ -648,7 +648,7 @@ class EnvironmentSystemIntegrationTests {
}
}
@Profile(Constants.DERIVED_DEV_ENV_NAME)
@Profile(DERIVED_DEV_ENV_NAME)
@Configuration
static class DerivedDevConfig extends DevConfig {
@Bean
@@ -666,4 +666,24 @@ 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";
}
}
@@ -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.Constants.DEV_ENV_NAME)
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_ENV_NAME)
@Configuration
class DevConfig {
@@ -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.Constants.PROD_ENV_NAME)
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_ENV_NAME)
@Configuration
class ProdConfig {
@@ -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.Constants.DEV_ENV_NAME)
@Component(org.springframework.core.env.Constants.DEV_BEAN_NAME)
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_ENV_NAME)
@Component(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.DEV_BEAN_NAME)
class DevBean {
}
@@ -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.Constants.PROD_ENV_NAME)
@Component(org.springframework.core.env.Constants.PROD_BEAN_NAME)
@Profile(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_ENV_NAME)
@Component(org.springframework.core.env.EnvironmentSystemIntegrationTests.Constants.PROD_BEAN_NAME)
class ProdBean {
}
@@ -171,7 +171,7 @@ public class MethodInvocationProceedingJoinPoint implements ProceedingJoinPoint,
@Override
public String toString() {
return "execution(" + getSignature() + ")";
return "execution(" + getSignature().toString() + ")";
}
@@ -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 honored when
* supplied must be a singleton aspect. True singleton lifecycle is not honoured 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
@@ -120,7 +120,7 @@ final class InstantiationModelAwarePointcutAdvisorImpl
/**
* The pointcut for Spring AOP to use.
* Actual behavior of the pointcut will change depending on the state of the advice.
* Actual behaviour of the pointcut will change depending on the state of the advice.
*/
@Override
public Pointcut getPointcut() {
@@ -261,7 +261,7 @@ final class InstantiationModelAwarePointcutAdvisorImpl
/**
* Pointcut implementation that changes its behavior when the advice is instantiated.
* Pointcut implementation that changes its behaviour 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.
*/
@@ -82,7 +82,7 @@ public class DelegatePerTargetObjectIntroductionInterceptor extends Introduction
/**
* Subclasses may need to override this if they want to perform custom
* behavior in around advice. However, subclasses should invoke this
* behaviour in around advice. However, subclasses should invoke this
* method, which handles introduced interfaces and forwarding to the target.
*/
@Override
@@ -98,7 +98,7 @@ public class DelegatingIntroductionInterceptor extends IntroductionInfoSupport
/**
* Subclasses may need to override this if they want to perform custom
* behavior in around advice. However, subclasses should invoke this
* behaviour in around advice. However, subclasses should invoke this
* method, which handles introduced interfaces and forwarding to the target.
*/
@Override
@@ -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 behavior as well.
* be overridden to customize ClassFilter behaviour as well.
*
* @author Rod Johnson
*/
@@ -23,6 +23,7 @@ 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;
@@ -36,7 +37,6 @@ 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,22 +50,30 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
*/
class AspectJExpressionPointcutTests {
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 Method getAge;
private Method setAge;
private Method setSomeNumber;
private final Map<String, Method> methodsOnHasGeneric = new HashMap<>();
AspectJExpressionPointcutTests() throws NoSuchMethodException {
@BeforeEach
void setup() throws NoSuchMethodException {
getAge = TestBean.class.getMethod("getAge");
setAge = TestBean.class.getMethod("setAge", int.class);
setSomeNumber = TestBean.class.getMethod("setSomeNumber", Number.class);
// Assumes no overloading
for (Method method : HasGeneric.class.getMethods()) {
this.methodsOnHasGeneric.put(method.getName(), method);
methodsOnHasGeneric.put(method.getName(), method);
}
}
@Test
void matchExplicit() {
void testMatchExplicit() {
String expression = "execution(int org.springframework.beans.testfixture.beans.TestBean.getAge())";
Pointcut pointcut = getPointcut(expression);
@@ -83,7 +91,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void matchWithTypePattern() {
void testMatchWithTypePattern() {
String expression = "execution(* *..TestBean.*Age(..))";
Pointcut pointcut = getPointcut(expression);
@@ -102,12 +110,12 @@ class AspectJExpressionPointcutTests {
@Test
void thisCase() throws SecurityException, NoSuchMethodException{
void testThis() throws SecurityException, NoSuchMethodException{
testThisOrTarget("this");
}
@Test
void target() throws SecurityException, NoSuchMethodException {
void testTarget() throws SecurityException, NoSuchMethodException {
testThisOrTarget("target");
}
@@ -131,12 +139,12 @@ class AspectJExpressionPointcutTests {
}
@Test
void withinRootPackage() throws SecurityException, NoSuchMethodException {
void testWithinRootPackage() throws SecurityException, NoSuchMethodException {
testWithinPackage(false);
}
@Test
void withinRootAndSubpackages() throws SecurityException, NoSuchMethodException {
void testWithinRootAndSubpackages() throws SecurityException, NoSuchMethodException {
testWithinPackage(true);
}
@@ -160,7 +168,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void friendlyErrorOnNoLocationClassMatching() {
void testFriendlyErrorOnNoLocationClassMatching() {
AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
assertThatIllegalStateException()
.isThrownBy(() -> pc.getClassFilter().matches(ITestBean.class))
@@ -168,7 +176,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void friendlyErrorOnNoLocation2ArgMatching() {
void testFriendlyErrorOnNoLocation2ArgMatching() {
AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
assertThatIllegalStateException()
.isThrownBy(() -> pc.getMethodMatcher().matches(getAge, ITestBean.class))
@@ -176,7 +184,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void friendlyErrorOnNoLocation3ArgMatching() {
void testFriendlyErrorOnNoLocation3ArgMatching() {
AspectJExpressionPointcut pc = new AspectJExpressionPointcut();
assertThatIllegalStateException()
.isThrownBy(() -> pc.getMethodMatcher().matches(getAge, ITestBean.class, (Object[]) null))
@@ -185,7 +193,7 @@ class AspectJExpressionPointcutTests {
@Test
void matchWithArgs() {
void testMatchWithArgs() {
String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number)) && args(Double)";
Pointcut pointcut = getPointcut(expression);
@@ -206,7 +214,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void simpleAdvice() {
void testSimpleAdvice() {
String expression = "execution(int org.springframework.beans.testfixture.beans.TestBean.getAge())";
CallCountingInterceptor interceptor = new CallCountingInterceptor();
TestBean testBean = getAdvisedProxy(expression, interceptor);
@@ -219,7 +227,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void dynamicMatchingProxy() {
void testDynamicMatchingProxy() {
String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number)) && args(Double)";
CallCountingInterceptor interceptor = new CallCountingInterceptor();
TestBean testBean = getAdvisedProxy(expression, interceptor);
@@ -233,7 +241,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void invalidExpression() {
void testInvalidExpression() {
String expression = "execution(void org.springframework.beans.testfixture.beans.TestBean.setSomeNumber(Number) && args(Double)";
assertThat(getPointcut(expression).getClassFilter().matches(Object.class)).isFalse();
}
@@ -263,20 +271,20 @@ class AspectJExpressionPointcutTests {
}
@Test
void withUnsupportedPointcutPrimitive() {
void testWithUnsupportedPointcutPrimitive() {
String expression = "call(int org.springframework.beans.testfixture.beans.TestBean.getAge())";
assertThat(getPointcut(expression).getClassFilter().matches(Object.class)).isFalse();
}
@Test
void andSubstitution() {
void testAndSubstitution() {
AspectJExpressionPointcut pc = getPointcut("execution(* *(..)) and args(String)");
String expr = pc.getPointcutExpression().getPointcutExpression();
assertThat(expr).isEqualTo("execution(* *(..)) && args(String)");
}
@Test
void multipleAndSubstitutions() {
void testMultipleAndSubstitutions() {
AspectJExpressionPointcut pc = getPointcut("execution(* *(..)) and args(String) and this(Object)");
String expr = pc.getPointcutExpression().getPointcutExpression();
assertThat(expr).isEqualTo("execution(* *(..)) && args(String) && this(Object)");
@@ -289,7 +297,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void matchGenericArgument() {
void testMatchGenericArgument() {
String expression = "execution(* set*(java.util.List<org.springframework.beans.testfixture.beans.TestBean>) )";
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(expression);
@@ -308,7 +316,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void matchVarargs() throws Exception {
void testMatchVarargs() throws Exception {
@SuppressWarnings("unused")
class MyTemplate {
@@ -334,19 +342,19 @@ class AspectJExpressionPointcutTests {
}
@Test
void matchAnnotationOnClassWithAtWithin() throws Exception {
void testMatchAnnotationOnClassWithAtWithin() throws Exception {
String expression = "@within(test.annotation.transaction.Tx)";
testMatchAnnotationOnClass(expression);
}
@Test
void matchAnnotationOnClassWithoutBinding() throws Exception {
void testMatchAnnotationOnClassWithoutBinding() throws Exception {
String expression = "within(@test.annotation.transaction.Tx *)";
testMatchAnnotationOnClass(expression);
}
@Test
void matchAnnotationOnClassWithSubpackageWildcard() throws Exception {
void testMatchAnnotationOnClassWithSubpackageWildcard() throws Exception {
String expression = "within(@(test.annotation..*) *)";
AspectJExpressionPointcut springAnnotatedPc = testMatchAnnotationOnClass(expression);
assertThat(springAnnotatedPc.matches(TestBean.class.getMethod("setName", String.class), TestBean.class)).isFalse();
@@ -358,7 +366,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void matchAnnotationOnClassWithExactPackageWildcard() throws Exception {
void testMatchAnnotationOnClassWithExactPackageWildcard() throws Exception {
String expression = "within(@(test.annotation.transaction.*) *)";
testMatchAnnotationOnClass(expression);
}
@@ -376,7 +384,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void annotationOnMethodWithFQN() throws Exception {
void testAnnotationOnMethodWithFQN() throws Exception {
String expression = "@annotation(test.annotation.transaction.Tx)";
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(expression);
@@ -390,7 +398,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void annotationOnCglibProxyMethod() throws Exception {
void testAnnotationOnCglibProxyMethod() throws Exception {
String expression = "@annotation(test.annotation.transaction.Tx)";
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(expression);
@@ -402,7 +410,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void notAnnotationOnCglibProxyMethod() throws Exception {
void testNotAnnotationOnCglibProxyMethod() throws Exception {
String expression = "!@annotation(test.annotation.transaction.Tx)";
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(expression);
@@ -414,7 +422,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void annotationOnDynamicProxyMethod() throws Exception {
void testAnnotationOnDynamicProxyMethod() throws Exception {
String expression = "@annotation(test.annotation.transaction.Tx)";
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(expression);
@@ -426,7 +434,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void notAnnotationOnDynamicProxyMethod() throws Exception {
void testNotAnnotationOnDynamicProxyMethod() throws Exception {
String expression = "!@annotation(test.annotation.transaction.Tx)";
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(expression);
@@ -438,7 +446,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void annotationOnMethodWithWildcard() throws Exception {
void testAnnotationOnMethodWithWildcard() throws Exception {
String expression = "execution(@(test.annotation..*) * *(..))";
AspectJExpressionPointcut anySpringMethodAnnotation = new AspectJExpressionPointcut();
anySpringMethodAnnotation.setExpression(expression);
@@ -454,7 +462,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void annotationOnMethodArgumentsWithFQN() throws Exception {
void testAnnotationOnMethodArgumentsWithFQN() throws Exception {
String expression = "@args(*, test.annotation.EmptySpringAnnotation))";
AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut();
takesSpringAnnotatedArgument2.setExpression(expression);
@@ -483,7 +491,7 @@ class AspectJExpressionPointcutTests {
}
@Test
void annotationOnMethodArgumentsWithWildcards() throws Exception {
void testAnnotationOnMethodArgumentsWithWildcards() throws Exception {
String expression = "execution(* *(*, @(test..*) *))";
AspectJExpressionPointcut takesSpringAnnotatedArgument2 = new AspectJExpressionPointcut();
takesSpringAnnotatedArgument2.setExpression(expression);
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class BeanNamePointcutMatchingTests {
@Test
void matchingPointcuts() {
void testMatchingPointcuts() {
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 nonMatchingPointcuts() {
void testNonMatchingPointcuts() {
assertMisMatch("someName", "bean(someNamex)");
assertMisMatch("someName", "bean(someX*Name)");
@@ -17,6 +17,7 @@
package org.springframework.aop.aspectj;
import java.io.IOException;
import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger;
import org.aspectj.lang.JoinPoint;
@@ -48,17 +49,17 @@ import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
class MethodInvocationProceedingJoinPointTests {
@Test
void bindingWithJoinPoint() {
void testingBindingWithJoinPoint() {
assertThatIllegalStateException().isThrownBy(AbstractAspectJAdvice::currentJoinPoint);
}
@Test
void bindingWithProceedingJoinPoint() {
void testingBindingWithProceedingJoinPoint() {
assertThatIllegalStateException().isThrownBy(AbstractAspectJAdvice::currentJoinPoint);
}
@Test
void canGetMethodSignatureFromJoinPoint() {
void testCanGetMethodSignatureFromJoinPoint() {
final Object raw = new TestBean();
// Will be set by advice during a method call
final int newAge = 23;
@@ -105,9 +106,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(method.getParameterTypes()).isEqualTo(msig.getParameterTypes());
assertThat(Arrays.equals(method.getParameterTypes(), msig.getParameterTypes())).isTrue();
assertThat(msig.getReturnType()).isEqualTo(method.getReturnType());
assertThat(method.getExceptionTypes()).isEqualTo(msig.getExceptionTypes());
assertThat(Arrays.equals(method.getExceptionTypes(), msig.getExceptionTypes())).isTrue();
msig.toLongString();
msig.toShortString();
});
@@ -117,7 +118,7 @@ class MethodInvocationProceedingJoinPointTests {
}
@Test
void canGetSourceLocationFromJoinPoint() {
void testCanGetSourceLocationFromJoinPoint() {
final Object raw = new TestBean();
ProxyFactory pf = new ProxyFactory(raw);
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
@@ -134,7 +135,7 @@ class MethodInvocationProceedingJoinPointTests {
}
@Test
void canGetStaticPartFromJoinPoint() {
void testCanGetStaticPartFromJoinPoint() {
final Object raw = new TestBean();
ProxyFactory pf = new ProxyFactory(raw);
pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
@@ -43,14 +43,14 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
class TrickyAspectJPointcutExpressionTests {
@Test
void manualProxyJavaWithUnconditionalPointcut() {
void testManualProxyJavaWithUnconditionalPointcut() {
TestService target = new TestServiceImpl();
LogUserAdvice logAdvice = new LogUserAdvice();
testAdvice(new DefaultPointcutAdvisor(logAdvice), logAdvice, target, "TestServiceImpl");
}
@Test
void manualProxyJavaWithStaticPointcut() {
void testManualProxyJavaWithStaticPointcut() {
TestService target = new TestServiceImpl();
LogUserAdvice logAdvice = new LogUserAdvice();
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
@@ -59,7 +59,7 @@ class TrickyAspectJPointcutExpressionTests {
}
@Test
void manualProxyJavaWithDynamicPointcut() {
void testManualProxyJavaWithDynamicPointcut() {
TestService target = new TestServiceImpl();
LogUserAdvice logAdvice = new LogUserAdvice();
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
@@ -68,7 +68,7 @@ class TrickyAspectJPointcutExpressionTests {
}
@Test
void manualProxyJavaWithDynamicPointcutAndProxyTargetClass() {
void testManualProxyJavaWithDynamicPointcutAndProxyTargetClass() {
TestService target = new TestServiceImpl();
LogUserAdvice logAdvice = new LogUserAdvice();
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
@@ -77,7 +77,7 @@ class TrickyAspectJPointcutExpressionTests {
}
@Test
void manualProxyJavaWithStaticPointcutAndTwoClassLoaders() throws Exception {
void testManualProxyJavaWithStaticPointcutAndTwoClassLoaders() throws Exception {
LogUserAdvice logAdvice = new LogUserAdvice();
AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
@@ -97,7 +97,7 @@ class TypePatternClassFilterTests {
}
@Test
void equals() {
void testEquals() {
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 hashCodeBehavior() {
void testHashCode() {
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 toStringOutput() {
void testToString() {
TypePatternClassFilter filter1 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*");
TypePatternClassFilter filter2 = new TypePatternClassFilter("org.springframework.beans.testfixture.beans.*");
@@ -430,8 +430,8 @@ abstract class AbstractAspectJAdvisorFactoryTests {
assertThatExceptionOfType(UnsupportedOperationException.class).isThrownBy(itb::getAge);
}
// TODO document this behavior.
// Is it different AspectJ behavior, at least for checked exceptions?
// TODO document this behaviour.
// Is it different AspectJ behaviour, at least for checked exceptions?
@Test
void aspectMethodThrowsExceptionIllegalOnSignature() {
TestBean target = new TestBean();
@@ -39,7 +39,7 @@ class AspectJPointcutAdvisorTests {
@Test
void singleton() throws SecurityException, NoSuchMethodException {
void testSingleton() throws SecurityException, NoSuchMethodException {
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(CommonExpressions.MATCH_ALL_METHODS);
@@ -53,7 +53,7 @@ class AspectJPointcutAdvisorTests {
}
@Test
void perTarget() throws SecurityException, NoSuchMethodException {
void testPerTarget() throws SecurityException, NoSuchMethodException {
AspectJExpressionPointcut ajexp = new AspectJExpressionPointcut();
ajexp.setExpression(CommonExpressions.MATCH_ALL_METHODS);
@@ -63,7 +63,8 @@ class AspectJPointcutAdvisorTests {
1, "someBean");
assertThat(ajpa.getAspectMetadata().getPerClausePointcut()).isNotSameAs(Pointcut.TRUE);
assertThat(ajpa.getAspectMetadata().getPerClausePointcut()).isInstanceOf(AspectJExpressionPointcut.class);
boolean condition = ajpa.getAspectMetadata().getPerClausePointcut() instanceof AspectJExpressionPointcut;
assertThat(condition).isTrue();
assertThat(ajpa.isPerInstance()).isTrue();
assertThat(ajpa.getAspectMetadata().getPerClausePointcut().getClassFilter().matches(TestBean.class)).isTrue();
@@ -75,13 +76,13 @@ class AspectJPointcutAdvisorTests {
}
@Test
void perCflowTarget() {
void testPerCflowTarget() {
assertThatExceptionOfType(AopConfigException.class).isThrownBy(() ->
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowAspect.class));
}
@Test
void perCflowBelowTarget() {
void testPerCflowBelowTarget() {
assertThatExceptionOfType(AopConfigException.class).isThrownBy(() ->
testIllegalInstantiationModel(AbstractAspectJAdvisorFactoryTests.PerCflowBelowAspect.class));
}
@@ -39,13 +39,13 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
class AspectProxyFactoryTests {
@Test
void withNonAspect() {
void testWithNonAspect() {
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
assertThatIllegalArgumentException().isThrownBy(() -> proxyFactory.addAspect(TestBean.class));
}
@Test
void withSimpleAspect() {
void testWithSimpleAspect() {
TestBean bean = new TestBean();
bean.setAge(2);
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(bean);
@@ -55,7 +55,7 @@ class AspectProxyFactoryTests {
}
@Test
void withPerThisAspect() {
void testWithPerThisAspect() {
TestBean bean1 = new TestBean();
TestBean bean2 = new TestBean();
@@ -75,14 +75,14 @@ class AspectProxyFactoryTests {
}
@Test
void withInstanceWithNonAspect() {
void testWithInstanceWithNonAspect() {
AspectJProxyFactory pf = new AspectJProxyFactory();
assertThatIllegalArgumentException().isThrownBy(() -> pf.addAspect(new TestBean()));
}
@Test
@SuppressWarnings("unchecked")
void serializable() throws Exception {
void testSerializable() throws Exception {
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
proxyFactory.addAspect(LoggingAspectOnVarargs.class);
ITestBean proxy = proxyFactory.getProxy();
@@ -92,7 +92,7 @@ class AspectProxyFactoryTests {
}
@Test
void withInstance() throws Exception {
void testWithInstance() throws Exception {
MultiplyReturnValue aspect = new MultiplyReturnValue();
int multiple = 3;
aspect.setMultiple(multiple);
@@ -111,14 +111,14 @@ class AspectProxyFactoryTests {
}
@Test
void withNonSingletonAspectInstance() {
void testWithNonSingletonAspectInstance() {
AspectJProxyFactory pf = new AspectJProxyFactory();
assertThatIllegalArgumentException().isThrownBy(() -> pf.addAspect(new PerThisAspect()));
}
@Test // SPR-13328
@SuppressWarnings("unchecked")
void proxiedVarargsWithEnumArray() {
public void testProxiedVarargsWithEnumArray() {
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")
void unproxiedVarargsWithEnumArray() {
public void testUnproxiedVarargsWithEnumArray() {
AspectJProxyFactory proxyFactory = new AspectJProxyFactory(new TestBean());
proxyFactory.addAspect(LoggingAspectOnSetter.class);
ITestBean proxy = proxyFactory.getProxy();
@@ -47,7 +47,7 @@ class AspectJNamespaceHandlerTests {
@BeforeEach
void setUp() {
public void setUp() {
SourceExtractor sourceExtractor = new PassThroughSourceExtractor();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(this.registry);
XmlReaderContext readerContext =
@@ -56,7 +56,7 @@ class AspectJNamespaceHandlerTests {
}
@Test
void registerAutoProxyCreator() {
void testRegisterAutoProxyCreator() {
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
assertThat(registry.getBeanDefinitionCount()).as("Incorrect number of definitions registered").isEqualTo(1);
@@ -65,7 +65,7 @@ class AspectJNamespaceHandlerTests {
}
@Test
void registerAspectJAutoProxyCreator() {
void testRegisterAspectJAutoProxyCreator() {
AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
assertThat(registry.getBeanDefinitionCount()).as("Incorrect number of definitions registered").isEqualTo(1);
@@ -77,7 +77,7 @@ class AspectJNamespaceHandlerTests {
}
@Test
void registerAspectJAutoProxyCreatorWithExistingAutoProxyCreator() {
void testRegisterAspectJAutoProxyCreatorWithExistingAutoProxyCreator() {
AopNamespaceUtils.registerAutoProxyCreatorIfNecessary(this.parserContext, null);
assertThat(registry.getBeanDefinitionCount()).isEqualTo(1);
@@ -89,7 +89,7 @@ class AspectJNamespaceHandlerTests {
}
@Test
void registerAutoProxyCreatorWhenAspectJAutoProxyCreatorAlreadyExists() {
void testRegisterAutoProxyCreatorWhenAspectJAutoProxyCreatorAlreadyExists() {
AopNamespaceUtils.registerAspectJAutoProxyCreatorIfNecessary(this.parserContext, null);
assertThat(registry.getBeanDefinitionCount()).isEqualTo(1);
@@ -33,7 +33,6 @@ 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;
@@ -49,21 +48,24 @@ class AspectJPrecedenceComparatorTests {
private static final int LATE_ADVICE_DECLARATION_ORDER = 10;
private final AspectJPrecedenceComparator comparator = new AspectJPrecedenceComparator();
private AspectJPrecedenceComparator comparator;
private final Method anyOldMethod = ClassUtils.getMethod(MessageService.class, "getMessage");
private Method anyOldMethod;
private final AspectJExpressionPointcut anyOldPointcut = new AspectJExpressionPointcut();
private AspectJExpressionPointcut anyOldPointcut;
@BeforeEach
void setUp() {
public void setUp() {
this.comparator = new AspectJPrecedenceComparator();
this.anyOldMethod = getClass().getMethods()[0];
this.anyOldPointcut = new AspectJExpressionPointcut();
this.anyOldPointcut.setExpression("execution(* *(..))");
}
@Test
void sameAspectNoAfterAdvice() {
void testSameAspectNoAfterAdvice() {
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);
@@ -74,7 +76,7 @@ class AspectJPrecedenceComparatorTests {
}
@Test
void sameAspectAfterAdvice() {
void testSameAspectAfterAdvice() {
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);
@@ -85,14 +87,14 @@ class AspectJPrecedenceComparatorTests {
}
@Test
void sameAspectOneOfEach() {
void testSameAspectOneOfEach() {
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 sameAdvisorPrecedenceDifferentAspectNoAfterAdvice() {
void testSameAdvisorPrecedenceDifferentAspectNoAfterAdvice() {
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);
@@ -103,7 +105,7 @@ class AspectJPrecedenceComparatorTests {
}
@Test
void sameAdvisorPrecedenceDifferentAspectAfterAdvice() {
void testSameAdvisorPrecedenceDifferentAspectAfterAdvice() {
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);
@@ -114,7 +116,7 @@ class AspectJPrecedenceComparatorTests {
}
@Test
void higherAdvisorPrecedenceNoAfterAdvice() {
void testHigherAdvisorPrecedenceNoAfterAdvice() {
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);
@@ -125,7 +127,7 @@ class AspectJPrecedenceComparatorTests {
}
@Test
void higherAdvisorPrecedenceAfterAdvice() {
void testHigherAdvisorPrecedenceAfterAdvice() {
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);
@@ -136,7 +138,7 @@ class AspectJPrecedenceComparatorTests {
}
@Test
void lowerAdvisorPrecedenceNoAfterAdvice() {
void testLowerAdvisorPrecedenceNoAfterAdvice() {
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);
@@ -147,7 +149,7 @@ class AspectJPrecedenceComparatorTests {
}
@Test
void lowerAdvisorPrecedenceAfterAdvice() {
void testLowerAdvisorPrecedenceAfterAdvice() {
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);
@@ -207,11 +209,4 @@ class AspectJPrecedenceComparatorTests {
return advisor;
}
static class MessageService {
public String getMessage() {
return "test";
}
}
}
@@ -35,7 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class MethodInvocationTests {
@Test
void validInvocation() throws Throwable {
void testValidInvocation() 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 toStringDoesntHitTarget() throws Throwable {
void testToStringDoesntHitTarget() throws Throwable {
Object target = new TestBean() {
@Override
public String toString() {
@@ -36,7 +36,7 @@ class NullPrimitiveTests {
}
@Test
void nullPrimitiveWithJdkProxy() {
void testNullPrimitiveWithJdkProxy() {
class SimpleFoo implements Foo {
@Override
@@ -62,7 +62,7 @@ class NullPrimitiveTests {
}
@Test
void nullPrimitiveWithCglibProxy() {
void testNullPrimitiveWithCglibProxy() {
Bar target = new Bar();
ProxyFactory factory = new ProxyFactory(target);
@@ -38,7 +38,7 @@ class PrototypeTargetTests {
@Test
void prototypeProxyWithPrototypeTarget() {
void testPrototypeProxyWithPrototypeTarget() {
TestBeanImpl.constructionCount = 0;
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
@@ -52,7 +52,7 @@ class PrototypeTargetTests {
}
@Test
void singletonProxyWithPrototypeTarget() {
void testSingletonProxyWithPrototypeTarget() {
TestBeanImpl.constructionCount = 0;
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
@@ -40,14 +40,14 @@ import static org.mockito.Mockito.mock;
class ThrowsAdviceInterceptorTests {
@Test
void noHandlerMethods() {
void testNoHandlerMethods() {
// should require one handler method at least
assertThatExceptionOfType(AopConfigException.class).isThrownBy(() ->
new ThrowsAdviceInterceptor(new Object()));
}
@Test
void notInvoked() throws Throwable {
void testNotInvoked() throws Throwable {
MyThrowsHandler th = new MyThrowsHandler();
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
Object ret = new Object();
@@ -58,7 +58,7 @@ class ThrowsAdviceInterceptorTests {
}
@Test
void noHandlerMethodForThrowable() throws Throwable {
void testNoHandlerMethodForThrowable() throws Throwable {
MyThrowsHandler th = new MyThrowsHandler();
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
assertThat(ti.getHandlerMethodCount()).isEqualTo(2);
@@ -70,7 +70,7 @@ class ThrowsAdviceInterceptorTests {
}
@Test
void correctHandlerUsed() throws Throwable {
void testCorrectHandlerUsed() throws Throwable {
MyThrowsHandler th = new MyThrowsHandler();
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
FileNotFoundException ex = new FileNotFoundException();
@@ -84,7 +84,7 @@ class ThrowsAdviceInterceptorTests {
}
@Test
void correctHandlerUsedForSubclass() throws Throwable {
void testCorrectHandlerUsedForSubclass() throws Throwable {
MyThrowsHandler th = new MyThrowsHandler();
ThrowsAdviceInterceptor ti = new ThrowsAdviceInterceptor(th);
// Extends RemoteException
@@ -97,7 +97,7 @@ class ThrowsAdviceInterceptorTests {
}
@Test
void handlerMethodThrowsException() throws Throwable {
void testHandlerMethodThrowsException() throws Throwable {
final Throwable t = new Throwable();
MyThrowsHandler th = new MyThrowsHandler() {
@@ -38,7 +38,7 @@ import static org.mockito.Mockito.verify;
class DebugInterceptorTests {
@Test
void sunnyDayPathLogsCorrectly() throws Throwable {
void testSunnyDayPathLogsCorrectly() throws Throwable {
MethodInvocation methodInvocation = mock();
Log log = mock();
@@ -52,7 +52,7 @@ class DebugInterceptorTests {
}
@Test
void exceptionPathStillLogsCorrectly() throws Throwable {
void testExceptionPathStillLogsCorrectly() throws Throwable {
MethodInvocation methodInvocation = mock();
IllegalArgumentException exception = new IllegalArgumentException();
@@ -46,7 +46,7 @@ class ExposeBeanNameAdvisorsTests {
}
@Test
void noIntroduction() {
void testNoIntroduction() {
String beanName = "foo";
TestBean target = new RequiresBeanNameBoundTestBean(beanName);
ProxyFactory pf = new ProxyFactory(target);
@@ -54,13 +54,14 @@ class ExposeBeanNameAdvisorsTests {
pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorWithoutIntroduction(beanName));
ITestBean proxy = (ITestBean) pf.getProxy();
assertThat(proxy).as("No introduction").isNotInstanceOf(NamedBean.class);
boolean condition = proxy instanceof NamedBean;
assertThat(condition).as("No introduction").isFalse();
// Requires binding
proxy.getAge();
}
@Test
void withIntroduction() {
void testWithIntroduction() {
String beanName = "foo";
TestBean target = new RequiresBeanNameBoundTestBean(beanName);
ProxyFactory pf = new ProxyFactory(target);
@@ -68,7 +69,8 @@ class ExposeBeanNameAdvisorsTests {
pf.addAdvisor(ExposeBeanNameAdvisors.createAdvisorIntroducingNamedBean(beanName));
ITestBean proxy = (ITestBean) pf.getProxy();
assertThat(proxy).as("Introduction was made").isInstanceOf(NamedBean.class);
boolean condition = proxy instanceof NamedBean;
assertThat(condition).as("Introduction was made").isTrue();
// Requires binding
proxy.getAge();
@@ -34,7 +34,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
class ExposeInvocationInterceptorTests {
@Test
void xmlConfig() {
void testXmlConfig() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
qualifiedResource(ExposeInvocationInterceptorTests.class, "context.xml"));
@@ -35,7 +35,7 @@ import static org.mockito.Mockito.verify;
class PerformanceMonitorInterceptorTests {
@Test
void suffixAndPrefixAssignment() {
void testSuffixAndPrefixAssignment() {
PerformanceMonitorInterceptor interceptor = new PerformanceMonitorInterceptor();
assertThat(interceptor.getPrefix()).isNotNull();
@@ -49,7 +49,7 @@ class PerformanceMonitorInterceptorTests {
}
@Test
void sunnyDayPathLogsPerformanceMetricsCorrectly() throws Throwable {
void testSunnyDayPathLogsPerformanceMetricsCorrectly() throws Throwable {
MethodInvocation mi = mock();
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
@@ -62,7 +62,7 @@ class PerformanceMonitorInterceptorTests {
}
@Test
void exceptionPathStillLogsPerformanceMetricsCorrectly() throws Throwable {
void testExceptionPathStillLogsPerformanceMetricsCorrectly() throws Throwable {
MethodInvocation mi = mock();
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
@@ -37,7 +37,7 @@ import static org.mockito.Mockito.verify;
class SimpleTraceInterceptorTests {
@Test
void sunnyDayPathLogsCorrectly() throws Throwable {
void testSunnyDayPathLogsCorrectly() 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 exceptionPathStillLogsCorrectly() throws Throwable {
void testExceptionPathStillLogsCorrectly() throws Throwable {
MethodInvocation mi = mock();
given(mi.getMethod()).willReturn(String.class.getMethod("toString"));
given(mi.getThis()).willReturn(this);
@@ -35,25 +35,25 @@ class DefaultScopedObjectTests {
@Test
void ctorWithNullBeanFactory() {
void testCtorWithNullBeanFactory() {
assertThatIllegalArgumentException().isThrownBy(() ->
new DefaultScopedObject(null, GOOD_BEAN_NAME));
}
@Test
void ctorWithNullTargetBeanName() {
void testCtorWithNullTargetBeanName() {
assertThatIllegalArgumentException().isThrownBy(() ->
testBadTargetBeanName(null));
}
@Test
void ctorWithEmptyTargetBeanName() {
void testCtorWithEmptyTargetBeanName() {
assertThatIllegalArgumentException().isThrownBy(() ->
testBadTargetBeanName(""));
}
@Test
void ctorWithJustWhitespacedTargetBeanName() {
void testCtorWithJustWhitespacedTargetBeanName() {
assertThatIllegalArgumentException().isThrownBy(() ->
testBadTargetBeanName(" "));
}
@@ -34,7 +34,7 @@ import static org.springframework.core.testfixture.io.ResourceTestUtils.qualifie
class ScopedProxyAutowireTests {
@Test
void scopedProxyInheritsAutowireCandidateFalse() {
void testScopedProxyInheritsAutowireCandidateFalse() {
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
qualifiedResource(ScopedProxyAutowireTests.class, "scopedAutowireFalse.xml"));
@@ -48,7 +48,7 @@ class ScopedProxyAutowireTests {
}
@Test
void scopedProxyReplacesAutowireCandidateTrue() {
void testScopedProxyReplacesAutowireCandidateTrue() {
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 pointcutCanNeverApply() {
void testPointcutCanNeverApply() {
class TestPointcut extends StaticMethodMatcherPointcut {
@Override
public boolean matches(Method method, @Nullable Class<?> clazzy) {
@@ -58,13 +58,13 @@ class AopUtilsTests {
}
@Test
void pointcutAlwaysApplies() {
void testPointcutAlwaysApplies() {
assertThat(AopUtils.canApply(new DefaultPointcutAdvisor(new NopInterceptor()), Object.class)).isTrue();
assertThat(AopUtils.canApply(new DefaultPointcutAdvisor(new NopInterceptor()), TestBean.class)).isTrue();
}
@Test
void pointcutAppliesToOneMethodOnObject() {
void testPointcutAppliesToOneMethodOnObject() {
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 canonicalFrameworkClassesStillCanonicalOnDeserialization() throws Exception {
void testCanonicalFrameworkClassesStillCanonicalOnDeserialization() 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 invokeJoinpointUsingReflection() throws Throwable {
void testInvokeJoinpointUsingReflection() throws Throwable {
String name = "foo";
TestBean testBean = new TestBean(name);
Method method = ReflectionUtils.findMethod(TestBean.class, "getName");
@@ -58,14 +58,14 @@ class ComposablePointcutTests {
@Test
void matchAll() throws NoSuchMethodException {
void testMatchAll() 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 filterByClass() {
void testFilterByClass() {
ComposablePointcut pc = new ComposablePointcut();
assertThat(pc.getClassFilter().matches(Object.class)).isTrue();
@@ -85,7 +85,7 @@ class ComposablePointcutTests {
}
@Test
void unionMethodMatcher() {
void testUnionMethodMatcher() {
// 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 intersectionMethodMatcher() {
void testIntersectionMethodMatcher() {
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 equalsAndHashCode() {
void testEqualsAndHashCode() {
ComposablePointcut pc1 = new ComposablePointcut();
ComposablePointcut pc2 = new ComposablePointcut();
@@ -152,7 +152,7 @@ class ControlFlowPointcutTests {
}
@Test
void toStringOutput() {
void testToString() {
String pointcutType = ControlFlowPointcut.class.getName();
String componentType = MyComponent.class.getName();
@@ -47,14 +47,14 @@ import static org.mockito.Mockito.mock;
class DelegatingIntroductionInterceptorTests {
@Test
void nullTarget() {
void testNullTarget() {
// Shouldn't accept null target
assertThatIllegalArgumentException().isThrownBy(() ->
new DelegatingIntroductionInterceptor(null));
}
@Test
void introductionInterceptorWithDelegation() {
void testIntroductionInterceptorWithDelegation() {
TestBean raw = new TestBean();
assertThat(raw).isNotInstanceOf(TimeStamped.class);
ProxyFactory factory = new ProxyFactory(raw);
@@ -70,7 +70,7 @@ class DelegatingIntroductionInterceptorTests {
}
@Test
void introductionInterceptorWithInterfaceHierarchy() {
void testIntroductionInterceptorWithInterfaceHierarchy() {
TestBean raw = new TestBean();
assertThat(raw).isNotInstanceOf(SubTimeStamped.class);
ProxyFactory factory = new ProxyFactory(raw);
@@ -86,7 +86,7 @@ class DelegatingIntroductionInterceptorTests {
}
@Test
void introductionInterceptorWithSuperInterface() {
void testIntroductionInterceptorWithSuperInterface() {
TestBean raw = new TestBean();
assertThat(raw).isNotInstanceOf(TimeStamped.class);
ProxyFactory factory = new ProxyFactory(raw);
@@ -103,7 +103,7 @@ class DelegatingIntroductionInterceptorTests {
}
@Test
void automaticInterfaceRecognitionInDelegate() throws Exception {
void testAutomaticInterfaceRecognitionInDelegate() throws Exception {
final long t = 1001L;
class Tester implements TimeStamped, ITester {
@Override
@@ -133,7 +133,7 @@ class DelegatingIntroductionInterceptorTests {
@Test
void automaticInterfaceRecognitionInSubclass() throws Exception {
void testAutomaticInterfaceRecognitionInSubclass() throws Exception {
final long t = 1001L;
@SuppressWarnings("serial")
class TestII extends DelegatingIntroductionInterceptor implements TimeStamped, ITester {
@@ -178,7 +178,7 @@ class DelegatingIntroductionInterceptorTests {
}
@Test
void introductionInterceptorDoesNotReplaceToString() {
void testIntroductionInterceptorDoesNotReplaceToString() {
TestBean raw = new TestBean();
assertThat(raw).isNotInstanceOf(TimeStamped.class);
ProxyFactory factory = new ProxyFactory(raw);
@@ -199,7 +199,7 @@ class DelegatingIntroductionInterceptorTests {
}
@Test
void delegateReturnsThisIsMassagedToReturnProxy() {
void testDelegateReturnsThisIsMassagedToReturnProxy() {
NestedTestBean target = new NestedTestBean();
String company = "Interface21";
target.setCompany(company);
@@ -220,7 +220,7 @@ class DelegatingIntroductionInterceptorTests {
}
@Test
void serializableDelegatingIntroductionInterceptorSerializable() throws Exception {
void testSerializableDelegatingIntroductionInterceptorSerializable() 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 introductionMasksTargetImplementation() {
void testIntroductionMasksTargetImplementation() {
final long t = 1001L;
@SuppressWarnings("serial")
class TestII extends DelegatingIntroductionInterceptor implements TimeStamped {
@@ -56,19 +56,19 @@ class MethodMatchersTests {
@Test
void defaultMatchesAll() {
void testDefaultMatchesAll() {
MethodMatcher defaultMm = MethodMatcher.TRUE;
assertThat(defaultMm.matches(EXCEPTION_GETMESSAGE, Exception.class)).isTrue();
assertThat(defaultMm.matches(ITESTBEAN_SETAGE, TestBean.class)).isTrue();
}
@Test
void methodMatcherTrueSerializable() throws Exception {
void testMethodMatcherTrueSerializable() throws Exception {
assertThat(MethodMatcher.TRUE).isSameAs(SerializationTestUtils.serializeAndDeserialize(MethodMatcher.TRUE));
}
@Test
void single() {
void testSingle() {
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 dynamicAndStaticMethodMatcherIntersection() {
void testDynamicAndStaticMethodMatcherIntersection() {
MethodMatcher mm1 = MethodMatcher.TRUE;
MethodMatcher mm2 = new TestDynamicMethodMatcherWhichMatches();
MethodMatcher intersection = MethodMatchers.intersection(mm1, mm2);
@@ -95,7 +95,7 @@ class MethodMatchersTests {
}
@Test
void staticMethodMatcherUnion() {
void testStaticMethodMatcherUnion() {
MethodMatcher getterMatcher = new StartsWithMatcher("get");
MethodMatcher setterMatcher = new StartsWithMatcher("set");
MethodMatcher union = MethodMatchers.union(getterMatcher, setterMatcher);
@@ -107,7 +107,7 @@ class MethodMatchersTests {
}
@Test
void unionEquals() {
void testUnionEquals() {
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 trueCase() {
void testTrue() {
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 matches() {
void testMatches() {
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 unionOfSettersAndGetters() {
void testUnionOfSettersAndGetters() {
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 unionOfSpecificGetters() {
void testUnionOfSpecificGetters() {
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 unionOfAllSettersAndSubclassSetters() {
void testUnionOfAllSettersAndSubclassSetters() {
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 intersectionOfSpecificGettersAndSubclassGetters() {
void testIntersectionOfSpecificGettersAndSubclassGetters() {
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 simpleIntersection() {
void testSimpleIntersection() {
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();
@@ -43,7 +43,7 @@ class RegexpMethodPointcutAdvisorIntegrationTests {
@Test
void singlePattern() throws Throwable {
void testSinglePattern() 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 multiplePatterns() throws Throwable {
void testMultiplePatterns() 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 serialization() throws Throwable {
void testSerialization() 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 equals() {
void testEquals() {
assertThat(filter1).isEqualTo(filter2);
assertThat(filter1).isNotEqualTo(filter3);
}
@Test
void hashCodeBehavior() {
void testHashCode() {
assertThat(filter1.hashCode()).isEqualTo(filter2.hashCode());
assertThat(filter1.hashCode()).isNotEqualTo(filter3.hashCode());
}
@Test
void toStringOutput() {
void testToString() {
assertThat(filter1.toString()).isEqualTo("org.springframework.aop.support.RootClassFilter: java.lang.Exception");
assertThat(filter1.toString()).isEqualTo(filter2.toString());
}
@@ -36,7 +36,7 @@ class CommonsPool2TargetSourceProxyTests {
qualifiedResource(CommonsPool2TargetSourceProxyTests.class, "context.xml");
@Test
void proxy() {
void testProxy() {
DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
reader.loadBeanDefinitions(CONTEXT);
@@ -48,7 +48,7 @@ class HotSwappableTargetSourceTests {
@BeforeEach
void setup() {
public 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
void close() {
public void close() {
// Will call pool.close()
this.beanFactory.destroySingletons();
}
@@ -68,7 +68,7 @@ class HotSwappableTargetSourceTests {
* Check it works like a normal invoker
*/
@Test
void basicFunctionality() {
void testBasicFunctionality() {
SideEffectBean proxied = (SideEffectBean) beanFactory.getBean("swappable");
assertThat(proxied.getCount()).isEqualTo(INITIAL_COUNT);
proxied.doWork();
@@ -80,7 +80,7 @@ class HotSwappableTargetSourceTests {
}
@Test
void validSwaps() {
void testValidSwaps() {
SideEffectBean target1 = (SideEffectBean) beanFactory.getBean("target1");
SideEffectBean target2 = (SideEffectBean) beanFactory.getBean("target2");
@@ -107,17 +107,17 @@ class HotSwappableTargetSourceTests {
}
@Test
void rejectsSwapToNull() {
void testRejectsSwapToNull() {
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
basicFunctionality();
testBasicFunctionality();
}
@Test
void serialization() throws Exception {
void testSerialization() throws Exception {
SerializablePerson sp1 = new SerializablePerson();
sp1.setName("Tony");
SerializablePerson sp2 = new SerializablePerson();
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class LazyCreationTargetSourceTests {
@Test
void createLazy() {
void testCreateLazy() {
TargetSource targetSource = new AbstractLazyCreationTargetSource() {
@Override
protected Object createObject() {
@@ -39,7 +39,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class PrototypeBasedTargetSourceTests {
@Test
void serializability() throws Exception {
void testSerializability() throws Exception {
MutablePropertyValues tsPvs = new MutablePropertyValues();
tsPvs.add("targetBeanName", "person");
RootBeanDefinition tsBd = new RootBeanDefinition(TestTargetSource.class);
@@ -39,7 +39,7 @@ class PrototypeTargetSourceTests {
@BeforeEach
void setup() {
public 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 prototypeAndSingletonBehaveDifferently() {
void testPrototypeAndSingletonBehaveDifferently() {
SideEffectBean singleton = (SideEffectBean) beanFactory.getBean("singleton");
assertThat(singleton.getCount()).isEqualTo(INITIAL_COUNT);
singleton.doWork();
@@ -40,7 +40,7 @@ class ThreadLocalTargetSourceTests {
@BeforeEach
void setup() {
public 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 useDifferentManagedInstancesInSameThread() {
void testUseDifferentManagedInstancesInSameThread() {
SideEffectBean apartment = (SideEffectBean) beanFactory.getBean("apartment");
assertThat(apartment.getCount()).isEqualTo(INITIAL_COUNT);
apartment.doWork();
@@ -72,7 +72,7 @@ class ThreadLocalTargetSourceTests {
}
@Test
void reuseInSameThread() {
void testReuseInSameThread() {
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 canGetStatsViaMixin() {
void testCanGetStatsViaMixin() {
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 newThreadHasOwnInstance() throws InterruptedException {
void testNewThreadHasOwnInstance() 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 reuseDestroyedTarget() {
void testReuseDestroyedTarget() {
ThreadLocalTargetSource source = (ThreadLocalTargetSource)this.beanFactory.getBean("threadLocalTs");
// try first time
@@ -33,7 +33,7 @@ class RefreshableTargetSourceTests {
* Test what happens when checking for refresh but not refreshing object.
*/
@Test
void refreshCheckWithNonRefresh() throws Exception {
void testRefreshCheckWithNonRefresh() 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 refreshCheckWithRefresh() throws Exception {
void testRefreshCheckWithRefresh() 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 withNoRefreshCheck() {
void testWithNoRefreshCheck() {
CountingRefreshableTargetSource ts = new CountingRefreshableTargetSource(true);
ts.setRefreshCheckDelay(-1);
@@ -78,7 +78,7 @@ class RefreshableTargetSourceTests {
@Test
@EnabledForTestGroups(LONG_RUNNING)
void refreshOverTime() throws Exception {
public void testRefreshOverTime() 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).as("A and D should not be equal").isNotEqualTo(d);
assertThat(a.equals(d)).as("A and D should not be equal").isFalse();
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).as("E and F should be different").isNotEqualTo(f);
assertThat(e.equals(f)).as("E and F should be different").isFalse();
}
@@ -1,5 +1,5 @@
/*
* Copyright 2002-present the original author or authors.
* Copyright 2002-2014 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.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-present the original author or authors.
* Copyright 2002-2020 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.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-present the original author or authors.
* Copyright 2002-2023 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.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-present the original author or authors.
* Copyright 2002-2017 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.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-present the original author or authors.
* Copyright 2002-2014 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.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-present the original author or authors.
* Copyright 2002-2013 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.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-present the original author or authors.
* Copyright 2002-2014 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.

Some files were not shown because too many files have changed in this diff Show More